From 509ea174f190c71bff97aeadd79c44271913f04c Mon Sep 17 00:00:00 2001 From: Taritsyn Date: Tue, 6 Sep 2022 19:57:10 +0300 Subject: [PATCH] In BundleTransformer.TypeScript added support of the TypeScript version 4.8 RTM (please note: The 4.8 RTM release is also called '4.8.2') --- global.json | 2 +- .../BundleTransformer.TypeScript.csproj | 4 +- .../Resources/DefaultLibraries/lib.dom.d.ts | 315 +- .../DefaultLibraries/lib.dom.iterable.d.ts | 12 +- .../lib.es2015.collection.d.ts | 63 +- .../DefaultLibraries/lib.es2015.proxy.d.ts | 93 +- .../DefaultLibraries/lib.es2017.intl.d.ts | 17 +- .../DefaultLibraries/lib.es2020.intl.d.ts | 35 +- .../DefaultLibraries/lib.es2021.intl.d.ts | 14 +- .../DefaultLibraries/lib.es2022.d.ts | 1 + .../DefaultLibraries/lib.es2022.error.d.ts | 4 +- .../lib.es2022.sharedmemory.d.ts | 27 + .../Resources/DefaultLibraries/lib.es5.d.ts | 14 +- .../DefaultLibraries/lib.esnext.intl.d.ts | 6 +- .../DefaultLibraries/lib.webworker.d.ts | 85 +- .../lib.webworker.iterable.d.ts | 2 +- .../Resources/typescript-combined.js | 7349 ++++++++++------- src/BundleTransformer.TypeScript/readme.txt | 5 +- 18 files changed, 4980 insertions(+), 3068 deletions(-) create mode 100644 src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2022.sharedmemory.d.ts diff --git a/global.json b/global.json index 19c87f2a5..0b738cd89 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "6.0.300" + "version": "6.0.400" } } diff --git a/src/BundleTransformer.TypeScript/BundleTransformer.TypeScript.csproj b/src/BundleTransformer.TypeScript/BundleTransformer.TypeScript.csproj index 82fcb4fb4..6ef1e4d96 100644 --- a/src/BundleTransformer.TypeScript/BundleTransformer.TypeScript.csproj +++ b/src/BundleTransformer.TypeScript/BundleTransformer.TypeScript.csproj @@ -15,7 +15,7 @@ - BundleTransformer.TypeScript contains one translator-adapter - `TypeScriptTranslator` (supports the TypeScript (https://www.typescriptlang.org) version 4.7.4). This adapter makes translation of TypeScript code to JS code. Also contains the `TypeScriptAssetHandler` debugging HTTP handler, which is responsible for text output of translated TypeScript asset. + BundleTransformer.TypeScript contains one translator-adapter - `TypeScriptTranslator` (supports the TypeScript (https://www.typescriptlang.org) version 4.8 RTM). This adapter makes translation of TypeScript code to JS code. Also contains the `TypeScriptAssetHandler` debugging HTTP handler, which is responsible for text output of translated TypeScript asset. BundleTransformer.TypeScript does not support external modules (CommonJS, AMD, SystemJS, UMD and ES6 modules). @@ -23,7 +23,7 @@ As a JS engine is used the JavaScript Engine Switcher library (https://github.co https://raw.githubusercontent.com/Taritsyn/BundleTransformer/master/images/icons/128/BundleTransformer_TypeScript_Logo_128x128.png ../../images/icons/128/BundleTransformer_TypeScript_Logo_128x128.png $(PackageCommonTags);JavaScript;JS;Bundling;TypeScript;Translation;Translator;Compilation;Compiler - Added support of the TypeScript version 4.7.4. + Added support of the TypeScript version 4.8 RTM (please note: The 4.8 RTM release is also called '4.8.2'). diff --git a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.dom.d.ts b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.dom.d.ts index f1761f1c5..d1223acc6 100644 --- a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.dom.d.ts +++ b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.dom.d.ts @@ -590,6 +590,10 @@ interface IDBObjectStoreParameters { keyPath?: string | string[] | null; } +interface IDBTransactionOptions { + durability?: IDBTransactionDurability; +} + interface IDBVersionChangeEventInit extends EventInit { newVersion?: number | null; oldVersion?: number; @@ -721,19 +725,6 @@ interface LockOptions { steal?: boolean; } -interface MIDIConnectionEventInit extends EventInit { - port?: MIDIPort; -} - -interface MIDIMessageEventInit extends EventInit { - data?: Uint8Array; -} - -interface MIDIOptions { - software?: boolean; - sysex?: boolean; -} - interface MediaCapabilitiesDecodingInfo extends MediaCapabilitiesInfo { configuration?: MediaDecodingConfiguration; } @@ -1514,12 +1505,12 @@ interface RTCTransportStats extends RTCStats { tlsVersion?: string; } -interface ReadableStreamDefaultReadDoneResult { +interface ReadableStreamReadDoneResult { done: true; value?: undefined; } -interface ReadableStreamDefaultReadValueResult { +interface ReadableStreamReadValueResult { done: false; value: T; } @@ -1815,6 +1806,19 @@ interface UnderlyingSource { type?: undefined; } +interface ValidityStateFlags { + badInput?: boolean; + customError?: boolean; + patternMismatch?: boolean; + rangeOverflow?: boolean; + rangeUnderflow?: boolean; + stepMismatch?: boolean; + tooLong?: boolean; + tooShort?: boolean; + typeMismatch?: boolean; + valueMissing?: boolean; +} + interface VideoColorSpaceInit { fullRange?: boolean; matrix?: VideoMatrixCoefficients; @@ -2191,6 +2195,7 @@ declare var AudioBufferSourceNode: { /** An audio-processing graph built from audio modules linked together, each represented by an AudioNode. */ interface AudioContext extends BaseAudioContext { readonly baseLatency: number; + readonly outputLatency: number; close(): Promise; createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; createMediaStreamDestination(): MediaStreamAudioDestinationNode; @@ -2567,7 +2572,7 @@ declare var CSSAnimation: { /** A single condition CSS at-rule, which consists of a condition and a statement block. It is a child of CSSGroupingRule. */ interface CSSConditionRule extends CSSGroupingRule { - conditionText: string; + readonly conditionText: string; } declare var CSSConditionRule: { @@ -2853,7 +2858,6 @@ interface CSSStyleDeclaration { columns: string; contain: string; content: string; - contentVisibility: string; counterIncrement: string; counterReset: string; counterSet: string; @@ -3227,6 +3231,8 @@ interface CSSStyleDeclaration { /** @deprecated This is a legacy alias of `perspectiveOrigin`. */ webkitPerspectiveOrigin: string; webkitTextFillColor: string; + /** @deprecated This is a legacy alias of `textSizeAdjust`. */ + webkitTextSizeAdjust: string; webkitTextStroke: string; webkitTextStrokeColor: string; webkitTextStrokeWidth: string; @@ -3294,6 +3300,8 @@ interface CSSStyleSheet extends StyleSheet { insertRule(rule: string, index?: number): number; /** @deprecated */ removeRule(index?: number): void; + replace(text: string): Promise; + replaceSync(text: string): void; } declare var CSSStyleSheet: { @@ -3777,6 +3785,7 @@ declare var CustomEvent: { /** An abnormal event (called an exception) which occurs as a result of calling a method or accessing a property of a web API. */ interface DOMException extends Error { + /** @deprecated */ readonly code: number; readonly message: string; readonly name: string; @@ -4521,8 +4530,6 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad createEvent(eventInterface: "IDBVersionChangeEvent"): IDBVersionChangeEvent; createEvent(eventInterface: "InputEvent"): InputEvent; createEvent(eventInterface: "KeyboardEvent"): KeyboardEvent; - createEvent(eventInterface: "MIDIConnectionEvent"): MIDIConnectionEvent; - createEvent(eventInterface: "MIDIMessageEvent"): MIDIMessageEvent; createEvent(eventInterface: "MediaEncryptedEvent"): MediaEncryptedEvent; createEvent(eventInterface: "MediaKeyMessageEvent"): MediaKeyMessageEvent; createEvent(eventInterface: "MediaQueryListEvent"): MediaQueryListEvent; @@ -4734,6 +4741,7 @@ interface DocumentOrShadowRoot { * Similarly, when the focused element is in a different node tree than documentOrShadowRoot, the element returned will be the host that's located in the same node tree as documentOrShadowRoot if documentOrShadowRoot is a shadow-including inclusive ancestor of the focused element, and null if not. */ readonly activeElement: Element | null; + adoptedStyleSheets: CSSStyleSheet[]; /** Returns document's fullscreen element. */ readonly fullscreenElement: Element | null; readonly pictureInPictureElement: Element | null; @@ -4981,14 +4989,24 @@ interface ElementInternals extends ARIAMixin { readonly labels: NodeList; /** Returns the ShadowRoot for internals's target element, if the target element is a shadow host, or null otherwise. */ readonly shadowRoot: ShadowRoot | null; + /** Returns the error message that would be shown to the user if internals's target element was to be checked for validity. */ + readonly validationMessage: string; + /** Returns the ValidityState object for internals's target element. */ + readonly validity: ValidityState; /** Returns true if internals's target element will be validated when the form is submitted; false otherwise. */ readonly willValidate: boolean; + /** Returns true if internals's target element has no validity problems; false otherwise. Fires an invalid event at the element in the latter case. */ + checkValidity(): boolean; + /** Returns true if internals's target element has no validity problems; otherwise, returns false, fires an invalid event at the element, and (if the event isn't canceled) reports the problem to the user. */ + reportValidity(): boolean; /** * Sets both the state and submission value of internals's target element to value. * * If value is null, the element won't participate in form submission. */ setFormValue(value: File | string | FormData | null, state?: File | string | FormData | null): void; + /** Marks internals's target element as suffering from the constraints indicated by the flags argument, and sets the element's validation message to message. If anchor is specified, the user agent might use it to indicate problems with the constraints of internals's target element when the form owner is validated interactively or reportValidity() is called. */ + setValidity(flags?: ValidityStateFlags, message?: string, anchor?: HTMLElement): void; } declare var ElementInternals: { @@ -6072,7 +6090,6 @@ declare var HTMLBaseElement: { }; interface HTMLBodyElementEventMap extends HTMLElementEventMap, WindowEventHandlersEventMap { - "orientationchange": Event; } /** Provides special properties (beyond those inherited from the regular HTMLElement interface) for manipulating elements. */ @@ -6086,8 +6103,6 @@ interface HTMLBodyElement extends HTMLElement, WindowEventHandlers { /** @deprecated */ link: string; /** @deprecated */ - onorientationchange: ((this: HTMLBodyElement, ev: Event) => any) | null; - /** @deprecated */ text: string; /** @deprecated */ vLink: string; @@ -6346,6 +6361,7 @@ interface HTMLElement extends Element, DocumentAndElementEventHandlers, ElementC dir: string; draggable: boolean; hidden: boolean; + inert: boolean; innerText: string; lang: string; readonly offsetHeight: number; @@ -7009,6 +7025,7 @@ interface HTMLInputElement extends HTMLElement { * @param direction The direction in which the selection is performed. */ setSelectionRange(start: number | null, end: number | null, direction?: "forward" | "backward" | "none"): void; + showPicker(): void; /** * Decrements a range input control's value by the value given by the Step attribute. If the optional parameter is used, it will decrement the input control's step value multiplied by the parameter's value. * @param n Value to decrement the value by. @@ -7236,6 +7253,7 @@ interface HTMLMediaElement extends HTMLElement { readonly played: TimeRanges; /** Gets or sets a value indicating what data should be preloaded, if any. */ preload: "none" | "metadata" | "auto" | ""; + preservesPitch: boolean; readonly readyState: number; readonly remote: RemotePlayback; /** Returns a TimeRanges object that represents the ranges of the current media resource that can be seeked. */ @@ -7602,16 +7620,25 @@ declare var HTMLParagraphElement: { new(): HTMLParagraphElement; }; -/** Provides special properties (beyond those of the regular HTMLElement object interface it inherits) for manipulating elements, representing a pair of a key and a value that acts as a parameter for an element. */ +/** + * Provides special properties (beyond those of the regular HTMLElement object interface it inherits) for manipulating elements, representing a pair of a key and a value that acts as a parameter for an element. + * @deprecated + */ interface HTMLParamElement extends HTMLElement { - /** Sets or retrieves the name of an input parameter for an element. */ + /** + * Sets or retrieves the name of an input parameter for an element. + * @deprecated + */ name: string; /** * Sets or retrieves the content type of the resource designated by the value attribute. * @deprecated */ type: string; - /** Sets or retrieves the value of an input parameter for an element. */ + /** + * Sets or retrieves the value of an input parameter for an element. + * @deprecated + */ value: string; /** * Sets or retrieves the data type of the value attribute. @@ -7624,6 +7651,7 @@ interface HTMLParamElement extends HTMLElement { removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; } +/** @deprecated */ declare var HTMLParamElement: { prototype: HTMLParamElement; new(): HTMLParamElement; @@ -8517,7 +8545,7 @@ interface IDBDatabase extends EventTarget { */ deleteObjectStore(name: string): void; /** Returns a new transaction with the given mode ("readonly" or "readwrite") and scope which can be a single object store name or an array of names. */ - transaction(storeNames: string | string[], mode?: IDBTransactionMode): IDBTransaction; + transaction(storeNames: string | string[], mode?: IDBTransactionMode, options?: IDBTransactionOptions): IDBTransaction; addEventListener(type: K, listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any, options?: boolean | EventListenerOptions): void; @@ -9103,126 +9131,6 @@ declare var LockManager: { new(): LockManager; }; -interface MIDIAccessEventMap { - "statechange": Event; -} - -/** Available only in secure contexts. */ -interface MIDIAccess extends EventTarget { - readonly inputs: MIDIInputMap; - onstatechange: ((this: MIDIAccess, ev: Event) => any) | null; - readonly outputs: MIDIOutputMap; - readonly sysexEnabled: boolean; - addEventListener(type: K, listener: (this: MIDIAccess, ev: MIDIAccessEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: MIDIAccess, ev: MIDIAccessEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var MIDIAccess: { - prototype: MIDIAccess; - new(): MIDIAccess; -}; - -/** Available only in secure contexts. */ -interface MIDIConnectionEvent extends Event { - readonly port: MIDIPort; -} - -declare var MIDIConnectionEvent: { - prototype: MIDIConnectionEvent; - new(type: string, eventInitDict?: MIDIConnectionEventInit): MIDIConnectionEvent; -}; - -interface MIDIInputEventMap extends MIDIPortEventMap { - "midimessage": Event; -} - -/** Available only in secure contexts. */ -interface MIDIInput extends MIDIPort { - onmidimessage: ((this: MIDIInput, ev: Event) => any) | null; - addEventListener(type: K, listener: (this: MIDIInput, ev: MIDIInputEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: MIDIInput, ev: MIDIInputEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var MIDIInput: { - prototype: MIDIInput; - new(): MIDIInput; -}; - -/** Available only in secure contexts. */ -interface MIDIInputMap { - forEach(callbackfn: (value: MIDIInput, key: string, parent: MIDIInputMap) => void, thisArg?: any): void; -} - -declare var MIDIInputMap: { - prototype: MIDIInputMap; - new(): MIDIInputMap; -}; - -/** Available only in secure contexts. */ -interface MIDIMessageEvent extends Event { - readonly data: Uint8Array; -} - -declare var MIDIMessageEvent: { - prototype: MIDIMessageEvent; - new(type: string, eventInitDict?: MIDIMessageEventInit): MIDIMessageEvent; -}; - -/** Available only in secure contexts. */ -interface MIDIOutput extends MIDIPort { - send(data: number[], timestamp?: DOMHighResTimeStamp): void; - addEventListener(type: K, listener: (this: MIDIOutput, ev: MIDIPortEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: MIDIOutput, ev: MIDIPortEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var MIDIOutput: { - prototype: MIDIOutput; - new(): MIDIOutput; -}; - -/** Available only in secure contexts. */ -interface MIDIOutputMap { - forEach(callbackfn: (value: MIDIOutput, key: string, parent: MIDIOutputMap) => void, thisArg?: any): void; -} - -declare var MIDIOutputMap: { - prototype: MIDIOutputMap; - new(): MIDIOutputMap; -}; - -interface MIDIPortEventMap { - "statechange": Event; -} - -/** Available only in secure contexts. */ -interface MIDIPort extends EventTarget { - readonly connection: MIDIPortConnectionState; - readonly id: string; - readonly manufacturer: string | null; - readonly name: string | null; - onstatechange: ((this: MIDIPort, ev: Event) => any) | null; - readonly state: MIDIPortDeviceState; - readonly type: MIDIPortType; - readonly version: string | null; - close(): Promise; - open(): Promise; - addEventListener(type: K, listener: (this: MIDIPort, ev: MIDIPortEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: MIDIPort, ev: MIDIPortEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var MIDIPort: { - prototype: MIDIPort; - new(): MIDIPort; -}; - interface MathMLElementEventMap extends ElementEventMap, DocumentAndElementEventHandlersEventMap, GlobalEventHandlersEventMap { } @@ -9925,7 +9833,7 @@ declare var NavigationPreloadManager: { }; /** The state and the identity of the user agent. It allows scripts to query it and to register themselves to carry on some activities. */ -interface Navigator extends NavigatorAutomationInformation, NavigatorConcurrentHardware, NavigatorContentUtils, NavigatorCookies, NavigatorID, NavigatorLanguage, NavigatorLocks, NavigatorNetworkInformation, NavigatorOnLine, NavigatorPlugins, NavigatorStorage { +interface Navigator extends NavigatorAutomationInformation, NavigatorConcurrentHardware, NavigatorContentUtils, NavigatorCookies, NavigatorID, NavigatorLanguage, NavigatorLocks, NavigatorOnLine, NavigatorPlugins, NavigatorStorage { /** Available only in secure contexts. */ readonly clipboard: Clipboard; /** Available only in secure contexts. */ @@ -9944,8 +9852,6 @@ interface Navigator extends NavigatorAutomationInformation, NavigatorConcurrentH canShare(data?: ShareData): boolean; getGamepads(): (Gamepad | null)[]; /** Available only in secure contexts. */ - requestMIDIAccess(options?: MIDIOptions): Promise; - /** Available only in secure contexts. */ requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): Promise; sendBeacon(url: string | URL, data?: BodyInit | null): boolean; /** Available only in secure contexts. */ @@ -9982,7 +9888,6 @@ interface NavigatorID { readonly appName: string; /** @deprecated */ readonly appVersion: string; - /** @deprecated */ readonly platform: string; /** @deprecated */ readonly product: string; @@ -10004,10 +9909,6 @@ interface NavigatorLocks { readonly locks: LockManager; } -interface NavigatorNetworkInformation { - readonly connection: NetworkInformation; -} - interface NavigatorOnLine { readonly onLine: boolean; } @@ -10027,15 +9928,6 @@ interface NavigatorStorage { readonly storage: StorageManager; } -interface NetworkInformation extends EventTarget { - readonly type: ConnectionType; -} - -declare var NetworkInformation: { - prototype: NetworkInformation; - new(): NetworkInformation; -}; - /** Node is an interface from which a number of DOM API object types inherit. It allows those types to be treated similarly; for example, inheriting the same set of methods, or being tested in the same way. */ interface Node extends EventTarget { /** Returns node's node document's document base URL. */ @@ -10994,6 +10886,7 @@ declare var PushManager: { */ interface PushSubscription { readonly endpoint: string; + readonly expirationTime: EpochTimeStamp | null; readonly options: PushSubscriptionOptions; getKey(name: PushEncryptionKeyName): ArrayBuffer | null; toJSON(): PushSubscriptionJSON; @@ -11475,6 +11368,19 @@ declare var Range: { toString(): string; }; +interface ReadableByteStreamController { + readonly byobRequest: ReadableStreamBYOBRequest | null; + readonly desiredSize: number | null; + close(): void; + enqueue(chunk: ArrayBufferView): void; + error(e?: any): void; +} + +declare var ReadableByteStreamController: { + prototype: ReadableByteStreamController; + new(): ReadableByteStreamController; +}; + /** This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object. */ interface ReadableStream { readonly locked: boolean; @@ -11490,6 +11396,27 @@ declare var ReadableStream: { new(underlyingSource?: UnderlyingSource, strategy?: QueuingStrategy): ReadableStream; }; +interface ReadableStreamBYOBReader extends ReadableStreamGenericReader { + read(view: ArrayBufferView): Promise>; + releaseLock(): void; +} + +declare var ReadableStreamBYOBReader: { + prototype: ReadableStreamBYOBReader; + new(stream: ReadableStream): ReadableStreamBYOBReader; +}; + +interface ReadableStreamBYOBRequest { + readonly view: ArrayBufferView | null; + respond(bytesWritten: number): void; + respondWithNewView(view: ArrayBufferView): void; +} + +declare var ReadableStreamBYOBRequest: { + prototype: ReadableStreamBYOBRequest; + new(): ReadableStreamBYOBRequest; +}; + interface ReadableStreamDefaultController { readonly desiredSize: number | null; close(): void; @@ -11503,7 +11430,7 @@ declare var ReadableStreamDefaultController: { }; interface ReadableStreamDefaultReader extends ReadableStreamGenericReader { - read(): Promise>; + read(): Promise>; releaseLock(): void; } @@ -13921,11 +13848,11 @@ declare var SubmitEvent: { * Available only in secure contexts. */ interface SubtleCrypto { - decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise; + decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise; deriveBits(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise; deriveKey(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise; digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise; - encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise; + encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise; exportKey(format: "jwk", key: CryptoKey): Promise; exportKey(format: Exclude, key: CryptoKey): Promise; generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray): Promise; @@ -16683,7 +16610,7 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler /** Returns true if the toolbar is visible; otherwise, returns false. */ readonly toolbar: BarProp; readonly top: WindowProxy | null; - readonly visualViewport: VisualViewport; + readonly visualViewport: VisualViewport | null; readonly window: Window & typeof globalThis; alert(message?: any): void; blur(): void; @@ -16802,8 +16729,8 @@ interface WindowOrWorkerGlobalScope { readonly performance: Performance; atob(data: string): string; btoa(data: string): string; - clearInterval(id?: number): void; - clearTimeout(id?: number): void; + clearInterval(id: number | undefined): void; + clearTimeout(id: number | undefined): void; createImageBitmap(image: ImageBitmapSource, options?: ImageBitmapOptions): Promise; createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; fetch(input: RequestInfo | URL, init?: RequestInit): Promise; @@ -16875,6 +16802,7 @@ declare var WritableStream: { /** This Streams API interface represents a controller allowing control of a WritableStream's state. When constructing a WritableStream, the underlying sink is given a corresponding WritableStreamDefaultController instance to manipulate. */ interface WritableStreamDefaultController { + readonly signal: AbortSignal; error(e?: any): void; } @@ -17493,7 +17421,6 @@ interface HTMLElementTagNameMap { "details": HTMLDetailsElement; "dfn": HTMLElement; "dialog": HTMLDialogElement; - "dir": HTMLDirectoryElement; "div": HTMLDivElement; "dl": HTMLDListElement; "dt": HTMLElement; @@ -17502,11 +17429,8 @@ interface HTMLElementTagNameMap { "fieldset": HTMLFieldSetElement; "figcaption": HTMLElement; "figure": HTMLElement; - "font": HTMLFontElement; "footer": HTMLElement; "form": HTMLFormElement; - "frame": HTMLFrameElement; - "frameset": HTMLFrameSetElement; "h1": HTMLHeadingElement; "h2": HTMLHeadingElement; "h3": HTMLHeadingElement; @@ -17531,7 +17455,6 @@ interface HTMLElementTagNameMap { "main": HTMLElement; "map": HTMLMapElement; "mark": HTMLElement; - "marquee": HTMLMarqueeElement; "menu": HTMLMenuElement; "meta": HTMLMetaElement; "meter": HTMLMeterElement; @@ -17543,7 +17466,6 @@ interface HTMLElementTagNameMap { "option": HTMLOptionElement; "output": HTMLOutputElement; "p": HTMLParagraphElement; - "param": HTMLParamElement; "picture": HTMLPictureElement; "pre": HTMLPreElement; "progress": HTMLProgressElement; @@ -17585,7 +17507,34 @@ interface HTMLElementTagNameMap { } interface HTMLElementDeprecatedTagNameMap { + "acronym": HTMLElement; + "applet": HTMLUnknownElement; + "basefont": HTMLElement; + "bgsound": HTMLUnknownElement; + "big": HTMLElement; + "blink": HTMLUnknownElement; + "center": HTMLElement; + "dir": HTMLDirectoryElement; + "font": HTMLFontElement; + "frame": HTMLFrameElement; + "frameset": HTMLFrameSetElement; + "isindex": HTMLUnknownElement; + "keygen": HTMLUnknownElement; "listing": HTMLPreElement; + "marquee": HTMLMarqueeElement; + "menuitem": HTMLElement; + "multicol": HTMLUnknownElement; + "nextid": HTMLUnknownElement; + "nobr": HTMLElement; + "noembed": HTMLElement; + "noframes": HTMLElement; + "param": HTMLParamElement; + "plaintext": HTMLElement; + "rb": HTMLElement; + "rtc": HTMLElement; + "spacer": HTMLUnknownElement; + "strike": HTMLElement; + "tt": HTMLElement; "xmp": HTMLPreElement; } @@ -17734,7 +17683,7 @@ declare var statusbar: BarProp; /** Returns true if the toolbar is visible; otherwise, returns false. */ declare var toolbar: BarProp; declare var top: WindowProxy | null; -declare var visualViewport: VisualViewport; +declare var visualViewport: VisualViewport | null; declare var window: Window & typeof globalThis; declare function alert(message?: any): void; declare function blur(): void; @@ -18088,8 +18037,8 @@ declare var origin: string; declare var performance: Performance; declare function atob(data: string): string; declare function btoa(data: string): string; -declare function clearInterval(id?: number): void; -declare function clearTimeout(id?: number): void; +declare function clearInterval(id: number | undefined): void; +declare function clearTimeout(id: number | undefined): void; declare function createImageBitmap(image: ImageBitmapSource, options?: ImageBitmapOptions): Promise; declare function createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; declare function fetch(input: RequestInfo | URL, init?: RequestInit): Promise; @@ -18138,7 +18087,7 @@ type GLuint64 = number; type HTMLOrSVGImageElement = HTMLImageElement | SVGImageElement; type HTMLOrSVGScriptElement = HTMLScriptElement | SVGScriptElement; type HashAlgorithmIdentifier = AlgorithmIdentifier; -type HeadersInit = string[][] | Record | Headers; +type HeadersInit = [string, string][] | Record | Headers; type IDBValidKey = number | string | Date | BufferSource | IDBValidKey[]; type ImageBitmapSource = CanvasImageSource | Blob | ImageData; type InsertPosition = "beforebegin" | "afterbegin" | "beforeend" | "afterend"; @@ -18152,7 +18101,7 @@ type OnBeforeUnloadEventHandler = OnBeforeUnloadEventHandlerNonNull | null; type OnErrorEventHandler = OnErrorEventHandlerNonNull | null; type PerformanceEntryList = PerformanceEntry[]; type ReadableStreamController = ReadableStreamDefaultController; -type ReadableStreamDefaultReadResult = ReadableStreamDefaultReadValueResult | ReadableStreamDefaultReadDoneResult; +type ReadableStreamReadResult = ReadableStreamReadValueResult | ReadableStreamReadDoneResult; type ReadableStreamReader = ReadableStreamDefaultReader; type RenderingContext = CanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext; type RequestInfo = Request | string; @@ -18196,11 +18145,10 @@ type ColorGamut = "p3" | "rec2020" | "srgb"; type ColorSpaceConversion = "default" | "none"; type CompositeOperation = "accumulate" | "add" | "replace"; type CompositeOperationOrAuto = "accumulate" | "add" | "auto" | "replace"; -type ConnectionType = "bluetooth" | "cellular" | "ethernet" | "mixed" | "none" | "other" | "unknown" | "wifi"; type CredentialMediationRequirement = "optional" | "required" | "silent"; type DOMParserSupportedType = "application/xhtml+xml" | "application/xml" | "image/svg+xml" | "text/html" | "text/xml"; type DirectionSetting = "" | "lr" | "rl"; -type DisplayCaptureSurfaceType = "application" | "browser" | "monitor" | "window"; +type DisplayCaptureSurfaceType = "browser" | "monitor" | "window"; type DistanceModelType = "exponential" | "inverse" | "linear"; type DocumentReadyState = "complete" | "interactive" | "loading"; type DocumentVisibilityState = "hidden" | "visible"; @@ -18227,9 +18175,6 @@ type KeyType = "private" | "public" | "secret"; type KeyUsage = "decrypt" | "deriveBits" | "deriveKey" | "encrypt" | "sign" | "unwrapKey" | "verify" | "wrapKey"; type LineAlignSetting = "center" | "end" | "start"; type LockMode = "exclusive" | "shared"; -type MIDIPortConnectionState = "closed" | "open" | "pending"; -type MIDIPortDeviceState = "connected" | "disconnected"; -type MIDIPortType = "input" | "output"; type MediaDecodingType = "file" | "media-source" | "webrtc"; type MediaDeviceKind = "audioinput" | "audiooutput" | "videoinput"; type MediaEncodingType = "record" | "webrtc"; diff --git a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.dom.iterable.d.ts b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.dom.iterable.d.ts index 4fcd2a2db..cde428dfc 100644 --- a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.dom.iterable.d.ts +++ b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.dom.iterable.d.ts @@ -121,7 +121,7 @@ interface Headers { interface IDBDatabase { /** Returns a new transaction with the given mode ("readonly" or "readwrite") and scope which can be a single object store name or an array of names. */ - transaction(storeNames: string | Iterable, mode?: IDBTransactionMode): IDBTransaction; + transaction(storeNames: string | Iterable, mode?: IDBTransactionMode, options?: IDBTransactionOptions): IDBTransaction; } interface IDBObjectStore { @@ -133,16 +133,6 @@ interface IDBObjectStore { createIndex(name: string, keyPath: string | Iterable, options?: IDBIndexParameters): IDBIndex; } -interface MIDIInputMap extends ReadonlyMap { -} - -interface MIDIOutput { - send(data: Iterable, timestamp?: DOMHighResTimeStamp): void; -} - -interface MIDIOutputMap extends ReadonlyMap { -} - interface MediaKeyStatusMap { [Symbol.iterator](): IterableIterator<[BufferSource, MediaKeyStatus]>; entries(): IterableIterator<[BufferSource, MediaKeyStatus]>; diff --git a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2015.collection.d.ts b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2015.collection.d.ts index dc154ca17..c2e7733ae 100644 --- a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2015.collection.d.ts +++ b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2015.collection.d.ts @@ -19,18 +19,38 @@ and limitations under the License. interface Map { + clear(): void; + /** + * @returns true if an element in the Map existed and has been removed, or false if the element does not exist. + */ delete(key: K): boolean; + /** + * Executes a provided function once per each key/value pair in the Map, in insertion order. + */ forEach(callbackfn: (value: V, key: K, map: Map) => void, thisArg?: any): void; + /** + * Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map. + * @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned. + */ get(key: K): V | undefined; + /** + * @returns boolean indicating whether an element with the specified key exists or not. + */ has(key: K): boolean; + /** + * Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated. + */ set(key: K, value: V): this; + /** + * @returns the number of elements in the Map. + */ readonly size: number; } interface MapConstructor { new(): Map; - new(entries?: readonly (readonly [K, V])[] | null): Map; + new (entries?: readonly (readonly [K, V])[] | null): Map; readonly prototype: Map; } declare var Map: MapConstructor; @@ -43,9 +63,23 @@ interface ReadonlyMap { } interface WeakMap { + /** + * Removes the specified element from the WeakMap. + * @returns true if the element was successfully removed, or false if it was not present. + */ delete(key: K): boolean; + /** + * @returns a specified element. + */ get(key: K): V | undefined; + /** + * @returns a boolean indicating whether an element with the specified key exists or not. + */ has(key: K): boolean; + /** + * Adds a new element with a specified key and value. + * @param key Must be an object. + */ set(key: K, value: V): this; } @@ -56,11 +90,28 @@ interface WeakMapConstructor { declare var WeakMap: WeakMapConstructor; interface Set { + /** + * Appends a new element with a specified value to the end of the Set. + */ add(value: T): this; + clear(): void; + /** + * Removes a specified value from the Set. + * @returns Returns true if an element in the Set existed and has been removed, or false if the element does not exist. + */ delete(value: T): boolean; + /** + * Executes a provided function once per each value in the Set object, in insertion order. + */ forEach(callbackfn: (value: T, value2: T, set: Set) => void, thisArg?: any): void; + /** + * @returns a boolean indicating whether an element with the specified value exists in the Set or not. + */ has(value: T): boolean; + /** + * @returns the number of (unique) elements in Set. + */ readonly size: number; } @@ -77,8 +128,18 @@ interface ReadonlySet { } interface WeakSet { + /** + * Appends a new object to the end of the WeakSet. + */ add(value: T): this; + /** + * Removes the specified element from the WeakSet. + * @returns Returns true if the element existed and has been removed, or false if the element does not exist. + */ delete(value: T): boolean; + /** + * @returns a boolean indicating whether an object exists in the WeakSet or not. + */ has(value: T): boolean; } diff --git a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2015.proxy.d.ts b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2015.proxy.d.ts index 9e8b8757a..c24186615 100644 --- a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2015.proxy.d.ts +++ b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2015.proxy.d.ts @@ -19,23 +19,112 @@ and limitations under the License. interface ProxyHandler { + /** + * A trap method for a function call. + * @param target The original callable object which is being proxied. + */ apply?(target: T, thisArg: any, argArray: any[]): any; + + /** + * A trap for the `new` operator. + * @param target The original object which is being proxied. + * @param newTarget The constructor that was originally called. + */ construct?(target: T, argArray: any[], newTarget: Function): object; - defineProperty?(target: T, p: string | symbol, attributes: PropertyDescriptor): boolean; + + /** + * A trap for `Object.defineProperty()`. + * @param target The original object which is being proxied. + * @returns A `Boolean` indicating whether or not the property has been defined. + */ + defineProperty?(target: T, property: string | symbol, attributes: PropertyDescriptor): boolean; + + /** + * A trap for the `delete` operator. + * @param target The original object which is being proxied. + * @param p The name or `Symbol` of the property to delete. + * @returns A `Boolean` indicating whether or not the property was deleted. + */ deleteProperty?(target: T, p: string | symbol): boolean; + + /** + * A trap for getting a property value. + * @param target The original object which is being proxied. + * @param p The name or `Symbol` of the property to get. + * @param receiver The proxy or an object that inherits from the proxy. + */ get?(target: T, p: string | symbol, receiver: any): any; + + /** + * A trap for `Object.getOwnPropertyDescriptor()`. + * @param target The original object which is being proxied. + * @param p The name of the property whose description should be retrieved. + */ getOwnPropertyDescriptor?(target: T, p: string | symbol): PropertyDescriptor | undefined; + + /** + * A trap for the `[[GetPrototypeOf]]` internal method. + * @param target The original object which is being proxied. + */ getPrototypeOf?(target: T): object | null; + + /** + * A trap for the `in` operator. + * @param target The original object which is being proxied. + * @param p The name or `Symbol` of the property to check for existence. + */ has?(target: T, p: string | symbol): boolean; + + /** + * A trap for `Object.isExtensible()`. + * @param target The original object which is being proxied. + */ isExtensible?(target: T): boolean; + + /** + * A trap for `Reflect.ownKeys()`. + * @param target The original object which is being proxied. + */ ownKeys?(target: T): ArrayLike; + + /** + * A trap for `Object.preventExtensions()`. + * @param target The original object which is being proxied. + */ preventExtensions?(target: T): boolean; - set?(target: T, p: string | symbol, value: any, receiver: any): boolean; + + /** + * A trap for setting a property value. + * @param target The original object which is being proxied. + * @param p The name or `Symbol` of the property to set. + * @param receiver The object to which the assignment was originally directed. + * @returns `A `Boolean` indicating whether or not the property was set. + */ + set?(target: T, p: string | symbol, newValue: any, receiver: any): boolean; + + /** + * A trap for `Object.setPrototypeOf()`. + * @param target The original object which is being proxied. + * @param newPrototype The object's new prototype or `null`. + */ setPrototypeOf?(target: T, v: object | null): boolean; } interface ProxyConstructor { + /** + * Creates a revocable Proxy object. + * @param target A target object to wrap with Proxy. + * @param handler An object whose properties define the behavior of Proxy when an operation is attempted on it. + */ revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; + + /** + * Creates a Proxy object. The Proxy object allows you to create an object that can be used in place of the + * original object, but which may redefine fundamental Object operations like getting, setting, and defining + * properties. Proxy objects are commonly used to log property accesses, validate, format, or sanitize inputs. + * @param target A target object to wrap with Proxy. + * @param handler An object whose properties define the behavior of Proxy when an operation is attempted on it. + */ new (target: T, handler: ProxyHandler): T; } declare var Proxy: ProxyConstructor; diff --git a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2017.intl.d.ts b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2017.intl.d.ts index f20c149f2..c2ab43e8f 100644 --- a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2017.intl.d.ts +++ b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2017.intl.d.ts @@ -19,7 +19,22 @@ and limitations under the License. declare namespace Intl { - type DateTimeFormatPartTypes = "day" | "dayPeriod" | "era" | "hour" | "literal" | "minute" | "month" | "second" | "timeZoneName" | "weekday" | "year"; + + interface DateTimeFormatPartTypesRegistry { + day: any + dayPeriod: any + era: any + hour: any + literal: any + minute: any + month: any + second: any + timeZoneName: any + weekday: any + year: any + } + + type DateTimeFormatPartTypes = keyof DateTimeFormatPartTypesRegistry; interface DateTimeFormatPart { type: DateTimeFormatPartTypes; diff --git a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2020.intl.d.ts b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2020.intl.d.ts index af981e31c..5bce3812d 100644 --- a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2020.intl.d.ts +++ b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2020.intl.d.ts @@ -18,6 +18,7 @@ and limitations under the License. /// +/// declare namespace Intl { /** @@ -50,6 +51,25 @@ declare namespace Intl { | "second" | "seconds"; + /** + * Value of the `unit` property in objects returned by + * `Intl.RelativeTimeFormat.prototype.formatToParts()`. `formatToParts` and + * `format` methods accept either singular or plural unit names as input, + * but `formatToParts` only outputs singular (e.g. "day") not plural (e.g. + * "days"). + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts#Using_formatToParts). + */ + type RelativeTimeFormatUnitSingular = + | "year" + | "quarter" + | "month" + | "week" + | "day" + | "hour" + | "minute" + | "second"; + /** * The locale matching algorithm to use. * @@ -120,11 +140,16 @@ declare namespace Intl { * * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts#Using_formatToParts). */ - interface RelativeTimeFormatPart { - type: string; - value: string; - unit?: RelativeTimeFormatUnit; - } + type RelativeTimeFormatPart = + | { + type: "literal"; + value: string; + } + | { + type: Exclude; + value: string; + unit: RelativeTimeFormatUnitSingular; + }; interface RelativeTimeFormat { /** diff --git a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2021.intl.d.ts b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2021.intl.d.ts index 1e8cec37a..e66ebb1af 100644 --- a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2021.intl.d.ts +++ b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2021.intl.d.ts @@ -20,17 +20,25 @@ and limitations under the License. declare namespace Intl { + interface DateTimeFormatPartTypesRegistry { + fractionalSecond: any + } + interface DateTimeFormatOptions { formatMatcher?: "basic" | "best fit" | "best fit" | undefined; dateStyle?: "full" | "long" | "medium" | "short" | undefined; timeStyle?: "full" | "long" | "medium" | "short" | undefined; dayPeriod?: "narrow" | "short" | "long" | undefined; - fractionalSecondDigits?: 0 | 1 | 2 | 3 | undefined; + fractionalSecondDigits?: 1 | 2 | 3 | undefined; + } + + interface DateTimeRangeFormatPart extends DateTimeFormatPart { + source: "startRange" | "endRange" | "shared" } interface DateTimeFormat { formatRange(startDate: Date | number | bigint, endDate: Date | number | bigint): string; - formatRangeToParts(startDate: Date | number | bigint, endDate: Date | number | bigint): DateTimeFormatPart[]; + formatRangeToParts(startDate: Date | number | bigint, endDate: Date | number | bigint): DateTimeRangeFormatPart[]; } interface ResolvedDateTimeFormatOptions { @@ -39,7 +47,7 @@ declare namespace Intl { timeStyle?: "full" | "long" | "medium" | "short"; hourCycle?: "h11" | "h12" | "h23" | "h24"; dayPeriod?: "narrow" | "short" | "long"; - fractionalSecondDigits?: 0 | 1 | 2 | 3; + fractionalSecondDigits?: 1 | 2 | 3; } /** diff --git a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2022.d.ts b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2022.d.ts index 6d4283d28..83eb960c4 100644 --- a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2022.d.ts +++ b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2022.d.ts @@ -23,4 +23,5 @@ and limitations under the License. /// /// /// +/// /// diff --git a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2022.error.d.ts b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2022.error.d.ts index d97525dcc..4b16e0912 100644 --- a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2022.error.d.ts +++ b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2022.error.d.ts @@ -19,11 +19,11 @@ and limitations under the License. interface ErrorOptions { - cause?: Error; + cause?: unknown; } interface Error { - cause?: Error; + cause?: unknown; } interface ErrorConstructor { diff --git a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2022.sharedmemory.d.ts b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2022.sharedmemory.d.ts new file mode 100644 index 000000000..43b9b88dc --- /dev/null +++ b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es2022.sharedmemory.d.ts @@ -0,0 +1,27 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + + + +/// + + +interface Atomics { + /** + * A non-blocking, asynchronous version of wait which is usable on the main thread. + * Waits asynchronously on a shared memory location and returns a Promise + */ + waitAsync(typedArray: BigInt64Array | Int32Array, index: number, value: bigint, timeout?: number): { async: false, value: "ok" | "not-equal" | "timed-out" } | { async: true, value: Promise<"ok" | "not-equal" | "timed-out"> }; +} diff --git a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es5.d.ts b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es5.d.ts index d45132b5b..28ca95abe 100644 --- a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es5.d.ts +++ b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.es5.d.ts @@ -933,12 +933,24 @@ interface DateConstructor { declare var Date: DateConstructor; interface RegExpMatchArray extends Array { + /** + * The index of the search at which the result was found. + */ index?: number; + /** + * A copy of the search string. + */ input?: string; } interface RegExpExecArray extends Array { + /** + * The index of the search at which the result was found. + */ index: number; + /** + * A copy of the search string. + */ input: string; } @@ -1584,7 +1596,7 @@ type Omit = Pick>; /** * Exclude null and undefined from T */ -type NonNullable = T extends null | undefined ? never : T; +type NonNullable = T & {}; /** * Obtain the parameters of a function type in a tuple diff --git a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.esnext.intl.d.ts b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.esnext.intl.d.ts index 954679457..0eaac02b9 100644 --- a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.esnext.intl.d.ts +++ b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.esnext.intl.d.ts @@ -19,8 +19,12 @@ and limitations under the License. declare namespace Intl { + interface NumberRangeFormatPart extends NumberFormatPart { + source: "startRange" | "endRange" | "shared" + } + interface NumberFormat { formatRange(start: number | bigint, end: number | bigint): string; - formatRangeToParts(start: number | bigint, end: number | bigint): NumberFormatPart[]; + formatRangeToParts(start: number | bigint, end: number | bigint): NumberRangeFormatPart[]; } } diff --git a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.webworker.d.ts b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.webworker.d.ts index 6f9a2eaf5..30f83bc84 100644 --- a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.webworker.d.ts +++ b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.webworker.d.ts @@ -271,6 +271,10 @@ interface IDBObjectStoreParameters { keyPath?: string | string[] | null; } +interface IDBTransactionOptions { + durability?: IDBTransactionDurability; +} + interface IDBVersionChangeEventInit extends EventInit { newVersion?: number | null; oldVersion?: number; @@ -496,12 +500,12 @@ interface RTCEncodedVideoFrameMetadata { width?: number; } -interface ReadableStreamDefaultReadDoneResult { +interface ReadableStreamReadDoneResult { done: true; value?: undefined; } -interface ReadableStreamDefaultReadValueResult { +interface ReadableStreamReadValueResult { done: false; value: T; } @@ -1004,6 +1008,7 @@ declare var CustomEvent: { /** An abnormal event (called an exception) which occurs as a result of calling a method or accessing a property of a web API. */ interface DOMException extends Error { + /** @deprecated */ readonly code: number; readonly message: string; readonly name: string; @@ -1466,7 +1471,7 @@ declare var EventTarget: { /** Extends the lifetime of the install and activate events dispatched on the global scope as part of the service worker lifecycle. This ensures that any functional events (like FetchEvent) are not dispatched until it upgrades database schemas and deletes the outdated cache entries. */ interface ExtendableEvent extends Event { - waitUntil(f: any): void; + waitUntil(f: Promise): void; } declare var ExtendableEvent: { @@ -1801,7 +1806,7 @@ interface IDBDatabase extends EventTarget { */ deleteObjectStore(name: string): void; /** Returns a new transaction with the given mode ("readonly" or "readwrite") and scope which can be a single object store name or an array of names. */ - transaction(storeNames: string | string[], mode?: IDBTransactionMode): IDBTransaction; + transaction(storeNames: string | string[], mode?: IDBTransactionMode, options?: IDBTransactionOptions): IDBTransaction; addEventListener(type: K, listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any, options?: boolean | EventListenerOptions): void; @@ -2287,7 +2292,6 @@ interface NavigatorID { readonly appName: string; /** @deprecated */ readonly appVersion: string; - /** @deprecated */ readonly platform: string; /** @deprecated */ readonly product: string; @@ -2304,10 +2308,6 @@ interface NavigatorLocks { readonly locks: LockManager; } -interface NavigatorNetworkInformation { - readonly connection: NetworkInformation; -} - interface NavigatorOnLine { readonly onLine: boolean; } @@ -2317,15 +2317,6 @@ interface NavigatorStorage { readonly storage: StorageManager; } -interface NetworkInformation extends EventTarget { - readonly type: ConnectionType; -} - -declare var NetworkInformation: { - prototype: NetworkInformation; - new(): NetworkInformation; -}; - interface NotificationEventMap { "click": Event; "close": Event; @@ -2658,6 +2649,7 @@ declare var PushMessageData: { */ interface PushSubscription { readonly endpoint: string; + readonly expirationTime: EpochTimeStamp | null; readonly options: PushSubscriptionOptions; getKey(name: PushEncryptionKeyName): ArrayBuffer | null; toJSON(): PushSubscriptionJSON; @@ -2702,6 +2694,19 @@ declare var RTCEncodedVideoFrame: { new(): RTCEncodedVideoFrame; }; +interface ReadableByteStreamController { + readonly byobRequest: ReadableStreamBYOBRequest | null; + readonly desiredSize: number | null; + close(): void; + enqueue(chunk: ArrayBufferView): void; + error(e?: any): void; +} + +declare var ReadableByteStreamController: { + prototype: ReadableByteStreamController; + new(): ReadableByteStreamController; +}; + /** This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object. */ interface ReadableStream { readonly locked: boolean; @@ -2717,6 +2722,27 @@ declare var ReadableStream: { new(underlyingSource?: UnderlyingSource, strategy?: QueuingStrategy): ReadableStream; }; +interface ReadableStreamBYOBReader extends ReadableStreamGenericReader { + read(view: ArrayBufferView): Promise>; + releaseLock(): void; +} + +declare var ReadableStreamBYOBReader: { + prototype: ReadableStreamBYOBReader; + new(stream: ReadableStream): ReadableStreamBYOBReader; +}; + +interface ReadableStreamBYOBRequest { + readonly view: ArrayBufferView | null; + respond(bytesWritten: number): void; + respondWithNewView(view: ArrayBufferView): void; +} + +declare var ReadableStreamBYOBRequest: { + prototype: ReadableStreamBYOBRequest; + new(): ReadableStreamBYOBRequest; +}; + interface ReadableStreamDefaultController { readonly desiredSize: number | null; close(): void; @@ -2730,7 +2756,7 @@ declare var ReadableStreamDefaultController: { }; interface ReadableStreamDefaultReader extends ReadableStreamGenericReader { - read(): Promise>; + read(): Promise>; releaseLock(): void; } @@ -2899,6 +2925,7 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope { onnotificationclose: ((this: ServiceWorkerGlobalScope, ev: NotificationEvent) => any) | null; onpush: ((this: ServiceWorkerGlobalScope, ev: PushEvent) => any) | null; readonly registration: ServiceWorkerRegistration; + readonly serviceWorker: ServiceWorker; skipWaiting(): Promise; addEventListener(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -2981,11 +3008,11 @@ declare var StorageManager: { * Available only in secure contexts. */ interface SubtleCrypto { - decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise; + decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise; deriveBits(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise; deriveKey(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise; digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise; - encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise; + encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise; exportKey(format: "jwk", key: CryptoKey): Promise; exportKey(format: Exclude, key: CryptoKey): Promise; generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray): Promise; @@ -5278,8 +5305,8 @@ interface WindowOrWorkerGlobalScope { readonly performance: Performance; atob(data: string): string; btoa(data: string): string; - clearInterval(id?: number): void; - clearTimeout(id?: number): void; + clearInterval(id: number | undefined): void; + clearTimeout(id: number | undefined): void; createImageBitmap(image: ImageBitmapSource, options?: ImageBitmapOptions): Promise; createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; fetch(input: RequestInfo | URL, init?: RequestInit): Promise; @@ -5371,7 +5398,7 @@ declare var WorkerLocation: { }; /** A subset of the Navigator interface allowed to be accessed from a Worker. Such an object is initialized for each worker and is available via the WorkerGlobalScope.navigator property obtained by calling window.self.navigator. */ -interface WorkerNavigator extends NavigatorConcurrentHardware, NavigatorID, NavigatorLanguage, NavigatorLocks, NavigatorNetworkInformation, NavigatorOnLine, NavigatorStorage { +interface WorkerNavigator extends NavigatorConcurrentHardware, NavigatorID, NavigatorLanguage, NavigatorLocks, NavigatorOnLine, NavigatorStorage { readonly mediaCapabilities: MediaCapabilities; } @@ -5395,6 +5422,7 @@ declare var WritableStream: { /** This Streams API interface represents a controller allowing control of a WritableStream's state. When constructing a WritableStream, the underlying sink is given a corresponding WritableStreamDefaultController instance to manipulate. */ interface WritableStreamDefaultController { + readonly signal: AbortSignal; error(e?: any): void; } @@ -5818,8 +5846,8 @@ declare var origin: string; declare var performance: Performance; declare function atob(data: string): string; declare function btoa(data: string): string; -declare function clearInterval(id?: number): void; -declare function clearTimeout(id?: number): void; +declare function clearInterval(id: number | undefined): void; +declare function clearTimeout(id: number | undefined): void; declare function createImageBitmap(image: ImageBitmapSource, options?: ImageBitmapOptions): Promise; declare function createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; declare function fetch(input: RequestInfo | URL, init?: RequestInit): Promise; @@ -5859,7 +5887,7 @@ type GLsizeiptr = number; type GLuint = number; type GLuint64 = number; type HashAlgorithmIdentifier = AlgorithmIdentifier; -type HeadersInit = string[][] | Record | Headers; +type HeadersInit = [string, string][] | Record | Headers; type IDBValidKey = number | string | Date | BufferSource | IDBValidKey[]; type ImageBitmapSource = CanvasImageSource | Blob | ImageData; type Int32List = Int32Array | GLint[]; @@ -5869,7 +5897,7 @@ type OnErrorEventHandler = OnErrorEventHandlerNonNull | null; type PerformanceEntryList = PerformanceEntry[]; type PushMessageDataInit = BufferSource | string; type ReadableStreamController = ReadableStreamDefaultController; -type ReadableStreamDefaultReadResult = ReadableStreamDefaultReadValueResult | ReadableStreamDefaultReadDoneResult; +type ReadableStreamReadResult = ReadableStreamReadValueResult | ReadableStreamReadDoneResult; type ReadableStreamReader = ReadableStreamDefaultReader; type RequestInfo = Request | string; type TexImageSource = ImageBitmap | ImageData | OffscreenCanvas; @@ -5882,7 +5910,6 @@ type BinaryType = "arraybuffer" | "blob"; type ClientTypes = "all" | "sharedworker" | "window" | "worker"; type ColorGamut = "p3" | "rec2020" | "srgb"; type ColorSpaceConversion = "default" | "none"; -type ConnectionType = "bluetooth" | "cellular" | "ethernet" | "mixed" | "none" | "other" | "unknown" | "wifi"; type DocumentVisibilityState = "hidden" | "visible"; type EndingType = "native" | "transparent"; type FileSystemHandleKind = "directory" | "file"; diff --git a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.webworker.iterable.d.ts b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.webworker.iterable.d.ts index af2588150..3d9e75d00 100644 --- a/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.webworker.iterable.d.ts +++ b/src/BundleTransformer.TypeScript/Resources/DefaultLibraries/lib.webworker.iterable.d.ts @@ -59,7 +59,7 @@ interface Headers { interface IDBDatabase { /** Returns a new transaction with the given mode ("readonly" or "readwrite") and scope which can be a single object store name or an array of names. */ - transaction(storeNames: string | Iterable, mode?: IDBTransactionMode): IDBTransaction; + transaction(storeNames: string | Iterable, mode?: IDBTransactionMode, options?: IDBTransactionOptions): IDBTransaction; } interface IDBObjectStore { diff --git a/src/BundleTransformer.TypeScript/Resources/typescript-combined.js b/src/BundleTransformer.TypeScript/Resources/typescript-combined.js index 5b12e582a..e8781dbea 100644 --- a/src/BundleTransformer.TypeScript/Resources/typescript-combined.js +++ b/src/BundleTransformer.TypeScript/Resources/typescript-combined.js @@ -68,8 +68,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; var ts; (function (ts) { - ts.versionMajorMinor = "4.7"; - ts.version = "4.7.4"; + ts.versionMajorMinor = "4.8"; + ts.version = "4.8.2"; var NativeCollections; (function (NativeCollections) { var globals = typeof globalThis !== "undefined" ? globalThis : @@ -234,8 +234,10 @@ var ts; return true; } ts.every = every; - function find(array, predicate) { - for (var i = 0; i < array.length; i++) { + function find(array, predicate, startIndex) { + if (array === undefined) + return undefined; + for (var i = startIndex !== null && startIndex !== void 0 ? startIndex : 0; i < array.length; i++) { var value = array[i]; if (predicate(value, i)) { return value; @@ -244,8 +246,10 @@ var ts; return undefined; } ts.find = find; - function findLast(array, predicate) { - for (var i = array.length - 1; i >= 0; i--) { + function findLast(array, predicate, startIndex) { + if (array === undefined) + return undefined; + for (var i = startIndex !== null && startIndex !== void 0 ? startIndex : array.length - 1; i >= 0; i--) { var value = array[i]; if (predicate(value, i)) { return value; @@ -255,7 +259,9 @@ var ts; } ts.findLast = findLast; function findIndex(array, predicate, startIndex) { - for (var i = startIndex || 0; i < array.length; i++) { + if (array === undefined) + return -1; + for (var i = startIndex !== null && startIndex !== void 0 ? startIndex : 0; i < array.length; i++) { if (predicate(array[i], i)) { return i; } @@ -264,7 +270,9 @@ var ts; } ts.findIndex = findIndex; function findLastIndex(array, predicate, startIndex) { - for (var i = startIndex === undefined ? array.length - 1 : startIndex; i >= 0; i--) { + if (array === undefined) + return -1; + for (var i = startIndex !== null && startIndex !== void 0 ? startIndex : array.length - 1; i >= 0; i--) { if (predicate(array[i], i)) { return i; } @@ -970,7 +978,7 @@ var ts; } ts.elementAt = elementAt; function firstOrUndefined(array) { - return array.length === 0 ? undefined : array[0]; + return array === undefined || array.length === 0 ? undefined : array[0]; } ts.firstOrUndefined = firstOrUndefined; function first(array) { @@ -979,7 +987,7 @@ var ts; } ts.first = first; function lastOrUndefined(array) { - return array.length === 0 ? undefined : array[array.length - 1]; + return array === undefined || array.length === 0 ? undefined : array[array.length - 1]; } ts.lastOrUndefined = lastOrUndefined; function last(array) { @@ -1270,6 +1278,41 @@ var ts; return createMultiMap(); } ts.createUnderscoreEscapedMultiMap = createUnderscoreEscapedMultiMap; + function createQueue(items) { + var elements = (items === null || items === void 0 ? void 0 : items.slice()) || []; + var headIndex = 0; + function isEmpty() { + return headIndex === elements.length; + } + function enqueue() { + var items = []; + for (var _i = 0; _i < arguments.length; _i++) { + items[_i] = arguments[_i]; + } + elements.push.apply(elements, items); + } + function dequeue() { + if (isEmpty()) { + throw new Error("Queue is empty"); + } + var result = elements[headIndex]; + elements[headIndex] = undefined; + headIndex++; + if (headIndex > 100 && headIndex > (elements.length >> 1)) { + var newLength = elements.length - headIndex; + elements.copyWithin(0, headIndex); + elements.length = newLength; + headIndex = 0; + } + return result; + } + return { + enqueue: enqueue, + dequeue: dequeue, + isEmpty: isEmpty, + }; + } + ts.createQueue = createQueue; function createSet(getHashCode, equals) { var multiMap = new ts.Map(); var size = 0; @@ -1441,6 +1484,10 @@ var ts; ts.cast = cast; function noop(_) { } ts.noop = noop; + ts.noopPush = { + push: noop, + length: 0 + }; function returnFalse() { return false; } @@ -1664,7 +1711,7 @@ var ts; } ts.compareBooleans = compareBooleans; function getSpellingSuggestion(name, candidates, getName) { - var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34)); + var maximumLengthDifference = Math.max(2, Math.floor(name.length * 0.34)); var bestDistance = Math.floor(name.length * 0.4) + 1; var bestCandidate; for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) { @@ -1862,6 +1909,7 @@ var ts; startsWith(candidate, prefix) && endsWith(candidate, suffix); } + ts.isPatternMatch = isPatternMatch; function and(f, g) { return function (arg) { return f(arg) && g(arg); }; } @@ -2023,6 +2071,7 @@ var ts; var currentAssertionLevel = 0; Debug.currentLogLevel = LogLevel.Warning; Debug.isDebugging = false; + Debug.enableDeprecationWarnings = true; function getTypeScriptVersion() { return typeScriptVersion !== null && typeScriptVersion !== void 0 ? typeScriptVersion : (typeScriptVersion = new ts.Version(ts.version)); } @@ -2230,7 +2279,7 @@ var ts; return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0"; } if (isFlags) { - var result = ""; + var result = []; var remainingFlags = value; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var _a = members_1[_i], enumValue = _a[0], enumName = _a[1]; @@ -2238,12 +2287,12 @@ var ts; break; } if (enumValue !== 0 && enumValue & value) { - result = "".concat(result).concat(result ? "|" : "").concat(enumName); + result.push(enumName); remainingFlags &= ~enumValue; } } if (remainingFlags === 0) { - return result; + return result.join("|"); } } else { @@ -2257,7 +2306,12 @@ var ts; return value.toString(); } Debug.formatEnum = formatEnum; + var enumMemberCache = new ts.Map(); function getEnumMembers(enumObject) { + var existing = enumMemberCache.get(enumObject); + if (existing) { + return existing; + } var result = []; for (var name in enumObject) { var value = enumObject[name]; @@ -2265,7 +2319,9 @@ var ts; result.push([value, name]); } } - return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); }); + var sorted = ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); }); + enumMemberCache.set(enumObject, sorted); + return sorted; } function formatSyntaxKind(kind) { return formatEnum(kind, ts.SyntaxKind, false); @@ -2311,6 +2367,22 @@ var ts; return formatEnum(flags, ts.FlowFlags, true); } Debug.formatFlowFlags = formatFlowFlags; + function formatRelationComparisonResult(result) { + return formatEnum(result, ts.RelationComparisonResult, true); + } + Debug.formatRelationComparisonResult = formatRelationComparisonResult; + function formatCheckMode(mode) { + return formatEnum(mode, ts.CheckMode, true); + } + Debug.formatCheckMode = formatCheckMode; + function formatSignatureCheckMode(mode) { + return formatEnum(mode, ts.SignatureCheckMode, true); + } + Debug.formatSignatureCheckMode = formatSignatureCheckMode; + function formatTypeFacts(facts) { + return formatEnum(facts, ts.TypeFacts, true); + } + Debug.formatTypeFacts = formatTypeFacts; var isDebugInfoEnabled = false; var extendedDebugModule; function extendedDebug() { @@ -2584,7 +2656,7 @@ var ts; function createWarningDeprecation(name, errorAfter, since, message) { var hasWrittenDeprecation = false; return function () { - if (!hasWrittenDeprecation) { + if (Debug.enableDeprecationWarnings && !hasWrittenDeprecation) { log.warn(formatDeprecationMessage(name, false, errorAfter, since, message)); hasWrittenDeprecation = true; } @@ -2603,6 +2675,7 @@ var ts; warn ? createWarningDeprecation(name, errorAfter, since, options.message) : ts.noop; } + Debug.createDeprecation = createDeprecation; function wrapFunction(deprecation, func) { return function () { deprecation(); @@ -2610,10 +2683,53 @@ var ts; }; } function deprecate(func, options) { - var deprecation = createDeprecation(getFunctionName(func), options); + var _a; + var deprecation = createDeprecation((_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : getFunctionName(func), options); return wrapFunction(deprecation, func); } Debug.deprecate = deprecate; + function formatVariance(varianceFlags) { + var variance = varianceFlags & 7; + var result = variance === 0 ? "in out" : + variance === 3 ? "[bivariant]" : + variance === 2 ? "in" : + variance === 1 ? "out" : + variance === 4 ? "[independent]" : ""; + if (varianceFlags & 8) { + result += " (unmeasurable)"; + } + else if (varianceFlags & 16) { + result += " (unreliable)"; + } + return result; + } + Debug.formatVariance = formatVariance; + var DebugTypeMapper = (function () { + function DebugTypeMapper() { + } + DebugTypeMapper.prototype.__debugToString = function () { + var _a; + type(this); + switch (this.kind) { + case 3: return ((_a = this.debugInfo) === null || _a === void 0 ? void 0 : _a.call(this)) || "(function mapper)"; + case 0: return "".concat(this.source.__debugTypeToString(), " -> ").concat(this.target.__debugTypeToString()); + case 1: return ts.zipWith(this.sources, this.targets || ts.map(this.sources, function () { return "any"; }), function (s, t) { return "".concat(s.__debugTypeToString(), " -> ").concat(typeof t === "string" ? t : t.__debugTypeToString()); }).join(", "); + case 2: return ts.zipWith(this.sources, this.targets, function (s, t) { return "".concat(s.__debugTypeToString(), " -> ").concat(t().__debugTypeToString()); }).join(", "); + case 5: + case 4: return "m1: ".concat(this.mapper1.__debugToString().split("\n").join("\n "), "\nm2: ").concat(this.mapper2.__debugToString().split("\n").join("\n ")); + default: return assertNever(this); + } + }; + return DebugTypeMapper; + }()); + Debug.DebugTypeMapper = DebugTypeMapper; + function attachDebugPrototypeIfDebug(mapper) { + if (Debug.isDebugging) { + return Object.setPrototypeOf(mapper, DebugTypeMapper.prototype); + } + return mapper; + } + Debug.attachDebugPrototypeIfDebug = attachDebugPrototypeIfDebug; })(Debug = ts.Debug || (ts.Debug = {})); })(ts || (ts = {})); var ts; @@ -3186,9 +3302,9 @@ var ts; eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd }); } tracingEnabled.push = push; - function pop() { + function pop(results) { ts.Debug.assert(eventStack.length > 0); - writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp()); + writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp(), results); eventStack.length--; } tracingEnabled.pop = pop; @@ -3201,13 +3317,14 @@ var ts; } tracingEnabled.popAll = popAll; var sampleInterval = 1000 * 10; - function writeStackEvent(index, endTime) { + function writeStackEvent(index, endTime, results) { var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd; if (separateBeginAndEnd) { + ts.Debug.assert(!results, "`results` are not supported for events with `separateBeginAndEnd`"); writeEvent("E", phase, name, args, undefined, endTime); } else if (sampleInterval - (time % sampleInterval) <= endTime - time) { - writeEvent("X", phase, name, args, "\"dur\":".concat(endTime - time), time); + writeEvent("X", phase, name, __assign(__assign({}, args), { results: results }), "\"dur\":".concat(endTime - time), time); } } function writeEvent(eventType, phase, name, args, extras, time) { @@ -4082,6 +4199,7 @@ var ts; String_literal_expected: diag(1141, ts.DiagnosticCategory.Error, "String_literal_expected_1141", "String literal expected."), Line_break_not_permitted_here: diag(1142, ts.DiagnosticCategory.Error, "Line_break_not_permitted_here_1142", "Line break not permitted here."), or_expected: diag(1144, ts.DiagnosticCategory.Error, "or_expected_1144", "'{' or ';' expected."), + or_JSX_element_expected: diag(1145, ts.DiagnosticCategory.Error, "or_JSX_element_expected_1145", "'{' or JSX element expected."), Declaration_expected: diag(1146, ts.DiagnosticCategory.Error, "Declaration_expected_1146", "Declaration expected."), Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), @@ -4135,6 +4253,7 @@ var ts; Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."), Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."), _0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module: diag(1208, ts.DiagnosticCategory.Error, "_0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_imp_1208", "'{0}' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module."), + Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0: diag(1209, ts.DiagnosticCategory.Error, "Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0_1209", "Invalid optional chain from new expression. Did you mean to call '{0}()'?"), Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of_0_For_more_information_see_https_Colon_Slash_Slashdeveloper_mozilla_org_Slashen_US_Slashdocs_SlashWeb_SlashJavaScript_SlashReference_SlashStrict_mode: diag(1210, ts.DiagnosticCategory.Error, "Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of__1210", "Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of '{0}'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode."), A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."), Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."), @@ -4227,6 +4346,7 @@ var ts; infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), + Class_constructor_may_not_be_an_accessor: diag(1341, ts.DiagnosticCategory.Error, "Class_constructor_may_not_be_an_accessor_1341", "Class constructor may not be an accessor."), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'."), A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), @@ -4245,6 +4365,7 @@ var ts; An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."), Tagged_template_expressions_are_not_permitted_in_an_optional_chain: diag(1358, ts.DiagnosticCategory.Error, "Tagged_template_expressions_are_not_permitted_in_an_optional_chain_1358", "Tagged template expressions are not permitted in an optional chain."), Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here: diag(1359, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359", "Identifier expected. '{0}' is a reserved word that cannot be used here."), + Class_constructor_may_not_be_a_generator: diag(1360, ts.DiagnosticCategory.Error, "Class_constructor_may_not_be_a_generator_1360", "Class constructor may not be a generator."), _0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type: diag(1361, ts.DiagnosticCategory.Error, "_0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type_1361", "'{0}' cannot be used as a value because it was imported using 'import type'."), _0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type: diag(1362, ts.DiagnosticCategory.Error, "_0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type_1362", "'{0}' cannot be used as a value because it was exported using 'export type'."), A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both: diag(1363, ts.DiagnosticCategory.Error, "A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both_1363", "A type-only import can specify a default import or named bindings, but not both."), @@ -4334,13 +4455,25 @@ var ts; resolution_mode_can_only_be_set_for_type_only_imports: diag(1454, ts.DiagnosticCategory.Error, "resolution_mode_can_only_be_set_for_type_only_imports_1454", "`resolution-mode` can only be set for type-only imports."), resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, ts.DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."), Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require: diag(1456, ts.DiagnosticCategory.Error, "Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require_1456", "Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`."), + Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk: diag(1457, ts.DiagnosticCategory.Message, "Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk_1457", "Matched by default include pattern '**/*'"), + File_is_ECMAScript_module_because_0_has_field_type_with_value_module: diag(1458, ts.DiagnosticCategory.Message, "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458", "File is ECMAScript module because '{0}' has field \"type\" with value \"module\""), + File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module: diag(1459, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459", "File is CommonJS module because '{0}' has field \"type\" whose value is not \"module\""), + File_is_CommonJS_module_because_0_does_not_have_field_type: diag(1460, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_does_not_have_field_type_1460", "File is CommonJS module because '{0}' does not have field \"type\""), + File_is_CommonJS_module_because_package_json_was_not_found: diag(1461, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_package_json_was_not_found_1461", "File is CommonJS module because 'package.json' was not found"), The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."), - Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."), + Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead."), catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."), An_import_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1473, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473", "An import declaration can only be used at the top level of a module."), An_export_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1474, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474", "An export declaration can only be used at the top level of a module."), Control_what_method_is_used_to_detect_module_format_JS_files: diag(1475, ts.DiagnosticCategory.Message, "Control_what_method_is_used_to_detect_module_format_JS_files_1475", "Control what method is used to detect module-format JS files."), auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules."), + An_instantiation_expression_cannot_be_followed_by_a_property_access: diag(1477, ts.DiagnosticCategory.Error, "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477", "An instantiation expression cannot be followed by a property access."), + Identifier_or_string_literal_expected: diag(1478, ts.DiagnosticCategory.Error, "Identifier_or_string_literal_expected_1478", "Identifier or string literal expected."), + The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead: diag(1479, ts.DiagnosticCategory.Error, "The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_reference_1479", "The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"{0}\")' call instead."), + To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module: diag(1480, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_packag_1480", "To convert this file to an ECMAScript module, change its file extension to '{0}' or create a local package.json file with `{ \"type\": \"module\" }`."), + To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1: diag(1481, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Co_1481", "To convert this file to an ECMAScript module, change its file extension to '{0}', or add the field `\"type\": \"module\"` to '{1}'."), + To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0: diag(1482, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0_1482", "To convert this file to an ECMAScript module, add the field `\"type\": \"module\"` to '{0}'."), + To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module: diag(1483, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module_1483", "To convert this file to an ECMAScript module, create a local package.json file with `{ \"type\": \"module\" }`."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", undefined, true), @@ -4349,8 +4482,11 @@ var ts; Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", undefined, true), The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."), The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."), + This_type_parameter_might_need_an_extends_0_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_might_need_an_extends_0_constraint_2208", "This type parameter might need an `extends {0}` constraint."), The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."), The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."), + Add_extends_constraint: diag(2211, ts.DiagnosticCategory.Message, "Add_extends_constraint_2211", "Add `extends` constraint."), + Add_extends_constraint_to_all_type_parameters: diag(2212, ts.DiagnosticCategory.Message, "Add_extends_constraint_to_all_type_parameters_2212", "Add `extends` constraint to all type parameters"), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), @@ -4551,6 +4687,7 @@ var ts; Cannot_create_an_instance_of_an_abstract_class: diag(2511, ts.DiagnosticCategory.Error, "Cannot_create_an_instance_of_an_abstract_class_2511", "Cannot create an instance of an abstract class."), Overload_signatures_must_all_be_abstract_or_non_abstract: diag(2512, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_abstract_or_non_abstract_2512", "Overload signatures must all be abstract or non-abstract."), Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: diag(2513, ts.DiagnosticCategory.Error, "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", "Abstract method '{0}' in class '{1}' cannot be accessed via super expression."), + A_tuple_type_cannot_be_indexed_with_a_negative_value: diag(2514, ts.DiagnosticCategory.Error, "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514", "A tuple type cannot be indexed with a negative value."), Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: diag(2515, ts.DiagnosticCategory.Error, "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'."), All_declarations_of_an_abstract_method_must_be_consecutive: diag(2516, ts.DiagnosticCategory.Error, "All_declarations_of_an_abstract_method_must_be_consecutive_2516", "All declarations of an abstract method must be consecutive."), Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: diag(2517, ts.DiagnosticCategory.Error, "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", "Cannot assign an abstract constructor type to a non-abstract constructor type."), @@ -4833,7 +4970,12 @@ var ts; Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls: diag(2836, ts.DiagnosticCategory.Error, "Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls_2836", "Import assertions are not allowed on statements that transpile to commonjs 'require' calls."), Import_assertion_values_must_be_string_literal_expressions: diag(2837, ts.DiagnosticCategory.Error, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."), All_declarations_of_0_must_have_identical_constraints: diag(2838, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."), + This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value: diag(2839, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value_2839", "This condition will always return '{0}' since JavaScript compares objects by reference, not value."), + An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes: diag(2840, ts.DiagnosticCategory.Error, "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840", "An interface cannot extend a primitive type like '{0}'; an interface can only extend named types and classes"), The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, ts.DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), + _0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, ts.DiagnosticCategory.Error, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"), + We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, ts.DiagnosticCategory.Error, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."), + Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, ts.DiagnosticCategory.Error, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "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: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -5244,8 +5386,8 @@ var ts; Cannot_prepend_project_0_because_it_does_not_have_outFile_set: diag(6308, ts.DiagnosticCategory.Error, "Cannot_prepend_project_0_because_it_does_not_have_outFile_set_6308", "Cannot prepend project '{0}' because it does not have 'outFile' set"), Output_file_0_from_project_1_does_not_exist: diag(6309, ts.DiagnosticCategory.Error, "Output_file_0_from_project_1_does_not_exist_6309", "Output file '{0}' from project '{1}' does not exist"), Referenced_project_0_may_not_disable_emit: diag(6310, ts.DiagnosticCategory.Error, "Referenced_project_0_may_not_disable_emit_6310", "Referenced project '{0}' may not disable emit."), - Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2: diag(6350, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2_6350", "Project '{0}' is out of date because oldest output '{1}' is older than newest input '{2}'"), - Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2: diag(6351, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2_6351", "Project '{0}' is up to date because newest input '{1}' is older than oldest output '{2}'"), + Project_0_is_out_of_date_because_output_1_is_older_than_input_2: diag(6350, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_1_is_older_than_input_2_6350", "Project '{0}' is out of date because output '{1}' is older than input '{2}'"), + Project_0_is_up_to_date_because_newest_input_1_is_older_than_output_2: diag(6351, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_because_newest_input_1_is_older_than_output_2_6351", "Project '{0}' is up to date because newest input '{1}' is older than output '{2}'"), Project_0_is_out_of_date_because_output_file_1_does_not_exist: diag(6352, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_file_1_does_not_exist_6352", "Project '{0}' is out of date because output file '{1}' does not exist"), Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date: diag(6353, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date_6353", "Project '{0}' is out of date because its dependency '{1}' is out of date"), Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies: diag(6354, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies_6354", "Project '{0}' is up to date with .d.ts files from its dependencies"), @@ -5289,6 +5431,8 @@ var ts; Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3: diag(6396, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6396", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}'."), Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4: diag(6397, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6397", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}' with Package ID '{4}'."), Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved: diag(6398, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_re_6398", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was not resolved."), + Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitted: diag(6399, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitte_6399", "Project '{0}' is out of date because buildinfo file '{1}' indicates that some of the changes were not emitted"), + Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_files: diag(6400, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_fil_6400", "Project '{0}' is up to date but needs to update timestamps of output files that are older than input files"), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), @@ -5529,6 +5673,8 @@ var ts; Qualified_name_0_is_not_allowed_without_a_leading_param_object_1: diag(8032, ts.DiagnosticCategory.Error, "Qualified_name_0_is_not_allowed_without_a_leading_param_object_1_8032", "Qualified name '{0}' is not allowed without a leading '@param {object} {1}'."), A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags: diag(8033, ts.DiagnosticCategory.Error, "A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033", "A JSDoc '@typedef' comment may not contain multiple '@type' tags."), The_tag_was_first_specified_here: diag(8034, ts.DiagnosticCategory.Error, "The_tag_was_first_specified_here_8034", "The tag was first specified here."), + You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder: diag(8035, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035", "You cannot rename elements that are defined in a 'node_modules' folder."), + You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder: diag(8036, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036", "You cannot rename elements that are defined in another 'node_modules' folder."), Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."), Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."), JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."), @@ -5799,6 +5945,9 @@ var ts; For_await_loops_cannot_be_used_inside_a_class_static_block: diag(18038, ts.DiagnosticCategory.Error, "For_await_loops_cannot_be_used_inside_a_class_static_block_18038", "'For await' loops cannot be used inside a class static block."), Invalid_use_of_0_It_cannot_be_used_inside_a_class_static_block: diag(18039, ts.DiagnosticCategory.Error, "Invalid_use_of_0_It_cannot_be_used_inside_a_class_static_block_18039", "Invalid use of '{0}'. It cannot be used inside a class static block."), A_return_statement_cannot_be_used_inside_a_class_static_block: diag(18041, ts.DiagnosticCategory.Error, "A_return_statement_cannot_be_used_inside_a_class_static_block_18041", "A 'return' statement cannot be used inside a class static block."), + _0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation: diag(18042, ts.DiagnosticCategory.Error, "_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042", "'{0}' is a type and cannot be imported in JavaScript files. Use '{1}' in a JSDoc type annotation."), + Types_cannot_appear_in_export_declarations_in_JavaScript_files: diag(18043, ts.DiagnosticCategory.Error, "Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043", "Types cannot appear in export declarations in JavaScript files."), + _0_is_automatically_exported_here: diag(18044, ts.DiagnosticCategory.Message, "_0_is_automatically_exported_here_18044", "'{0}' is automatically exported here."), }; })(ts || (ts = {})); var ts; @@ -8320,6 +8469,18 @@ var ts; } } ts.getAssignedName = getAssignedName; + function getDecorators(node) { + if (ts.hasDecorators(node)) { + return ts.filter(node.modifiers, ts.isDecorator); + } + } + ts.getDecorators = getDecorators; + function getModifiers(node) { + if (ts.hasSyntacticModifier(node, 125951)) { + return ts.filter(node.modifiers, isModifier); + } + } + ts.getModifiers = getModifiers; function getJSDocParameterTagsWorker(param, noCache) { if (param.name) { if (ts.isIdentifier(param.name)) { @@ -8524,6 +8685,9 @@ var ts; if (node.typeParameters) { return node.typeParameters; } + if (ts.canHaveIllegalTypeParameters(node) && node.typeParameters) { + return node.typeParameters; + } if (ts.isInJSFile(node)) { var decls = ts.getJSDocTypeParameterDeclarations(node); if (decls.length) { @@ -8659,6 +8823,18 @@ var ts; return isLiteralKind(node.kind); } ts.isLiteralExpression = isLiteralExpression; + function isLiteralExpressionOfObject(node) { + switch (node.kind) { + case 205: + case 204: + case 13: + case 213: + case 226: + return true; + } + return false; + } + ts.isLiteralExpressionOfObject = isLiteralExpressionOfObject; function isTemplateLiteralKind(kind) { return 14 <= kind && kind <= 17; } @@ -8848,6 +9024,10 @@ var ts; } } ts.isMethodOrAccessor = isMethodOrAccessor; + function isModifierLike(node) { + return isModifier(node) || ts.isDecorator(node); + } + ts.isModifierLike = isModifierLike; function isTypeElement(node) { var kind = node.kind; return kind === 175 @@ -9371,7 +9551,6 @@ var ts; case 254: case 164: case 203: - case 166: case 167: case 296: case 299: @@ -9421,6 +9600,16 @@ var ts; return node.kind === 324 || node.kind === 325 || node.kind === 326; } ts.isJSDocLinkLike = isJSDocLinkLike; + function hasRestParameter(s) { + var last = ts.lastOrUndefined(s.parameters); + return !!last && isRestParameter(last); + } + ts.hasRestParameter = hasRestParameter; + function isRestParameter(node) { + var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; + return node.dotDotDotToken !== undefined || !!type && type.kind === 318; + } + ts.isRestParameter = isRestParameter; })(ts || (ts = {})); var ts; (function (ts) { @@ -9834,10 +10023,11 @@ var ts; } ts.getTokenPosOfNode = getTokenPosOfNode; function getNonDecoratorTokenPosOfNode(node, sourceFile) { - if (nodeIsMissing(node) || !node.decorators) { + var lastDecorator = !nodeIsMissing(node) && ts.canHaveModifiers(node) ? ts.findLast(node.modifiers, ts.isDecorator) : undefined; + if (!lastDecorator) { return getTokenPosOfNode(node, sourceFile); } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, lastDecorator.end); } ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { @@ -11089,7 +11279,7 @@ var ts; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node, parent, grandparent) { - return node.decorators !== undefined + return hasDecorators(node) && nodeCanBeDecorated(node, parent, grandparent); } ts.nodeIsDecorated = nodeIsDecorated; @@ -11914,16 +12104,6 @@ var ts; return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; - function hasRestParameter(s) { - var last = ts.lastOrUndefined(s.parameters); - return !!last && isRestParameter(last); - } - ts.hasRestParameter = hasRestParameter; - function isRestParameter(node) { - var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 318; - } - ts.isRestParameter = isRestParameter; function hasTypeArguments(node) { return !!node.typeArguments; } @@ -12026,6 +12206,12 @@ var ts; return [child, node]; } ts.walkUpParenthesizedTypesAndGetParentAndChild = walkUpParenthesizedTypesAndGetParentAndChild; + function skipTypeParentheses(node) { + while (ts.isParenthesizedTypeNode(node)) + node = node.type; + return node; + } + ts.skipTypeParentheses = skipTypeParentheses; function skipParentheses(node, excludeJSDocTypeAssertions) { var flags = excludeJSDocTypeAssertions ? 1 | 16 : @@ -13439,6 +13625,10 @@ var ts; return hasEffectiveModifier(node, 64); } ts.hasEffectiveReadonlyModifier = hasEffectiveReadonlyModifier; + function hasDecorators(node) { + return hasSyntacticModifier(node, 131072); + } + ts.hasDecorators = hasDecorators; function getSelectedEffectiveModifierFlags(node, flags) { return getEffectiveModifierFlags(node) & flags; } @@ -13496,7 +13686,7 @@ var ts; } ts.getEffectiveModifierFlagsNoCache = getEffectiveModifierFlagsNoCache; function getSyntacticModifierFlagsNoCache(node) { - var flags = modifiersToFlags(node.modifiers); + var flags = ts.canHaveModifiers(node) ? modifiersToFlags(node.modifiers) : 0; if (node.flags & 4 || (node.kind === 79 && node.isInJSDocNamespace)) { flags |= 1; } @@ -13530,6 +13720,7 @@ var ts; case 159: return 16384; case 101: return 32768; case 144: return 65536; + case 165: return 131072; } return 0; } @@ -13864,14 +14055,16 @@ var ts; } ts.moveRangePos = moveRangePos; function moveRangePastDecorators(node) { - return node.decorators && node.decorators.length > 0 - ? moveRangePos(node, node.decorators.end) + var lastDecorator = ts.canHaveModifiers(node) ? ts.findLast(node.modifiers, ts.isDecorator) : undefined; + return lastDecorator && !positionIsSynthesized(lastDecorator.end) + ? moveRangePos(node, lastDecorator.end) : node; } ts.moveRangePastDecorators = moveRangePastDecorators; function moveRangePastModifiers(node) { - return node.modifiers && node.modifiers.length > 0 - ? moveRangePos(node, node.modifiers.end) + var lastModifier = ts.canHaveModifiers(node) ? ts.lastOrUndefined(node.modifiers) : undefined; + return lastModifier && !positionIsSynthesized(lastModifier.end) + ? moveRangePos(node, lastModifier.end) : moveRangePastDecorators(node); } ts.moveRangePastModifiers = moveRangePastModifiers; @@ -13977,7 +14170,8 @@ var ts; function getDeclarationModifierFlagsFromSymbol(s, isWrite) { if (isWrite === void 0) { isWrite = false; } if (s.valueDeclaration) { - var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 173; })) || s.valueDeclaration; + var declaration = (isWrite && s.declarations && ts.find(s.declarations, ts.isSetAccessorDeclaration)) + || (s.flags & 32768 && ts.find(s.declarations, ts.isGetAccessorDeclaration)) || s.valueDeclaration; var flags = ts.getCombinedModifierFlags(declaration); return s.parent && s.parent.flags & 32 ? flags : flags & ~28; } @@ -14599,7 +14793,7 @@ var ts; return !file.isDeclarationFile ? walkTreeForJSXTags(file) : undefined; } function isFileForcedToBeModuleByFormat(file) { - return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs", ".cts"]))) && !file.isDeclarationFile ? true : undefined; + return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs", ".cts", ".mjs", ".mts"]))) && !file.isDeclarationFile ? true : undefined; } function getSetExternalModuleIndicator(options) { switch (getEmitModuleDetectionKind(options)) { @@ -14616,10 +14810,7 @@ var ts; if (options.jsx === 4 || options.jsx === 5) { checks.push(isFileModuleFromUsingJSXTag); } - var moduleKind = getEmitModuleKind(options); - if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) { - checks.push(isFileForcedToBeModuleByFormat); - } + checks.push(isFileForcedToBeModuleByFormat); var combined_1 = ts.or.apply(void 0, checks); var callback = function (file) { return void (file.externalModuleIndicator = combined_1(file)); }; return callback; @@ -14745,6 +14936,10 @@ var ts; return optionsHaveChanges(oldOptions, newOptions, ts.affectsEmitOptionDeclarations); } ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit; + function compilerOptionsAffectDeclarationPath(newOptions, oldOptions) { + return optionsHaveChanges(oldOptions, newOptions, ts.affectsDeclarationPathOptionDeclarations); + } + ts.compilerOptionsAffectDeclarationPath = compilerOptionsAffectDeclarationPath; function getCompilerOptionValue(options, option) { return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name]; } @@ -15556,8 +15751,12 @@ var ts; return node.parent.templateSpans; case 233: return node.parent.templateSpans; - case 165: - return node.parent.decorators; + case 165: { + var parent_2 = node.parent; + return ts.canHaveDecorators(parent_2) ? parent_2.modifiers : + ts.canHaveIllegalDecorators(parent_2) ? parent_2.illegalDecorators : + undefined; + } case 291: return node.parent.heritageClauses; } @@ -15918,10 +16117,11 @@ var ts; } return parenthesizeLeftSideOfAccess(expression); } - function parenthesizeLeftSideOfAccess(expression) { + function parenthesizeLeftSideOfAccess(expression, optionalChain) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 209 || emittedExpression.arguments)) { + && (emittedExpression.kind !== 209 || emittedExpression.arguments) + && (optionalChain || !ts.isOptionalChain(emittedExpression))) { return expression; } return ts.setTextRange(factory.createParenthesizedExpression(expression), expression); @@ -16736,23 +16936,22 @@ var ts; function createBaseNode(kind) { return baseFactory.createBaseNode(kind); } - function createBaseDeclaration(kind, decorators, modifiers) { + function createBaseDeclaration(kind) { var node = createBaseNode(kind); - node.decorators = asNodeArray(decorators); - node.modifiers = asNodeArray(modifiers); - node.transformFlags |= - propagateChildrenFlags(node.decorators) | - propagateChildrenFlags(node.modifiers); node.symbol = undefined; node.localSymbol = undefined; node.locals = undefined; node.nextContainer = undefined; return node; } - function createBaseNamedDeclaration(kind, decorators, modifiers, name) { - var node = createBaseDeclaration(kind, decorators, modifiers); + function createBaseNamedDeclaration(kind, modifiers, name) { + var node = createBaseDeclaration(kind); name = asName(name); node.name = name; + if (ts.canHaveModifiers(node)) { + node.modifiers = asNodeArray(modifiers); + node.transformFlags |= propagateChildrenFlags(node.modifiers); + } if (name) { switch (node.kind) { case 169: @@ -16771,16 +16970,16 @@ var ts; } return node; } - function createBaseGenericNamedDeclaration(kind, decorators, modifiers, name, typeParameters) { - var node = createBaseNamedDeclaration(kind, decorators, modifiers, name); + function createBaseGenericNamedDeclaration(kind, modifiers, name, typeParameters) { + var node = createBaseNamedDeclaration(kind, modifiers, name); node.typeParameters = asNodeArray(typeParameters); node.transformFlags |= propagateChildrenFlags(node.typeParameters); if (typeParameters) node.transformFlags |= 1; return node; } - function createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type) { - var node = createBaseGenericNamedDeclaration(kind, decorators, modifiers, name, typeParameters); + function createBaseSignatureDeclaration(kind, modifiers, name, typeParameters, parameters, type) { + var node = createBaseGenericNamedDeclaration(kind, modifiers, name, typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.transformFlags |= @@ -16788,48 +16987,43 @@ var ts; propagateChildFlags(node.type); if (type) node.transformFlags |= 1; + node.typeArguments = undefined; return node; } - function updateBaseSignatureDeclaration(updated, original) { - if (original.typeArguments) + function finishUpdateBaseSignatureDeclaration(updated, original) { + if (updated !== original) { updated.typeArguments = original.typeArguments; + } return update(updated, original); } - function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) { - var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type); + function createBaseFunctionLikeDeclaration(kind, modifiers, name, typeParameters, parameters, type, body) { + var node = createBaseSignatureDeclaration(kind, modifiers, name, typeParameters, parameters, type); node.body = body; - node.transformFlags |= propagateChildFlags(node.body) & ~16777216; + node.transformFlags |= propagateChildFlags(node.body) & ~67108864; if (!body) node.transformFlags |= 1; return node; } - function updateBaseFunctionLikeDeclaration(updated, original) { - if (original.exclamationToken) - updated.exclamationToken = original.exclamationToken; - if (original.typeArguments) - updated.typeArguments = original.typeArguments; - return updateBaseSignatureDeclaration(updated, original); - } - function createBaseInterfaceOrClassLikeDeclaration(kind, decorators, modifiers, name, typeParameters, heritageClauses) { - var node = createBaseGenericNamedDeclaration(kind, decorators, modifiers, name, typeParameters); + function createBaseInterfaceOrClassLikeDeclaration(kind, modifiers, name, typeParameters, heritageClauses) { + var node = createBaseGenericNamedDeclaration(kind, modifiers, name, typeParameters); node.heritageClauses = asNodeArray(heritageClauses); node.transformFlags |= propagateChildrenFlags(node.heritageClauses); return node; } - function createBaseClassLikeDeclaration(kind, decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(kind, decorators, modifiers, name, typeParameters, heritageClauses); + function createBaseClassLikeDeclaration(kind, modifiers, name, typeParameters, heritageClauses, members) { + var node = createBaseInterfaceOrClassLikeDeclaration(kind, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members); return node; } - function createBaseBindingLikeDeclaration(kind, decorators, modifiers, name, initializer) { - var node = createBaseNamedDeclaration(kind, decorators, modifiers, name); + function createBaseBindingLikeDeclaration(kind, modifiers, name, initializer) { + var node = createBaseNamedDeclaration(kind, modifiers, name); node.initializer = initializer; node.transformFlags |= propagateChildFlags(node.initializer); return node; } - function createBaseVariableLikeDeclaration(kind, decorators, modifiers, name, type, initializer) { - var node = createBaseBindingLikeDeclaration(kind, decorators, modifiers, name, initializer); + function createBaseVariableLikeDeclaration(kind, modifiers, name, type, initializer) { + var node = createBaseBindingLikeDeclaration(kind, modifiers, name, initializer); node.type = type; node.transformFlags |= propagateChildFlags(type); if (type) @@ -16911,7 +17105,7 @@ var ts; node.typeArguments = createNodeArray(typeArguments); } if (node.originalKeywordKind === 132) { - node.transformFlags |= 16777216; + node.transformFlags |= 67108864; } return node; } @@ -16954,7 +17148,7 @@ var ts; ts.Debug.fail("First character of private identifier must be #: " + text); var node = baseFactory.createBasePrivateIdentifierNode(80); node.escapedText = ts.escapeLeadingUnderscores(text); - node.transformFlags |= 8388608; + node.transformFlags |= 16777216; return node; } function createBaseToken(kind) { @@ -16997,13 +17191,13 @@ var ts; transformFlags = 1; break; case 106: - transformFlags = 1024 | 33554432; + transformFlags = 1024 | 134217728; break; case 124: transformFlags = 1024; break; case 108: - transformFlags = 8192; + transformFlags = 16384; break; } if (transformFlags) { @@ -17082,7 +17276,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.expression) | 1024 | - 65536; + 131072; return node; } function updateComputedPropertyName(node, expression) { @@ -17090,40 +17284,14 @@ var ts; ? update(createComputedPropertyName(expression), node) : node; } - function createTypeParameterDeclaration(modifiersOrName, nameOrConstraint, constraintOrDefault, defaultType) { - var name; - var modifiers; - var constraint; - if (modifiersOrName === undefined || ts.isArray(modifiersOrName)) { - modifiers = modifiersOrName; - name = nameOrConstraint; - constraint = constraintOrDefault; - } - else { - modifiers = undefined; - name = modifiersOrName; - constraint = nameOrConstraint; - } - var node = createBaseNamedDeclaration(163, undefined, modifiers, name); + function createTypeParameterDeclaration(modifiers, name, constraint, defaultType) { + var node = createBaseNamedDeclaration(163, modifiers, name); node.constraint = constraint; node.default = defaultType; node.transformFlags = 1; return node; } - function updateTypeParameterDeclaration(node, modifiersOrName, nameOrConstraint, constraintOrDefault, defaultType) { - var name; - var modifiers; - var constraint; - if (modifiersOrName === undefined || ts.isArray(modifiersOrName)) { - modifiers = modifiersOrName; - name = nameOrConstraint; - constraint = constraintOrDefault; - } - else { - modifiers = undefined; - name = modifiersOrName; - constraint = nameOrConstraint; - } + function updateTypeParameterDeclaration(node, modifiers, name, constraint, defaultType) { return node.modifiers !== modifiers || node.name !== name || node.constraint !== constraint @@ -17131,8 +17299,8 @@ var ts; ? update(createTypeParameterDeclaration(modifiers, name, constraint, defaultType), node) : node; } - function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(164, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + function createParameterDeclaration(modifiers, dotDotDotToken, name, questionToken, type, initializer) { + var node = createBaseVariableLikeDeclaration(164, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.dotDotDotToken = dotDotDotToken; node.questionToken = questionToken; if (ts.isThisIdentifier(node.name)) { @@ -17145,30 +17313,30 @@ var ts; if (questionToken) node.transformFlags |= 1; if (ts.modifiersToFlags(node.modifiers) & 16476) - node.transformFlags |= 4096; + node.transformFlags |= 8192; if (initializer || dotDotDotToken) node.transformFlags |= 1024; } return node; } - function updateParameterDeclaration(node, decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - return node.decorators !== decorators - || node.modifiers !== modifiers + function updateParameterDeclaration(node, modifiers, dotDotDotToken, name, questionToken, type, initializer) { + return node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.questionToken !== questionToken || node.type !== type || node.initializer !== initializer - ? update(createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer), node) + ? update(createParameterDeclaration(modifiers, dotDotDotToken, name, questionToken, type, initializer), node) : node; } function createDecorator(expression) { var node = createBaseNode(165); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, false); node.transformFlags |= propagateChildFlags(node.expression) | 1 | - 4096; + 8192 | + 33554432; return node; } function updateDecorator(node, expression) { @@ -17177,10 +17345,11 @@ var ts; : node; } function createPropertySignature(modifiers, name, questionToken, type) { - var node = createBaseNamedDeclaration(166, undefined, modifiers, name); + var node = createBaseNamedDeclaration(166, modifiers, name); node.type = type; node.questionToken = questionToken; node.transformFlags = 1; + node.initializer = undefined; return node; } function updatePropertySignature(node, modifiers, name, questionToken, type) { @@ -17188,38 +17357,43 @@ var ts; || node.name !== name || node.questionToken !== questionToken || node.type !== type - ? update(createPropertySignature(modifiers, name, questionToken, type), node) + ? finishUpdatePropertySignature(createPropertySignature(modifiers, name, questionToken, type), node) : node; } - function createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(167, decorators, modifiers, name, type, initializer); + function finishUpdatePropertySignature(updated, original) { + if (updated !== original) { + updated.initializer = original.initializer; + } + return update(updated, original); + } + function createPropertyDeclaration(modifiers, name, questionOrExclamationToken, type, initializer) { + var node = createBaseVariableLikeDeclaration(167, modifiers, name, type, initializer); node.questionToken = questionOrExclamationToken && ts.isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.transformFlags |= propagateChildFlags(node.questionToken) | propagateChildFlags(node.exclamationToken) | - 8388608; + 16777216; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { - node.transformFlags |= 4096; + node.transformFlags |= 8192; } if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2) { node.transformFlags |= 1; } return node; } - function updatePropertyDeclaration(node, decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - return node.decorators !== decorators - || node.modifiers !== modifiers + function updatePropertyDeclaration(node, modifiers, name, questionOrExclamationToken, type, initializer) { + return node.modifiers !== modifiers || node.name !== name || node.questionToken !== (questionOrExclamationToken !== undefined && ts.isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined) || node.exclamationToken !== (questionOrExclamationToken !== undefined && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined) || node.type !== type || node.initializer !== initializer - ? update(createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node) + ? update(createPropertyDeclaration(modifiers, name, questionOrExclamationToken, type, initializer), node) : node; } function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(168, undefined, modifiers, name, typeParameters, parameters, type); + var node = createBaseSignatureDeclaration(168, modifiers, name, typeParameters, parameters, type); node.questionToken = questionToken; node.transformFlags = 1; return node; @@ -17231,11 +17405,11 @@ var ts; || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type - ? updateBaseSignatureDeclaration(createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type), node) + ? finishUpdateBaseSignatureDeclaration(createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type), node) : node; } - function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(169, decorators, modifiers, name, typeParameters, parameters, type, body); + function createMethodDeclaration(modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { + var node = createBaseFunctionLikeDeclaration(169, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.questionToken = questionToken; node.transformFlags |= @@ -17256,11 +17430,11 @@ var ts; else if (asteriskToken) { node.transformFlags |= 2048; } + node.exclamationToken = undefined; return node; } - function updateMethodDeclaration(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - return node.decorators !== decorators - || node.modifiers !== modifiers + function updateMethodDeclaration(node, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { + return node.modifiers !== modifiers || node.asteriskToken !== asteriskToken || node.name !== name || node.questionToken !== questionToken @@ -17268,62 +17442,101 @@ var ts; || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateBaseFunctionLikeDeclaration(createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node) + ? finishUpdateMethodDeclaration(createMethodDeclaration(modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node) : node; } - function createClassStaticBlockDeclaration(decorators, modifiers, body) { - var node = createBaseGenericNamedDeclaration(170, decorators, modifiers, undefined, undefined); + function finishUpdateMethodDeclaration(updated, original) { + if (updated !== original) { + updated.exclamationToken = original.exclamationToken; + } + return update(updated, original); + } + function createClassStaticBlockDeclaration(body) { + var node = createBaseGenericNamedDeclaration(170, undefined, undefined, undefined); node.body = body; - node.transformFlags = propagateChildFlags(body) | 8388608; + node.transformFlags = propagateChildFlags(body) | 16777216; + node.illegalDecorators = undefined; + node.modifiers = undefined; return node; } - function updateClassStaticBlockDeclaration(node, decorators, modifiers, body) { - return node.decorators !== decorators - || node.modifier !== modifiers - || node.body !== body - ? update(createClassStaticBlockDeclaration(decorators, modifiers, body), node) + function updateClassStaticBlockDeclaration(node, body) { + return node.body !== body + ? finishUpdateClassStaticBlockDeclaration(createClassStaticBlockDeclaration(body), node) : node; } - function createConstructorDeclaration(decorators, modifiers, parameters, body) { - var node = createBaseFunctionLikeDeclaration(171, decorators, modifiers, undefined, undefined, parameters, undefined, body); + function finishUpdateClassStaticBlockDeclaration(updated, original) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + updated.modifiers = original.modifiers; + } + return update(updated, original); + } + function createConstructorDeclaration(modifiers, parameters, body) { + var node = createBaseFunctionLikeDeclaration(171, modifiers, undefined, undefined, parameters, undefined, body); node.transformFlags |= 1024; + node.illegalDecorators = undefined; + node.typeParameters = undefined; + node.type = undefined; return node; } - function updateConstructorDeclaration(node, decorators, modifiers, parameters, body) { - return node.decorators !== decorators - || node.modifiers !== modifiers + function updateConstructorDeclaration(node, modifiers, parameters, body) { + return node.modifiers !== modifiers || node.parameters !== parameters || node.body !== body - ? updateBaseFunctionLikeDeclaration(createConstructorDeclaration(decorators, modifiers, parameters, body), node) + ? finishUpdateConstructorDeclaration(createConstructorDeclaration(modifiers, parameters, body), node) : node; } - function createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) { - return createBaseFunctionLikeDeclaration(172, decorators, modifiers, name, undefined, parameters, type, body); + function finishUpdateConstructorDeclaration(updated, original) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + updated.typeParameters = original.typeParameters; + updated.type = original.type; + } + return finishUpdateBaseSignatureDeclaration(updated, original); } - function updateGetAccessorDeclaration(node, decorators, modifiers, name, parameters, type, body) { - return node.decorators !== decorators - || node.modifiers !== modifiers + function createGetAccessorDeclaration(modifiers, name, parameters, type, body) { + var node = createBaseFunctionLikeDeclaration(172, modifiers, name, undefined, parameters, type, body); + node.typeParameters = undefined; + return node; + } + function updateGetAccessorDeclaration(node, modifiers, name, parameters, type, body) { + return node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateBaseFunctionLikeDeclaration(createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body), node) + ? finishUpdateGetAccessorDeclaration(createGetAccessorDeclaration(modifiers, name, parameters, type, body), node) : node; } - function createSetAccessorDeclaration(decorators, modifiers, name, parameters, body) { - return createBaseFunctionLikeDeclaration(173, decorators, modifiers, name, undefined, parameters, undefined, body); + function finishUpdateGetAccessorDeclaration(updated, original) { + if (updated !== original) { + updated.typeParameters = original.typeParameters; + } + return finishUpdateBaseSignatureDeclaration(updated, original); } - function updateSetAccessorDeclaration(node, decorators, modifiers, name, parameters, body) { - return node.decorators !== decorators - || node.modifiers !== modifiers + function createSetAccessorDeclaration(modifiers, name, parameters, body) { + var node = createBaseFunctionLikeDeclaration(173, modifiers, name, undefined, parameters, undefined, body); + node.typeParameters = undefined; + node.type = undefined; + return node; + } + function updateSetAccessorDeclaration(node, modifiers, name, parameters, body) { + return node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.body !== body - ? updateBaseFunctionLikeDeclaration(createSetAccessorDeclaration(decorators, modifiers, name, parameters, body), node) + ? finishUpdateSetAccessorDeclaration(createSetAccessorDeclaration(modifiers, name, parameters, body), node) : node; } + function finishUpdateSetAccessorDeclaration(updated, original) { + if (updated !== original) { + updated.typeParameters = original.typeParameters; + updated.type = original.type; + } + return finishUpdateBaseSignatureDeclaration(updated, original); + } function createCallSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(174, undefined, undefined, undefined, typeParameters, parameters, type); + var node = createBaseSignatureDeclaration(174, undefined, undefined, typeParameters, parameters, type); node.transformFlags = 1; return node; } @@ -17331,11 +17544,11 @@ var ts; return node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type - ? updateBaseSignatureDeclaration(createCallSignature(typeParameters, parameters, type), node) + ? finishUpdateBaseSignatureDeclaration(createCallSignature(typeParameters, parameters, type), node) : node; } function createConstructSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(175, undefined, undefined, undefined, typeParameters, parameters, type); + var node = createBaseSignatureDeclaration(175, undefined, undefined, typeParameters, parameters, type); node.transformFlags = 1; return node; } @@ -17343,20 +17556,19 @@ var ts; return node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type - ? updateBaseSignatureDeclaration(createConstructSignature(typeParameters, parameters, type), node) + ? finishUpdateBaseSignatureDeclaration(createConstructSignature(typeParameters, parameters, type), node) : node; } - function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createBaseSignatureDeclaration(176, decorators, modifiers, undefined, undefined, parameters, type); + function createIndexSignature(modifiers, parameters, type) { + var node = createBaseSignatureDeclaration(176, modifiers, undefined, undefined, parameters, type); node.transformFlags = 1; return node; } - function updateIndexSignature(node, decorators, modifiers, parameters, type) { + function updateIndexSignature(node, modifiers, parameters, type) { return node.parameters !== parameters || node.type !== type - || node.decorators !== decorators || node.modifiers !== modifiers - ? updateBaseSignatureDeclaration(createIndexSignature(decorators, modifiers, parameters, type), node) + ? finishUpdateBaseSignatureDeclaration(createIndexSignature(modifiers, parameters, type), node) : node; } function createTemplateLiteralTypeSpan(type, literal) { @@ -17404,17 +17616,24 @@ var ts; : node; } function createFunctionTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(179, undefined, undefined, undefined, typeParameters, parameters, type); + var node = createBaseSignatureDeclaration(179, undefined, undefined, typeParameters, parameters, type); node.transformFlags = 1; + node.modifiers = undefined; return node; } function updateFunctionTypeNode(node, typeParameters, parameters, type) { return node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type - ? updateBaseSignatureDeclaration(createFunctionTypeNode(typeParameters, parameters, type), node) + ? finishUpdateFunctionTypeNode(createFunctionTypeNode(typeParameters, parameters, type), node) : node; } + function finishUpdateFunctionTypeNode(updated, original) { + if (updated !== original) { + updated.modifiers = original.modifiers; + } + return finishUpdateBaseSignatureDeclaration(updated, original); + } function createConstructorTypeNode() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -17425,7 +17644,7 @@ var ts; ts.Debug.fail("Incorrect number of arguments specified."); } function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(180, undefined, modifiers, undefined, typeParameters, parameters, type); + var node = createBaseSignatureDeclaration(180, modifiers, undefined, typeParameters, parameters, type); node.transformFlags = 1; return node; } @@ -17446,7 +17665,7 @@ var ts; || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type - ? updateBaseSignatureDeclaration(createConstructorTypeNode(modifiers, typeParameters, parameters, type), node) + ? finishUpdateBaseSignatureDeclaration(createConstructorTypeNode(modifiers, typeParameters, parameters, type), node) : node; } function updateConstructorTypeNode2(node, typeParameters, parameters, type) { @@ -17601,33 +17820,25 @@ var ts; ? update(createTemplateLiteralType(head, templateSpans), node) : node; } - function createImportTypeNode(argument, qualifierOrAssertions, typeArgumentsOrQualifier, isTypeOfOrTypeArguments, isTypeOf) { - var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 ? qualifierOrAssertions : undefined; - var qualifier = qualifierOrAssertions && ts.isEntityName(qualifierOrAssertions) ? qualifierOrAssertions - : typeArgumentsOrQualifier && !ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : undefined; - var typeArguments = ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : ts.isArray(isTypeOfOrTypeArguments) ? isTypeOfOrTypeArguments : undefined; - isTypeOf = typeof isTypeOfOrTypeArguments === "boolean" ? isTypeOfOrTypeArguments : typeof isTypeOf === "boolean" ? isTypeOf : false; + function createImportTypeNode(argument, assertions, qualifier, typeArguments, isTypeOf) { + if (isTypeOf === void 0) { isTypeOf = false; } var node = createBaseNode(200); node.argument = argument; - node.assertions = assertion; + node.assertions = assertions; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.isTypeOf = isTypeOf; node.transformFlags = 1; return node; } - function updateImportTypeNode(node, argument, qualifierOrAssertions, typeArgumentsOrQualifier, isTypeOfOrTypeArguments, isTypeOf) { - var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 ? qualifierOrAssertions : undefined; - var qualifier = qualifierOrAssertions && ts.isEntityName(qualifierOrAssertions) ? qualifierOrAssertions - : typeArgumentsOrQualifier && !ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : undefined; - var typeArguments = ts.isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : ts.isArray(isTypeOfOrTypeArguments) ? isTypeOfOrTypeArguments : undefined; - isTypeOf = typeof isTypeOfOrTypeArguments === "boolean" ? isTypeOfOrTypeArguments : typeof isTypeOf === "boolean" ? isTypeOf : node.isTypeOf; + function updateImportTypeNode(node, argument, assertions, qualifier, typeArguments, isTypeOf) { + if (isTypeOf === void 0) { isTypeOf = node.isTypeOf; } return node.argument !== argument - || node.assertions !== assertion + || node.assertions !== assertions || node.qualifier !== qualifier || node.typeArguments !== typeArguments || node.isTypeOf !== isTypeOf - ? update(createImportTypeNode(argument, assertion, qualifier, typeArguments, isTypeOf), node) + ? update(createImportTypeNode(argument, assertions, qualifier, typeArguments, isTypeOf), node) : node; } function createParenthesizedType(type) { @@ -17711,11 +17922,11 @@ var ts; node.transformFlags |= propagateChildrenFlags(node.elements) | 1024 | - 262144; - if (node.transformFlags & 16384) { + 524288; + if (node.transformFlags & 32768) { node.transformFlags |= 128 | - 32768; + 65536; } return node; } @@ -17730,7 +17941,7 @@ var ts; node.transformFlags |= propagateChildrenFlags(node.elements) | 1024 | - 262144; + 524288; return node; } function updateArrayBindingPattern(node, elements) { @@ -17739,7 +17950,7 @@ var ts; : node; } function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createBaseBindingLikeDeclaration(203, undefined, undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseBindingLikeDeclaration(203, undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= @@ -17751,7 +17962,7 @@ var ts; propagateChildFlags(node.propertyName); } if (dotDotDotToken) - node.transformFlags |= 16384; + node.transformFlags |= 32768; return node; } function updateBindingElement(node, dotDotDotToken, propertyName, name, initializer) { @@ -17794,13 +18005,13 @@ var ts; } function createPropertyAccessExpression(expression, name) { var node = createBaseExpression(206); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, false); node.name = asName(name); node.transformFlags = propagateChildFlags(node.expression) | (ts.isIdentifier(node.name) ? propagateIdentifierNameFlags(node.name) : - propagateChildFlags(node.name)); + propagateChildFlags(node.name) | 536870912); if (ts.isSuperKeyword(expression)) { node.transformFlags |= 256 | @@ -17820,7 +18031,7 @@ var ts; function createPropertyAccessChain(expression, questionDotToken, name) { var node = createBaseExpression(206); node.flags |= 32; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, true); node.questionDotToken = questionDotToken; node.name = asName(name); node.transformFlags |= @@ -17829,7 +18040,7 @@ var ts; propagateChildFlags(node.questionDotToken) | (ts.isIdentifier(node.name) ? propagateIdentifierNameFlags(node.name) : - propagateChildFlags(node.name)); + propagateChildFlags(node.name) | 536870912); return node; } function updatePropertyAccessChain(node, expression, questionDotToken, name) { @@ -17842,7 +18053,7 @@ var ts; } function createElementAccessExpression(expression, index) { var node = createBaseExpression(207); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, false); node.argumentExpression = asExpression(index); node.transformFlags |= propagateChildFlags(node.expression) | @@ -17866,7 +18077,7 @@ var ts; function createElementAccessChain(expression, questionDotToken, index) { var node = createBaseExpression(207); node.flags |= 32; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, true); node.questionDotToken = questionDotToken; node.argumentExpression = asExpression(index); node.transformFlags |= @@ -17886,7 +18097,7 @@ var ts; } function createCallExpression(expression, typeArguments, argumentsArray) { var node = createBaseExpression(208); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, false); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); node.transformFlags |= @@ -17897,10 +18108,10 @@ var ts; node.transformFlags |= 1; } if (ts.isImportKeyword(node.expression)) { - node.transformFlags |= 4194304; + node.transformFlags |= 8388608; } else if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 8192; + node.transformFlags |= 16384; } return node; } @@ -17917,7 +18128,7 @@ var ts; function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { var node = createBaseExpression(208); node.flags |= 32; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, true); node.questionDotToken = questionDotToken; node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -17931,7 +18142,7 @@ var ts; node.transformFlags |= 1; } if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 8192; + node.transformFlags |= 16384; } return node; } @@ -17968,7 +18179,7 @@ var ts; } function createTaggedTemplateExpression(tag, typeArguments, template) { var node = createBaseExpression(210); - node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); + node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag, false); node.typeArguments = asNodeArray(typeArguments); node.template = template; node.transformFlags |= @@ -18019,7 +18230,7 @@ var ts; : node; } function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(213, undefined, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(213, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.asteriskToken); if (node.typeParameters) { @@ -18046,17 +18257,17 @@ var ts; || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateBaseFunctionLikeDeclaration(createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) + ? finishUpdateBaseSignatureDeclaration(createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) : node; } function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createBaseFunctionLikeDeclaration(214, undefined, modifiers, undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); + var node = createBaseFunctionLikeDeclaration(214, modifiers, undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38); node.transformFlags |= propagateChildFlags(node.equalsGreaterThanToken) | 1024; if (ts.modifiersToFlags(node.modifiers) & 256) { - node.transformFlags |= 256 | 8192; + node.transformFlags |= 256 | 16384; } return node; } @@ -18067,7 +18278,7 @@ var ts; || node.type !== type || node.equalsGreaterThanToken !== equalsGreaterThanToken || node.body !== body - ? updateBaseFunctionLikeDeclaration(createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body), node) + ? finishUpdateBaseSignatureDeclaration(createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body), node) : node; } function createDeleteExpression(expression) { @@ -18110,7 +18321,7 @@ var ts; propagateChildFlags(node.expression) | 256 | 128 | - 1048576; + 2097152; return node; } function updateAwaitExpression(node, expression) { @@ -18127,7 +18338,7 @@ var ts; ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 67108864; + node.transformFlags |= 268435456; } return node; } @@ -18144,7 +18355,7 @@ var ts; if (ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 67108864; + node.transformFlags |= 268435456; } return node; } @@ -18188,18 +18399,21 @@ var ts; else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) { node.transformFlags |= 16; } + if (operatorKind === 101 && ts.isPrivateIdentifier(node.left)) { + node.transformFlags |= 536870912; + } return node; } function propagateAssignmentPatternFlags(node) { - if (node.transformFlags & 32768) - return 32768; + if (node.transformFlags & 65536) + return 65536; if (node.transformFlags & 128) { for (var _i = 0, _a = ts.getElementsOfBindingOrAssignmentPattern(node); _i < _a.length; _i++) { var element = _a[_i]; var target = ts.getTargetOfBindingOrAssignmentElement(element); if (target && ts.isAssignmentPattern(target)) { - if (target.transformFlags & 32768) { - return 32768; + if (target.transformFlags & 65536) { + return 65536; } if (target.transformFlags & 128) { var flags_1 = propagateAssignmentPatternFlags(target); @@ -18312,7 +18526,7 @@ var ts; propagateChildFlags(node.asteriskToken) | 1024 | 128 | - 524288; + 1048576; return node; } function updateYieldExpression(node, asteriskToken, expression) { @@ -18327,7 +18541,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.expression) | 1024 | - 16384; + 32768; return node; } function updateSpreadElement(node, expression) { @@ -18335,19 +18549,18 @@ var ts; ? update(createSpreadElement(expression), node) : node; } - function createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(226, decorators, modifiers, name, typeParameters, heritageClauses, members); + function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { + var node = createBaseClassLikeDeclaration(226, modifiers, name, typeParameters, heritageClauses, members); node.transformFlags |= 1024; return node; } - function updateClassExpression(node, decorators, modifiers, name, typeParameters, heritageClauses, members) { - return node.decorators !== decorators - || node.modifiers !== modifiers + function updateClassExpression(node, modifiers, name, typeParameters, heritageClauses, members) { + return node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members - ? update(createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members), node) + ? update(createClassExpression(modifiers, name, typeParameters, heritageClauses, members), node) : node; } function createOmittedExpression() { @@ -18355,7 +18568,7 @@ var ts; } function createExpressionWithTypeArguments(expression, typeArguments) { var node = createBaseNode(228); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, false); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | @@ -18387,7 +18600,7 @@ var ts; } function createNonNullExpression(expression) { var node = createBaseExpression(230); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, false); node.transformFlags |= propagateChildFlags(node.expression) | 1; @@ -18404,7 +18617,7 @@ var ts; function createNonNullChain(expression) { var node = createBaseExpression(230); node.flags |= 32; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, true); node.transformFlags |= propagateChildFlags(node.expression) | 1; @@ -18472,10 +18685,12 @@ var ts; : node; } function createVariableStatement(modifiers, declarationList) { - var node = createBaseDeclaration(237, undefined, modifiers); + var node = createBaseDeclaration(237); + node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= - propagateChildFlags(node.declarationList); + propagateChildrenFlags(node.modifiers) | + propagateChildFlags(node.declarationList); if (ts.modifiersToFlags(node.modifiers) & 2) { node.transformFlags = 1; } @@ -18617,7 +18832,7 @@ var ts; node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 2097152; + 4194304; return node; } function updateContinueStatement(node, label) { @@ -18630,7 +18845,7 @@ var ts; node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 2097152; + 4194304; return node; } function updateBreakStatement(node, label) { @@ -18644,7 +18859,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.expression) | 128 | - 2097152; + 4194304; return node; } function updateReturnStatement(node, expression) { @@ -18730,7 +18945,7 @@ var ts; return createBaseNode(253); } function createVariableDeclaration(name, exclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(254, undefined, undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(254, undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.exclamationToken = exclamationToken; node.transformFlags |= propagateChildFlags(node.exclamationToken); if (exclamationToken) { @@ -18753,11 +18968,11 @@ var ts; node.declarations = createNodeArray(declarations); node.transformFlags |= propagateChildrenFlags(node.declarations) | - 2097152; + 4194304; if (flags & 3) { node.transformFlags |= 1024 | - 131072; + 262144; } return node; } @@ -18766,8 +18981,8 @@ var ts; ? update(createVariableDeclarationList(declarations, node.flags), node) : node; } - function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(256, decorators, modifiers, name, typeParameters, parameters, type, body); + function createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + var node = createBaseFunctionLikeDeclaration(256, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; if (!node.body || ts.modifiersToFlags(node.modifiers) & 2) { node.transformFlags = 1; @@ -18775,7 +18990,7 @@ var ts; else { node.transformFlags |= propagateChildFlags(node.asteriskToken) | - 2097152; + 4194304; if (ts.modifiersToFlags(node.modifiers) & 256) { if (node.asteriskToken) { node.transformFlags |= 128; @@ -18788,94 +19003,118 @@ var ts; node.transformFlags |= 2048; } } + node.illegalDecorators = undefined; return node; } - function updateFunctionDeclaration(node, decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - return node.decorators !== decorators - || node.modifiers !== modifiers + function updateFunctionDeclaration(node, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { + return node.modifiers !== modifiers || node.asteriskToken !== asteriskToken || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateBaseFunctionLikeDeclaration(createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) + ? finishUpdateFunctionDeclaration(createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) : node; } - function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(257, decorators, modifiers, name, typeParameters, heritageClauses, members); + function finishUpdateFunctionDeclaration(updated, original) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + } + return finishUpdateBaseSignatureDeclaration(updated, original); + } + function createClassDeclaration(modifiers, name, typeParameters, heritageClauses, members) { + var node = createBaseClassLikeDeclaration(257, modifiers, name, typeParameters, heritageClauses, members); if (ts.modifiersToFlags(node.modifiers) & 2) { node.transformFlags = 1; } else { node.transformFlags |= 1024; - if (node.transformFlags & 4096) { + if (node.transformFlags & 8192) { node.transformFlags |= 1; } } return node; } - function updateClassDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) { - return node.decorators !== decorators - || node.modifiers !== modifiers + function updateClassDeclaration(node, modifiers, name, typeParameters, heritageClauses, members) { + return node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members - ? update(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node) + ? update(createClassDeclaration(modifiers, name, typeParameters, heritageClauses, members), node) : node; } - function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(258, decorators, modifiers, name, typeParameters, heritageClauses); + function createInterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, members) { + var node = createBaseInterfaceOrClassLikeDeclaration(258, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); node.transformFlags = 1; + node.illegalDecorators = undefined; return node; } - function updateInterfaceDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) { - return node.decorators !== decorators - || node.modifiers !== modifiers + function updateInterfaceDeclaration(node, modifiers, name, typeParameters, heritageClauses, members) { + return node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members - ? update(createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node) + ? finishUpdateInterfaceDeclaration(createInterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, members), node) : node; } - function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createBaseGenericNamedDeclaration(259, decorators, modifiers, name, typeParameters); + function finishUpdateInterfaceDeclaration(updated, original) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + } + return update(updated, original); + } + function createTypeAliasDeclaration(modifiers, name, typeParameters, type) { + var node = createBaseGenericNamedDeclaration(259, modifiers, name, typeParameters); node.type = type; node.transformFlags = 1; + node.illegalDecorators = undefined; return node; } - function updateTypeAliasDeclaration(node, decorators, modifiers, name, typeParameters, type) { - return node.decorators !== decorators - || node.modifiers !== modifiers + function updateTypeAliasDeclaration(node, modifiers, name, typeParameters, type) { + return node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.type !== type - ? update(createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type), node) + ? finishUpdateTypeAliasDeclaration(createTypeAliasDeclaration(modifiers, name, typeParameters, type), node) : node; } - function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createBaseNamedDeclaration(260, decorators, modifiers, name); + function finishUpdateTypeAliasDeclaration(updated, original) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + } + return update(updated, original); + } + function createEnumDeclaration(modifiers, name, members) { + var node = createBaseNamedDeclaration(260, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members) | 1; - node.transformFlags &= ~16777216; + node.transformFlags &= ~67108864; + node.illegalDecorators = undefined; return node; } - function updateEnumDeclaration(node, decorators, modifiers, name, members) { - return node.decorators !== decorators - || node.modifiers !== modifiers + function updateEnumDeclaration(node, modifiers, name, members) { + return node.modifiers !== modifiers || node.name !== name || node.members !== members - ? update(createEnumDeclaration(decorators, modifiers, name, members), node) + ? finishUpdateEnumDeclaration(createEnumDeclaration(modifiers, name, members), node) : node; } - function createModuleDeclaration(decorators, modifiers, name, body, flags) { + function finishUpdateEnumDeclaration(updated, original) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + } + return update(updated, original); + } + function createModuleDeclaration(modifiers, name, body, flags) { if (flags === void 0) { flags = 0; } - var node = createBaseDeclaration(261, decorators, modifiers); + var node = createBaseDeclaration(261); + node.modifiers = asNodeArray(modifiers); node.flags |= flags & (16 | 4 | 1024); node.name = name; node.body = body; @@ -18884,21 +19123,28 @@ var ts; } else { node.transformFlags |= - propagateChildFlags(node.name) | + propagateChildrenFlags(node.modifiers) | + propagateChildFlags(node.name) | propagateChildFlags(node.body) | 1; } - node.transformFlags &= ~16777216; + node.transformFlags &= ~67108864; + node.illegalDecorators = undefined; return node; } - function updateModuleDeclaration(node, decorators, modifiers, name, body) { - return node.decorators !== decorators - || node.modifiers !== modifiers + function updateModuleDeclaration(node, modifiers, name, body) { + return node.modifiers !== modifiers || node.name !== name || node.body !== body - ? update(createModuleDeclaration(decorators, modifiers, name, body, node.flags), node) + ? finishUpdateModuleDeclaration(createModuleDeclaration(modifiers, name, body, node.flags), node) : node; } + function finishUpdateModuleDeclaration(updated, original) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + } + return update(updated, original); + } function createModuleBlock(statements) { var node = createBaseNode(262); node.statements = createNodeArray(statements); @@ -18922,54 +19168,76 @@ var ts; : node; } function createNamespaceExportDeclaration(name) { - var node = createBaseNamedDeclaration(264, undefined, undefined, name); + var node = createBaseNamedDeclaration(264, undefined, name); node.transformFlags = 1; + node.illegalDecorators = undefined; + node.modifiers = undefined; return node; } function updateNamespaceExportDeclaration(node, name) { return node.name !== name - ? update(createNamespaceExportDeclaration(name), node) + ? finishUpdateNamespaceExportDeclaration(createNamespaceExportDeclaration(name), node) : node; } - function createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference) { - var node = createBaseNamedDeclaration(265, decorators, modifiers, name); + function finishUpdateNamespaceExportDeclaration(updated, original) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + updated.modifiers = original.modifiers; + } + return update(updated, original); + } + function createImportEqualsDeclaration(modifiers, isTypeOnly, name, moduleReference) { + var node = createBaseNamedDeclaration(265, modifiers, name); node.isTypeOnly = isTypeOnly; node.moduleReference = moduleReference; node.transformFlags |= propagateChildFlags(node.moduleReference); if (!ts.isExternalModuleReference(node.moduleReference)) node.transformFlags |= 1; - node.transformFlags &= ~16777216; + node.transformFlags &= ~67108864; + node.illegalDecorators = undefined; return node; } - function updateImportEqualsDeclaration(node, decorators, modifiers, isTypeOnly, name, moduleReference) { - return node.decorators !== decorators - || node.modifiers !== modifiers + function updateImportEqualsDeclaration(node, modifiers, isTypeOnly, name, moduleReference) { + return node.modifiers !== modifiers || node.isTypeOnly !== isTypeOnly || node.name !== name || node.moduleReference !== moduleReference - ? update(createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference), node) + ? finishUpdateImportEqualsDeclaration(createImportEqualsDeclaration(modifiers, isTypeOnly, name, moduleReference), node) : node; } - function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(266, decorators, modifiers); + function finishUpdateImportEqualsDeclaration(updated, original) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + } + return update(updated, original); + } + function createImportDeclaration(modifiers, importClause, moduleSpecifier, assertClause) { + var node = createBaseDeclaration(266); + node.modifiers = asNodeArray(modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; node.assertClause = assertClause; node.transformFlags |= propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~16777216; + node.transformFlags &= ~67108864; + node.illegalDecorators = undefined; return node; } - function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier, assertClause) { - return node.decorators !== decorators - || node.modifiers !== modifiers + function updateImportDeclaration(node, modifiers, importClause, moduleSpecifier, assertClause) { + return node.modifiers !== modifiers || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier || node.assertClause !== assertClause - ? update(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, assertClause), node) + ? finishUpdateImportDeclaration(createImportDeclaration(modifiers, importClause, moduleSpecifier, assertClause), node) : node; } + function finishUpdateImportDeclaration(updated, original) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + } + return update(updated, original); + } function createImportClause(isTypeOnly, name, namedBindings) { var node = createBaseNode(267); node.isTypeOnly = isTypeOnly; @@ -18981,7 +19249,7 @@ var ts; if (isTypeOnly) { node.transformFlags |= 1; } - node.transformFlags &= ~16777216; + node.transformFlags &= ~67108864; return node; } function updateImportClause(node, isTypeOnly, name, namedBindings) { @@ -19033,7 +19301,7 @@ var ts; var node = createBaseNode(268); node.name = name; node.transformFlags |= propagateChildFlags(node.name); - node.transformFlags &= ~16777216; + node.transformFlags &= ~67108864; return node; } function updateNamespaceImport(node, name) { @@ -19047,7 +19315,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.name) | 4; - node.transformFlags &= ~16777216; + node.transformFlags &= ~67108864; return node; } function updateNamespaceExport(node, name) { @@ -19059,7 +19327,7 @@ var ts; var node = createBaseNode(269); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~16777216; + node.transformFlags &= ~67108864; return node; } function updateNamedImports(node, elements) { @@ -19075,7 +19343,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~16777216; + node.transformFlags &= ~67108864; return node; } function updateImportSpecifier(node, isTypeOnly, propertyName, name) { @@ -19085,50 +19353,65 @@ var ts; ? update(createImportSpecifier(isTypeOnly, propertyName, name), node) : node; } - function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createBaseDeclaration(271, decorators, modifiers); + function createExportAssignment(modifiers, isExportEquals, expression) { + var node = createBaseDeclaration(271); + node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals ? parenthesizerRules().parenthesizeRightSideOfBinary(63, undefined, expression) : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression); - node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~16777216; + node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.expression); + node.transformFlags &= ~67108864; + node.illegalDecorators = undefined; return node; } - function updateExportAssignment(node, decorators, modifiers, expression) { - return node.decorators !== decorators - || node.modifiers !== modifiers + function updateExportAssignment(node, modifiers, expression) { + return node.modifiers !== modifiers || node.expression !== expression - ? update(createExportAssignment(decorators, modifiers, node.isExportEquals, expression), node) + ? finishUpdateExportAssignment(createExportAssignment(modifiers, node.isExportEquals, expression), node) : node; } - function createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(272, decorators, modifiers); + function finishUpdateExportAssignment(updated, original) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + } + return update(updated, original); + } + function createExportDeclaration(modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause) { + var node = createBaseDeclaration(272); + node.modifiers = asNodeArray(modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; node.assertClause = assertClause; node.transformFlags |= - propagateChildFlags(node.exportClause) | + propagateChildrenFlags(node.modifiers) | + propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~16777216; + node.transformFlags &= ~67108864; + node.illegalDecorators = undefined; return node; } - function updateExportDeclaration(node, decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause) { - return node.decorators !== decorators - || node.modifiers !== modifiers + function updateExportDeclaration(node, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause) { + return node.modifiers !== modifiers || node.isTypeOnly !== isTypeOnly || node.exportClause !== exportClause || node.moduleSpecifier !== moduleSpecifier || node.assertClause !== assertClause - ? update(createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause), node) + ? finishUpdateExportDeclaration(createExportDeclaration(modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause), node) : node; } + function finishUpdateExportDeclaration(updated, original) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + } + return update(updated, original); + } function createNamedExports(elements) { var node = createBaseNode(273); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~16777216; + node.transformFlags &= ~67108864; return node; } function updateNamedExports(node, elements) { @@ -19144,7 +19427,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~16777216; + node.transformFlags &= ~67108864; return node; } function updateExportSpecifier(node, isTypeOnly, propertyName, name) { @@ -19155,14 +19438,14 @@ var ts; : node; } function createMissingDeclaration() { - var node = createBaseDeclaration(276, undefined, undefined); + var node = createBaseDeclaration(276); return node; } function createExternalModuleReference(expression) { var node = createBaseNode(277); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~16777216; + node.transformFlags &= ~67108864; return node; } function updateExternalModuleReference(node, expression) { @@ -19195,7 +19478,7 @@ var ts; : node; } function createJSDocFunctionType(parameters, type) { - var node = createBaseSignatureDeclaration(317, undefined, undefined, undefined, undefined, parameters, type); + var node = createBaseSignatureDeclaration(317, undefined, undefined, undefined, parameters, type); return node; } function updateJSDocFunctionType(node, parameters, type) { @@ -19734,64 +20017,68 @@ var ts; : node; } function createPropertyAssignment(name, initializer) { - var node = createBaseNamedDeclaration(296, undefined, undefined, name); + var node = createBaseNamedDeclaration(296, undefined, name); node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer); + node.illegalDecorators = undefined; + node.modifiers = undefined; + node.questionToken = undefined; + node.exclamationToken = undefined; return node; } - function finishUpdatePropertyAssignment(updated, original) { - if (original.decorators) - updated.decorators = original.decorators; - if (original.modifiers) - updated.modifiers = original.modifiers; - if (original.questionToken) - updated.questionToken = original.questionToken; - if (original.exclamationToken) - updated.exclamationToken = original.exclamationToken; - return update(updated, original); - } function updatePropertyAssignment(node, name, initializer) { return node.name !== name || node.initializer !== initializer ? finishUpdatePropertyAssignment(createPropertyAssignment(name, initializer), node) : node; } + function finishUpdatePropertyAssignment(updated, original) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + updated.modifiers = original.modifiers; + updated.questionToken = original.questionToken; + updated.exclamationToken = original.exclamationToken; + } + return update(updated, original); + } function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createBaseNamedDeclaration(297, undefined, undefined, name); + var node = createBaseNamedDeclaration(297, undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= propagateChildFlags(node.objectAssignmentInitializer) | 1024; + node.equalsToken = undefined; + node.illegalDecorators = undefined; + node.modifiers = undefined; + node.questionToken = undefined; + node.exclamationToken = undefined; return node; } - function finishUpdateShorthandPropertyAssignment(updated, original) { - if (original.decorators) - updated.decorators = original.decorators; - if (original.modifiers) - updated.modifiers = original.modifiers; - if (original.equalsToken) - updated.equalsToken = original.equalsToken; - if (original.questionToken) - updated.questionToken = original.questionToken; - if (original.exclamationToken) - updated.exclamationToken = original.exclamationToken; - return update(updated, original); - } function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { return node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer ? finishUpdateShorthandPropertyAssignment(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node) : node; } + function finishUpdateShorthandPropertyAssignment(updated, original) { + if (updated !== original) { + updated.equalsToken = original.equalsToken; + updated.illegalDecorators = original.illegalDecorators; + updated.modifiers = original.modifiers; + updated.questionToken = original.questionToken; + updated.exclamationToken = original.exclamationToken; + } + return update(updated, original); + } function createSpreadAssignment(expression) { var node = createBaseNode(298); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | 128 | - 32768; + 65536; return node; } function updateSpreadAssignment(node, expression) { @@ -20035,10 +20322,10 @@ var ts; return createVoidExpression(createNumericLiteral("0")); } function createExportDefault(expression) { - return createExportAssignment(undefined, undefined, false, expression); + return createExportAssignment(undefined, false, expression); } function createExternalModuleExport(exportName) { - return createExportDeclaration(undefined, undefined, false, createNamedExports([ + return createExportDeclaration(undefined, false, createNamedExports([ createExportSpecifier(false, undefined, exportName) ])); } @@ -20173,7 +20460,7 @@ var ts; } else if (ts.getEmitFlags(callee) & 4096) { thisArg = createVoidZero(); - target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee); + target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee, false); } else if (ts.isPropertyAccessExpression(callee)) { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { @@ -20199,13 +20486,13 @@ var ts; } else { thisArg = createVoidZero(); - target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, false); } return { target: target, thisArg: thisArg }; } function createAssignmentTargetWrapper(paramName, expression) { return createPropertyAccessExpression(createParenthesizedExpression(createObjectLiteralExpression([ - createSetAccessorDeclaration(undefined, undefined, "value", [createParameterDeclaration(undefined, undefined, undefined, paramName, undefined, undefined, undefined)], createBlock([ + createSetAccessorDeclaration(undefined, "value", [createParameterDeclaration(undefined, undefined, paramName, undefined, undefined, undefined)], createBlock([ createExpressionStatement(expression) ])) ])), "value"); @@ -20381,30 +20668,32 @@ var ts; else { modifierArray = modifiers; } - return ts.isParameter(node) ? updateParameterDeclaration(node, node.decorators, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : - ts.isPropertySignature(node) ? updatePropertySignature(node, modifierArray, node.name, node.questionToken, node.type) : - ts.isPropertyDeclaration(node) ? updatePropertyDeclaration(node, node.decorators, modifierArray, node.name, (_a = node.questionToken) !== null && _a !== void 0 ? _a : node.exclamationToken, node.type, node.initializer) : - ts.isMethodSignature(node) ? updateMethodSignature(node, modifierArray, node.name, node.questionToken, node.typeParameters, node.parameters, node.type) : - ts.isMethodDeclaration(node) ? updateMethodDeclaration(node, node.decorators, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) : - ts.isConstructorDeclaration(node) ? updateConstructorDeclaration(node, node.decorators, modifierArray, node.parameters, node.body) : - ts.isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, node.decorators, modifierArray, node.name, node.parameters, node.type, node.body) : - ts.isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, node.decorators, modifierArray, node.name, node.parameters, node.body) : - ts.isIndexSignatureDeclaration(node) ? updateIndexSignature(node, node.decorators, modifierArray, node.parameters, node.type) : - ts.isFunctionExpression(node) ? updateFunctionExpression(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : - ts.isArrowFunction(node) ? updateArrowFunction(node, modifierArray, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, node.body) : - ts.isClassExpression(node) ? updateClassExpression(node, node.decorators, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : - ts.isVariableStatement(node) ? updateVariableStatement(node, modifierArray, node.declarationList) : - ts.isFunctionDeclaration(node) ? updateFunctionDeclaration(node, node.decorators, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : - ts.isClassDeclaration(node) ? updateClassDeclaration(node, node.decorators, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : - ts.isInterfaceDeclaration(node) ? updateInterfaceDeclaration(node, node.decorators, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : - ts.isTypeAliasDeclaration(node) ? updateTypeAliasDeclaration(node, node.decorators, modifierArray, node.name, node.typeParameters, node.type) : - ts.isEnumDeclaration(node) ? updateEnumDeclaration(node, node.decorators, modifierArray, node.name, node.members) : - ts.isModuleDeclaration(node) ? updateModuleDeclaration(node, node.decorators, modifierArray, node.name, node.body) : - ts.isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, node.decorators, modifierArray, node.isTypeOnly, node.name, node.moduleReference) : - ts.isImportDeclaration(node) ? updateImportDeclaration(node, node.decorators, modifierArray, node.importClause, node.moduleSpecifier, node.assertClause) : - ts.isExportAssignment(node) ? updateExportAssignment(node, node.decorators, modifierArray, node.expression) : - ts.isExportDeclaration(node) ? updateExportDeclaration(node, node.decorators, modifierArray, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.assertClause) : - ts.Debug.assertNever(node); + return ts.isTypeParameterDeclaration(node) ? updateTypeParameterDeclaration(node, modifierArray, node.name, node.constraint, node.default) : + ts.isParameter(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : + ts.isConstructorTypeNode(node) ? updateConstructorTypeNode1(node, modifierArray, node.typeParameters, node.parameters, node.type) : + ts.isPropertySignature(node) ? updatePropertySignature(node, modifierArray, node.name, node.questionToken, node.type) : + ts.isPropertyDeclaration(node) ? updatePropertyDeclaration(node, modifierArray, node.name, (_a = node.questionToken) !== null && _a !== void 0 ? _a : node.exclamationToken, node.type, node.initializer) : + ts.isMethodSignature(node) ? updateMethodSignature(node, modifierArray, node.name, node.questionToken, node.typeParameters, node.parameters, node.type) : + ts.isMethodDeclaration(node) ? updateMethodDeclaration(node, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) : + ts.isConstructorDeclaration(node) ? updateConstructorDeclaration(node, modifierArray, node.parameters, node.body) : + ts.isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.type, node.body) : + ts.isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.body) : + ts.isIndexSignatureDeclaration(node) ? updateIndexSignature(node, modifierArray, node.parameters, node.type) : + ts.isFunctionExpression(node) ? updateFunctionExpression(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : + ts.isArrowFunction(node) ? updateArrowFunction(node, modifierArray, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, node.body) : + ts.isClassExpression(node) ? updateClassExpression(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : + ts.isVariableStatement(node) ? updateVariableStatement(node, modifierArray, node.declarationList) : + ts.isFunctionDeclaration(node) ? updateFunctionDeclaration(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : + ts.isClassDeclaration(node) ? updateClassDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : + ts.isInterfaceDeclaration(node) ? updateInterfaceDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : + ts.isTypeAliasDeclaration(node) ? updateTypeAliasDeclaration(node, modifierArray, node.name, node.typeParameters, node.type) : + ts.isEnumDeclaration(node) ? updateEnumDeclaration(node, modifierArray, node.name, node.members) : + ts.isModuleDeclaration(node) ? updateModuleDeclaration(node, modifierArray, node.name, node.body) : + ts.isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, modifierArray, node.isTypeOnly, node.name, node.moduleReference) : + ts.isImportDeclaration(node) ? updateImportDeclaration(node, modifierArray, node.importClause, node.moduleSpecifier, node.assertClause) : + ts.isExportAssignment(node) ? updateExportAssignment(node, modifierArray, node.expression) : + ts.isExportDeclaration(node) ? updateExportDeclaration(node, modifierArray, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.assertClause) : + ts.Debug.assertNever(node); } function asNodeArray(array) { return array ? createNodeArray(array) : undefined; @@ -20509,10 +20798,10 @@ var ts; return tokenValue; } function propagateIdentifierNameFlags(node) { - return propagateChildFlags(node) & ~16777216; + return propagateChildFlags(node) & ~67108864; } function propagatePropertyNameFlagsOfChild(node, transformFlags) { - return transformFlags | (node.transformFlags & 33562624); + return transformFlags | (node.transformFlags & 134234112); } function propagateChildFlags(child) { if (!child) @@ -20539,29 +20828,29 @@ var ts; case 208: case 209: case 204: - return 536887296; + return -2147450880; case 261: - return 589443072; + return -1941676032; case 164: - return 536870912; + return -2147483648; case 214: - return 557748224; + return -2072174592; case 213: case 256: - return 591310848; + return -1937940480; case 255: - return 537165824; + return -2146893824; case 257: case 226: - return 536940544; + return -2147344384; case 171: - return 591306752; + return -1937948672; case 167: - return 570433536; + return -2013249536; case 169: case 172: case 173: - return 574529536; + return -2005057536; case 130: case 147: case 158: @@ -20581,23 +20870,23 @@ var ts; case 259: return -2; case 205: - return 536973312; + return -2147278848; case 292: - return 536903680; + return -2147418112; case 201: case 202: - return 536887296; + return -2147450880; case 211: case 229: case 350: case 212: case 106: - return 536870912; + return -2147483648; case 206: case 207: - return 536870912; + return -2147483648; default: - return 536870912; + return -2147483648; } } ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; @@ -21654,6 +21943,10 @@ var ts; return node.kind === 126; } ts.isAbstractModifier = isAbstractModifier; + function isOverrideModifier(node) { + return node.kind === 159; + } + ts.isOverrideModifier = isOverrideModifier; function isSuperKeyword(node) { return node.kind === 106; } @@ -22418,7 +22711,7 @@ var ts; var ts; (function (ts) { function createEmptyExports(factory) { - return factory.createExportDeclaration(undefined, undefined, false, factory.createNamedExports([]), undefined); + return factory.createExportDeclaration(undefined, false, factory.createNamedExports([]), undefined); } ts.createEmptyExports = createEmptyExports; function createMemberAccessForPropertyName(factory, target, memberName, location) { @@ -22552,8 +22845,8 @@ var ts; return ts.setTextRange(factory.createObjectDefinePropertyCall(receiver, createExpressionForPropertyName(factory, property.name), factory.createPropertyDescriptor({ enumerable: factory.createFalse(), configurable: true, - get: getAccessor && ts.setTextRange(ts.setOriginalNode(factory.createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body), getAccessor), getAccessor), - set: setAccessor && ts.setTextRange(ts.setOriginalNode(factory.createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body), setAccessor), setAccessor) + get: getAccessor && ts.setTextRange(ts.setOriginalNode(factory.createFunctionExpression(ts.getModifiers(getAccessor), undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body), getAccessor), getAccessor), + set: setAccessor && ts.setTextRange(ts.setOriginalNode(factory.createFunctionExpression(ts.getModifiers(setAccessor), undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body), setAccessor), setAccessor) }, !multiLine)), firstAccessor); } return undefined; @@ -22565,7 +22858,7 @@ var ts; return ts.setOriginalNode(ts.setTextRange(factory.createAssignment(createMemberAccessForPropertyName(factory, receiver, property.name, property.name), factory.cloneNode(property.name)), property), property); } function createExpressionForMethodDeclaration(factory, method, receiver) { - return ts.setOriginalNode(ts.setTextRange(factory.createAssignment(createMemberAccessForPropertyName(factory, receiver, method.name, method.name), ts.setOriginalNode(ts.setTextRange(factory.createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body), method), method)), method), method); + return ts.setOriginalNode(ts.setTextRange(factory.createAssignment(createMemberAccessForPropertyName(factory, receiver, method.name, method.name), ts.setOriginalNode(ts.setTextRange(factory.createFunctionExpression(ts.getModifiers(method), method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body), method), method)), method), method); } function createExpressionForObjectLiteralElementLike(factory, node, property, receiver) { if (property.name && ts.isPrivateIdentifier(property.name)) { @@ -22743,7 +23036,7 @@ var ts; } } if (namedBindings) { - var externalHelpersImportDeclaration = nodeFactory.createImportDeclaration(undefined, undefined, nodeFactory.createImportClause(false, undefined, namedBindings), nodeFactory.createStringLiteral(ts.externalHelpersModuleNameText), undefined); + var externalHelpersImportDeclaration = nodeFactory.createImportDeclaration(undefined, nodeFactory.createImportClause(false, undefined, namedBindings), nodeFactory.createStringLiteral(ts.externalHelpersModuleNameText), undefined); ts.addEmitFlags(externalHelpersImportDeclaration, 67108864); return externalHelpersImportDeclaration; } @@ -22952,33 +23245,50 @@ var ts; } } ts.getJSDocTypeAliasName = getJSDocTypeAliasName; - function canHaveModifiers(node) { + function canHaveIllegalType(node) { var kind = node.kind; - return kind === 164 - || kind === 166 - || kind === 167 - || kind === 168 - || kind === 169 - || kind === 171 + return kind === 171 + || kind === 173; + } + ts.canHaveIllegalType = canHaveIllegalType; + function canHaveIllegalTypeParameters(node) { + var kind = node.kind; + return kind === 171 || kind === 172 - || kind === 173 + || kind === 173; + } + ts.canHaveIllegalTypeParameters = canHaveIllegalTypeParameters; + function canHaveIllegalDecorators(node) { + var kind = node.kind; + return kind === 296 + || kind === 297 + || kind === 256 + || kind === 171 || kind === 176 - || kind === 213 - || kind === 214 - || kind === 226 + || kind === 170 + || kind === 276 || kind === 237 - || kind === 256 - || kind === 257 || kind === 258 || kind === 259 || kind === 260 || kind === 261 || kind === 265 || kind === 266 - || kind === 271 - || kind === 272; + || kind === 264 + || kind === 272 + || kind === 271; } - ts.canHaveModifiers = canHaveModifiers; + ts.canHaveIllegalDecorators = canHaveIllegalDecorators; + function canHaveIllegalModifiers(node) { + var kind = node.kind; + return kind === 170 + || kind === 296 + || kind === 297 + || kind === 179 + || kind === 276 + || kind === 264; + } + ts.canHaveIllegalModifiers = canHaveIllegalModifiers; ts.isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); ts.isQuestionOrExclamationToken = ts.or(ts.isQuestionToken, ts.isExclamationToken); ts.isIdentifierOrThisTypeNode = ts.or(ts.isIdentifier, ts.isThisTypeNode); @@ -23201,6 +23511,14 @@ var ts; } } ts.createBinaryExpressionTrampoline = createBinaryExpressionTrampoline; + function elideNodes(factory, nodes) { + if (nodes === undefined) + return undefined; + if (nodes.length === 0) + return nodes; + return ts.setTextRange(factory.createNodeArray([], nodes.hasTrailingComma), nodes); + } + ts.elideNodes = elideNodes; })(ts || (ts = {})); var ts; (function (ts) { @@ -23208,6 +23526,46 @@ var ts; return location ? ts.setTextRangePosEnd(range, location.pos, location.end) : range; } ts.setTextRange = setTextRange; + function canHaveModifiers(node) { + var kind = node.kind; + return kind === 163 + || kind === 164 + || kind === 166 + || kind === 167 + || kind === 168 + || kind === 169 + || kind === 171 + || kind === 172 + || kind === 173 + || kind === 176 + || kind === 180 + || kind === 213 + || kind === 214 + || kind === 226 + || kind === 237 + || kind === 256 + || kind === 257 + || kind === 258 + || kind === 259 + || kind === 260 + || kind === 261 + || kind === 265 + || kind === 266 + || kind === 271 + || kind === 272; + } + ts.canHaveModifiers = canHaveModifiers; + function canHaveDecorators(node) { + var kind = node.kind; + return kind === 164 + || kind === 167 + || kind === 169 + || kind === 172 + || kind === 173 + || kind === 226 + || kind === 257; + } + ts.canHaveDecorators = canHaveDecorators; })(ts || (ts = {})); var ts; (function (ts) { @@ -23253,7 +23611,7 @@ var ts; } ts.isFileProbablyExternalModule = isFileProbablyExternalModule; function isAnExternalModuleIndicatorNode(node) { - return hasModifierOfKind(node, 93) + return ts.canHaveModifiers(node) && hasModifierOfKind(node, 93) || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference) || ts.isImportDeclaration(node) || ts.isExportAssignment(node) @@ -23288,7 +23646,7 @@ var ts; visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); case 297: - return visitNodes(cbNode, cbNodes, node.decorators) || + return visitNodes(cbNode, cbNodes, node.illegalDecorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || @@ -23298,79 +23656,128 @@ var ts; case 298: return visitNode(cbNode, node.expression); case 164: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || + return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); case 167: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || + return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); case 166: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || + return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); case 296: - return visitNodes(cbNode, cbNodes, node.decorators) || + return visitNodes(cbNode, cbNodes, node.illegalDecorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.initializer); case 254: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || + return visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); case 203: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || - visitNode(cbNode, node.dotDotDotToken) || + return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 179: - case 180: - case 174: - case 175: case 176: - return visitNodes(cbNode, cbNodes, node.decorators) || + return visitNodes(cbNode, cbNodes, node.illegalDecorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); + case 180: + return visitNodes(cbNode, cbNodes, node.modifiers) || + visitNodes(cbNode, cbNodes, node.typeParameters) || + visitNodes(cbNode, cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 179: + return visitNodes(cbNode, cbNodes, node.modifiers) || + visitNodes(cbNode, cbNodes, node.typeParameters) || + visitNodes(cbNode, cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 174: + case 175: + return visitNodes(cbNode, cbNodes, node.typeParameters) || + visitNodes(cbNode, cbNodes, node.parameters) || + visitNode(cbNode, node.type); case 169: + return visitNodes(cbNode, cbNodes, node.modifiers) || + visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.exclamationToken) || + visitNodes(cbNode, cbNodes, node.typeParameters) || + visitNodes(cbNode, cbNodes, node.parameters) || + visitNode(cbNode, node.type) || + visitNode(cbNode, node.body); case 168: + return visitNodes(cbNode, cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNodes(cbNode, cbNodes, node.typeParameters) || + visitNodes(cbNode, cbNodes, node.parameters) || + visitNode(cbNode, node.type); case 171: + return visitNodes(cbNode, cbNodes, node.illegalDecorators) || + visitNodes(cbNode, cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNode, cbNodes, node.typeParameters) || + visitNodes(cbNode, cbNodes, node.parameters) || + visitNode(cbNode, node.type) || + visitNode(cbNode, node.body); case 172: + return visitNodes(cbNode, cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNode, cbNodes, node.typeParameters) || + visitNodes(cbNode, cbNodes, node.parameters) || + visitNode(cbNode, node.type) || + visitNode(cbNode, node.body); case 173: - case 213: + return visitNodes(cbNode, cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNode, cbNodes, node.typeParameters) || + visitNodes(cbNode, cbNodes, node.parameters) || + visitNode(cbNode, node.type) || + visitNode(cbNode, node.body); case 256: - case 214: - return visitNodes(cbNode, cbNodes, node.decorators) || + return visitNodes(cbNode, cbNodes, node.illegalDecorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.name) || - visitNode(cbNode, node.questionToken) || - visitNode(cbNode, node.exclamationToken) || + visitNodes(cbNode, cbNodes, node.typeParameters) || + visitNodes(cbNode, cbNodes, node.parameters) || + visitNode(cbNode, node.type) || + visitNode(cbNode, node.body); + case 213: + return visitNodes(cbNode, cbNodes, node.modifiers) || + visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.name) || + visitNodes(cbNode, cbNodes, node.typeParameters) || + visitNodes(cbNode, cbNodes, node.parameters) || + visitNode(cbNode, node.type) || + visitNode(cbNode, node.body); + case 214: + return visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); case 170: - return visitNodes(cbNode, cbNodes, node.decorators) || + return visitNodes(cbNode, cbNodes, node.illegalDecorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.body); case 178: @@ -23498,7 +23905,7 @@ var ts; return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); case 237: - return visitNodes(cbNode, cbNodes, node.decorators) || + return visitNodes(cbNode, cbNodes, node.illegalDecorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); case 255: @@ -23563,27 +23970,26 @@ var ts; return visitNode(cbNode, node.expression); case 257: case 226: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || + return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); case 258: - return visitNodes(cbNode, cbNodes, node.decorators) || + return visitNodes(cbNode, cbNodes, node.illegalDecorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); case 259: - return visitNodes(cbNode, cbNodes, node.decorators) || + return visitNodes(cbNode, cbNodes, node.illegalDecorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); case 260: - return visitNodes(cbNode, cbNodes, node.decorators) || + return visitNodes(cbNode, cbNodes, node.illegalDecorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); @@ -23591,17 +23997,17 @@ var ts; return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); case 261: - return visitNodes(cbNode, cbNodes, node.decorators) || + return visitNodes(cbNode, cbNodes, node.illegalDecorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); case 265: - return visitNodes(cbNode, cbNodes, node.decorators) || + return visitNodes(cbNode, cbNodes, node.illegalDecorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); case 266: - return visitNodes(cbNode, cbNodes, node.decorators) || + return visitNodes(cbNode, cbNodes, node.illegalDecorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier) || @@ -23615,7 +24021,8 @@ var ts; return visitNode(cbNode, node.name) || visitNode(cbNode, node.value); case 264: - return visitNode(cbNode, node.name); + return visitNodes(cbNode, cbNodes, node.illegalDecorators) || + visitNode(cbNode, node.name); case 268: return visitNode(cbNode, node.name); case 274: @@ -23624,7 +24031,7 @@ var ts; case 273: return visitNodes(cbNode, cbNodes, node.elements); case 272: - return visitNodes(cbNode, cbNodes, node.decorators) || + return visitNodes(cbNode, cbNodes, node.illegalDecorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier) || @@ -23634,17 +24041,21 @@ var ts; return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); case 271: - return visitNodes(cbNode, cbNodes, node.decorators) || + return visitNodes(cbNode, cbNodes, node.illegalDecorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); case 223: - return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); + return visitNode(cbNode, node.head) || + visitNodes(cbNode, cbNodes, node.templateSpans); case 233: - return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.literal); case 198: - return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); + return visitNode(cbNode, node.head) || + visitNodes(cbNode, cbNodes, node.templateSpans); case 199: - return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal); + return visitNode(cbNode, node.type) || + visitNode(cbNode, node.literal); case 162: return visitNode(cbNode, node.expression); case 291: @@ -23655,7 +24066,8 @@ var ts; case 277: return visitNode(cbNode, node.expression); case 276: - return visitNodes(cbNode, cbNodes, node.decorators); + return visitNodes(cbNode, cbNodes, node.illegalDecorators) || + visitNodes(cbNode, cbNodes, node.modifiers); case 351: return visitNodes(cbNode, cbNodes, node.elements); case 278: @@ -24192,7 +24604,7 @@ var ts; return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements)); function containsPossibleTopLevelAwait(node) { return !(node.flags & 32768) - && !!(node.transformFlags & 16777216); + && !!(node.transformFlags & 67108864); } function findNextStatementWithAwait(statements, start) { for (var i = start; i < statements.length; i++) { @@ -24226,7 +24638,7 @@ var ts; var sourceFile = factory.createSourceFile(statements, endOfFileToken, flags); ts.setTextRangePosWidth(sourceFile, 0, sourceText.length); setFields(sourceFile); - if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216) { + if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 67108864) { sourceFile = reparseTopLevelAwait(sourceFile); setFields(sourceFile); } @@ -25014,11 +25426,11 @@ var ts; } return parseElement(); } - function currentNode(parsingContext) { + function currentNode(parsingContext, pos) { if (!syntaxCursor || !isReusableParsingContext(parsingContext) || parseErrorBeforeNextFinishedNode) { return undefined; } - var node = syntaxCursor.currentNode(scanner.getStartPos()); + var node = syntaxCursor.currentNode(pos !== null && pos !== void 0 ? pos : scanner.getStartPos()); if (ts.nodeIsMissing(node) || node.intersectsChange || ts.containsParseError(node)) { return undefined; } @@ -25216,7 +25628,9 @@ var ts; case 23: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); case 13: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); case 14: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - default: return [undefined]; + case 24: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_or_string_literal_expected); + case 25: return ts.Debug.fail("ParsingContext.Count used as a context"); + default: ts.Debug.assertNever(context); } } function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { @@ -25471,7 +25885,7 @@ var ts; name = parseIdentifierName(); parseExpected(58); } - return finishNode(factory.createParameterDeclaration(undefined, undefined, undefined, name, undefined, parseJSDocType(), undefined), pos); + return finishNode(factory.createParameterDeclaration(undefined, undefined, name, undefined, parseJSDocType(), undefined), pos); } function parseJSDocType() { scanner.setInJSDocType(true); @@ -25562,9 +25976,9 @@ var ts; if (allowAmbiguity === void 0) { allowAmbiguity = true; } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators(); + var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : doOutsideOfAwaitContext(parseDecorators); if (token() === 108) { - var node_1 = factory.createParameterDeclaration(decorators, undefined, undefined, createIdentifier(true), undefined, parseTypeAnnotation(), undefined); + var node_1 = factory.createParameterDeclaration(decorators, undefined, createIdentifier(true), undefined, parseTypeAnnotation(), undefined); if (decorators) { parseErrorAtRange(decorators[0], ts.Diagnostics.Decorators_may_not_be_applied_to_this_parameters); } @@ -25572,12 +25986,12 @@ var ts; } var savedTopLevel = topLevel; topLevel = false; - var modifiers = parseModifiers(); + var modifiers = combineDecoratorsAndModifiers(decorators, parseModifiers()); var dotDotDotToken = parseOptionalToken(25); if (!allowAmbiguity && !isParameterNameStart()) { return undefined; } - var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); + var node = withJSDoc(finishNode(factory.createParameterDeclaration(modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); topLevel = savedTopLevel; return node; } @@ -25675,7 +26089,8 @@ var ts; var parameters = parseBracketedList(16, function () { return parseParameter(false); }, 22, 23); var type = parseTypeAnnotation(); parseTypeMemberSemicolon(); - var node = factory.createIndexSignature(decorators, modifiers, parameters, type); + var node = factory.createIndexSignature(modifiers, parameters, type); + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyOrMethodSignature(pos, hasJSDoc, modifiers) { @@ -25737,10 +26152,10 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); if (parseContextualModifier(136)) { - return parseAccessorDeclaration(pos, hasJSDoc, undefined, modifiers, 172); + return parseAccessorDeclaration(pos, hasJSDoc, undefined, modifiers, 172, 4); } if (parseContextualModifier(149)) { - return parseAccessorDeclaration(pos, hasJSDoc, undefined, modifiers, 173); + return parseAccessorDeclaration(pos, hasJSDoc, undefined, modifiers, 173, 4); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(pos, hasJSDoc, undefined, modifiers); @@ -26342,10 +26757,10 @@ var ts; setDecoratorContext(false); } var pos = getNodePos(); - var expr = parseAssignmentExpressionOrHigher(); + var expr = parseAssignmentExpressionOrHigher(true); var operatorToken; while ((operatorToken = parseOptionalToken(27))) { - expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(), pos); + expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(true), pos); } if (saveDecoratorContext) { setDecoratorContext(true); @@ -26353,25 +26768,25 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(63) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(63) ? parseAssignmentExpressionOrHigher(true) : undefined; } - function parseAssignmentExpressionOrHigher() { + function parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) { if (isYieldExpression()) { return parseYieldExpression(); } - var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression(); + var arrowExpression = tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) || tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction); if (arrowExpression) { return arrowExpression; } var pos = getNodePos(); var expr = parseBinaryExpressionOrHigher(0); if (expr.kind === 79 && token() === 38) { - return parseSimpleArrowFunctionExpression(pos, expr, undefined); + return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, undefined); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { - return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos); + return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction), pos); } - return parseConditionalExpressionRest(expr, pos); + return parseConditionalExpressionRest(expr, pos, allowReturnTypeInArrowFunction); } function isYieldExpression() { if (token() === 125) { @@ -26391,30 +26806,30 @@ var ts; nextToken(); if (!scanner.hasPrecedingLineBreak() && (token() === 41 || isStartOfExpression())) { - return finishNode(factory.createYieldExpression(parseOptionalToken(41), parseAssignmentExpressionOrHigher()), pos); + return finishNode(factory.createYieldExpression(parseOptionalToken(41), parseAssignmentExpressionOrHigher(true)), pos); } else { return finishNode(factory.createYieldExpression(undefined, undefined), pos); } } - function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) { + function parseSimpleArrowFunctionExpression(pos, identifier, allowReturnTypeInArrowFunction, asyncModifier) { ts.Debug.assert(token() === 38, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var parameter = factory.createParameterDeclaration(undefined, undefined, undefined, identifier, undefined, undefined, undefined); + var parameter = factory.createParameterDeclaration(undefined, undefined, identifier, undefined, undefined, undefined); finishNode(parameter, identifier.pos); var parameters = createNodeArray([parameter], parameter.pos, parameter.end); var equalsGreaterThanToken = parseExpectedToken(38); - var body = parseArrowFunctionExpressionBody(!!asyncModifier); + var body = parseArrowFunctionExpressionBody(!!asyncModifier, allowReturnTypeInArrowFunction); var node = factory.createArrowFunction(asyncModifier, undefined, parameters, undefined, equalsGreaterThanToken, body); return addJSDocComment(finishNode(node, pos)); } - function tryParseParenthesizedArrowFunctionExpression() { + function tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) { var triState = isParenthesizedArrowFunctionExpression(); if (triState === 0) { return undefined; } return triState === 1 ? - parseParenthesizedArrowFunctionExpression(true) : - tryParse(parsePossibleParenthesizedArrowFunctionExpression); + parseParenthesizedArrowFunctionExpression(true, true) : + tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction); }); } function isParenthesizedArrowFunctionExpression() { if (token() === 20 || token() === 29 || token() === 131) { @@ -26456,7 +26871,7 @@ var ts; return 1; } if (ts.isModifierKind(second) && second !== 131 && lookAhead(nextTokenIsIdentifier)) { - if (lookAhead(function () { return nextToken() === 127; })) { + if (nextToken() === 127) { return 0; } return 1; @@ -26511,24 +26926,24 @@ var ts; return 2; } } - function parsePossibleParenthesizedArrowFunctionExpression() { + function parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) { var tokenPos = scanner.getTokenPos(); if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) { return undefined; } - var result = parseParenthesizedArrowFunctionExpression(false); + var result = parseParenthesizedArrowFunctionExpression(false, allowReturnTypeInArrowFunction); if (!result) { (notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos); } return result; } - function tryParseAsyncSimpleArrowFunctionExpression() { + function tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction) { if (token() === 131) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1) { var pos = getNodePos(); var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(0); - return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier); + return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, asyncModifier); } } return undefined; @@ -26546,7 +26961,7 @@ var ts; } return 0; } - function parseParenthesizedArrowFunctionExpression(allowAmbiguity) { + function parseParenthesizedArrowFunctionExpression(allowAmbiguity, allowReturnTypeInArrowFunction) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForArrowFunction(); @@ -26574,6 +26989,7 @@ var ts; return undefined; } } + var hasReturnColon = token() === 58; var type = parseReturnType(58, false); if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) { return undefined; @@ -26589,12 +27005,17 @@ var ts; var lastToken = token(); var equalsGreaterThanToken = parseExpectedToken(38); var body = (lastToken === 38 || lastToken === 18) - ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier)) + ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier), allowReturnTypeInArrowFunction) : parseIdentifier(); + if (!allowReturnTypeInArrowFunction && hasReturnColon) { + if (token() !== 58) { + return undefined; + } + } var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body); return withJSDoc(finishNode(node, pos), hasJSDoc); } - function parseArrowFunctionExpressionBody(isAsync) { + function parseArrowFunctionExpressionBody(isAsync, allowReturnTypeInArrowFunction) { if (token() === 18) { return parseFunctionBlock(isAsync ? 2 : 0); } @@ -26608,19 +27029,19 @@ var ts; var savedTopLevel = topLevel; topLevel = false; var node = isAsync - ? doInAwaitContext(parseAssignmentExpressionOrHigher) - : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); + ? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction); }) + : doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction); }); topLevel = savedTopLevel; return node; } - function parseConditionalExpressionRest(leftOperand, pos) { + function parseConditionalExpressionRest(leftOperand, pos, allowReturnTypeInArrowFunction) { var questionToken = parseOptionalToken(57); if (!questionToken) { return leftOperand; } var colonToken; - return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58), ts.nodeIsPresent(colonToken) - ? parseAssignmentExpressionOrHigher() + return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(false); }), colonToken = parseExpectedToken(58), ts.nodeIsPresent(colonToken) + ? parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) : createMissingNode(79, false, ts.Diagnostics._0_expected, ts.tokenToString(58))), pos); } function parseBinaryExpressionOrHigher(precedence) { @@ -26817,6 +27238,9 @@ var ts; var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments); + if (!isTemplateStartOfTaggedTemplate()) { + expression = factory.createExpressionWithTypeArguments(expression, typeArguments); + } } } if (token() === 20 || token() === 24 || token() === 22) { @@ -26995,9 +27419,22 @@ var ts; } scanJsxIdentifier(); var pos = getNodePos(); - return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 ? undefined : - scanJsxAttributeValue() === 10 ? parseLiteralNode() : - parseJsxExpression(true)), pos); + return finishNode(factory.createJsxAttribute(parseIdentifierName(), parseJsxAttributeValue()), pos); + } + function parseJsxAttributeValue() { + if (token() === 63) { + if (scanJsxAttributeValue() === 10) { + return parseLiteralNode(); + } + if (token() === 18) { + return parseJsxExpression(true); + } + if (token() === 29) { + return parseJsxElementOrSelfClosingElementOrFragment(true); + } + parseErrorAtCurrentToken(ts.Diagnostics.or_JSX_element_expected); + } + return undefined; } function parseJsxSpreadAttribute() { var pos = getNodePos(); @@ -27083,6 +27520,11 @@ var ts; if (isOptionalChain && ts.isPrivateIdentifier(propertyAccess.name)) { parseErrorAtRange(propertyAccess.name, ts.Diagnostics.An_optional_chain_cannot_contain_private_identifiers); } + if (ts.isExpressionWithTypeArguments(expression) && expression.typeArguments) { + var pos_2 = expression.typeArguments.pos - 1; + var end = ts.skipTrivia(sourceText, expression.typeArguments.end) + 1; + parseErrorAt(pos_2, end, ts.Diagnostics.An_instantiation_expression_cannot_be_followed_by_a_property_access); + } return finishNode(propertyAccess, pos); } function parseElementAccessExpressionRest(pos, expression, questionDotToken) { @@ -27215,8 +27657,13 @@ var ts; case 14: case 15: return true; + case 29: + case 31: + case 39: + case 40: + return false; } - return !isStartOfExpression(); + return scanner.hasPrecedingLineBreak() || isBinaryOperator() || !isStartOfExpression(); } function parsePrimaryExpression() { switch (token()) { @@ -27272,13 +27719,13 @@ var ts; function parseSpreadElement() { var pos = getNodePos(); parseExpected(25); - var expression = parseAssignmentExpressionOrHigher(); + var expression = parseAssignmentExpressionOrHigher(true); return finishNode(factory.createSpreadElement(expression), pos); } function parseArgumentOrArrayLiteralElement() { return token() === 25 ? parseSpreadElement() : token() === 27 ? finishNode(factory.createOmittedExpression(), getNodePos()) : - parseAssignmentExpressionOrHigher(); + parseAssignmentExpressionOrHigher(true); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); @@ -27296,16 +27743,16 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); if (parseOptionalToken(25)) { - var expression = parseAssignmentExpressionOrHigher(); + var expression = parseAssignmentExpressionOrHigher(true); return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc); } var decorators = parseDecorators(); var modifiers = parseModifiers(); if (parseContextualModifier(136)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172); + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172, 0); } if (parseContextualModifier(149)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173); + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173, 0); } var asteriskToken = parseOptionalToken(41); var tokenIsIdentifier = isIdentifier(); @@ -27319,16 +27766,16 @@ var ts; var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58); if (isShorthandPropertyAssignment) { var equalsToken = parseOptionalToken(63); - var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined; + var objectAssignmentInitializer = equalsToken ? allowInAnd(function () { return parseAssignmentExpressionOrHigher(true); }) : undefined; node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer); node.equalsToken = equalsToken; } else { parseExpected(58); - var initializer = allowInAnd(parseAssignmentExpressionOrHigher); + var initializer = allowInAnd(function () { return parseAssignmentExpressionOrHigher(true); }); node = factory.createPropertyAssignment(name, initializer); } - node.decorators = decorators; + node.illegalDecorators = decorators; node.modifiers = modifiers; node.questionToken = questionToken; node.exclamationToken = exclamationToken; @@ -27382,6 +27829,9 @@ var ts; typeArguments = expression.typeArguments; expression = expression.expression; } + if (token() === 28) { + parseErrorAtCurrentToken(ts.Diagnostics.Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0, ts.getTextOfNodeFromSourceText(sourceText, expression)); + } var argumentList = token() === 20 ? parseArgumentList() : undefined; return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos); } @@ -27485,7 +27935,7 @@ var ts; } var node; if (awaitToken ? parseExpected(160) : parseOptional(160)) { - var expression = allowInAnd(parseAssignmentExpressionOrHigher); + var expression = allowInAnd(function () { return parseAssignmentExpressionOrHigher(true); }); parseExpected(21); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); } @@ -27843,18 +28293,16 @@ var ts; return modifier.kind === 135; } function parseDeclaration() { - var isAmbient = ts.some(lookAhead(function () { return (parseDecorators(), parseModifiers()); }), isDeclareModifier); - if (isAmbient) { - var node = tryReuseAmbientDeclaration(); - if (node) { - return node; - } - } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(); + var isAmbient = ts.some(modifiers, isDeclareModifier); if (isAmbient) { + var node = tryReuseAmbientDeclaration(pos); + if (node) { + return node; + } for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; m.flags |= 16777216; @@ -27865,9 +28313,9 @@ var ts; return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); } } - function tryReuseAmbientDeclaration() { + function tryReuseAmbientDeclaration(pos) { return doInsideOfContext(16777216, function () { - var node = currentNode(parsingContext); + var node = currentNode(parsingContext, pos); if (node) { return consumeNode(node); } @@ -27910,7 +28358,7 @@ var ts; if (decorators || modifiers) { var missing = createMissingNode(276, true, ts.Diagnostics.Declaration_expected); ts.setTextRangePos(missing, pos); - missing.decorators = decorators; + missing.illegalDecorators = decorators; missing.modifiers = modifiers; return missing; } @@ -27922,9 +28370,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10); } function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) { - if (token() !== 18 && canParseSemicolon()) { - parseSemicolon(); - return; + if (token() !== 18) { + if (flags & 4) { + parseTypeMemberSemicolon(); + return; + } + if (canParseSemicolon()) { + parseSemicolon(); + return; + } } return parseFunctionBlock(flags, diagnosticMessage); } @@ -28036,7 +28490,7 @@ var ts; var declarationList = parseVariableDeclarationList(false); parseSemicolon(); var node = factory.createVariableStatement(modifiers, declarationList); - node.decorators = decorators; + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers) { @@ -28054,7 +28508,8 @@ var ts; var type = parseReturnType(58, false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); setAwaitContext(savedAwaitContext); - var node = factory.createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body); + var node = factory.createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, body); + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseConstructorName() { @@ -28075,7 +28530,8 @@ var ts; var parameters = parseParameters(0); var type = parseReturnType(58, false); var body = parseFunctionBlockOrSemicolon(0, ts.Diagnostics.or_expected); - var node = factory.createConstructorDeclaration(decorators, modifiers, parameters, body); + var node = factory.createConstructorDeclaration(modifiers, parameters, body); + node.illegalDecorators = decorators; node.typeParameters = typeParameters; node.type = type; return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -28089,7 +28545,7 @@ var ts; var parameters = parseParameters(isGenerator | isAsync); var type = parseReturnType(58, false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); - var node = factory.createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body); + var node = factory.createMethodDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), asteriskToken, name, questionToken, typeParameters, parameters, type, body); node.exclamationToken = exclamationToken; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -28098,7 +28554,7 @@ var ts; var type = parseTypeAnnotation(); var initializer = doOutsideOfContext(8192 | 32768 | 4096, parseInitializer); parseSemicolonAfterPropertyName(name, type, initializer); - var node = factory.createPropertyDeclaration(decorators, modifiers, name, questionToken || exclamationToken, type, initializer); + var node = factory.createPropertyDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, questionToken || exclamationToken, type, initializer); return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers) { @@ -28110,17 +28566,17 @@ var ts; } return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken); } - function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) { + function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind, flags) { var name = parsePropertyName(); var typeParameters = parseTypeParameters(); var parameters = parseParameters(0); var type = parseReturnType(58, false); - var body = parseFunctionBlockOrSemicolon(0); + var body = parseFunctionBlockOrSemicolon(flags); var node = kind === 172 - ? factory.createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) - : factory.createSetAccessorDeclaration(decorators, modifiers, name, parameters, body); + ? factory.createGetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, type, body) + : factory.createSetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, body); node.typeParameters = typeParameters; - if (type && node.kind === 173) + if (ts.isSetAccessorDeclaration(node)) node.type = type; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -28167,7 +28623,10 @@ var ts; function parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers) { parseExpectedToken(124); var body = parseClassStaticBlockBody(); - return withJSDoc(finishNode(factory.createClassStaticBlockDeclaration(decorators, modifiers, body), pos), hasJSDoc); + var node = withJSDoc(finishNode(factory.createClassStaticBlockDeclaration(body), pos), hasJSDoc); + node.illegalDecorators = decorators; + node.modifiers = modifiers; + return node; } function parseClassStaticBlockBody() { var savedYieldContext = inYieldContext(); @@ -28226,6 +28685,15 @@ var ts; } return finishNode(factory.createToken(kind), pos); } + function combineDecoratorsAndModifiers(decorators, modifiers) { + if (!decorators) + return modifiers; + if (!modifiers) + return decorators; + var decoratorsAndModifiers = factory.createNodeArray(ts.concatenate(decorators, modifiers)); + ts.setTextRangePosEnd(decoratorsAndModifiers, decorators.pos, modifiers.end); + return decoratorsAndModifiers; + } function parseModifiers(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock) { var pos = getNodePos(); var list, modifier, hasSeenStatic = false; @@ -28259,10 +28727,10 @@ var ts; return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers); } if (parseContextualModifier(136)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172); + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172, 0); } if (parseContextualModifier(149)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173); + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173, 0); } if (token() === 134 || token() === 10) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -28320,8 +28788,8 @@ var ts; } setAwaitContext(savedAwaitContext); var node = kind === 257 - ? factory.createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) - : factory.createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members); + ? factory.createClassDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, typeParameters, heritageClauses, members) + : factory.createClassExpression(combineDecoratorsAndModifiers(decorators, modifiers), name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseNameOfClassDeclarationOrExpression() { @@ -28371,7 +28839,8 @@ var ts; var typeParameters = parseTypeParameters(); var heritageClauses = parseHeritageClauses(); var members = parseObjectTypeMembers(); - var node = factory.createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members); + var node = factory.createInterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, members); + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) { @@ -28381,7 +28850,8 @@ var ts; parseExpected(63); var type = token() === 138 && tryParse(parseKeywordAndNoDot) || parseType(); parseSemicolon(); - var node = factory.createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type); + var node = factory.createTypeAliasDeclaration(modifiers, name, typeParameters, type); + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseEnumMember() { @@ -28402,7 +28872,8 @@ var ts; else { members = createMissingList(); } - var node = factory.createEnumDeclaration(decorators, modifiers, name, members); + var node = factory.createEnumDeclaration(modifiers, name, members); + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseModuleBlock() { @@ -28423,7 +28894,8 @@ var ts; var body = parseOptional(24) ? parseModuleOrNamespaceDeclaration(getNodePos(), false, undefined, undefined, 4 | namespaceFlag) : parseModuleBlock(); - var node = factory.createModuleDeclaration(decorators, modifiers, name, body, flags); + var node = factory.createModuleDeclaration(modifiers, name, body, flags); + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { @@ -28444,7 +28916,8 @@ var ts; else { parseSemicolon(); } - var node = factory.createModuleDeclaration(decorators, modifiers, name, body, flags); + var node = factory.createModuleDeclaration(modifiers, name, body, flags); + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { @@ -28482,7 +28955,7 @@ var ts; var name = parseIdentifier(); parseSemicolon(); var node = factory.createNamespaceExportDeclaration(name); - node.decorators = decorators; + node.illegalDecorators = decorators; node.modifiers = modifiers; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -28516,14 +28989,15 @@ var ts; assertClause = parseAssertClause(); } parseSemicolon(); - var node = factory.createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, assertClause); + var node = factory.createImportDeclaration(modifiers, importClause, moduleSpecifier, assertClause); + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseAssertEntry() { var pos = getNodePos(); var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10); parseExpected(58); - var value = parseAssignmentExpressionOrHigher(); + var value = parseAssignmentExpressionOrHigher(true); return finishNode(factory.createAssertEntry(name, value), pos); } function parseAssertClause(skipAssertKeyword) { @@ -28558,7 +29032,8 @@ var ts; parseExpected(63); var moduleReference = parseModuleReference(); parseSemicolon(); - var node = factory.createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, identifier, moduleReference); + var node = factory.createImportEqualsDeclaration(modifiers, isTypeOnly, identifier, moduleReference); + node.illegalDecorators = decorators; var finished = withJSDoc(finishNode(node, pos), hasJSDoc); return finished; } @@ -28704,7 +29179,8 @@ var ts; } parseSemicolon(); setAwaitContext(savedAwaitContext); - var node = factory.createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause); + var node = factory.createExportDeclaration(modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause); + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseExportAssignment(pos, hasJSDoc, decorators, modifiers) { @@ -28717,10 +29193,11 @@ var ts; else { parseExpected(88); } - var expression = parseAssignmentExpressionOrHigher(); + var expression = parseAssignmentExpressionOrHigher(true); parseSemicolon(); setAwaitContext(savedAwaitContext); - var node = factory.createExportAssignment(decorators, modifiers, isExportEquals, expression); + var node = factory.createExportAssignment(modifiers, isExportEquals, expression); + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } var JSDocParser; @@ -29429,7 +29906,7 @@ var ts; var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(24)) { var body = parseJSDocTypeNameWithNamespace(true); - var jsDocNamespaceNode = factory.createModuleDeclaration(undefined, undefined, typeNameOrNamespaceName, body, nested ? 4 : undefined); + var jsDocNamespaceNode = factory.createModuleDeclaration(undefined, typeNameOrNamespaceName, body, nested ? 4 : undefined); return finishNode(jsDocNamespaceNode, pos); } if (nested) { @@ -29748,10 +30225,10 @@ var ts; } function checkNodePositions(node, aggressiveChecks) { if (aggressiveChecks) { - var pos_2 = node.pos; + var pos_3 = node.pos; var visitNode_1 = function (child) { - ts.Debug.assert(child.pos >= pos_2); - pos_2 = child.end; + ts.Debug.assert(child.pos >= pos_3); + pos_3 = child.end; }; if (ts.hasJSDocNodes(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { @@ -29760,7 +30237,7 @@ var ts; } } forEachChild(node, visitNode_1); - ts.Debug.assert(pos_2 <= node.end); + ts.Debug.assert(pos_3 <= node.end); } } function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) { @@ -30242,6 +30719,7 @@ var ts; ["es2022.error", "lib.es2022.error.d.ts"], ["es2022.intl", "lib.es2022.intl.d.ts"], ["es2022.object", "lib.es2022.object.d.ts"], + ["es2022.sharedmemory", "lib.es2022.sharedmemory.d.ts"], ["es2022.string", "lib.es2022.string.d.ts"], ["esnext.array", "lib.es2022.array.d.ts"], ["esnext.symbol", "lib.es2019.symbol.d.ts"], @@ -30304,16 +30782,18 @@ var ts; ts.Debug.assert(ts.extensionIsTS(resolved.extension)); return { fileName: resolved.path, packageId: resolved.packageId }; } - function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, diagnostics, resultFromCache) { - var _a; + function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) { + var _a, _b; if (resultFromCache) { (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations); + (_b = resultFromCache.affectingLocations).push.apply(_b, affectingLocations); return resultFromCache; } return { resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId }, failedLookupLocations: failedLookupLocations, - resolutionDiagnostics: diagnostics + affectingLocations: affectingLocations, + resolutionDiagnostics: diagnostics, }; } function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) { @@ -30489,6 +30969,7 @@ var ts; } } var failedLookupLocations = []; + var affectingLocations = []; var features = getDefaultNodeResolutionFeatures(options); if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) { features |= NodeResolutionFeatures.EsmMode; @@ -30500,6 +30981,7 @@ var ts; host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, + affectingLocations: affectingLocations, packageJsonInfoCache: cache, features: features, conditions: conditions, @@ -30516,15 +30998,16 @@ var ts; if (resolved) { var fileName = resolved.fileName, packageId = resolved.packageId; var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled); + var pathsAreEqual = arePathsEqual(fileName, resolvedFileName, host); resolvedTypeReferenceDirective = { primary: primary, - resolvedFileName: resolvedFileName, - originalPath: arePathsEqual(fileName, resolvedFileName, host) ? undefined : fileName, + resolvedFileName: pathsAreEqual ? fileName : resolvedFileName, + originalPath: pathsAreEqual ? undefined : fileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName), }; } - result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, resolutionDiagnostics: diagnostics }; + result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, affectingLocations: affectingLocations, resolutionDiagnostics: diagnostics }; perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, resolutionMode, result); if (traceEnabled) traceResult(result); @@ -30593,17 +31076,7 @@ var ts; NodeResolutionFeatures.None; } function resolvePackageNameToPackageJson(packageName, containingDirectory, options, host, cache) { - var moduleResolutionState = { - compilerOptions: options, - host: host, - traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: [], - packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), - conditions: ts.emptyArray, - features: NodeResolutionFeatures.None, - requestContainingDirectory: containingDirectory, - reportDiagnostic: ts.noop - }; + var moduleResolutionState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options); return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { var nodeModulesFolder = ts.combinePaths(ancestorDirectory, "node_modules"); @@ -30683,7 +31156,7 @@ var ts; ts.createCacheWithRedirects = createCacheWithRedirects; function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) { var cache; - return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries }; + return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries, getInternalMap: getInternalMap }; function getPackageJsonInfo(packageJsonPath) { return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName)); } @@ -30697,6 +31170,9 @@ var ts; var iter = cache === null || cache === void 0 ? void 0 : cache.entries(); return iter ? ts.arrayFrom(iter) : []; } + function getInternalMap() { + return cache; + } } function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); @@ -30795,15 +31271,18 @@ var ts; } ts.zipToModeAwareCache = zipToModeAwareCache; function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) { - var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options)); var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName); - return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; } }); + return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache }); function clear() { - preDirectoryResolutionCache.clear(); - moduleNameToDirectoryMap.clear(); + clearAllExceptPackageJsonInfoCache(); packageJsonInfoCache.clear(); } + function clearAllExceptPackageJsonInfoCache() { + perDirectoryResolutionCache.clear(); + moduleNameToDirectoryMap.clear(); + } function update(options) { updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap); } @@ -30860,13 +31339,16 @@ var ts; } ts.createModuleResolutionCache = createModuleResolutionCache; function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) { - var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName)); - return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear }); + return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache }); function clear() { - preDirectoryResolutionCache.clear(); + clearAllExceptPackageJsonInfoCache(); packageJsonInfoCache.clear(); } + function clearAllExceptPackageJsonInfoCache() { + perDirectoryResolutionCache.clear(); + } } ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache; function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) { @@ -31131,6 +31613,7 @@ var ts; var _a, _b; var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; + var affectingLocations = []; var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]; if (compilerOptions.noDtsResolution) { conditions.pop(); @@ -31141,6 +31624,7 @@ var ts; host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, + affectingLocations: affectingLocations, packageJsonInfoCache: cache, features: features, conditions: conditions, @@ -31148,7 +31632,7 @@ var ts; reportDiagnostic: function (diag) { return void diagnostics.push(diag); }, }; var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); }); - return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, diagnostics, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache); function tryResolve(extensions) { var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, true); }; var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state); @@ -31174,8 +31658,9 @@ var ts; var resolvedValue = resolved_1.value; if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) { var path = realPath(resolvedValue.path, host, traceEnabled); - var originalPath = arePathsEqual(path, resolvedValue.path, host) ? undefined : resolvedValue.path; - resolvedValue = __assign(__assign({}, resolvedValue), { path: path, originalPath: originalPath }); + var pathsAreEqual = arePathsEqual(path, resolvedValue.path, host); + var originalPath = pathsAreEqual ? undefined : resolvedValue.path; + resolvedValue = __assign(__assign({}, resolvedValue), { path: pathsAreEqual ? resolvedValue.path : path, originalPath: originalPath }); } return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } }; } @@ -31401,17 +31886,9 @@ var ts; var entrypoints; var extensions = resolveJs ? Extensions.JavaScript : Extensions.TypeScript; var features = getDefaultNodeResolutionFeatures(options); - var requireState = { - compilerOptions: options, - host: host, - traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: [], - packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), - conditions: ["node", "require", "types"], - features: features, - requestContainingDirectory: packageJsonInfo.packageDirectory, - reportDiagnostic: ts.noop - }; + var requireState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options); + requireState.conditions = ["node", "require", "types"]; + requireState.requestContainingDirectory = packageJsonInfo.packageDirectory; var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory, false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths); entrypoints = ts.append(entrypoints, requireResolution === null || requireResolution === void 0 ? void 0 : requireResolution.path); if (features & NodeResolutionFeatures.Exports && packageJsonInfo.packageJsonContent.exports) { @@ -31481,18 +31958,22 @@ var ts; } } } - function getPackageScopeForPath(fileName, packageJsonInfoCache, host, options) { - var state = { + function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options) { + return { host: host, compilerOptions: options, traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: [], + failedLookupLocations: ts.noopPush, + affectingLocations: ts.noopPush, packageJsonInfoCache: packageJsonInfoCache, - features: 0, - conditions: [], + features: NodeResolutionFeatures.None, + conditions: ts.emptyArray, requestContainingDirectory: undefined, reportDiagnostic: ts.noop }; + } + ts.getTemporaryModuleResolutionState = getTemporaryModuleResolutionState; + function getPackageScopeForPath(fileName, state) { var parts = ts.getPathComponents(fileName); parts.pop(); while (parts.length > 0) { @@ -31518,6 +31999,7 @@ var ts; if (typeof existing !== "boolean") { if (traceEnabled) trace(host, ts.Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath); + state.affectingLocations.push(packageJsonPath); return existing; } else { @@ -31536,6 +32018,7 @@ var ts; var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state); var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined }; (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result); + state.affectingLocations.push(packageJsonPath); return result; } else { @@ -31647,7 +32130,7 @@ var ts; var _a, _b; var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames; var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames)); - var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions); + var scope = getPackageScopeForPath(directoryPath, state); if (!scope || !scope.packageJsonContent.exports) { return undefined; } @@ -31706,7 +32189,7 @@ var ts; } var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames; var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames)); - var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions); + var scope = getPackageScopeForPath(directoryPath, state); if (!scope) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath); @@ -31747,6 +32230,7 @@ var ts; return 1; return 0; } + ts.comparePatternKeys = comparePatternKeys; function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) { var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports); if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) { @@ -32126,11 +32610,23 @@ var ts; function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; + var affectingLocations = []; var containingDirectory = ts.getDirectoryPath(containingFile); var diagnostics = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: containingDirectory, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } }; + var state = { + compilerOptions: compilerOptions, + host: host, + traceEnabled: traceEnabled, + failedLookupLocations: failedLookupLocations, + affectingLocations: affectingLocations, + packageJsonInfoCache: cache, + features: NodeResolutionFeatures.None, + conditions: [], + requestContainingDirectory: containingDirectory, + reportDiagnostic: function (diag) { return void diagnostics.push(diag); }, + }; var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); - return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations, diagnostics, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state); if (resolvedUsingSettings) { @@ -32166,10 +32662,22 @@ var ts; 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 failedLookupLocations = []; + var affectingLocations = []; var diagnostics = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: undefined, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } }; + var state = { + compilerOptions: compilerOptions, + host: host, + traceEnabled: traceEnabled, + failedLookupLocations: failedLookupLocations, + affectingLocations: affectingLocations, + packageJsonInfoCache: packageJsonInfoCache, + features: NodeResolutionFeatures.None, + conditions: [], + requestContainingDirectory: undefined, + reportDiagnostic: function (diag) { return void diagnostics.push(diag); }, + }; var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, false, undefined, undefined); - return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations, diagnostics, state.resultFromCache); + return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; function toSearchResult(value) { @@ -32463,7 +32971,7 @@ var ts; case 317: return (ts.isJSDocConstructSignature(node) ? "__new" : "__call"); case 164: - ts.Debug.assert(node.parent.kind === 317, "Impossible parameter parent kind", function () { return "parent is: ".concat(ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind, ", expected JSDocFunctionType"); }); + ts.Debug.assert(node.parent.kind === 317, "Impossible parameter parent kind", function () { return "parent is: ".concat(ts.Debug.formatSyntaxKind(node.parent.kind), ", expected JSDocFunctionType"); }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -33498,8 +34006,6 @@ var ts; } function bindBindingElementFlow(node) { if (ts.isBindingPattern(node.name)) { - bindEach(node.decorators); - bindEach(node.modifiers); bind(node.dotDotDotToken); bind(node.propertyName); bind(node.initializer); @@ -33782,24 +34288,6 @@ var ts; typeLiteralSymbol.members.set(symbol.escapedName, symbol); } function bindObjectLiteralExpression(node) { - if (inStrictMode && !ts.isAssignmentTarget(node)) { - var seen = new ts.Map(); - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var prop = _a[_i]; - if (prop.kind === 298 || prop.name.kind !== 79) { - continue; - } - var identifier = prop.name; - var currentKind = prop.kind === 296 || prop.kind === 297 || prop.kind === 169 - ? 1 - : 2; - var existingKind = seen.get(identifier.escapedText); - if (!existingKind) { - seen.set(identifier.escapedText, currentKind); - continue; - } - } - } return bindAnonymousDeclaration(node, 4096, "__object"); } function bindJsxAttributes(node) { @@ -34370,7 +34858,7 @@ var ts; } } function bindNamespaceExportDeclaration(node) { - if (node.modifiers && node.modifiers.length) { + if (ts.some(node.modifiers)) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } var diag = !ts.isSourceFile(node.parent) ? ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level @@ -34927,10 +35415,11 @@ var ts; } function isExportsOrModuleExportsOrAlias(sourceFile, node) { var i = 0; - var q = [node]; - while (q.length && i < 100) { + var q = ts.createQueue(); + q.enqueue(node); + while (!q.isEmpty() && i < 100) { i++; - node = q.shift(); + node = q.dequeue(); if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) { return true; } @@ -34938,10 +35427,10 @@ var ts; var symbol = lookupSymbolForName(sourceFile, node.escapedText); if (!!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) { var init = symbol.valueDeclaration.initializer; - q.push(init); + q.enqueue(init); if (ts.isAssignmentExpression(init, true)) { - q.push(init.left); - q.push(init.right); + q.enqueue(init.left); + q.enqueue(init.right); } } } @@ -35131,16 +35620,6 @@ var ts; var nextNodeId = 1; var nextMergeId = 1; var nextFlowId = 1; - var typeofEQFacts = new ts.Map(ts.getEntries({ - string: 1, - number: 2, - bigint: 4, - boolean: 8, - symbol: 16, - undefined: 65536, - object: 32, - function: 64 - })); var typeofNEFacts = new ts.Map(ts.getEntries({ string: 256, number: 512, @@ -35395,7 +35874,7 @@ var ts; }, getContextualTypeForObjectLiteralElement: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike); - return node ? getContextualTypeForObjectLiteralElement(node) : undefined; + return node ? getContextualTypeForObjectLiteralElement(node, undefined) : undefined; }, getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) { var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression); @@ -35403,7 +35882,7 @@ var ts; }, getContextualTypeForJsxAttribute: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike); - return node && getContextualTypeForJsxAttribute(node); + return node && getContextualTypeForJsxAttribute(node, undefined); }, isContextSensitive: isContextSensitive, getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType, @@ -35515,9 +35994,9 @@ var ts; return moduleSpecifier && resolveExternalModuleName(moduleSpecifier, moduleSpecifier, true); }, resolveExternalModuleSymbol: resolveExternalModuleSymbol, - tryGetThisTypeAt: function (nodeIn, includeGlobalThis) { + tryGetThisTypeAt: function (nodeIn, includeGlobalThis, container) { var node = ts.getParseTreeNode(nodeIn); - return node && tryGetThisTypeAt(node, includeGlobalThis); + return node && tryGetThisTypeAt(node, includeGlobalThis, container); }, getTypeArgumentConstraint: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode); @@ -35603,6 +36082,7 @@ var ts; var stringMappingTypes = new ts.Map(); var substitutionTypes = new ts.Map(); var subtypeReductionCache = new ts.Map(); + var cachedTypes = new ts.Map(); var evolvingArrayTypes = []; var undefinedProperties = new ts.Map(); var markerTypes = new ts.Set(); @@ -35611,11 +36091,10 @@ var ts; var unresolvedSymbols = new ts.Map(); var errorTypes = new ts.Map(); var anyType = createIntrinsicType(1, "any"); - var autoType = createIntrinsicType(1, "any"); + var autoType = createIntrinsicType(1, "any", 262144); var wildcardType = createIntrinsicType(1, "any"); var errorType = createIntrinsicType(1, "error"); var unresolvedType = createIntrinsicType(1, "unresolved"); - var nonInferrableAnyType = createIntrinsicType(1, "any", 65536); var intrinsicMarkerType = createIntrinsicType(1, "intrinsic"); var unknownType = createIntrinsicType(2, "unknown"); var nonNullUnknownType = createIntrinsicType(2, "unknown"); @@ -35644,8 +36123,7 @@ var ts; var esSymbolType = createIntrinsicType(4096, "symbol"); var voidType = createIntrinsicType(16384, "void"); var neverType = createIntrinsicType(131072, "never"); - var silentNeverType = createIntrinsicType(131072, "never"); - var nonInferrableType = createIntrinsicType(131072, "never", 262144); + var silentNeverType = createIntrinsicType(131072, "never", 262144); var implicitNeverType = createIntrinsicType(131072, "never"); var unreachableNeverType = createIntrinsicType(131072, "never"); var nonPrimitiveType = createIntrinsicType(67108864, "object"); @@ -35655,16 +36133,30 @@ var ts; var numberOrBigIntType = getUnionType([numberType, bigintType]); var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]); var numericStringType = getTemplateLiteralType(["", ""], [numberType]); - var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? getRestrictiveTypeParameter(t) : t; }); - var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? wildcardType : t; }); + var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? getRestrictiveTypeParameter(t) : t; }, function () { return "(restrictive mapper)"; }); + var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? wildcardType : t; }, function () { return "(permissive mapper)"; }); var uniqueLiteralType = createIntrinsicType(131072, "never"); - var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? uniqueLiteralType : t; }); + var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? uniqueLiteralType : t; }, function () { return "(unique literal mapper)"; }); + var outofbandVarianceMarkerHandler; + var reportUnreliableMapper = makeFunctionTypeMapper(function (t) { + if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) { + outofbandVarianceMarkerHandler(true); + } + return t; + }, function () { return "(unmeasurable reporter)"; }); + var reportUnmeasurableMapper = makeFunctionTypeMapper(function (t) { + if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) { + outofbandVarianceMarkerHandler(false); + } + return t; + }, function () { return "(unreliable reporter)"; }); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); emptyJsxObjectType.objectFlags |= 2048; var emptyTypeLiteralSymbol = createSymbol(2048, "__type"); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); + var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType; var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); emptyGenericType.instantiations = new ts.Map(); var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); @@ -35676,6 +36168,9 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); + var markerSuperTypeForCheck = createTypeParameter(); + var markerSubTypeForCheck = createTypeParameter(); + markerSubTypeForCheck.constraint = markerSuperTypeForCheck; var noTypePredicate = createTypePredicate(1, "<>", 0, anyType); var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, 0); var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, undefined, 0, 0); @@ -35796,21 +36291,13 @@ var ts; var potentialNewTargetCollisions = []; var potentialWeakMapSetCollisions = []; var potentialReflectCollisions = []; + var potentialUnusedRenamedBindingElementsInTypes = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var suggestionDiagnostics = ts.createDiagnosticCollection(); - var typeofTypesByName = new ts.Map(ts.getEntries({ - string: stringType, - number: numberType, - bigint: bigintType, - boolean: booleanType, - symbol: esSymbolType, - undefined: undefinedType - })); var typeofType = createTypeofType(); var _jsxNamespace; var _jsxFactoryEntity; - var outofbandVarianceMarkerHandler; var subtypeRelation = new ts.Map(); var strictSubtypeRelation = new ts.Map(); var assignableRelation = new ts.Map(); @@ -35832,6 +36319,14 @@ var ts; ]; initializeTypeChecker(); return checker; + function getCachedType(key) { + return key ? cachedTypes.get(key) : undefined; + } + function setCachedType(key, type) { + if (key) + cachedTypes.set(key, type); + return type; + } function getJsxNamespace(location) { if (location) { var file = ts.getSourceFileOfNode(location); @@ -36571,6 +37066,7 @@ var ts; var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (lookup(ctor.locals, name, meaning & 111551)) { + ts.Debug.assertNode(location, ts.isPropertyDeclaration); propertyWithInvalidInitializer = location; } } @@ -36716,11 +37212,21 @@ var ts; } } } + function checkAndReportErrorForInvalidInitializer() { + if (propertyWithInvalidInitializer && !(useDefineForClassFields && ts.getEmitScriptTarget(compilerOptions) >= 9)) { + error(errorLocation, errorLocation && propertyWithInvalidInitializer.type && ts.textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos) + ? ts.Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor + : ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyWithInvalidInitializer.name), diagnosticName(nameArg)); + return true; + } + return false; + } if (!result) { if (nameNotFoundMessage) { addLazyDiagnostic(function () { if (!errorLocation || !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && + !checkAndReportErrorForInvalidInitializer() && !checkAndReportErrorForExtendingInterface(errorLocation) && !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) && @@ -36728,7 +37234,14 @@ var ts; !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) && !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) { var suggestion = void 0; - if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) { + var suggestedLib = void 0; + if (nameArg) { + suggestedLib = getSuggestedLibForNonExistentName(nameArg); + if (suggestedLib) { + error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), suggestedLib); + } + } + if (!suggestedLib && getSpellingSuggestions && suggestionCount < maximumSuggestionCount) { suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning); var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration); if (isGlobalScopeAugmentationDeclaration) { @@ -36747,16 +37260,8 @@ var ts; } } } - if (!suggestion) { - if (nameArg) { - var lib = getSuggestedLibForNonExistentName(nameArg); - if (lib) { - error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib); - } - else { - error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg)); - } - } + if (!suggestion && !suggestedLib && nameArg) { + error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg)); } suggestionCount++; } @@ -36764,9 +37269,7 @@ var ts; } return undefined; } - if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 && useDefineForClassFields)) { - var propertyName = propertyWithInvalidInitializer.name; - error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg)); + else if (checkAndReportErrorForInvalidInitializer()) { return undefined; } if (nameNotFoundMessage) { @@ -36951,7 +37454,12 @@ var ts; function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { if (meaning & (111551 & ~1024)) { if (isPrimitiveTypeName(name)) { - error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); + if (isExtendedByInterface(errorLocation)) { + error(errorLocation, ts.Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes, ts.unescapeLeadingUnderscores(name)); + } + else { + error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); + } return true; } var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 & ~111551, undefined, undefined, false)); @@ -36971,6 +37479,16 @@ var ts; } return false; } + function isExtendedByInterface(node) { + var grandparent = node.parent.parent; + var parentOfGrandparent = grandparent.parent; + if (grandparent && parentOfGrandparent) { + var isExtending = ts.isHeritageClause(grandparent) && grandparent.token === 94; + var isInterface = ts.isInterfaceDeclaration(parentOfGrandparent); + return isExtending && isInterface; + } + return false; + } function maybeMappedType(node, symbol) { var container = ts.findAncestor(node.parent, function (n) { return ts.isComputedPropertyName(n) || ts.isPropertySignature(n) ? false : ts.isTypeLiteralNode(n) || "quit"; @@ -37419,10 +37937,6 @@ var ts; checkExpressionCached(expression); return getNodeLinks(expression).resolvedSymbol; } - function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) { - var expression = node.initializer; - return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); - } function getTargetOfAccessExpression(node, dontRecursivelyResolve) { if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63)) { return undefined; @@ -37454,7 +37968,7 @@ var ts; case 297: return resolveEntityName(node.name, 111551 | 788968 | 1920, true, dontRecursivelyResolve); case 296: - return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); + return getTargetOfAliasLikeExpression(node.initializer, dontRecursivelyResolve); case 207: case 206: return getTargetOfAccessExpression(node, dontRecursivelyResolve); @@ -37792,7 +38306,34 @@ var ts; var overrideClauseHost = ts.findAncestor(location, function (l) { return ts.isImportTypeNode(l) || ts.isExportDeclaration(l) || ts.isImportDeclaration(l); }); var overrideClause = overrideClauseHost && ts.isImportTypeNode(overrideClauseHost) ? (_g = overrideClauseHost.assertions) === null || _g === void 0 ? void 0 : _g.assertClause : overrideClauseHost === null || overrideClauseHost === void 0 ? void 0 : overrideClauseHost.assertClause; if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext && !ts.getResolutionModeOverrideForClause(overrideClause)) { - error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference); + if (ts.findAncestor(location, ts.isImportEqualsDeclaration)) { + error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead, moduleReference); + } + else { + var diagnosticDetails = void 0; + var ext = ts.tryGetExtensionFromPath(currentSourceFile.fileName); + if (ext === ".ts" || ext === ".js" || ext === ".tsx" || ext === ".jsx") { + var scope = currentSourceFile.packageJsonScope; + var targetExt = ext === ".ts" ? ".mts" : ext === ".js" ? ".mjs" : undefined; + if (scope && !scope.packageJsonContent.type) { + if (targetExt) { + diagnosticDetails = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1, targetExt, ts.combinePaths(scope.packageDirectory, "package.json")); + } + else { + diagnosticDetails = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0, ts.combinePaths(scope.packageDirectory, "package.json")); + } + } + else { + if (targetExt) { + diagnosticDetails = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module, targetExt); + } + else { + diagnosticDetails = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module); + } + } + } + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, ts.chainDiagnosticMessages(diagnosticDetails, ts.Diagnostics.The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead, moduleReference))); + } } } return getMergedSymbol(sourceFile.symbol); @@ -38249,8 +38790,9 @@ var ts; function getExportSymbolOfValueSymbolIfExported(symbol) { return getMergedSymbol(symbol && (symbol.flags & 1048576) !== 0 && symbol.exportSymbol || symbol); } - function symbolIsValue(symbol) { - return !!(symbol.flags & 111551 || symbol.flags & 2097152 && resolveAlias(symbol).flags & 111551 && !getTypeOnlyAliasDeclaration(symbol)); + function symbolIsValue(symbol, includeTypeOnlyMembers) { + return !!(symbol.flags & 111551 || + symbol.flags & 2097152 && resolveAlias(symbol).flags & 111551 && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol))); } function findConstructorDeclaration(node) { var members = node.members; @@ -38290,7 +38832,7 @@ var ts; return type; } function createTypeofType() { - return getUnionType(ts.arrayFrom(typeofEQFacts.keys(), getStringLiteralType)); + return getUnionType(ts.arrayFrom(typeofNEFacts.keys(), getStringLiteralType)); } function createTypeParameter(symbol) { var type = createType(262144); @@ -38624,13 +39166,25 @@ var ts; && isDeclarationVisible(declaration.parent)) { return addVisibleAlias(declaration, declaration); } - else if (symbol.flags & 2097152 && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) - && ts.isVariableDeclaration(declaration.parent.parent) - && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent) - && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1) - && declaration.parent.parent.parent.parent.parent - && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { - return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); + else if (ts.isBindingElement(declaration)) { + if (symbol.flags & 2097152 && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) + && ts.isVariableDeclaration(declaration.parent.parent) + && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent) + && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1) + && declaration.parent.parent.parent.parent.parent + && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { + return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); + } + else if (symbol.flags & 2) { + var variableStatement = ts.findAncestor(declaration, ts.isVariableStatement); + if (ts.hasSyntacticModifier(variableStatement, 1)) { + return true; + } + if (!isDeclarationVisible(variableStatement.parent)) { + return false; + } + return addVisibleAlias(declaration, variableStatement); + } } return false; } @@ -38663,6 +39217,9 @@ var ts; if (symbol && symbol.flags & 262144 && meaning & 788968) { return { accessibility: 0 }; } + if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, false)), firstIdentifier, meaning, false).accessibility === 0) { + return { accessibility: 0 }; + } return (symbol && hasVisibleDeclarations(symbol, true)) || { accessibility: 1, errorSymbolName: ts.getTextOfNode(firstIdentifier), @@ -38747,7 +39304,7 @@ var ts; } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0; } - return flags & 814775659; + return flags & 848330091; } function isClassInstanceSide(type) { return !!type.symbol && !!(type.symbol.flags & 32) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288) && !!(ts.getObjectFlags(type) & 16777216))); @@ -38848,6 +39405,12 @@ var ts; return context.truncating = context.approximateLength > ((context.flags & 1) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); } function typeToTypeNodeHelper(type, context) { + var savedFlags = context.flags; + var typeNode = typeToTypeNodeWorker(type, context); + context.flags = savedFlags; + return typeNode; + } + function typeToTypeNodeWorker(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { cancellationToken.throwIfCancellationRequested(); } @@ -38987,6 +39550,9 @@ var ts; var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32)) return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""), typeArgumentNodes); + if (ts.length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) { + return ts.factory.createArrayTypeNode(typeArgumentNodes[0]); + } return symbolToTypeNode(type.aliasSymbol, context, 788968, typeArgumentNodes); } var objectFlags = ts.getObjectFlags(type); @@ -39018,8 +39584,8 @@ var ts; if (type.symbol) { return symbolToTypeNode(type.symbol, context, 788968); } - var name = (type === markerSuperType || type === markerSubType) && varianceTypeParameter && varianceTypeParameter.symbol ? - (type === markerSubType ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?"; + var name = (type === markerSuperTypeForCheck || type === markerSubTypeForCheck) && varianceTypeParameter && varianceTypeParameter.symbol ? + (type === markerSubTypeForCheck ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?"; return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(name), undefined); } if (type.flags & 1048576 && type.origin) { @@ -39084,7 +39650,7 @@ var ts; var name = typeParameterToName(newParam, context); var newTypeVariable = ts.factory.createTypeReferenceNode(name); context.approximateLength += 37; - var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper); + var newMapper = prependTypeMapping(type.root.checkType, newParam, type.mapper); var saveInferTypeParameters_1 = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context); @@ -39115,6 +39681,10 @@ var ts; } return typeToTypeNodeHelper(type, context); } + function isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) { + return isMappedTypeWithKeyofConstraintDeclaration(type) + && !(getModifiersTypeFromMappedType(type).flags & 262144); + } function createMappedTypeNodeFromType(type) { ts.Debug.assert(!!(type.flags & 524288)); var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined; @@ -39122,7 +39692,7 @@ var ts; var appropriateConstraintTypeNode; var newTypeVariable; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { - if (!(getModifiersTypeFromMappedType(type).flags & 262144) && context.flags & 4) { + if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4) { var newParam = createTypeParameter(createSymbol(262144, "T")); var name = typeParameterToName(newParam, context); newTypeVariable = ts.factory.createTypeReferenceNode(name); @@ -39138,8 +39708,9 @@ var ts; var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, undefined); context.approximateLength += 10; var result = ts.setEmitFlags(mappedTypeNode, 1); - if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144) && context.flags & 4) { - return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(undefined, ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143)); + if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4) { + var originalConstraint = instantiateType(getConstraintOfTypeParameter(getTypeFromTypeNode(type.declaration.typeParameter.constraint.type)) || unknownType, type.mapper); + return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(undefined, ts.factory.cloneNode(newTypeVariable.typeName), originalConstraint.flags & 2 ? undefined : typeToTypeNodeHelper(originalConstraint, context))), result, ts.factory.createKeywordTypeNode(143)); } return result; } @@ -39154,7 +39725,7 @@ var ts; } else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) - && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 226 && context.flags & 2048) || + && !(symbol.valueDeclaration && ts.isClassLike(symbol.valueDeclaration) && context.flags & 2048 && (!ts.isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, false).accessibility !== 0)) || symbol.flags & (384 | 512) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, isInstanceType); @@ -39400,7 +39971,7 @@ var ts; var id = ids_1[_i]; qualifier = qualifier ? ts.factory.createQualifiedName(qualifier, id) : id; } - return ts.factory.updateImportTypeNode(root, root.argument, qualifier, typeArguments, root.isTypeOf); + return ts.factory.updateImportTypeNode(root, root.argument, root.assertions, qualifier, typeArguments, root.isTypeOf); } else { var typeArguments = root.typeArguments; @@ -39496,7 +40067,7 @@ var ts; anyType : getNonMissingTypeOfSymbol(propertySymbol); var saveEnclosingDeclaration = context.enclosingDeclaration; context.enclosingDeclaration = undefined; - if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 && isLateBoundName(propertySymbol.escapedName)) { + if (context.tracker.trackSymbol && isLateBoundName(propertySymbol.escapedName)) { if (propertySymbol.declarations) { var decl = ts.first(propertySymbol.declarations); if (hasLateBindableName(decl)) { @@ -39631,7 +40202,7 @@ var ts; function indexInfoToIndexSignatureDeclarationHelper(indexInfo, context, typeNode) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; var indexerTypeNode = typeToTypeNodeHelper(indexInfo.keyType, context); - var indexingParameter = ts.factory.createParameterDeclaration(undefined, undefined, undefined, name, undefined, indexerTypeNode, undefined); + var indexingParameter = ts.factory.createParameterDeclaration(undefined, undefined, name, undefined, indexerTypeNode, undefined); if (!typeNode) { typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context); } @@ -39639,7 +40210,7 @@ var ts; context.encounteredError = true; } context.approximateLength += (name.length + 4); - return ts.factory.createIndexSignature(undefined, indexInfo.isReadonly ? [ts.factory.createToken(145)] : undefined, [indexingParameter], typeNode); + return ts.factory.createIndexSignature(indexInfo.isReadonly ? [ts.factory.createToken(145)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context, options) { var _a, _b, _c, _d; @@ -39657,7 +40228,7 @@ var ts; } var expandedParams = getExpandedParameters(signature, true)[0]; var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); - var thisParameter = tryGetThisParameterDeclaration(signature, context); + var thisParameter = context.flags & 33554432 ? undefined : tryGetThisParameterDeclaration(signature, context); if (thisParameter) { parameters.unshift(thisParameter); } @@ -39690,15 +40261,15 @@ var ts; var node = kind === 174 ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : kind === 175 ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : kind === 168 ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : - kind === 169 ? ts.factory.createMethodDeclaration(undefined, modifiers, undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), undefined, typeParameters, parameters, returnTypeNode, undefined) : - kind === 171 ? ts.factory.createConstructorDeclaration(undefined, modifiers, parameters, undefined) : - kind === 172 ? ts.factory.createGetAccessorDeclaration(undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, undefined) : - kind === 173 ? ts.factory.createSetAccessorDeclaration(undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, undefined) : - kind === 176 ? ts.factory.createIndexSignature(undefined, modifiers, parameters, returnTypeNode) : + kind === 169 ? ts.factory.createMethodDeclaration(modifiers, undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), undefined, typeParameters, parameters, returnTypeNode, undefined) : + kind === 171 ? ts.factory.createConstructorDeclaration(modifiers, parameters, undefined) : + kind === 172 ? ts.factory.createGetAccessorDeclaration(modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, undefined) : + kind === 173 ? ts.factory.createSetAccessorDeclaration(modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, undefined) : + kind === 176 ? ts.factory.createIndexSignature(modifiers, parameters, returnTypeNode) : kind === 317 ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : kind === 179 ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : kind === 180 ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 256 ? ts.factory.createFunctionDeclaration(undefined, modifiers, undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, undefined) : + kind === 256 ? ts.factory.createFunctionDeclaration(modifiers, undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, undefined) : kind === 213 ? ts.factory.createFunctionExpression(modifiers, undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : kind === 214 ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, undefined, ts.factory.createBlock([])) : ts.Debug.assertNever(kind); @@ -39714,7 +40285,7 @@ var ts; if (signature.declaration) { var thisTag = ts.getJSDocThisTag(signature.declaration); if (thisTag && thisTag.typeExpression) { - return ts.factory.createParameterDeclaration(undefined, undefined, undefined, "this", undefined, typeToTypeNodeHelper(getTypeFromTypeNode(thisTag.typeExpression), context)); + return ts.factory.createParameterDeclaration(undefined, undefined, "this", undefined, typeToTypeNodeHelper(getTypeFromTypeNode(thisTag.typeExpression), context)); } } } @@ -39743,7 +40314,7 @@ var ts; parameterType = getOptionalType(parameterType); } var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports); - var modifiers = !(context.flags & 8192) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined; + var modifiers = !(context.flags & 8192) && preserveModifierFlags && parameterDeclaration && ts.canHaveModifiers(parameterDeclaration) ? ts.map(ts.getModifiers(parameterDeclaration), ts.factory.cloneNode) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768; var dotDotDotToken = isRest ? ts.factory.createToken(25) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? @@ -39754,18 +40325,23 @@ var ts; ts.symbolName(parameterSymbol); var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384; var questionToken = isOptional ? ts.factory.createToken(57) : undefined; - var parameterNode = ts.factory.createParameterDeclaration(undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, undefined); + var parameterNode = ts.factory.createParameterDeclaration(modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, undefined); context.approximateLength += ts.symbolName(parameterSymbol).length + 3; return parameterNode; function cloneBindingName(node) { - return elideInitializerAndSetEmitFlags(node); - function elideInitializerAndSetEmitFlags(node) { + return elideInitializerAndPropertyRenamingAndSetEmitFlags(node); + function elideInitializerAndPropertyRenamingAndSetEmitFlags(node) { if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) { trackComputedName(node.expression, context.enclosingDeclaration, context); } - var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, undefined, elideInitializerAndSetEmitFlags); + var visited = ts.visitEachChild(node, elideInitializerAndPropertyRenamingAndSetEmitFlags, ts.nullTransformationContext, undefined, elideInitializerAndPropertyRenamingAndSetEmitFlags); if (ts.isBindingElement(visited)) { - visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name, undefined); + if (visited.propertyName && ts.isIdentifier(visited.propertyName) && ts.isIdentifier(visited.name)) { + visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, undefined, visited.propertyName, undefined); + } + else { + visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name, undefined); + } } if (!ts.nodeIsSynthesized(visited)) { visited = ts.factory.cloneNode(visited); @@ -40362,15 +40938,15 @@ var ts; return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130), node); } if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { - return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature(undefined, undefined, [ts.factory.createParameterDeclaration(undefined, undefined, undefined, "x", undefined, ts.visitNode(node.typeArguments[0], visitExistingNodeTreeSymbols))], ts.visitNode(node.typeArguments[1], visitExistingNodeTreeSymbols))]); + return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature(undefined, [ts.factory.createParameterDeclaration(undefined, undefined, "x", undefined, ts.visitNode(node.typeArguments[0], visitExistingNodeTreeSymbols))], ts.visitNode(node.typeArguments[1], visitExistingNodeTreeSymbols))]); } if (ts.isJSDocFunctionType(node)) { if (ts.isJSDocConstructSignature(node)) { var newTypeNode_1; - return ts.factory.createConstructorTypeNode(node.modifiers, ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.factory.createParameterDeclaration(undefined, undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130)); + return ts.factory.createConstructorTypeNode(undefined, ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.factory.createParameterDeclaration(undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130)); } else { - return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration(undefined, undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130)); + return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration(undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130)); } } if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968, true))) { @@ -40384,7 +40960,7 @@ var ts; !(ts.length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); } - return ts.factory.updateImportTypeNode(node, ts.factory.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); + return ts.factory.updateImportTypeNode(node, ts.factory.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.assertions, node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); } if (ts.isEntityName(node) || ts.isEntityNameExpression(node)) { var _a = trackExistingEntityName(node, context, includePrivateSymbol), introducesError = _a.introducesError, result = _a.node; @@ -40435,7 +41011,7 @@ var ts; } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169, true); - var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168, false); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168, false); var enclosingDeclaration = context.enclosingDeclaration; var results = []; var visitedSymbols = new ts.Set(); @@ -40487,7 +41063,7 @@ var ts; var name_3 = ns.name; var body = ns.body; if (ts.length(excessExports)) { - ns = ts.factory.updateModuleDeclaration(ns, ns.decorators, ns.modifiers, ns.name, body = ts.factory.updateModuleBlock(body, ts.factory.createNodeArray(__spreadArray(__spreadArray([], ns.body.statements, true), [ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.factory.createExportSpecifier(false, undefined, id); })), undefined)], false)))); + ns = ts.factory.updateModuleDeclaration(ns, ns.modifiers, ns.name, body = ts.factory.updateModuleBlock(body, ts.factory.createNodeArray(__spreadArray(__spreadArray([], ns.body.statements, true), [ts.factory.createExportDeclaration(undefined, false, ts.factory.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.factory.createExportSpecifier(false, undefined, id); })), undefined)], false)))); statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, nsIndex), true), [ns], false), statements.slice(nsIndex + 1), true); } if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, name_3); })) { @@ -40505,7 +41081,7 @@ var ts; var exports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause && ts.isNamedExports(d.exportClause); }); if (ts.length(exports) > 1) { var nonExports = ts.filter(statements, function (d) { return !ts.isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause; }); - statements = __spreadArray(__spreadArray([], nonExports, true), [ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports(ts.flatMap(exports, function (e) { return ts.cast(e.exportClause, ts.isNamedExports).elements; })), undefined)], false); + statements = __spreadArray(__spreadArray([], nonExports, true), [ts.factory.createExportDeclaration(undefined, false, ts.factory.createNamedExports(ts.flatMap(exports, function (e) { return ts.cast(e.exportClause, ts.isNamedExports).elements; })), undefined)], false); } var reexports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause && ts.isNamedExports(d.exportClause); }); if (ts.length(reexports) > 1) { @@ -40514,7 +41090,7 @@ var ts; var _loop_9 = function (group_1) { if (group_1.length > 1) { statements = __spreadArray(__spreadArray([], ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), true), [ - ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports(ts.flatMap(group_1, function (e) { return ts.cast(e.exportClause, ts.isNamedExports).elements; })), group_1[0].moduleSpecifier) + ts.factory.createExportDeclaration(undefined, false, ts.factory.createNamedExports(ts.flatMap(group_1, function (e) { return ts.cast(e.exportClause, ts.isNamedExports).elements; })), group_1[0].moduleSpecifier) ], false); } }; @@ -40548,7 +41124,7 @@ var ts; ts.orderedRemoveItemAt(statements, index); } else { - statements[index] = ts.factory.updateExportDeclaration(exportDecl, exportDecl.decorators, exportDecl.modifiers, exportDecl.isTypeOnly, ts.factory.updateNamedExports(exportDecl.exportClause, replacements), exportDecl.moduleSpecifier, exportDecl.assertClause); + statements[index] = ts.factory.updateExportDeclaration(exportDecl, exportDecl.modifiers, exportDecl.isTypeOnly, ts.factory.updateNamedExports(exportDecl.exportClause, replacements), exportDecl.moduleSpecifier, exportDecl.assertClause); } } return statements; @@ -40605,12 +41181,11 @@ var ts; if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) { var oldContext = context; context = cloneNodeBuilderContext(context); - var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); if (context.reportedDiagnostic) { oldcontext.reportedDiagnostic = context.reportedDiagnostic; } context = oldContext; - return result; } } function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { @@ -40673,7 +41248,7 @@ var ts; if (propertyAccessRequire && ts.isBinaryExpression(propertyAccessRequire.parent) && ts.isIdentifier(propertyAccessRequire.parent.right) && ((_d = type.symbol) === null || _d === void 0 ? void 0 : _d.valueDeclaration) && ts.isSourceFile(type.symbol.valueDeclaration)) { var alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right; - addResult(ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(false, alias, localName)])), 0); + addResult(ts.factory.createExportDeclaration(undefined, false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(false, alias, localName)])), 0); context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551); } else { @@ -40682,7 +41257,7 @@ var ts; ], flags)), textRange); addResult(statement, name !== localName ? modifierFlags & ~1 : modifierFlags); if (name !== localName && !isPrivate) { - addResult(ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(false, name, localName)])), 0); + addResult(ts.factory.createExportDeclaration(undefined, false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(false, name, localName)])), 0); needsExportDeclaration = false; needsPostExportDefault = false; } @@ -40723,15 +41298,15 @@ var ts; var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); if (!resolvedModule) continue; - addResult(ts.factory.createExportDeclaration(undefined, undefined, false, undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0); + addResult(ts.factory.createExportDeclaration(undefined, false, undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0); } } } if (needsPostExportDefault) { - addResult(ts.factory.createExportAssignment(undefined, undefined, false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0); + addResult(ts.factory.createExportAssignment(undefined, false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0); } else if (needsExportDeclaration) { - addResult(ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0); + addResult(ts.factory.createExportDeclaration(undefined, false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0); } } function includePrivateSymbol(symbol) { @@ -40789,7 +41364,7 @@ var ts; && ts.isJSDocTypeExpression(jsdocAliasDecl.typeExpression) && serializeExistingTypeNode(context, jsdocAliasDecl.typeExpression.type, includePrivateSymbol, bundled) || typeToTypeNodeHelper(aliasType, context); - addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(undefined, undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); context.flags = oldFlags; context.enclosingDeclaration = oldEnclosingDecl; } @@ -40804,7 +41379,7 @@ var ts; var constructSignatures = serializeSignatures(1, interfaceType, baseType, 175); var indexSignatures = serializeIndexSignatures(interfaceType, baseType); var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551); }))]; - addResult(ts.factory.createInterfaceDeclaration(undefined, undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures, true), constructSignatures, true), callSignatures, true), members, true)), modifierFlags); + addResult(ts.factory.createInterfaceDeclaration(undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures, true), constructSignatures, true), callSignatures, true), members, true)), modifierFlags); } function getNamespaceMembersForSerialization(symbol) { return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember); @@ -40824,7 +41399,7 @@ var ts; if (ts.length(mergedMembers)) { var containingFile_1 = ts.getSourceFileOfNode(context.enclosingDeclaration); var localName = getInternalSymbolName(symbol, symbolName); - var nsBody = ts.factory.createModuleBlock([ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export="; }), function (s) { + var nsBody = ts.factory.createModuleBlock([ts.factory.createExportDeclaration(undefined, false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export="; }), function (s) { var _a, _b; var name = ts.unescapeLeadingUnderscores(s.escapedName); var localName = getInternalSymbolName(s, name); @@ -40838,11 +41413,11 @@ var ts; var targetName = target ? getInternalSymbolName(target, ts.unescapeLeadingUnderscores(target.escapedName)) : localName; return ts.factory.createExportSpecifier(false, name === targetName ? undefined : targetName, name); })))]); - addResult(ts.factory.createModuleDeclaration(undefined, undefined, ts.factory.createIdentifier(localName), nsBody, 16), 0); + addResult(ts.factory.createModuleDeclaration(undefined, ts.factory.createIdentifier(localName), nsBody, 16), 0); } } function serializeEnum(symbol, symbolName, modifierFlags) { - addResult(ts.factory.createEnumDeclaration(undefined, ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8); }), function (p) { + addResult(ts.factory.createEnumDeclaration(ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8); }), function (p) { var initializedValue = p.declarations && p.declarations[0] && ts.isEnumMember(p.declarations[0]) ? getConstantValue(p.declarations[0]) : undefined; return ts.factory.createEnumMember(ts.unescapeLeadingUnderscores(p.escapedName), initializedValue === undefined ? undefined : typeof initializedValue === "string" ? ts.factory.createStringLiteral(initializedValue) : @@ -40880,7 +41455,7 @@ var ts; }) ? "local" : "remote"; }); var localProps = localVsRemoteMap.get("local") || ts.emptyArray; - var fakespace = ts.parseNodeFactory.createModuleDeclaration(undefined, undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16); + var fakespace = ts.parseNodeFactory.createModuleDeclaration(undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16); ts.setParent(fakespace, enclosingDeclaration); fakespace.locals = ts.createSymbolTable(props); fakespace.symbol = props[0].parent; @@ -40896,9 +41471,9 @@ var ts; addingDeclare = oldAddingDeclare; var declarations = results; results = oldResults; - var defaultReplaced = ts.map(declarations, function (d) { return ts.isExportAssignment(d) && !d.isExportEquals && ts.isIdentifier(d.expression) ? ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(false, d.expression, ts.factory.createIdentifier("default"))])) : d; }); + var defaultReplaced = ts.map(declarations, function (d) { return ts.isExportAssignment(d) && !d.isExportEquals && ts.isIdentifier(d.expression) ? ts.factory.createExportDeclaration(undefined, false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(false, d.expression, ts.factory.createIdentifier("default"))])) : d; }); var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; - fakespace = ts.factory.updateModuleDeclaration(fakespace, fakespace.decorators, fakespace.modifiers, fakespace.name, ts.factory.createModuleBlock(exportModifierStripped)); + fakespace = ts.factory.updateModuleDeclaration(fakespace, fakespace.modifiers, fakespace.name, ts.factory.createModuleBlock(exportModifierStripped)); addResult(fakespace, modifierFlags); } } @@ -40954,7 +41529,7 @@ var ts; ? getBaseConstructorTypeOfClass(staticType) : anyType; var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117, implementsExpressions)], true); - var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType)); + var symbolProps = getNonInheritedProperties(classType, baseTypes, getPropertiesOfType(classType)); var publicSymbolProps = ts.filter(symbolProps, function (s) { var valueDecl = s.valueDeclaration; return !!valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name)); @@ -40964,7 +41539,7 @@ var ts; return !!valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name); }); var privateProperties = hasPrivateIdentifier ? - [ts.factory.createPropertyDeclaration(undefined, undefined, ts.factory.createPrivateIdentifier("#private"), undefined, undefined, undefined)] : + [ts.factory.createPropertyDeclaration(undefined, ts.factory.createPrivateIdentifier("#private"), undefined, undefined, undefined)] : ts.emptyArray; var publicProperties = ts.flatMap(publicSymbolProps, function (p) { return serializePropertySymbolForClass(p, false, baseTypes[0]); }); var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, true, staticBaseType); }); @@ -40973,11 +41548,11 @@ var ts; ts.isInJSFile(symbol.valueDeclaration) && !ts.some(getSignaturesOfType(staticType, 1)); var constructors = isNonConstructableClassLikeInJsFile ? - [ts.factory.createConstructorDeclaration(undefined, ts.factory.createModifiersFromModifierFlags(8), [], undefined)] : + [ts.factory.createConstructorDeclaration(ts.factory.createModifiersFromModifierFlags(8), [], undefined)] : serializeSignatures(1, staticType, staticBaseType, 171); var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); context.enclosingDeclaration = oldEnclosing; - addResult(ts.setTextRange(ts.factory.createClassDeclaration(undefined, undefined, localName, typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures, true), staticMembers, true), constructors, true), publicProperties, true), privateProperties, true)), symbol.declarations && ts.filter(symbol.declarations, function (d) { return ts.isClassDeclaration(d) || ts.isClassExpression(d); })[0]), modifierFlags); + addResult(ts.setTextRange(ts.factory.createClassDeclaration(undefined, localName, typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures, true), staticMembers, true), constructors, true), publicProperties, true), privateProperties, true)), symbol.declarations && ts.filter(symbol.declarations, function (d) { return ts.isClassDeclaration(d) || ts.isClassExpression(d); })[0]), modifierFlags); } function getSomeTargetNameFromDeclarations(declarations) { return ts.firstDefined(declarations, function (d) { @@ -41019,7 +41594,7 @@ var ts; if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254) { var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); var propertyName = node.propertyName; - addResult(ts.factory.createImportDeclaration(undefined, undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier(false, propertyName && ts.isIdentifier(propertyName) ? ts.factory.createIdentifier(ts.idText(propertyName)) : undefined, ts.factory.createIdentifier(localName))])), ts.factory.createStringLiteral(specifier_1), undefined), 0); + addResult(ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier(false, propertyName && ts.isIdentifier(propertyName) ? ts.factory.createIdentifier(ts.idText(propertyName)) : undefined, ts.factory.createIdentifier(localName))])), ts.factory.createStringLiteral(specifier_1), undefined), 0); break; } ts.Debug.failBadSyntaxKind(((_c = node.parent) === null || _c === void 0 ? void 0 : _c.parent) || node, "Unhandled binding element grandparent kind in declaration serialization"); @@ -41034,8 +41609,8 @@ var ts; var initializer = node.initializer; var uniqueName = ts.factory.createUniqueName(localName); var specifier_2 = getSpecifierForModuleSymbol(target.parent || target, context); - addResult(ts.factory.createImportEqualsDeclaration(undefined, undefined, false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0); - addResult(ts.factory.createImportEqualsDeclaration(undefined, undefined, false, ts.factory.createIdentifier(localName), ts.factory.createQualifiedName(uniqueName, initializer.name)), modifierFlags); + addResult(ts.factory.createImportEqualsDeclaration(undefined, false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0); + addResult(ts.factory.createImportEqualsDeclaration(undefined, false, ts.factory.createIdentifier(localName), ts.factory.createQualifiedName(uniqueName, initializer.name)), modifierFlags); break; } case 265: @@ -41044,7 +41619,7 @@ var ts; break; } var isLocalImport = !(target.flags & 512) && !ts.isVariableDeclaration(node); - addResult(ts.factory.createImportEqualsDeclaration(undefined, undefined, false, ts.factory.createIdentifier(localName), isLocalImport + addResult(ts.factory.createImportEqualsDeclaration(undefined, false, ts.factory.createIdentifier(localName), isLocalImport ? symbolToName(target, context, 67108863, false) : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0); break; @@ -41052,16 +41627,16 @@ var ts; addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0); break; case 267: - addResult(ts.factory.createImportDeclaration(undefined, undefined, ts.factory.createImportClause(false, ts.factory.createIdentifier(localName), undefined), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), undefined), 0); + addResult(ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, ts.factory.createIdentifier(localName), undefined), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), undefined), 0); break; case 268: - addResult(ts.factory.createImportDeclaration(undefined, undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)), undefined), 0); + addResult(ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)), undefined), 0); break; case 274: - addResult(ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0); + addResult(ts.factory.createExportDeclaration(undefined, false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0); break; case 270: - addResult(ts.factory.createImportDeclaration(undefined, undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports([ + addResult(ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports([ ts.factory.createImportSpecifier(false, localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), undefined), 0); break; @@ -41087,7 +41662,7 @@ var ts; } } function serializeExportSpecifier(localName, targetName, specifier) { - addResult(ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0); + addResult(ts.factory.createExportDeclaration(undefined, false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0); } function serializeMaybeAliasAssignment(symbol) { if (symbol.flags & 4194304) { @@ -41109,7 +41684,7 @@ var ts; var oldTrack = context.tracker.trackSymbol; context.tracker.trackSymbol = function () { return false; }; if (isExportAssignmentCompatibleSymbolName) { - results.push(ts.factory.createExportAssignment(undefined, undefined, isExportEquals, symbolToExpression(target, context, 67108863))); + results.push(ts.factory.createExportAssignment(undefined, isExportEquals, symbolToExpression(target, context, 67108863))); } else { if (first_1 === expr && first_1) { @@ -41120,7 +41695,7 @@ var ts; } else { var varName = getUnusedName(name, symbol); - addResult(ts.factory.createImportEqualsDeclaration(undefined, undefined, false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863, false)), 0); + addResult(ts.factory.createImportEqualsDeclaration(undefined, false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863, false)), 0); serializeExportSpecifier(name, varName); } } @@ -41142,7 +41717,7 @@ var ts; : 0); } if (isExportAssignmentCompatibleSymbolName) { - results.push(ts.factory.createExportAssignment(undefined, undefined, isExportEquals, ts.factory.createIdentifier(varName))); + results.push(ts.factory.createExportAssignment(undefined, isExportEquals, ts.factory.createIdentifier(varName))); return true; } else if (name !== varName) { @@ -41186,22 +41761,22 @@ var ts; if (p.flags & 98304 && useAccessors) { var result = []; if (p.flags & 65536) { - result.push(ts.setTextRange(ts.factory.createSetAccessorDeclaration(undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [ts.factory.createParameterDeclaration(undefined, undefined, undefined, "arg", undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], undefined), ((_b = p.declarations) === null || _b === void 0 ? void 0 : _b.find(ts.isSetAccessor)) || firstPropertyLikeDecl)); + result.push(ts.setTextRange(ts.factory.createSetAccessorDeclaration(ts.factory.createModifiersFromModifierFlags(flag), name, [ts.factory.createParameterDeclaration(undefined, undefined, "arg", undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], undefined), ((_b = p.declarations) === null || _b === void 0 ? void 0 : _b.find(ts.isSetAccessor)) || firstPropertyLikeDecl)); } if (p.flags & 32768) { var isPrivate_1 = modifierFlags & 8; - result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration(undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), undefined), ((_c = p.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isGetAccessor)) || firstPropertyLikeDecl)); + result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration(ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), undefined), ((_c = p.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isGetAccessor)) || firstPropertyLikeDecl)); } return result; } else if (p.flags & (4 | 3 | 98304)) { - return ts.setTextRange(createProperty(undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 : 0) | flag), name, p.flags & 16777216 ? ts.factory.createToken(57) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), undefined), ((_d = p.declarations) === null || _d === void 0 ? void 0 : _d.find(ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration))) || firstPropertyLikeDecl); + return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 : 0) | flag), name, p.flags & 16777216 ? ts.factory.createToken(57) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), undefined), ((_d = p.declarations) === null || _d === void 0 ? void 0 : _d.find(ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration))) || firstPropertyLikeDecl); } if (p.flags & (8192 | 16)) { var type = getTypeOfSymbol(p); var signatures = getSignaturesOfType(type, 0); if (flag & 8) { - return ts.setTextRange(createProperty(undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 : 0) | flag), name, p.flags & 16777216 ? ts.factory.createToken(57) : undefined, undefined, undefined), ((_e = p.declarations) === null || _e === void 0 ? void 0 : _e.find(ts.isFunctionLikeDeclaration)) || signatures[0] && signatures[0].declaration || p.declarations && p.declarations[0]); + return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 : 0) | flag), name, p.flags & 16777216 ? ts.factory.createToken(57) : undefined, undefined, undefined), ((_e = p.declarations) === null || _e === void 0 ? void 0 : _e.find(ts.isFunctionLikeDeclaration)) || signatures[0] && signatures[0].declaration || p.declarations && p.declarations[0]); } var results_1 = []; for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { @@ -41254,7 +41829,7 @@ var ts; } } if (privateProtected) { - return [ts.setTextRange(ts.factory.createConstructorDeclaration(undefined, ts.factory.createModifiersFromModifierFlags(privateProtected), [], undefined), signatures[0].declaration)]; + return [ts.setTextRange(ts.factory.createConstructorDeclaration(ts.factory.createModifiersFromModifierFlags(privateProtected), [], undefined), signatures[0].declaration)]; } } var results = []; @@ -41868,7 +42443,7 @@ var ts; return type; } if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) { - return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0)) & 32768) ? getNonUndefinedType(type) : type; + return strictNullChecks && !(getTypeFacts(checkDeclarationInitializer(declaration, 0)) & 16777216) ? getNonUndefinedType(type) : type; } return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0)], 2)); } @@ -42231,7 +42806,7 @@ var ts; (resolvedSymbol || symbol).exports.forEach(function (s, name) { var _a; var exportedMember = members_4.get(name); - if (exportedMember && exportedMember !== s) { + if (exportedMember && exportedMember !== s && !(s.flags & 2097152)) { if (s.flags & 111551 && exportedMember.flags & 111551) { if (s.valueDeclaration && exportedMember.valueDeclaration && ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) { var unescapedName = ts.unescapeLeadingUnderscores(s.escapedName); @@ -42254,6 +42829,17 @@ var ts; } }); var result = createAnonymousType(initialSize !== members_4.size ? undefined : exportedType.symbol, members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.indexInfos); + if (initialSize === members_4.size) { + if (type.aliasSymbol) { + result.aliasSymbol = type.aliasSymbol; + result.aliasTypeArguments = type.aliasTypeArguments; + } + if (ts.getObjectFlags(type) & 4) { + result.aliasSymbol = type.symbol; + var args = getTypeArguments(type); + result.aliasTypeArguments = ts.length(args) ? args : undefined; + } + } result.objectFlags |= (ts.getObjectFlags(type) & 4096); if (result.symbol && result.symbol.flags & 32 && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { result.objectFlags |= 16777216; @@ -42297,7 +42883,7 @@ var ts; if (reportErrors && !declarationBelongsToPrivateAmbientMember(element)) { reportImplicitAny(element, anyType); } - return includePatternInType ? nonInferrableAnyType : anyType; + return anyType; } function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createSymbolTable(); @@ -43184,7 +43770,7 @@ var ts; error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } else { - error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + error(ts.isNamedDeclaration(declaration) ? declaration.name || declaration : declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } } links.declaredType = type; @@ -44308,6 +44894,9 @@ var ts; else if (type.objectFlags & 32) { resolveMappedTypeMembers(type); } + else { + ts.Debug.fail("Unhandled object type " + ts.Debug.formatObjectFlags(type.objectFlags)); + } } else if (type.flags & 1048576) { resolveUnionTypeMembers(type); @@ -44315,6 +44904,9 @@ var ts; else if (type.flags & 2097152) { resolveIntersectionTypeMembers(type); } + else { + ts.Debug.fail("Unhandled type " + ts.Debug.formatTypeFlags(type.flags)); + } } return type; } @@ -44476,7 +45068,7 @@ var ts; } } } - else if (t.flags & 469892092) { + else if (t.flags & 469892092 || isEmptyAnonymousObjectType(t)) { hasDisjointDomainType = true; } } @@ -44484,12 +45076,12 @@ var ts; if (hasDisjointDomainType) { for (var _a = 0, types_6 = types; _a < types_6.length; _a++) { var t = types_6[_a]; - if (t.flags & 469892092) { + if (t.flags & 469892092 || isEmptyAnonymousObjectType(t)) { constraints = ts.append(constraints, t); } } } - return getIntersectionType(constraints); + return getNormalizedType(getIntersectionType(constraints), false); } return undefined; } @@ -44585,7 +45177,7 @@ var ts; } if (t.flags & 268435456) { var constraint = getBaseConstraint(t.type); - return constraint ? getStringMappingType(t.symbol, constraint) : stringType; + return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType; } if (t.flags & 8388608) { if (isMappedTypeGenericIndexedAccess(t)) { @@ -44889,12 +45481,12 @@ var ts; } return errorInfo; } - function getPropertyOfType(type, name, skipObjectFunctionPropertyAugment) { + function getPropertyOfType(type, name, skipObjectFunctionPropertyAugment, includeTypeOnlyMembers) { type = getReducedApparentType(type); if (type.flags & 524288) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); - if (symbol && symbolIsValue(symbol)) { + if (symbol && symbolIsValue(symbol, includeTypeOnlyMembers)) { return symbol; } if (skipObjectFunctionPropertyAugment) @@ -44984,12 +45576,15 @@ var ts; return getApplicableIndexInfo(type, isLateBoundName(name) ? esSymbolType : getStringLiteralType(ts.unescapeLeadingUnderscores(name))); } function getTypeParametersFromDeclaration(declaration) { + var _a; var result; - for (var _i = 0, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) { - var node = _a[_i]; + for (var _i = 0, _b = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _b.length; _i++) { + var node = _b[_i]; result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol)); } - return result; + return (result === null || result === void 0 ? void 0 : result.length) ? result + : ts.isFunctionDeclaration(declaration) ? (_a = getSignatureOfTypeTag(declaration)) === null || _a === void 0 ? void 0 : _a.typeParameters + : undefined; } function symbolsToArray(symbols) { var result = []; @@ -45492,19 +46087,20 @@ var ts; var _a; var inferences; if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) { - for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) { - var declaration = _b[_i]; + var _loop_15 = function (declaration) { if (declaration.parent.kind === 190) { var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1]; if (grandParent.kind === 178 && !omitTypeReferences) { - var typeReference = grandParent; - var typeParameters = getTypeParametersForTypeReference(typeReference); - if (typeParameters) { - var index = typeReference.typeArguments.indexOf(childTypeParameter); - if (index < typeParameters.length) { - var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); + var typeReference_1 = grandParent; + var typeParameters_1 = getTypeParametersForTypeReference(typeReference_1); + if (typeParameters_1) { + var index = typeReference_1.typeArguments.indexOf(childTypeParameter); + if (index < typeParameters_1.length) { + var declaredConstraint = getConstraintOfTypeParameter(typeParameters_1[index]); if (declaredConstraint) { - var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); + var mapper = makeDeferredTypeMapper(typeParameters_1, typeParameters_1.map(function (_, index) { return function () { + return getEffectiveTypeArgumentAtIndex(typeReference_1, typeParameters_1, index); + }; })); var constraint = instantiateType(declaredConstraint, mapper); if (constraint !== typeParameter) { inferences = ts.append(inferences, constraint); @@ -45533,6 +46129,10 @@ var ts; inferences = ts.append(inferences, instantiateType(nodeType, makeUnaryTypeMapper(getDeclaredTypeOfTypeParameter(getSymbolOfNode(checkMappedType_1.typeParameter)), checkMappedType_1.typeParameter.constraint ? getTypeFromTypeNode(checkMappedType_1.typeParameter.constraint) : keyofConstraintType))); } } + }; + for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) { + var declaration = _b[_i]; + _loop_15(declaration); } } return inferences && getIntersectionType(inferences); @@ -45594,7 +46194,7 @@ var ts; var result = 0; for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { var type = types_8[_i]; - if (!(type.flags & excludeKinds)) { + if (excludeKinds === undefined || !(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } } @@ -45606,7 +46206,7 @@ var ts; if (!type) { type = createObjectType(4, target.symbol); target.instantiations.set(id, type); - type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0; + type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0; type.target = target; type.resolvedTypeArguments = typeArguments; } @@ -46340,7 +46940,7 @@ var ts; var lastRequiredIndex = -1; var firstRestIndex = -1; var lastOptionalOrRestIndex = -1; - var _loop_15 = function (i) { + var _loop_16 = function (i) { var type = elementTypes[i]; var flags = target.elementFlags[i]; if (flags & 8) { @@ -46366,7 +46966,7 @@ var ts; } }; for (var i = 0; i < elementTypes.length; i++) { - var state_4 = _loop_15(i); + var state_4 = _loop_16(i); if (typeof state_4 === "object") return state_4.value; } @@ -46543,7 +47143,7 @@ var ts; var templates = ts.filter(types, isPatternLiteralType); if (templates.length) { var i = types.length; - var _loop_16 = function () { + var _loop_17 = function () { i--; var t = types[i]; if (t.flags & 128 && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { @@ -46551,7 +47151,7 @@ var ts; } }; while (i > 0) { - _loop_16(); + _loop_17(); } } } @@ -46621,14 +47221,14 @@ var ts; var namedUnions = []; addNamedUnions(namedUnions, types); var reducedTypes = []; - var _loop_17 = function (t) { + var _loop_18 = function (t) { if (!ts.some(namedUnions, function (union) { return containsType(union.types, t); })) { reducedTypes.push(t); } }; for (var _i = 0, typeSet_1 = typeSet; _i < typeSet_1.length; _i++) { var t = typeSet_1[_i]; - _loop_17(t); + _loop_18(t); } if (!aliasSymbol && namedUnions.length === 1 && reducedTypes.length === 0) { return namedUnions[0]; @@ -46754,7 +47354,7 @@ var ts; } return includes; } - function removeRedundantPrimitiveTypes(types, includes) { + function removeRedundantSupertypes(types, includes) { var i = types.length; while (i > 0) { i--; @@ -46762,7 +47362,9 @@ var ts; var remove = t.flags & 4 && includes & (128 | 134217728 | 268435456) || t.flags & 8 && includes & 256 || t.flags & 64 && includes & 2048 || - t.flags & 4096 && includes & 8192; + t.flags & 4096 && includes & 8192 || + t.flags & 16384 && includes & 32768 || + isEmptyAnonymousObjectType(t) && includes & 470302716; if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -46857,7 +47459,7 @@ var ts; result.aliasTypeArguments = aliasTypeArguments; return result; } - function getIntersectionType(types, aliasSymbol, aliasTypeArguments) { + function getIntersectionType(types, aliasSymbol, aliasTypeArguments, noSupertypeReduction) { var typeMembershipMap = new ts.Map(); var includes = addTypesToIntersection(typeMembershipMap, 0, types); var typeSet = ts.arrayFrom(typeMembershipMap.values()); @@ -46885,11 +47487,11 @@ var ts; if (includes & 4 && includes & (128 | 134217728 | 268435456) || includes & 8 && includes & 256 || includes & 64 && includes & 2048 || - includes & 4096 && includes & 8192) { - removeRedundantPrimitiveTypes(typeSet, includes); - } - if (includes & 16777216 && includes & 524288) { - ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType)); + includes & 4096 && includes & 8192 || + includes & 16384 && includes & 32768 || + includes & 16777216 && includes & 470302716) { + if (!noSupertypeReduction) + removeRedundantSupertypes(typeSet, includes); } if (includes & 262144) { typeSet[typeSet.indexOf(undefinedType)] = missingType; @@ -46921,7 +47523,7 @@ var ts; return errorType; } var constituents = getCrossProductIntersections(typeSet); - var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152); }) ? createOriginUnionOrIntersectionType(2097152, typeSet) : undefined; + var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152, typeSet) : undefined; result = getUnionType(constituents, 1, aliasSymbol, aliasTypeArguments, origin); } } @@ -46964,11 +47566,21 @@ var ts; } return intersections; } + function getConstituentCount(type) { + return !(type.flags & 3145728) || type.aliasSymbol ? 1 : + type.flags & 1048576 && type.origin ? getConstituentCount(type.origin) : + getConstituentCountOfTypes(type.types); + } + function getConstituentCountOfTypes(types) { + return ts.reduceLeft(types, function (n, t) { return n + getConstituentCount(t); }, 0); + } function getTypeFromIntersectionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); - links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); + var types = ts.map(node.types, getTypeFromTypeNode); + var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 | 8 | 64)) && types[1] === emptyTypeLiteralType; + links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction); } return links.resolvedType; } @@ -47066,19 +47678,22 @@ var ts; return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1, undefined, undefined, origin); } function isPossiblyReducibleByInstantiation(type) { - return ts.some(type.types, function (t) { - var uniqueFilled = getUniqueLiteralFilledInstantiation(t); - return getReducedType(uniqueFilled) !== uniqueFilled; - }); + var uniqueFilled = getUniqueLiteralFilledInstantiation(type); + return getReducedType(uniqueFilled) !== uniqueFilled; + } + function shouldDeferIndexType(type) { + return !!(type.flags & 58982400 || + isGenericTupleType(type) || + isGenericMappedType(type) && !hasDistributiveNameType(type) || + type.flags & 1048576 && ts.some(type.types, isPossiblyReducibleByInstantiation) || + type.flags & 2097152 && maybeTypeOfKind(type, 465829888) && ts.some(type.types, isEmptyAnonymousObjectType)); } function getIndexType(type, stringsOnly, noIndexSignatures) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } type = getReducedType(type); - return type.flags & 1048576 ? isPossiblyReducibleByInstantiation(type) - ? getIndexTypeForGenericType(type, stringsOnly) - : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 2097152 ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 58982400 || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : + return shouldDeferIndexType(type) ? getIndexTypeForGenericType(type, stringsOnly) : + type.flags & 1048576 ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : + type.flags & 2097152 ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : ts.getObjectFlags(type) & 32 ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : type === wildcardType ? wildcardType : type.flags & 2 ? neverType : @@ -47204,9 +47819,11 @@ var ts; } function getStringMappingType(symbol, type) { return type.flags & (1048576 | 131072) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : - isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) : - type.flags & 128 ? getStringLiteralType(applyStringMapping(symbol, type.value)) : - type; + type.flags & 268435456 && symbol === type.symbol ? type : + isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456) ? getTemplateLiteralType(["", ""], [type]) : type) : + type.flags & 128 ? getStringLiteralType(applyStringMapping(symbol, type.value)) : + type.flags & 134217728 ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) : + type; } function applyStringMapping(symbol, str) { switch (intrinsicTypeKinds.get(symbol.escapedName)) { @@ -47217,6 +47834,15 @@ var ts; } return str; } + function applyTemplateStringMapping(symbol, texts, types) { + switch (intrinsicTypeKinds.get(symbol.escapedName)) { + case 0: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; + case 1: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; + case 2: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toUpperCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; + case 3: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toLowerCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; + } + return [texts, types]; + } function getStringMappingTypeForGenericType(symbol, type) { var id = "".concat(getSymbolId(symbol), ",").concat(getTypeId(type)); var result = stringMappingTypes.get(id); @@ -47308,21 +47934,28 @@ var ts; getFlowTypeOfReference(accessExpression, propType) : propType; } - if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) { + if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName)) { + var index = +propName; if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16)) { var indexNode = getIndexNodeForAccessExpression(accessNode); if (isTupleType(objectType)) { + if (index < 0) { + error(indexNode, ts.Diagnostics.A_tuple_type_cannot_be_indexed_with_a_negative_value); + return undefinedType; + } error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName)); } else { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } } - errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType)); - return mapType(objectType, function (t) { - var restType = getRestTypeOfTupleType(t) || undefinedType; - return accessFlags & 1 ? getUnionType([restType, undefinedType]) : restType; - }); + if (index >= 0) { + errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType)); + return mapType(objectType, function (t) { + var restType = getRestTypeOfTupleType(t) || undefinedType; + return accessFlags & 1 ? getUnionType([restType, undefinedType]) : restType; + }); + } } } if (!(indexType.flags & 98304) && isTypeAssignableToKind(indexType, 402653316 | 296 | 12288)) { @@ -47446,7 +48079,7 @@ var ts; accessNode; } function isPatternLiteralPlaceholderType(type) { - return !!(type.flags & (1 | 4 | 8 | 64)); + return !!(type.flags & (1 | 4 | 8 | 64)) || !!(type.flags & 268435456 && isPatternLiteralPlaceholderType(type.type)); } function isPatternLiteralType(type) { return !!(type.flags & 134217728) && ts.every(type.types, isPatternLiteralPlaceholderType); @@ -47556,7 +48189,7 @@ var ts; function substituteIndexedMappedType(objectType, index) { var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]); var templateMapper = combineTypeMappers(objectType.mapper, mapper); - return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper); + return instantiateType(getTemplateTypeFromMappedType(objectType.target || objectType), templateMapper); } function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { if (accessFlags === void 0) { accessFlags = 0; } @@ -47681,7 +48314,7 @@ var ts; var result; var extraTypes; var tailCount = 0; - var _loop_18 = function () { + var _loop_19 = function () { if (tailCount === 1000) { error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); result = errorType; @@ -47755,7 +48388,7 @@ var ts; return "break"; }; while (true) { - var state_5 = _loop_18(); + var state_5 = _loop_19(); if (typeof state_5 === "object") return state_5.value; if (state_5 === "break") @@ -47852,6 +48485,7 @@ var ts; } } function getTypeFromImportTypeNode(node) { + var _a; var links = getNodeLinks(node); if (!links.resolvedType) { if (node.isTypeOf && node.typeArguments) { @@ -47870,6 +48504,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } + var isExportEquals = !!((_a = innerModuleSymbol.exports) === null || _a === void 0 ? void 0 : _a.get("export=")); var moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, false); if (!ts.nodeIsMissing(node.qualifier)) { var nameStack = getIdentifierChain(node.qualifier); @@ -47878,9 +48513,11 @@ var ts; while (current = nameStack.shift()) { var meaning = nameStack.length ? 1920 : targetMeaning; var mergedResolvedSymbol = getMergedSymbol(resolveSymbol(currentNamespace)); - var next = node.isTypeOf - ? getPropertyOfType(getTypeOfSymbol(mergedResolvedSymbol), current.escapedText) - : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning); + var symbolFromVariable = node.isTypeOf || ts.isInJSFile(node) && isExportEquals + ? getPropertyOfType(getTypeOfSymbol(mergedResolvedSymbol), current.escapedText, false, true) + : undefined; + var symbolFromModule = node.isTypeOf ? undefined : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning); + var next = symbolFromModule !== null && symbolFromModule !== void 0 ? symbolFromModule : symbolFromVariable; if (!next) { error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current)); return links.resolvedType = errorType; @@ -48356,7 +48993,7 @@ var ts; switch (mapper.kind) { case 0: return type === mapper.source ? mapper.target : type; - case 1: + case 1: { var sources = mapper.sources; var targets = mapper.targets; for (var i = 0; i < sources.length; i++) { @@ -48365,43 +49002,58 @@ var ts; } } return type; - case 2: - return mapper.func(type); + } + case 2: { + var sources = mapper.sources; + var targets = mapper.targets; + for (var i = 0; i < sources.length; i++) { + if (type === sources[i]) { + return targets[i](); + } + } + return type; + } case 3: + return mapper.func(type); case 4: + case 5: var t1 = getMappedType(type, mapper.mapper1); - return t1 !== type && mapper.kind === 3 ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); + return t1 !== type && mapper.kind === 4 ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); } } function makeUnaryTypeMapper(source, target) { - return { kind: 0, source: source, target: target }; + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 0, source: source, target: target }); } function makeArrayTypeMapper(sources, targets) { - return { kind: 1, sources: sources, targets: targets }; + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 1, sources: sources, targets: targets }); } - function makeFunctionTypeMapper(func) { - return { kind: 2, func: func }; + function makeFunctionTypeMapper(func, debugInfo) { + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 3, func: func, debugInfo: ts.Debug.isDebugging ? debugInfo : undefined }); + } + function makeDeferredTypeMapper(sources, targets) { + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 2, sources: sources, targets: targets }); } function makeCompositeTypeMapper(kind, mapper1, mapper2) { - return { kind: kind, mapper1: mapper1, mapper2: mapper2 }; + return ts.Debug.attachDebugPrototypeIfDebug({ kind: kind, mapper1: mapper1, mapper2: mapper2 }); } function createTypeEraser(sources) { return createTypeMapper(sources, undefined); } function createBackreferenceMapper(context, index) { - return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; }); + var forwardInferences = context.inferences.slice(index); + return createTypeMapper(ts.map(forwardInferences, function (i) { return i.typeParameter; }), ts.map(forwardInferences, function () { return unknownType; })); } function combineTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(3, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(4, mapper1, mapper2) : mapper2; } function mergeTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(4, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(5, mapper1, mapper2) : mapper2; } function prependTypeMapping(source, target, mapper) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4, makeUnaryTypeMapper(source, target), mapper); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(5, makeUnaryTypeMapper(source, target), mapper); } function appendTypeMapping(mapper, source, target) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4, mapper, makeUnaryTypeMapper(source, target)); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(5, mapper, makeUnaryTypeMapper(source, target)); } function getRestrictiveTypeParameter(tp) { return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol), @@ -48625,6 +49277,7 @@ var ts; result.mapper = mapper; result.aliasSymbol = aliasSymbol || type.aliasSymbol; result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); + result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0; return result; } function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { @@ -49212,7 +49865,7 @@ var ts; }); } function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068) + if (target.flags & (131068 | 131072)) return false; if (isTupleLikeType(source)) { return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer); @@ -49277,7 +49930,7 @@ var ts; }); } function elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068) + if (target.flags & (131068 | 131072)) return false; return elaborateElementwise(generateObjectLiteralElements(node), source, target, relation, containingMessageChain, errorOutputContainer); } @@ -49343,7 +49996,7 @@ var ts; var sourceSig = checkMode & 3 ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = checkMode & 3 ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && - (getFalsyFlags(sourceType) & 98304) === (getFalsyFlags(targetType) & 98304); + (getTypeFacts(sourceType) & 50331648) === (getTypeFacts(targetType) & 50331648); var related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8) | (strictVariance ? 2 : 1), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : !(checkMode & 3) && !strictVariance && compareTypes(sourceType, targetType, false) || compareTypes(targetType, sourceType, reportErrors); @@ -49447,6 +50100,20 @@ var ts; return !!(ts.getObjectFlags(type) & 16 && (type.members && isEmptyResolvedType(type) || type.symbol && type.symbol.flags & 2048 && getMembersOfSymbol(type.symbol).size === 0)); } + function isUnknownLikeUnionType(type) { + if (strictNullChecks && type.flags & 1048576) { + if (!(type.objectFlags & 33554432)) { + var types = type.types; + type.objectFlags |= 33554432 | (types.length >= 3 && types[0].flags & 32768 && + types[1].flags & 65536 && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 : 0); + } + return !!(type.objectFlags & 67108864); + } + return false; + } + function containsUndefinedType(type) { + return !!((type.flags & 1048576 ? type.types[0] : type).flags & 32768); + } function isStringIndexSignatureOnlyType(type) { return type.flags & 524288 && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || type.flags & 3145728 && ts.every(type.types, isStringIndexSignatureOnlyType) || @@ -49524,13 +50191,15 @@ var ts; return true; if (s & 65536 && (!strictNullChecks && !(t & 3145728) || t & 65536)) return true; - if (s & 524288 && t & 67108864) + if (s & 524288 && t & 67108864 && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(ts.getObjectFlags(source) & 8192))) return true; if (relation === assignableRelation || relation === comparableRelation) { if (s & 1) return true; if (s & (8 | 256) && !(s & 1024) && (t & 32 || relation === assignableRelation && t & 256 && t & 1024)) return true; + if (isUnknownLikeUnionType(target)) + return true; } return false; } @@ -49572,16 +50241,27 @@ var ts; function getNormalizedType(type, writing) { while (true) { var t = isFreshLiteralType(type) ? type.regularType : - ts.getObjectFlags(type) & 4 && type.node ? createTypeReference(type.target, getTypeArguments(type)) : - type.flags & 3145728 ? getReducedType(type) : + ts.getObjectFlags(type) & 4 ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type : + type.flags & 3145728 ? getNormalizedUnionOrIntersectionType(type, writing) : type.flags & 33554432 ? writing ? type.baseType : type.substitute : type.flags & 25165824 ? getSimplifiedType(type, writing) : type; - t = getSingleBaseForNonAugmentingSubtype(t) || t; if (t === type) - break; + return t; type = t; } + } + function getNormalizedUnionOrIntersectionType(type, writing) { + var reduced = getReducedType(type); + if (reduced !== type) { + return reduced; + } + if (type.flags & 2097152) { + var normalizedTypes = ts.sameMap(type.types, function (t) { return getNormalizedType(t, writing); }); + if (normalizedTypes !== type.types) { + return getIntersectionType(normalizedTypes); + } + } return type; } function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) { @@ -49788,7 +50468,7 @@ var ts; ts.Debug.assert(!isTypeAssignableTo(generalizedSource, target), "generalized source shouldn't be assignable"); generalizedSourceType = getTypeNameForErrorDisplay(generalizedSource); } - if (target.flags & 262144 && target !== markerSuperType && target !== markerSubType) { + if (target.flags & 262144 && target !== markerSuperTypeForCheck && target !== markerSubTypeForCheck) { var constraint = getBaseConstraintOfType(target); var needsOriginalSource = void 0; if (constraint && (isTypeAssignableTo(generalizedSource, constraint) || (needsOriginalSource = isTypeAssignableTo(source, constraint)))) { @@ -49956,6 +50636,7 @@ var ts; return 0; } function reportErrorResults(originalSource, originalTarget, source, target, headMessage) { + var _a, _b; var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource); var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget); source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source; @@ -49994,6 +50675,14 @@ var ts; return; } reportRelationError(headMessage, source, target); + if (source.flags & 262144 && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source)) { + var syntheticParam = cloneTypeParameter(source); + syntheticParam.constraint = instantiateType(target, makeUnaryTypeMapper(source, syntheticParam)); + if (hasNonCircularBaseConstraint(syntheticParam)) { + var targetConstraintString = typeToString(target, source.symbol.declarations[0]); + associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint, targetConstraintString)); + } + } } function traceUnionsOrIntersectionsTooLarge(source, target) { if (!ts.tracing) { @@ -50045,7 +50734,7 @@ var ts; reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target); checkTypes = reducedTarget.flags & 1048576 ? reducedTarget.types : [reducedTarget]; } - var _loop_19 = function (prop) { + var _loop_20 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) { if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { @@ -50098,7 +50787,7 @@ var ts; }; for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) { var prop = _b[_i]; - var state_6 = _loop_19(prop); + var state_6 = _loop_20(prop); if (typeof state_6 === "object") return state_6.value; } @@ -50117,7 +50806,7 @@ var ts; return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068) && !(target.flags & 131068)); } if (target.flags & 2097152) { - return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2); + return typeRelatedToEachType(source, target, reportErrors, 2); } if (relation === comparableRelation && target.flags & 131068) { var constraints = ts.sameMap(source.types, getBaseConstraintOrType); @@ -50286,10 +50975,10 @@ var ts; if (outofbandVarianceMarkerHandler) { var saved = entry & 24; if (saved & 8) { - instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers)); + instantiateType(source, reportUnmeasurableMapper); } if (saved & 16) { - instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); + instantiateType(source, reportUnreliableMapper); } } return entry & 1 ? -1 : 0; @@ -50381,13 +51070,26 @@ var ts; return result; } function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) { + var saveErrorInfo = captureErrorCalculationState(); + var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo); + if (!result && (source.flags & 2097152 || source.flags & 262144 && target.flags & 1048576)) { + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 ? source.types : [source], !!(target.flags & 1048576)); + if (constraint && everyType(constraint, function (c) { return c !== source; })) { + result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState); + } + } + if (result) { + resetErrorInfo(saveErrorInfo); + } + return result; + } + function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) { if (intersectionState & 4) { return propertiesRelatedTo(source, target, reportErrors, undefined, 0); } var result; var originalErrorInfo; var varianceCheckFailed = false; - var saveErrorInfo = captureErrorCalculationState(); var sourceFlags = source.flags; var targetFlags = target.flags; if (relation === identityRelation) { @@ -50432,15 +51134,6 @@ var ts; if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) { return result; } - if (source.flags & 2097152 || source.flags & 262144 && target.flags & 1048576) { - var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 ? source.types : [source], !!(target.flags & 1048576)); - if (constraint && everyType(constraint, function (c) { return c !== source; })) { - if (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState)) { - resetErrorInfo(saveErrorInfo); - return result; - } - } - } if (!(sourceFlags & 465829888 || sourceFlags & 524288 && targetFlags & 1048576 || sourceFlags & 2097152 && targetFlags & (524288 | 1048576 | 465829888))) { @@ -50472,6 +51165,18 @@ var ts; } } } + if (relation === comparableRelation && sourceFlags & 262144) { + var constraint = getConstraintOfTypeParameter(source); + if (constraint && hasNonCircularBaseConstraint(source)) { + while (constraint && constraint.flags & 262144) { + if (result = isRelatedTo(constraint, target, 1, false)) { + return result; + } + constraint = getConstraintOfTypeParameter(constraint); + } + } + return 0; + } } else if (targetFlags & 4194304) { var targetType_1 = target.type; @@ -50517,7 +51222,6 @@ var ts; result &= isRelatedTo(source.indexType, target.indexType, 3, reportErrors); } if (result) { - resetErrorInfo(saveErrorInfo); return result; } if (reportErrors) { @@ -50593,7 +51297,6 @@ var ts; } else if (targetFlags & 16777216) { if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) { - resetErrorInfo(saveErrorInfo); return 3; } var c = target; @@ -50603,7 +51306,6 @@ var ts; if (result = skipTrue ? -1 : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2, false)) { result &= skipFalse ? -1 : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2, false); if (result) { - resetErrorInfo(saveErrorInfo); return result; } } @@ -50614,34 +51316,32 @@ var ts; if (relation === comparableRelation) { return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 : -1; } - instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); + instantiateType(source, reportUnreliableMapper); } if (isTypeMatchedByTemplateLiteralType(source, target)) { return -1; } } + else if (target.flags & 268435456) { + if (!(source.flags & 268435456)) { + if (isMemberOfStringMapping(source, target)) { + return -1; + } + } + } if (sourceFlags & 8650752) { if (!(sourceFlags & 8388608 && targetFlags & 8388608)) { - var constraint = getConstraintOfType(source); - if (!constraint || (sourceFlags & 262144 && constraint.flags & 1)) { - if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864), 3)) { - resetErrorInfo(saveErrorInfo); - return result; - } - } - else if (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState)) { - resetErrorInfo(saveErrorInfo); + var constraint = getConstraintOfType(source) || unknownType; + if (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState)) { return result; } - else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1, reportErrors && !(targetFlags & sourceFlags & 262144), undefined, intersectionState)) { - resetErrorInfo(saveErrorInfo); + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144), undefined, intersectionState)) { return result; } if (isMappedTypeGenericIndexedAccess(source)) { var indexConstraint = getConstraintOfType(source.indexType); if (indexConstraint) { if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1, reportErrors)) { - resetErrorInfo(saveErrorInfo); return result; } } @@ -50650,7 +51350,6 @@ var ts; } else if (sourceFlags & 4194304) { if (result = isRelatedTo(keyofConstraintType, target, 1, reportErrors)) { - resetErrorInfo(saveErrorInfo); return result; } } @@ -50658,29 +51357,28 @@ var ts; if (!(targetFlags & 134217728)) { var constraint = getBaseConstraintOfType(source); if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1, reportErrors))) { - resetErrorInfo(saveErrorInfo); return result; } } } else if (sourceFlags & 268435456) { - if (targetFlags & 268435456 && source.symbol === target.symbol) { + if (targetFlags & 268435456) { + if (source.symbol !== target.symbol) { + return 0; + } if (result = isRelatedTo(source.type, target.type, 3, reportErrors)) { - resetErrorInfo(saveErrorInfo); return result; } } else { var constraint = getBaseConstraintOfType(source); if (constraint && (result = isRelatedTo(constraint, target, 1, reportErrors))) { - resetErrorInfo(saveErrorInfo); return result; } } } else if (sourceFlags & 16777216) { if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) { - resetErrorInfo(saveErrorInfo); return 3; } if (targetFlags & 16777216) { @@ -50699,7 +51397,6 @@ var ts; result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3, reportErrors); } if (result) { - resetErrorInfo(saveErrorInfo); return result; } } @@ -50708,7 +51405,6 @@ var ts; var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined; if (distributiveConstraint) { if (result = isRelatedTo(distributiveConstraint, target, 1, reportErrors)) { - resetErrorInfo(saveErrorInfo); return result; } } @@ -50716,7 +51412,6 @@ var ts; var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { if (result = isRelatedTo(defaultConstraint, target, 1, reportErrors)) { - resetErrorInfo(saveErrorInfo); return result; } } @@ -50728,7 +51423,6 @@ var ts; if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { if (result = mappedTypeRelatedTo(source, target, reportErrors)) { - resetErrorInfo(saveErrorInfo); return result; } } @@ -50822,25 +51516,13 @@ var ts; } } } - function reportUnmeasurableMarkers(p) { - if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) { - outofbandVarianceMarkerHandler(false); - } - return p; - } - function reportUnreliableMarkers(p) { - if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) { - outofbandVarianceMarkerHandler(true); - } - return p; - } function mappedTypeRelatedTo(source, target, reportErrors) { var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) : getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target)); if (modifiersRelated) { var result_10; var targetConstraint = getConstraintTypeFromMappedType(target); - var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); + var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMapper : reportUnreliableMapper); if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3, reportErrors)) { var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) { @@ -50876,11 +51558,11 @@ var ts; } var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_20 = function (combination) { + var _loop_21 = function (combination) { var hasMatch = false; outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) { var type = _d[_c]; - var _loop_21 = function (i) { + var _loop_22 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfType(type, sourceProperty.escapedName); if (!targetProperty) @@ -50893,7 +51575,7 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_8 = _loop_21(i); + var state_8 = _loop_22(i); switch (state_8) { case "continue-outer": continue outer; } @@ -50907,7 +51589,7 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_7 = _loop_20(combination); + var state_7 = _loop_21(combination); if (typeof state_7 === "object") return state_7.value; } @@ -51313,7 +51995,7 @@ var ts; return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; } function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers)); + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, reportUnreliableMapper); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -51460,7 +52142,7 @@ var ts; return typeCouldHaveTopLevelSingletonTypes(constraint); } } - return isUnitType(type) || !!(type.flags & 134217728); + return isUnitType(type) || !!(type.flags & 134217728) || !!(type.flags & 268435456); } function getExactOptionalUnassignableProperties(source, target) { if (isTupleType(source) && isTupleType(target)) @@ -51551,7 +52233,7 @@ var ts; ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes", "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); links.variances = ts.emptyArray; var variances = []; - var _loop_22 = function (tp) { + var _loop_23 = function (tp) { var modifiers = getVarianceModifiers(tp); var variance = modifiers & 65536 ? modifiers & 32768 ? 0 : 1 : @@ -51580,12 +52262,12 @@ var ts; } variances.push(variance); }; - for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { - var tp = typeParameters_1[_i]; - _loop_22(tp); + for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { + var tp = typeParameters_2[_i]; + _loop_23(tp); } links.variances = variances; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) }); } return links.variances; } @@ -51861,32 +52543,28 @@ var ts; var commonBaseType; for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { var t = types_13[_i]; - var baseType = getBaseTypeOfLiteralType(t); - if (!commonBaseType) { - commonBaseType = baseType; - } - if (baseType === t || baseType !== commonBaseType) { - return false; + if (!(t.flags & 131072)) { + var baseType = getBaseTypeOfLiteralType(t); + commonBaseType !== null && commonBaseType !== void 0 ? commonBaseType : (commonBaseType = baseType); + if (baseType === t || baseType !== commonBaseType) { + return false; + } } } return true; } - function getSupertypeOrUnion(types) { - if (types.length === 1) { - return types[0]; - } - return literalTypesWithSameBaseType(types) ? - getUnionType(types) : - ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; }); + function getCombinedTypeFlags(types) { + return ts.reduceLeft(types, function (flags, t) { return flags | (t.flags & 1048576 ? getCombinedTypeFlags(t.types) : t.flags); }, 0); } function getCommonSupertype(types) { - if (!strictNullChecks) { - return getSupertypeOrUnion(types); + if (types.length === 1) { + return types[0]; } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304); }); - return primaryTypes.length ? - getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304) : - getUnionType(types, 2); + var primaryTypes = strictNullChecks ? ts.sameMap(types, function (t) { return filterType(t, function (u) { return !(u.flags & 98304); }); }) : types; + var superTypeOrUnion = literalTypesWithSameBaseType(primaryTypes) ? + getUnionType(primaryTypes) : + ts.reduceLeft(primaryTypes, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; }); + return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) & 98304); } function getCommonSubtype(types) { return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; }); @@ -51985,9 +52663,14 @@ var ts; type.flags & 256 ? numberType : type.flags & 2048 ? bigintType : type.flags & 512 ? booleanType : - type.flags & 1048576 ? mapType(type, getBaseTypeOfLiteralType) : + type.flags & 1048576 ? getBaseTypeOfLiteralTypeUnion(type) : type; } + function getBaseTypeOfLiteralTypeUnion(type) { + var _a; + var key = "B".concat(getTypeId(type)); + return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, mapType(type, getBaseTypeOfLiteralType)); + } function getWidenedLiteralType(type) { return type.flags & 1024 && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : type.flags & 128 && isFreshLiteralType(type) ? stringType : @@ -52064,26 +52747,8 @@ var ts; var value = _a.value; return value.base10Value === "0"; } - function getFalsyFlagsOfTypes(types) { - var result = 0; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; - result |= getFalsyFlags(t); - } - return result; - } - function getFalsyFlags(type) { - return type.flags & 1048576 ? getFalsyFlagsOfTypes(type.types) : - type.flags & 128 ? type.value === "" ? 128 : 0 : - type.flags & 256 ? type.value === 0 ? 256 : 0 : - type.flags & 2048 ? isZeroBigInt(type) ? 2048 : 0 : - type.flags & 512 ? (type === falseType || type === regularFalseType) ? 512 : 0 : - type.flags & 117724; - } function removeDefinitelyFalsyTypes(type) { - return getFalsyFlags(type) & 117632 ? - filterType(type, function (t) { return !(getFalsyFlags(t) & 117632); }) : - type; + return filterType(type, function (t) { return !!(getTypeFacts(t) & 4194304); }); } function extractDefinitelyFalsyTypes(type) { return mapType(type, getDefinitelyFalsyPartOfType); @@ -52113,16 +52778,15 @@ var ts; return type.flags & 32768 ? type : getUnionType([type, isProperty ? missingType : undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { - var reducedType = getTypeWithFacts(type, 2097152); if (!deferredGlobalNonNullableTypeAlias) { deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288, undefined) || unknownSymbol; } return deferredGlobalNonNullableTypeAlias !== unknownSymbol ? - getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) : - reducedType; + getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]) : + getIntersectionType([type, emptyObjectType]); } function getNonNullableType(type) { - return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; + return strictNullChecks ? getAdjustedTypeWithFacts(type, 2097152) : type; } function addOptionalTypeMarker(type) { return strictNullChecks ? getUnionType([type, optionalType]) : type; @@ -52152,12 +52816,13 @@ var ts; && ((target.flags & (8 | 4 | 16)) !== 0); } function isObjectTypeWithInferableIndex(type) { + var objectFlags = ts.getObjectFlags(type); return type.flags & 2097152 ? ts.every(type.types, isObjectTypeWithInferableIndex) : !!(type.symbol && (type.symbol.flags & (4096 | 2048 | 384 | 512)) !== 0 && !(type.symbol.flags & 32) - && !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 && isObjectTypeWithInferableIndex(type.source)); + && !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304) || !!(objectFlags & 1024 && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8); @@ -52466,25 +53131,27 @@ var ts; signature: signature, flags: flags, compareTypes: compareTypes, - mapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, true); }), - nonFixingMapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, false); }), + mapper: reportUnmeasurableMapper, + nonFixingMapper: reportUnmeasurableMapper, }; + context.mapper = makeFixingMapperForContext(context); + context.nonFixingMapper = makeNonFixingMapperForContext(context); return context; } - function mapToInferredType(context, t, fix) { - var inferences = context.inferences; - for (var i = 0; i < inferences.length; i++) { - var inference = inferences[i]; - if (t === inference.typeParameter) { - if (fix && !inference.isFixed) { - inferFromIntraExpressionSites(context); - clearCachedInferences(inferences); - inference.isFixed = true; - } - return getInferredType(context, i); + function makeFixingMapperForContext(context) { + return makeDeferredTypeMapper(ts.map(context.inferences, function (i) { return i.typeParameter; }), ts.map(context.inferences, function (inference, i) { return function () { + if (!inference.isFixed) { + inferFromIntraExpressionSites(context); + clearCachedInferences(context.inferences); + inference.isFixed = true; } - } - return t; + return getInferredType(context, i); + }; })); + } + function makeNonFixingMapperForContext(context) { + return makeDeferredTypeMapper(ts.map(context.inferences, function (i) { return i.typeParameter; }), ts.map(context.inferences, function (_, i) { return function () { + return getInferredType(context, i); + }; })); } function clearCachedInferences(inferences) { for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) { @@ -52716,17 +53383,50 @@ var ts; return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) || sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen); } - function isValidBigIntString(s) { + function isValidNumberString(s, roundTripOnly) { + if (s === "") + return false; + var n = +s; + return isFinite(n) && (!roundTripOnly || "" + n === s); + } + function parseBigIntLiteralType(text) { + var negative = text.startsWith("-"); + var base10Value = ts.parsePseudoBigInt("".concat(negative ? text.slice(1) : text, "n")); + return getBigIntLiteralType({ negative: negative, base10Value: base10Value }); + } + function isValidBigIntString(s, roundTripOnly) { + if (s === "") + return false; var scanner = ts.createScanner(99, false); var success = true; scanner.setOnError(function () { return success = false; }); scanner.setText(s + "n"); var result = scanner.scan(); - if (result === 40) { + var negative = result === 40; + if (negative) { result = scanner.scan(); } var flags = scanner.getTokenFlags(); - return success && result === 9 && scanner.getTextPos() === (s.length + 1) && !(flags & 512); + return success && result === 9 && scanner.getTextPos() === (s.length + 1) && !(flags & 512) + && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) })); + } + function isMemberOfStringMapping(source, target) { + if (target.flags & (4 | 3)) { + return true; + } + if (target.flags & 134217728) { + return isTypeAssignableTo(source, target); + } + if (target.flags & 268435456) { + var mappingStack = []; + while (target.flags & 268435456) { + mappingStack.unshift(target.symbol); + target = target.type; + } + var mappedSource = ts.reduceLeft(mappingStack, function (memo, value) { return getStringMappingType(value, memo); }, source); + return mappedSource === source && isMemberOfStringMapping(source, target); + } + return false; } function isValidTypeForTemplateLiteralPlaceholder(source, target) { if (source === target || target.flags & (1 | 4)) { @@ -52734,9 +53434,10 @@ var ts; } if (source.flags & 128) { var value = source.value; - return !!(target.flags & 8 && value !== "" && isFinite(+value) || - target.flags & 64 && value !== "" && isValidBigIntString(value) || - target.flags & (512 | 98304) && value === target.intrinsicName); + return !!(target.flags & 8 && isValidNumberString(value, false) || + target.flags & 64 && isValidBigIntString(value, false) || + target.flags & (512 | 98304) && value === target.intrinsicName || + target.flags & 268435456 && isMemberOfStringMapping(getStringLiteralType(value), target)); } if (source.flags & 134217728) { var texts = source.texts; @@ -52837,8 +53538,10 @@ var ts; propagationType = savePropagationType; return; } - if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { - inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + if (source.aliasSymbol && source.aliasSymbol === target.aliasSymbol) { + if (source.aliasTypeArguments) { + inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + } return; } if (source === target && source.flags & 3145728) { @@ -52875,7 +53578,7 @@ var ts; target = getActualTypeVariable(target); } if (target.flags & 8650752) { - if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { + if (isFromInferenceBlockedSource(source)) { return; } var inference = getInferenceInfoForType(target); @@ -52930,15 +53633,11 @@ var ts; inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } else if (source.flags & 4194304 && target.flags & 4194304) { - contravariant = !contravariant; - inferFromTypes(source.type, target.type); - contravariant = !contravariant; + inferFromContravariantTypes(source.type, target.type); } else if ((isLiteralType(source) || source.flags & 4) && target.flags & 4194304) { var empty = createEmptyObjectTypeFromStringLiteral(source); - contravariant = !contravariant; - inferWithPriority(empty, target.type, 256); - contravariant = !contravariant; + inferFromContravariantTypesWithPriority(empty, target.type, 256); } else if (source.flags & 8388608 && target.flags & 8388608) { inferFromTypes(source.objectType, target.objectType); @@ -52951,10 +53650,7 @@ var ts; } else if (source.flags & 33554432) { inferFromTypes(source.baseType, target); - var oldPriority = priority; - priority |= 4; - inferFromTypes(source.substitute, target); - priority = oldPriority; + inferWithPriority(source.substitute, target, 4); } else if (target.flags & 16777216) { invokeOnce(source, target, inferToConditionalType); @@ -52993,6 +53689,18 @@ var ts; inferFromTypes(source, target); priority = savePriority; } + function inferFromContravariantTypesWithPriority(source, target, newPriority) { + var savePriority = priority; + priority |= newPriority; + inferFromContravariantTypes(source, target); + priority = savePriority; + } + function inferToMultipleTypesWithPriority(source, targets, targetFlags, newPriority) { + var savePriority = priority; + priority |= newPriority; + inferToMultipleTypes(source, targets, targetFlags); + priority = savePriority; + } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; var status = visited && visited.get(key); @@ -53055,10 +53763,13 @@ var ts; } } function inferFromContravariantTypes(source, target) { + contravariant = !contravariant; + inferFromTypes(source, target); + contravariant = !contravariant; + } + function inferFromContravariantTypesIfStrictFunctionTypes(source, target) { if (strictFunctionTypes || priority & 1024) { - contravariant = !contravariant; - inferFromTypes(source, target); - contravariant = !contravariant; + inferFromContravariantTypes(source, target); } else { inferFromTypes(source, target); @@ -53077,8 +53788,8 @@ var ts; } function getSingleTypeVariableFromIntersectionTypes(types) { var typeVariable; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var type = types_15[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var type = types_14[_i]; var t = type.flags & 2097152 && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); if (!t || typeVariable && t !== typeVariable) { return undefined; @@ -53189,19 +53900,59 @@ var ts; inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); } else { - var savePriority = priority; - priority |= contravariant ? 64 : 0; var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)]; - inferToMultipleTypes(source, targetTypes, target.flags); - priority = savePriority; + inferToMultipleTypesWithPriority(source, targetTypes, target.flags, contravariant ? 64 : 0); } } function inferToTemplateLiteralType(source, target) { var matches = inferTypesFromTemplateLiteralType(source, target); var types = target.types; if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) { + var _loop_24 = function (i) { + var source_1 = matches ? matches[i] : neverType; + var target_3 = types[i]; + if (source_1.flags & 128 && target_3.flags & 8650752) { + var inferenceContext = getInferenceInfoForType(target_3); + var constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : undefined; + if (constraint && !isTypeAny(constraint)) { + var constraintTypes = constraint.flags & 1048576 ? constraint.types : [constraint]; + var allTypeFlags_1 = ts.reduceLeft(constraintTypes, function (flags, t) { return flags | t.flags; }, 0); + if (!(allTypeFlags_1 & 4)) { + var str_1 = source_1.value; + if (allTypeFlags_1 & 296 && !isValidNumberString(str_1, true)) { + allTypeFlags_1 &= ~296; + } + if (allTypeFlags_1 & 2112 && !isValidBigIntString(str_1, true)) { + allTypeFlags_1 &= ~2112; + } + var matchingType = ts.reduceLeft(constraintTypes, function (left, right) { + return !(right.flags & allTypeFlags_1) ? left : + left.flags & 4 ? left : right.flags & 4 ? source_1 : + left.flags & 134217728 ? left : right.flags & 134217728 && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 : + left.flags & 268435456 ? left : right.flags & 268435456 && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 : + left.flags & 128 ? left : right.flags & 128 && right.value === str_1 ? right : + left.flags & 8 ? left : right.flags & 8 ? getNumberLiteralType(+str_1) : + left.flags & 32 ? left : right.flags & 32 ? getNumberLiteralType(+str_1) : + left.flags & 256 ? left : right.flags & 256 && right.value === +str_1 ? right : + left.flags & 64 ? left : right.flags & 64 ? parseBigIntLiteralType(str_1) : + left.flags & 2048 ? left : right.flags & 2048 && ts.pseudoBigIntToString(right.value) === str_1 ? right : + left.flags & 16 ? left : right.flags & 16 ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType : + left.flags & 512 ? left : right.flags & 512 && right.intrinsicName === str_1 ? right : + left.flags & 32768 ? left : right.flags & 32768 && right.intrinsicName === str_1 ? right : + left.flags & 65536 ? left : right.flags & 65536 && right.intrinsicName === str_1 ? right : + left; + }, neverType); + if (!(matchingType.flags & 131072)) { + inferFromTypes(matchingType, target_3); + return "continue"; + } + } + } + } + inferFromTypes(source_1, target_3); + }; for (var i = 0; i < types.length; i++) { - inferFromTypes(matches ? matches[i] : neverType, types[i]); + _loop_24(i); } } } @@ -53301,19 +54052,16 @@ var ts; var sourceLen = sourceSignatures.length; var targetLen = targetSignatures.length; var len = sourceLen < targetLen ? sourceLen : targetLen; - var skipParameters = !!(ts.getObjectFlags(source) & 262144); for (var i = 0; i < len; i++) { - inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters); + inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i])); } } - function inferFromSignature(source, target, skipParameters) { - if (!skipParameters) { - var saveBivariant = bivariant; - var kind = target.declaration ? target.declaration.kind : 0; - bivariant = bivariant || kind === 169 || kind === 168 || kind === 171; - applyToParameterTypes(source, target, inferFromContravariantTypes); - bivariant = saveBivariant; - } + function inferFromSignature(source, target) { + var saveBivariant = bivariant; + var kind = target.declaration ? target.declaration.kind : 0; + bivariant = bivariant || kind === 169 || kind === 168 || kind === 171; + applyToParameterTypes(source, target, inferFromContravariantTypesIfStrictFunctionTypes); + bivariant = saveBivariant; applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source, target) { @@ -53531,6 +54279,14 @@ var ts; var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); return key && key + "." + propName; } + break; + case 201: + case 202: + case 256: + case 213: + case 214: + case 169: + return "".concat(getNodeId(node), "#").concat(getTypeId(declaredType)); } return undefined; } @@ -53671,7 +54427,7 @@ var ts; function mapTypesByKeyProperty(types, name) { var map = new ts.Map(); var count = 0; - var _loop_23 = function (type) { + var _loop_25 = function (type) { if (type.flags & (524288 | 2097152 | 58982400)) { var discriminant = getTypeOfPropertyOfType(type, name); if (discriminant) { @@ -53695,9 +54451,9 @@ var ts; } } }; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var type = types_16[_i]; - var state_9 = _loop_23(type); + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var type = types_15[_i]; + var state_9 = _loop_25(type); if (typeof state_9 === "object") return state_9.value; } @@ -53776,33 +54532,36 @@ var ts; return false; } function getAssignmentReducedType(declaredType, assignedType) { - if (declaredType !== assignedType) { - if (assignedType.flags & 131072) { - return assignedType; - } - var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (assignedType.flags & 512 && isFreshLiteralType(assignedType)) { - reducedType = mapType(reducedType, getFreshTypeOfLiteralType); - } - if (isTypeAssignableTo(assignedType, reducedType)) { - return reducedType; - } + var _a; + if (declaredType === assignedType) { + return declaredType; } - return declaredType; + if (assignedType.flags & 131072) { + return assignedType; + } + var key = "A".concat(getTypeId(declaredType), ",").concat(getTypeId(assignedType)); + return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getAssignmentReducedTypeWorker(declaredType, assignedType)); + } + function getAssignmentReducedTypeWorker(declaredType, assignedType) { + var filteredType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); + var reducedType = assignedType.flags & 512 && isFreshLiteralType(assignedType) ? mapType(filteredType, getFreshTypeOfLiteralType) : filteredType; + return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType; } function isFunctionObjectType(type) { var resolved = resolveStructuredTypeMembers(type); return !!(resolved.callSignatures.length || resolved.constructSignatures.length || resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } - function getTypeFacts(type, ignoreObjects) { - if (ignoreObjects === void 0) { ignoreObjects = false; } + function getTypeFacts(type) { + if (type.flags & (2097152 | 465829888)) { + type = getBaseConstraintOfType(type) || unknownType; + } var flags = type.flags; - if (flags & 4) { + if (flags & (4 | 268435456)) { return strictNullChecks ? 16317953 : 16776705; } - if (flags & 128) { - var isEmpty = type.value === ""; + if (flags & (128 | 134217728)) { + var isEmpty = flags & 128 && type.value === ""; return strictNullChecks ? isEmpty ? 12123649 : 7929345 : isEmpty ? 12582401 : 16776705; @@ -53834,20 +54593,20 @@ var ts; (type === falseType || type === regularFalseType) ? 12580616 : 16774920; } if (flags & 524288) { - if (ignoreObjects) { - return 16768959; - } return ts.getObjectFlags(type) & 16 && isEmptyObjectType(type) ? - strictNullChecks ? 16318463 : 16777215 : + strictNullChecks ? 83427327 : 83886079 : isFunctionObjectType(type) ? strictNullChecks ? 7880640 : 16728000 : strictNullChecks ? 7888800 : 16736160; } - if (flags & (16384 | 32768)) { + if (flags & 16384) { return 9830144; } + if (flags & 32768) { + return 26607360; + } if (flags & 65536) { - return 9363232; + return 42917664; } if (flags & 12288) { return strictNullChecks ? 7925520 : 16772880; @@ -53858,33 +54617,49 @@ var ts; if (flags & 131072) { return 0; } - if (flags & 465829888) { - return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType, ignoreObjects) : - strictNullChecks ? 7929345 : 16776705; - } if (flags & 1048576) { - return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0); + return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t); }, 0); } if (flags & 2097152) { - ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068)); - return getIntersectionTypeFacts(type, ignoreObjects); + return getIntersectionTypeFacts(type); } - return 16777215; + return 83886079; } - function getIntersectionTypeFacts(type, ignoreObjects) { + function getIntersectionTypeFacts(type) { + var ignoreObjects = maybeTypeOfKind(type, 131068); var oredFacts = 0; - var andedFacts = 16777215; + var andedFacts = 134217727; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - var f = getTypeFacts(t, ignoreObjects); - oredFacts |= f; - andedFacts &= f; + if (!(ignoreObjects && t.flags & 524288)) { + var f = getTypeFacts(t); + oredFacts |= f; + andedFacts &= f; + } } - return oredFacts & 8256 | andedFacts & 16768959; + return oredFacts & 8256 | andedFacts & 134209471; } function getTypeWithFacts(type, include) { return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); } + function getAdjustedTypeWithFacts(type, facts) { + var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 ? unknownUnionType : type, facts)); + if (strictNullChecks) { + switch (facts) { + case 524288: + return mapType(reduced, function (t) { return getTypeFacts(t) & 65536 ? getIntersectionType([t, getTypeFacts(t) & 131072 && !maybeTypeOfKind(reduced, 65536) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t; }); + case 1048576: + return mapType(reduced, function (t) { return getTypeFacts(t) & 131072 ? getIntersectionType([t, getTypeFacts(t) & 65536 && !maybeTypeOfKind(reduced, 32768) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t; }); + case 2097152: + case 4194304: + return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 ? getGlobalNonNullableTypeInstantiation(t) : t; }); + } + } + return reduced; + } + function recombineUnknownType(type) { + return type === unknownUnionType ? unknownType : type; + } function getTypeWithDefault(type, defaultExpression) { return defaultExpression ? getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) : @@ -54036,19 +54811,15 @@ var ts; } return links.switchTypes; } - function getSwitchClauseTypeOfWitnesses(switchStatement, retainDefault) { + function getSwitchClauseTypeOfWitnesses(switchStatement) { + if (ts.some(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 289 && !ts.isStringLiteralLike(clause.expression); })) { + return undefined; + } var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 289) { - if (ts.isStringLiteralLike(clause.expression)) { - witnesses.push(clause.expression.text); - continue; - } - return ts.emptyArray; - } - if (retainDefault) - witnesses.push(undefined); + var text = clause.kind === 289 ? clause.expression.text : undefined; + witnesses.push(text && !ts.contains(witnesses, text) ? text : undefined); } return witnesses; } @@ -54125,8 +54896,8 @@ var ts; var types = origin && origin.flags & 1048576 ? origin.types : type.types; var mappedTypes; var changed = false; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var t = types_17[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; var mapped = t.flags & 1048576 ? mapType(t, mapper, noReductions) : mapper(t); changed || (changed = t !== mapped); if (mapped) { @@ -54199,8 +54970,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var t = types_18[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var t = types_17[_i]; if (!(t.flags & 131072)) { if (!(ts.getObjectFlags(t) & 256)) { return false; @@ -54616,7 +55387,7 @@ var ts; return declaredType; } if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 && isMatchingReference(reference, node.parent.parent.expression)) { - return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); + return getNonNullableTypeIfNeeded(finalizeEvolvingArrayType(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent)))); } return undefined; } @@ -54825,7 +55596,7 @@ var ts; if (isEvolvingArrayTypeList(types)) { return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))); } - var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction); + var result = recombineUnknownType(getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction)); if (result !== declaredType && result.flags & declaredType.flags & 1048576 && ts.arraysEqual(result.types, declaredType.types)) { return declaredType; } @@ -54921,11 +55692,10 @@ var ts; } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { - return type.flags & 2 && assumeTrue ? nonNullUnknownType : - getTypeWithFacts(type, assumeTrue ? 4194304 : 8388608); + return getAdjustedTypeWithFacts(type, assumeTrue ? 4194304 : 8388608); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { - type = getTypeWithFacts(type, 2097152); + type = getAdjustedTypeWithFacts(type, 2097152); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { @@ -55044,7 +55814,7 @@ var ts; var targetType = ts.hasStaticModifier(ts.Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); - return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom); + return getNarrowedType(type, targetType, assumeTrue, true); } function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) { var equalsOperator = operator === 34 || operator === 36; @@ -55052,7 +55822,7 @@ var ts; var valueType = getTypeOfExpression(value); var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) || equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 | nullableFlags)); }); - return removeNullable ? getTypeWithFacts(type, 2097152) : type; + return removeNullable ? getAdjustedTypeWithFacts(type, 2097152) : type; } function narrowTypeByEquality(type, operator, value, assumeTrue) { if (type.flags & 1) { @@ -55062,9 +55832,6 @@ var ts; assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if (assumeTrue && (type.flags & 2) && (operator === 34 || operator === 35) && (valueType.flags & 65536)) { - return getUnionType([nullType, undefinedType]); - } if ((type.flags & 2) && assumeTrue && (operator === 36 || operator === 37)) { if (valueType.flags & (131068 | 67108864)) { return valueType; @@ -55084,7 +55851,7 @@ var ts; valueType.flags & 65536 ? assumeTrue ? 131072 : 1048576 : assumeTrue ? 65536 : 524288; - return type.flags & 2 && facts & (1048576 | 2097152) ? nonNullUnknownType : getTypeWithFacts(type, facts); + return getAdjustedTypeWithFacts(type, facts); } if (assumeTrue) { var filterFn = operator === 34 ? @@ -55104,21 +55871,13 @@ var ts; var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) { - return getTypeWithFacts(type, 2097152); + return getAdjustedTypeWithFacts(type, 2097152); } return type; } - if (type.flags & 1 && literal.text === "function") { - return type; - } - if (assumeTrue && type.flags & 2 && literal.text === "object") { - return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]); - } - var facts = assumeTrue ? - typeofEQFacts.get(literal.text) || 128 : - typeofNEFacts.get(literal.text) || 32768; - var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text); - return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts); + return assumeTrue ? + narrowTypeByTypeName(type, literal.text) : + getTypeWithFacts(type, typeofNEFacts.get(literal.text) || 32768); } function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) { var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck); @@ -55161,58 +55920,40 @@ var ts; var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); }); return caseType.flags & 131072 ? defaultType : getUnionType([caseType, defaultType]); } - function getImpliedTypeFromTypeofGuard(type, text) { - switch (text) { - case "function": - return type.flags & 1 ? type : globalFunctionType; - case "object": - return type.flags & 2 ? getUnionType([nonPrimitiveType, nullType]) : type; - default: - return typeofTypesByName.get(text); - } - } - function narrowUnionMemberByTypeof(candidate) { - return function (type) { - if (isTypeSubtypeOf(type, candidate)) { - return type; - } - if (isTypeSubtypeOf(candidate, type)) { - return candidate; - } - if (type.flags & 465829888) { - var constraint = getBaseConstraintOfType(type) || anyType; - if (isTypeSubtypeOf(candidate, constraint)) { - return getIntersectionType([type, candidate]); - } - } - return type; - }; + function narrowTypeByTypeName(type, typeName) { + switch (typeName) { + case "string": return narrowTypeByTypeFacts(type, stringType, 1); + case "number": return narrowTypeByTypeFacts(type, numberType, 2); + case "bigint": return narrowTypeByTypeFacts(type, bigintType, 4); + case "boolean": return narrowTypeByTypeFacts(type, booleanType, 8); + case "symbol": return narrowTypeByTypeFacts(type, esSymbolType, 16); + case "object": return type.flags & 1 ? type : getUnionType([narrowTypeByTypeFacts(type, nonPrimitiveType, 32), narrowTypeByTypeFacts(type, nullType, 131072)]); + case "function": return type.flags & 1 ? type : narrowTypeByTypeFacts(type, globalFunctionType, 64); + case "undefined": return narrowTypeByTypeFacts(type, undefinedType, 65536); + } + return narrowTypeByTypeFacts(type, nonPrimitiveType, 128); + } + function narrowTypeByTypeFacts(type, impliedType, facts) { + return mapType(type, function (t) { + return isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ? getTypeFacts(t) & facts ? t : neverType : + isTypeSubtypeOf(impliedType, t) ? impliedType : + getTypeFacts(t) & facts ? getIntersectionType([t, impliedType]) : + neverType; + }); } function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) { - var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, true); - if (!switchWitnesses.length) { + var witnesses = getSwitchClauseTypeOfWitnesses(switchStatement); + if (!witnesses) { return type; } - var defaultCaseLocation = ts.findIndex(switchWitnesses, function (elem) { return elem === undefined; }); - var hasDefaultClause = clauseStart === clauseEnd || (defaultCaseLocation >= clauseStart && defaultCaseLocation < clauseEnd); - var clauseWitnesses; - var switchFacts; - if (defaultCaseLocation > -1) { - var witnesses = switchWitnesses.filter(function (witness) { return witness !== undefined; }); - var fixedClauseStart = defaultCaseLocation < clauseStart ? clauseStart - 1 : clauseStart; - var fixedClauseEnd = defaultCaseLocation < clauseEnd ? clauseEnd - 1 : clauseEnd; - clauseWitnesses = witnesses.slice(fixedClauseStart, fixedClauseEnd); - switchFacts = getFactsFromTypeofSwitch(fixedClauseStart, fixedClauseEnd, witnesses, hasDefaultClause); - } - else { - clauseWitnesses = switchWitnesses.slice(clauseStart, clauseEnd); - switchFacts = getFactsFromTypeofSwitch(clauseStart, clauseEnd, switchWitnesses, hasDefaultClause); - } + var defaultIndex = ts.findIndex(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 290; }); + var hasDefaultClause = clauseStart === clauseEnd || (defaultIndex >= clauseStart && defaultIndex < clauseEnd); if (hasDefaultClause) { - return filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; }); + var notEqualFacts_1 = getNotEqualFactsFromTypeofSwitch(clauseStart, clauseEnd, witnesses); + return filterType(type, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }); } - var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts); - return getTypeWithFacts(mapType(type, narrowUnionMemberByTypeof(impliedType)), switchFacts); + var clauseWitnesses = witnesses.slice(clauseStart, clauseEnd); + return getUnionType(ts.map(clauseWitnesses, function (text) { return text ? narrowTypeByTypeName(type, text) : neverType; })); } function isMatchingConstructorReference(expr) { return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" || @@ -55252,7 +55993,7 @@ var ts; var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) { - return getTypeWithFacts(type, 2097152); + return getAdjustedTypeWithFacts(type, 2097152); } return type; } @@ -55282,22 +56023,37 @@ var ts; if (!nonConstructorTypeInUnion) return type; } - return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom); + return getNarrowedType(type, targetType, assumeTrue, true); } - function getNarrowedType(type, candidate, assumeTrue, isRelated) { + function getNarrowedType(type, candidate, assumeTrue, checkDerived) { + var _a; + var key = type.flags & 1048576 ? "N".concat(getTypeId(type), ",").concat(getTypeId(candidate), ",").concat((assumeTrue ? 1 : 0) | (checkDerived ? 2 : 0)) : undefined; + return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived)); + } + function getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived) { + var isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf; if (!assumeTrue) { return filterType(type, function (t) { return !isRelated(t, candidate); }); } - if (type.flags & 1048576) { - var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 131072)) { - return assignableType; - } + if (type.flags & 3) { + return candidate; } - return isTypeSubtypeOf(candidate, type) ? candidate : - isTypeAssignableTo(type, candidate) ? type : - isTypeAssignableTo(candidate, type) ? candidate : - getIntersectionType([type, candidate]); + var keyPropertyName = type.flags & 1048576 ? getKeyPropertyName(type) : undefined; + var narrowedType = mapType(candidate, function (c) { + var discriminant = keyPropertyName && getTypeOfPropertyOfType(c, keyPropertyName); + var matching = discriminant && getConstituentTypeForKeyType(type, discriminant); + var directlyRelated = mapType(matching || type, checkDerived ? + function (t) { return isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType; } : + function (t) { return isTypeSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : neverType; }); + return directlyRelated.flags & 131072 ? + mapType(type, function (t) { return maybeTypeOfKind(t, 465829888) && isRelated(c, getBaseConstraintOfType(t) || unknownType) ? getIntersectionType([t, c]) : neverType; }) : + directlyRelated; + }); + return !(narrowedType.flags & 131072) ? narrowedType : + isTypeSubtypeOf(candidate, type) ? candidate : + isTypeAssignableTo(type, candidate) ? type : + isTypeAssignableTo(candidate, type) ? candidate : + getIntersectionType([type, candidate]); } function narrowTypeByCallExpression(type, callExpression, assumeTrue) { if (hasMatchingArgument(callExpression, reference)) { @@ -55324,15 +56080,15 @@ var ts; var predicateArgument = getTypePredicateArgument(predicate, callExpression); if (predicateArgument) { if (isMatchingReference(reference, predicateArgument)) { - return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); + return getNarrowedType(type, predicate.type, assumeTrue, false); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !(getTypeFacts(predicate.type) & 65536)) { - type = getTypeWithFacts(type, 2097152); + type = getAdjustedTypeWithFacts(type, 2097152); } var access = getDiscriminantPropertyAccess(predicateArgument, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, false); }); } } } @@ -55379,7 +56135,7 @@ var ts; } function narrowTypeByOptionality(type, expr, assumePresent) { if (isMatchingReference(reference, expr)) { - return getTypeWithFacts(type, assumePresent ? 2097152 : 262144); + return getAdjustedTypeWithFacts(type, assumePresent ? 2097152 : 262144); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { @@ -55454,8 +56210,8 @@ var ts; var annotationIncludesUndefined = strictNullChecks && declaration.kind === 164 && declaration.initializer && - getFalsyFlags(declaredType) & 32768 && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768); + getTypeFacts(declaredType) & 16777216 && + !(getTypeFacts(checkExpression(declaration.initializer)) & 16777216); popTypeResolution(); return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288) : declaredType; } @@ -55473,7 +56229,9 @@ var ts; !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression))); } function isGenericTypeWithUnionConstraint(type) { - return !!(type.flags & 465829888 && getBaseConstraintOrType(type).flags & (98304 | 1048576)); + return type.flags & 2097152 ? + ts.some(type.types, isGenericTypeWithUnionConstraint) : + !!(type.flags & 465829888 && getBaseConstraintOrType(type).flags & (98304 | 1048576)); } function isGenericTypeWithoutNullableConstraint(type) { return !!(type.flags & 465829888 && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304)); @@ -55483,14 +56241,14 @@ var ts; !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 64 ? getContextualType(node, 8) - : getContextualType(node)); + : getContextualType(node, undefined)); return contextualType && !isGenericType(contextualType); } function getNarrowableTypeForReference(type, reference, checkMode) { var substituteConstraints = !(checkMode && checkMode & 2) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode)); - return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 ? getBaseConstraintOrType(t) : t; }) : type; + return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type; } function isExportOrExportExpression(location) { return !!ts.findAncestor(location, function (n) { @@ -55586,7 +56344,7 @@ var ts; getNodeLinks(container).flags |= 8192; return getTypeOfSymbol(symbol); } - if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) { + if (shouldMarkIdentifierAliasReferenced(node)) { markAliasReferenced(symbol, node); } var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); @@ -55693,12 +56451,29 @@ var ts; return convertAutoToAny(flowType); } } - else if (!assumeInitialized && !(getFalsyFlags(type) & 32768) && getFalsyFlags(flowType) & 32768) { + else if (!assumeInitialized && !containsUndefinedType(type) && containsUndefinedType(flowType)) { error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); return type; } return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } + function shouldMarkIdentifierAliasReferenced(node) { + var _a; + var parent = node.parent; + if (parent) { + if (ts.isPropertyAccessExpression(parent) && parent.expression === node) { + return false; + } + if (ts.isExportSpecifier(parent) && parent.isTypeOnly) { + return false; + } + var greatGrandparent = (_a = parent.parent) === null || _a === void 0 ? void 0 : _a.parent; + if (greatGrandparent && ts.isExportDeclaration(greatGrandparent) && greatGrandparent.isTypeOnly) { + return false; + } + } + return true; + } function isInsideFunctionOrInstancePropertyInitializer(node, threshold) { return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n) || (n.parent && ts.isPropertyDeclaration(n.parent) && !ts.hasStaticModifier(n.parent) && n.parent.initializer === n); }); } @@ -55807,7 +56582,7 @@ var ts; } function checkThisInStaticClassFieldInitializerInDecoratedClass(thisExpression, container) { if (ts.isPropertyDeclaration(container) && ts.hasStaticModifier(container) && - container.initializer && ts.textRangeContainsPositionInclusive(container.initializer, thisExpression.pos) && ts.length(container.parent.decorators)) { + container.initializer && ts.textRangeContainsPositionInclusive(container.initializer, thisExpression.pos) && ts.hasDecorators(container.parent)) { error(thisExpression, ts.Diagnostics.Cannot_use_this_in_a_static_property_initializer_of_a_decorated_class); } } @@ -56123,7 +56898,7 @@ var ts; if (noImplicitThis || inJs) { var containingLiteral = getContainingObjectLiteral(func); if (containingLiteral) { - var contextualType = getApparentTypeOfContextualType(containingLiteral); + var contextualType = getApparentTypeOfContextualType(containingLiteral, undefined); var literal = containingLiteral; var type = contextualType; while (type) { @@ -56135,7 +56910,7 @@ var ts; break; } literal = literal.parent.parent; - type = getApparentTypeOfContextualType(literal); + type = getApparentTypeOfContextualType(literal, undefined); } return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral)); } @@ -56185,7 +56960,7 @@ var ts; tryGetTypeAtPosition(contextualSignature, index); } } - function getContextualTypeForVariableLikeDeclaration(declaration) { + function getContextualTypeForVariableLikeDeclaration(declaration, contextFlags) { var typeNode = ts.getEffectiveTypeAnnotationNode(declaration); if (typeNode) { return getTypeFromTypeNode(typeNode); @@ -56194,17 +56969,17 @@ var ts; case 164: return getContextuallyTypedParameterType(declaration); case 203: - return getContextualTypeForBindingElement(declaration); + return getContextualTypeForBindingElement(declaration, contextFlags); case 167: if (ts.isStatic(declaration)) { - return getContextualTypeForStaticPropertyDeclaration(declaration); + return getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags); } } } - function getContextualTypeForBindingElement(declaration) { + function getContextualTypeForBindingElement(declaration, contextFlags) { var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - var parentType = getContextualTypeForVariableLikeDeclaration(parent) || + var parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) || parent.kind !== 203 && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 : 0); if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) return undefined; @@ -56220,8 +56995,8 @@ var ts; return getTypeOfPropertyOfType(parentType, text); } } - function getContextualTypeForStaticPropertyDeclaration(declaration) { - var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent); + function getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags) { + var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent, contextFlags); if (!parentType) return undefined; return getTypeOfPropertyOfContextualType(parentType, getSymbolOfNode(declaration).escapedName); @@ -56229,29 +57004,32 @@ var ts; function getContextualTypeForInitializerExpression(node, contextFlags) { var declaration = node.parent; if (ts.hasInitializer(declaration) && node === declaration.initializer) { - var result = getContextualTypeForVariableLikeDeclaration(declaration); + var result = getContextualTypeForVariableLikeDeclaration(declaration, contextFlags); if (result) { return result; } - if (!(contextFlags & 8) && ts.isBindingPattern(declaration.name)) { + if (!(contextFlags & 8) && ts.isBindingPattern(declaration.name) && declaration.name.elements.length > 0) { return getTypeFromBindingPattern(declaration.name, true, false); } } return undefined; } - function getContextualTypeForReturnExpression(node) { + function getContextualTypeForReturnExpression(node, contextFlags) { var func = ts.getContainingFunction(node); if (func) { - var contextualReturnType = getContextualReturnType(func); + var contextualReturnType = getContextualReturnType(func, contextFlags); if (contextualReturnType) { var functionFlags = ts.getFunctionFlags(func); if (functionFlags & 1) { - var use = functionFlags & 2 ? 2 : 1; - var iterationTypes = getIterationTypesOfIterable(contextualReturnType, use, undefined); - if (!iterationTypes) { + var isAsyncGenerator_1 = (functionFlags & 2) !== 0; + if (contextualReturnType.flags & 1048576) { + contextualReturnType = filterType(contextualReturnType, function (type) { return !!getIterationTypeOfGeneratorFunctionReturnType(1, type, isAsyncGenerator_1); }); + } + var iterationReturnType = getIterationTypeOfGeneratorFunctionReturnType(1, contextualReturnType, (functionFlags & 2) !== 0); + if (!iterationReturnType) { return undefined; } - contextualReturnType = iterationTypes.returnType; + contextualReturnType = iterationReturnType; } if (functionFlags & 2) { var contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeNoAlias); @@ -56270,15 +57048,19 @@ var ts; } return undefined; } - function getContextualTypeForYieldOperand(node) { + function getContextualTypeForYieldOperand(node, contextFlags) { var func = ts.getContainingFunction(node); if (func) { var functionFlags = ts.getFunctionFlags(func); - var contextualReturnType = getContextualReturnType(func); + var contextualReturnType = getContextualReturnType(func, contextFlags); if (contextualReturnType) { + var isAsyncGenerator_2 = (functionFlags & 2) !== 0; + if (!node.asteriskToken && contextualReturnType.flags & 1048576) { + contextualReturnType = filterType(contextualReturnType, function (type) { return !!getIterationTypeOfGeneratorFunctionReturnType(1, type, isAsyncGenerator_2); }); + } return node.asteriskToken ? contextualReturnType - : getIterationTypeOfGeneratorFunctionReturnType(0, contextualReturnType, (functionFlags & 2) !== 0); + : getIterationTypeOfGeneratorFunctionReturnType(0, contextualReturnType, isAsyncGenerator_2); } } return undefined; @@ -56298,14 +57080,14 @@ var ts; } function getContextualIterationType(kind, functionDecl) { var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2); - var contextualReturnType = getContextualReturnType(functionDecl); + var contextualReturnType = getContextualReturnType(functionDecl, undefined); if (contextualReturnType) { return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) || undefined; } return undefined; } - function getContextualReturnType(functionDecl) { + function getContextualReturnType(functionDecl, contextFlags) { var returnType = getReturnTypeFromAnnotation(functionDecl); if (returnType) { return returnType; @@ -56316,7 +57098,7 @@ var ts; } var iife = ts.getImmediatelyInvokedFunctionExpression(functionDecl); if (iife) { - return getContextualType(iife); + return getContextualType(iife, contextFlags); } return undefined; } @@ -56378,6 +57160,14 @@ var ts; var lhsType = getTypeOfExpression(e.expression); return ts.isPrivateIdentifier(e.name) ? tryGetPrivateIdentifierPropertyOfType(lhsType, e.name) : getPropertyOfType(lhsType, e.name.escapedText); } + if (ts.isElementAccessExpression(e)) { + var propType = checkExpressionCached(e.argumentExpression); + if (!isTypeUsableAsPropertyName(propType)) { + return undefined; + } + var lhsType = getTypeOfExpression(e.expression); + return getPropertyOfType(lhsType, getPropertyNameFromType(propType)); + } return undefined; function tryGetPrivateIdentifierPropertyOfType(type, id) { var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(id.escapedText, id); @@ -56395,7 +57185,7 @@ var ts; if (decl && (ts.isPropertyDeclaration(decl) || ts.isPropertySignature(decl))) { var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl); return (overallAnnotation && instantiateType(getTypeFromTypeNode(overallAnnotation), getSymbolLinks(lhsSymbol).mapper)) || - (decl.initializer && getTypeOfExpression(binaryExpression.left)); + (ts.isPropertyDeclaration(decl) ? decl.initializer && getTypeOfExpression(binaryExpression.left) : undefined); } if (kind === 0) { return getTypeOfExpression(binaryExpression.left); @@ -56521,7 +57311,7 @@ var ts; } function getContextualTypeForObjectLiteralElement(element, contextFlags) { var objectLiteral = element.parent; - var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element); + var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element, contextFlags); if (propertyAssignmentType) { return propertyAssignmentType; } @@ -56546,8 +57336,8 @@ var ts; var conditional = node.parent; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional, contextFlags) : undefined; } - function getContextualTypeForChildJsxExpression(node, child) { - var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName); + function getContextualTypeForChildJsxExpression(node, child, contextFlags) { + var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName, contextFlags); var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node)); if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) { return undefined; @@ -56564,24 +57354,24 @@ var ts; } }, true)); } - function getContextualTypeForJsxExpression(node) { + function getContextualTypeForJsxExpression(node, contextFlags) { var exprParent = node.parent; return ts.isJsxAttributeLike(exprParent) - ? getContextualType(node) + ? getContextualType(node, contextFlags) : ts.isJsxElement(exprParent) - ? getContextualTypeForChildJsxExpression(exprParent, node) + ? getContextualTypeForChildJsxExpression(exprParent, node, contextFlags) : undefined; } - function getContextualTypeForJsxAttribute(attribute) { + function getContextualTypeForJsxAttribute(attribute, contextFlags) { if (ts.isJsxAttribute(attribute)) { - var attributesType = getApparentTypeOfContextualType(attribute.parent); + var attributesType = getApparentTypeOfContextualType(attribute.parent, contextFlags); if (!attributesType || isTypeAny(attributesType)) { return undefined; } return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText); } else { - return getContextualType(attribute.parent); + return getContextualType(attribute.parent, contextFlags); } } function isPossiblyDiscriminantValue(node) { @@ -56625,16 +57415,14 @@ var ts; function instantiateContextualType(contextualType, node, contextFlags) { if (contextualType && maybeTypeOfKind(contextualType, 465829888)) { var inferenceContext = getInferenceContext(node); - if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) { - if (contextFlags && contextFlags & 1) { - return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper); - } - if (inferenceContext.returnMapper) { - var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper); - return type.flags & 1048576 && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? - filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) : - type; - } + if (inferenceContext && contextFlags & 1 && ts.some(inferenceContext.inferences, hasInferenceCandidates)) { + return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper); + } + if (inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.returnMapper) { + var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper); + return type.flags & 1048576 && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? + filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) : + type; } } return contextualType; @@ -56668,9 +57456,9 @@ var ts; return getContextualTypeForInitializerExpression(node, contextFlags); case 214: case 247: - return getContextualTypeForReturnExpression(node); + return getContextualTypeForReturnExpression(node, contextFlags); case 224: - return getContextualTypeForYieldOperand(parent); + return getContextualTypeForYieldOperand(parent, contextFlags); case 218: return getContextualTypeForAwaitOperand(parent, contextFlags); case 208: @@ -56707,17 +57495,17 @@ var ts; case 271: return tryGetTypeFromEffectiveTypeNode(parent); case 288: - return getContextualTypeForJsxExpression(parent); + return getContextualTypeForJsxExpression(parent, contextFlags); case 285: case 287: - return getContextualTypeForJsxAttribute(parent); + return getContextualTypeForJsxAttribute(parent, contextFlags); case 280: case 279: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; function tryFindWhenConstTypeReference(node) { - return getContextualType(node); + return getContextualType(node, contextFlags); } } function getInferenceContext(node) { @@ -56948,8 +57736,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { - var current = types_19[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var current = types_18[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -56986,7 +57774,7 @@ var ts; var elementCount = elements.length; var elementTypes = []; var elementFlags = []; - var contextualType = getApparentTypeOfContextualType(node); + var contextualType = getApparentTypeOfContextualType(node, undefined); var inDestructuringPattern = ts.isAssignmentTarget(node); var inConstContext = isConstContext(node); var hasOmittedExpression = false; @@ -57135,7 +57923,7 @@ var ts; var propertiesTable = ts.createSymbolTable(); var propertiesArray = []; var spread = emptyObjectType; - var contextualType = getApparentTypeOfContextualType(node); + var contextualType = getApparentTypeOfContextualType(node, undefined); var contextualTypeHasPattern = contextualType && contextualType.pattern && (contextualType.pattern.kind === 201 || contextualType.pattern.kind === 205); var inConstContext = isConstContext(node); @@ -57433,7 +58221,7 @@ var ts; if (explicitlySpecifyChildrenAttribute) { error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName)); } - var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes); + var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes, undefined); var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName); var childrenPropSymbol = createSymbol(4, jsxChildrenPropertyName); childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] : @@ -57912,19 +58700,19 @@ var ts; return checkNonNullType(checkExpression(node), node); } function isNullableType(type) { - return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304); + return !!(getTypeFacts(type) & 50331648); } function getNonNullableTypeIfNeeded(type) { return isNullableType(type) ? getNonNullableType(type) : type; } - function reportObjectPossiblyNullOrUndefinedError(node, flags) { - error(node, flags & 32768 ? flags & 65536 ? + function reportObjectPossiblyNullOrUndefinedError(node, facts) { + error(node, facts & 16777216 ? facts & 33554432 ? ts.Diagnostics.Object_is_possibly_null_or_undefined : ts.Diagnostics.Object_is_possibly_undefined : ts.Diagnostics.Object_is_possibly_null); } - function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) { - error(node, flags & 32768 ? flags & 65536 ? + function reportCannotInvokePossiblyNullOrUndefinedError(node, facts) { + error(node, facts & 16777216 ? facts & 33554432 ? ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null); @@ -57934,9 +58722,9 @@ var ts; error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304; - if (kind) { - reportError(node, kind); + var facts = getTypeFacts(type); + if (facts & 50331648) { + reportError(node, facts); var t = getNonNullableType(type); return t.flags & (98304 | 131072) ? errorType : t; } @@ -58097,9 +58885,8 @@ var ts; markAliasReferenced(parentSymbol, node); } return isErrorType(apparentType) ? errorType : apparentType; - ; } - prop = getPropertyOfType(apparentType, right.escapedText); + prop = getPropertyOfType(apparentType, right.escapedText, false, node.kind === 161); } if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 && node.parent.kind === 299)) || @@ -58203,7 +58990,7 @@ var ts; assumeUninitialized = true; } var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType); - if (assumeUninitialized && !(getFalsyFlags(propType) & 32768) && getFalsyFlags(flowType) & 32768) { + if (assumeUninitialized && !containsUndefinedType(propType) && containsUndefinedType(flowType)) { error(errorNode, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); return propType; } @@ -58381,9 +59168,9 @@ var ts; function getSuggestedSymbolForNonexistentProperty(name, containingType) { var props = getPropertiesOfType(containingType); if (typeof name !== "string") { - var parent_2 = name.parent; - if (ts.isPropertyAccessExpression(parent_2)) { - props = ts.filter(props, function (prop) { return isValidPropertyAccessForCompletions(parent_2, containingType, prop); }); + var parent_3 = name.parent; + if (ts.isPropertyAccessExpression(parent_3)) { + props = ts.filter(props, function (prop) { return isValidPropertyAccessForCompletions(parent_3, containingType, prop); }); } name = ts.idText(name); } @@ -58789,18 +59576,22 @@ var ts; return inferJsxTypeArguments(node, signature, checkMode, context); } if (node.kind !== 165) { - var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 : 0); + var skipBindingPatterns = ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }); + var contextualType = getContextualType(node, skipBindingPatterns ? 8 : 0); if (contextualType) { var inferenceTargetType = getReturnTypeOfSignature(signature); if (couldContainTypeVariables(inferenceTargetType)) { var outerContext = getInferenceContext(node); - var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1)); - var instantiatedType = instantiateType(contextualType, outerMapper); - var contextualSignature = getSingleCallSignature(instantiatedType); - var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? - getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : - instantiatedType; - inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128); + var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8) !== contextualType; + if (!isFromBindingPattern) { + var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1)); + var instantiatedType = instantiateType(contextualType, outerMapper); + var contextualSignature = getSingleCallSignature(instantiatedType); + var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? + getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : + instantiatedType; + inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128); + } var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags); var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper); inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType); @@ -59094,7 +59885,7 @@ var ts; var spreadIndex = getSpreadArgumentIndex(args); if (spreadIndex >= 0) { var effectiveArgs_1 = args.slice(0, spreadIndex); - var _loop_24 = function (i) { + var _loop_26 = function (i) { var arg = args[i]; var spreadType = arg.kind === 225 && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { @@ -59110,7 +59901,7 @@ var ts; } }; for (var i = spreadIndex; i < args.length; i++) { - _loop_24(i); + _loop_26(i); } return effectiveArgs_1; } @@ -59296,7 +60087,7 @@ var ts; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; - if (!isDecorator) { + if (!isDecorator && !ts.isSuperCall(node)) { typeArguments = node.typeArguments; if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106) { ts.forEach(typeArguments, checkSourceElement); @@ -59328,6 +60119,8 @@ var ts; if (result) { return result; } + result = getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode); + getNodeLinks(node).resolvedSignature = result; if (reportErrors) { if (candidatesForArgumentError) { if (candidatesForArgumentError.length === 1 || candidatesForArgumentError.length > 3) { @@ -59358,7 +60151,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_25 = function (c) { + var _loop_27 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0, true, chain_2); if (diags_2) { @@ -59376,7 +60169,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_25(c); + _loop_27(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); @@ -59413,7 +60206,7 @@ var ts; } } } - return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode); + return result; function addImplementationSuccessElaboration(failed, diagnostic) { var _a, _b; var oldCandidatesForArgumentError = candidatesForArgumentError; @@ -59487,7 +60280,7 @@ var ts; argCheckMode = checkMode & 32; if (inferenceContext) { var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext); - checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); + checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters); if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) { candidateForArgumentArityError = checkCandidate; continue; @@ -59519,7 +60312,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_26 = function (i) { + var _loop_28 = function (i) { var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ? i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) : i < s.parameters.length ? s.parameters[i] : undefined; }); @@ -59527,7 +60320,7 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_26(i); + _loop_28(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); var flags = 0; @@ -59803,8 +60596,8 @@ var ts; if (apparentType.flags & 1048576) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { - var constituent = types_20[_i]; + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var constituent = types_19[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -59954,7 +60747,7 @@ var ts; var exports = namespace && getExportsOfSymbol(namespace); var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968); var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968, node); - var declaration = ts.factory.createFunctionTypeNode(undefined, [ts.factory.createParameterDeclaration(undefined, undefined, undefined, "props", undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, undefined) : ts.factory.createKeywordTypeNode(130)); + var declaration = ts.factory.createFunctionTypeNode(undefined, [ts.factory.createParameterDeclaration(undefined, undefined, "props", undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, undefined) : ts.factory.createKeywordTypeNode(130)); var parameterSymbol = createSymbol(1, "props"); parameterSymbol.type = result; return createSignature(declaration, undefined, undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, undefined, 1, 0); @@ -60126,7 +60919,7 @@ var ts; checkGrammarTypeArguments(node, node.typeArguments); var signature = getResolvedSignature(node, undefined, checkMode); if (signature === resolvingSignature) { - return nonInferrableType; + return silentNeverType; } checkDeprecatedSignature(signature, node); if (node.expression.kind === 106) { @@ -60716,13 +61509,6 @@ var ts; } } } - var restType = getEffectiveRestType(context); - if (restType && restType.flags & 262144) { - var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper); - assignContextualParameterTypes(signature, instantiatedContext); - var restPos = getParameterCount(context) - 1; - inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType); - } } function assignContextualParameterTypes(signature, context) { if (context.typeParameters) { @@ -60895,7 +61681,7 @@ var ts; var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); var contextualType = !contextualSignature ? undefined : contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType : - instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func); + instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func, undefined); if (isGenerator) { yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0, isAsync); returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1, isAsync); @@ -60958,7 +61744,7 @@ var ts; nextType = iterationTypes && iterationTypes.nextType; } else { - nextType = getContextualType(yieldExpression); + nextType = getContextualType(yieldExpression, undefined); } if (nextType) ts.pushIfUnique(nextTypes, nextType); @@ -60972,26 +61758,11 @@ var ts; ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } - function getFactsFromTypeofSwitch(start, end, witnesses, hasDefault) { + function getNotEqualFactsFromTypeofSwitch(start, end, witnesses) { var facts = 0; - if (hasDefault) { - for (var i = end; i < witnesses.length; i++) { - facts |= typeofNEFacts.get(witnesses[i]) || 32768; - } - for (var i = start; i < end; i++) { - facts &= ~(typeofNEFacts.get(witnesses[i]) || 0); - } - for (var i = 0; i < start; i++) { - facts |= typeofNEFacts.get(witnesses[i]) || 32768; - } - } - else { - for (var i = start; i < end; i++) { - facts |= typeofEQFacts.get(witnesses[i]) || 128; - } - for (var i = 0; i < start; i++) { - facts &= ~(typeofEQFacts.get(witnesses[i]) || 0); - } + for (var i = 0; i < witnesses.length; i++) { + var witness = i < start || i >= end ? witnesses[i] : undefined; + facts |= witness !== undefined ? typeofNEFacts.get(witness) || 32768 : 0; } return facts; } @@ -61001,14 +61772,16 @@ var ts; } function computeExhaustiveSwitchStatement(node) { if (node.expression.kind === 216) { - var operandType = getTypeOfExpression(node.expression.expression); - var witnesses = getSwitchClauseTypeOfWitnesses(node, false); - var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, true); - var type_6 = getBaseConstraintOfType(operandType) || operandType; - if (type_6.flags & 3) { - return (556800 & notEqualFacts_1) === 556800; + var witnesses = getSwitchClauseTypeOfWitnesses(node); + if (!witnesses) { + return false; } - return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072); + var operandConstraint = getBaseConstraintOrType(getTypeOfExpression(node.expression.expression)); + var notEqualFacts_2 = getNotEqualFactsFromTypeofSwitch(0, 0, witnesses); + if (operandConstraint.flags & 3) { + return (556800 & notEqualFacts_2) === 556800; + } + return !someType(operandConstraint, function (t) { return (getTypeFacts(t) & notEqualFacts_2) === notEqualFacts_2; }); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -61144,11 +61917,16 @@ var ts; if (isContextSensitive(node)) { if (contextualSignature) { var inferenceContext = getInferenceContext(node); + var instantiatedContextualSignature = void 0; if (checkMode && checkMode & 2) { inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext); + var restType = getEffectiveRestType(contextualSignature); + if (restType && restType.flags & 262144) { + instantiatedContextualSignature = instantiateSignature(contextualSignature, inferenceContext.nonFixingMapper); + } } - var instantiatedContextualSignature = inferenceContext ? - instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature; + instantiatedContextualSignature || (instantiatedContextualSignature = inferenceContext ? + instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature); assignContextualParameterTypes(signature, instantiatedContextualSignature); } else { @@ -61312,7 +62090,7 @@ var ts; var type = getTypeOfSymbol(symbol); if (strictNullChecks && !(type.flags & (3 | 131072)) && - !(exactOptionalPropertyTypes ? symbol.flags & 16777216 : getFalsyFlags(type) & 32768)) { + !(exactOptionalPropertyTypes ? symbol.flags & 16777216 : getTypeFacts(type) & 16777216)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional); } } @@ -61417,7 +62195,7 @@ var ts; error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } if (node.operator === 39) { - if (maybeTypeOfKind(operandType, 2112)) { + if (maybeTypeOfKindConsideringBaseConstraint(operandType, 2112)) { error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; @@ -61471,8 +62249,8 @@ var ts; } if (type.flags & 3145728) { var types = type.types; - for (var _i = 0, types_21 = types; _i < types_21.length; _i++) { - var t = types_21[_i]; + for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { + var t = types_20[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -61662,7 +62440,7 @@ var ts; var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && - !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768)) { + !(getTypeFacts(checkExpression(prop.objectAssignmentInitializer)) & 16777216)) { sourceType = getTypeWithFacts(sourceType, 524288); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); @@ -61675,6 +62453,9 @@ var ts; if (target.kind === 221 && target.operatorToken.kind === 63) { checkBinaryExpression(target, checkMode); target = target.left; + if (strictNullChecks) { + sourceType = getTypeWithFacts(sourceType, 524288); + } } if (target.kind === 205) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); @@ -61804,7 +62585,11 @@ var ts; var operator = operatorToken.kind; if (operator === 55 || operator === 56 || operator === 60) { if (operator === 55) { - var parent = ts.walkUpParenthesizedExpressions(node.parent); + var parent = node.parent; + while (parent.kind === 212 + || ts.isBinaryExpression(parent) && (parent.operatorToken.kind === 55 || parent.operatorToken.kind === 56)) { + parent = parent.parent; + } checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined); } checkTruthinessOfType(leftType, node.left); @@ -62004,6 +62789,10 @@ var ts; case 35: case 36: case 37: + if (ts.isLiteralExpressionOfObject(left) || ts.isLiteralExpressionOfObject(right)) { + var eqType = operator === 34 || operator === 36; + error(errorNode, ts.Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true"); + } reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; case 102: @@ -62023,7 +62812,7 @@ var ts; case 56: case 75: { var resultType_3 = getTypeFacts(leftType) & 8388608 ? - getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2) : + getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2) : leftType; if (operator === 75) { checkAssignmentOperator(rightType); @@ -62256,7 +63045,7 @@ var ts; type = anyType; addLazyDiagnostic(function () { if (noImplicitAny && !ts.expressionResultIsUnused(node)) { - var contextualType = getContextualType(node); + var contextualType = getContextualType(node, undefined); if (!contextualType || isTypeAny(contextualType)) { error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation); } @@ -62297,7 +63086,7 @@ var ts; texts.push(span.literal.text); types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType); } - return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; + return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node, undefined) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; } function isTemplateLiteralContextualType(type) { return !!(type.flags & (128 | 134217728) || @@ -62320,7 +63109,7 @@ var ts; if (inferenceContext && inferenceContext.intraExpressionInferenceSites) { inferenceContext.intraExpressionInferenceSites = undefined; } - var result = maybeTypeOfKind(type, 2944) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? + var result = maybeTypeOfKind(type, 2944) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node, undefined)) ? getRegularTypeOfLiteralType(type) : type; return result; } @@ -62424,7 +63213,7 @@ var ts; var type = checkExpression(node, checkMode, forceTuple); return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) : isTypeAssertion(node) ? type : - getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node)); + getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node, undefined) : contextualType, node, undefined)); } function checkPropertyAssignment(node, checkMode) { if (node.name.kind === 162) { @@ -62510,8 +63299,8 @@ var ts; var result = []; var oldTypeParameters; var newTypeParameters; - for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { - var tp = typeParameters_2[_i]; + for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) { + var tp = typeParameters_3[_i]; var name = tp.symbol.escapedName; if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) { var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name); @@ -62804,12 +63593,14 @@ var ts; error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types); } else if (modifiers === 32768 || modifiers === 65536) { - var source = createMarkerType(symbol, typeParameter, modifiers === 65536 ? markerSubType : markerSuperType); - var target = createMarkerType(symbol, typeParameter, modifiers === 65536 ? markerSuperType : markerSubType); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes", "checkTypeParameterDeferred", { parent: getTypeId(getDeclaredTypeOfSymbol(symbol)), id: getTypeId(typeParameter) }); + var source = createMarkerType(symbol, typeParameter, modifiers === 65536 ? markerSubTypeForCheck : markerSuperTypeForCheck); + var target = createMarkerType(symbol, typeParameter, modifiers === 65536 ? markerSuperTypeForCheck : markerSubTypeForCheck); var saveVarianceTypeParameter = typeParameter; varianceTypeParameter = typeParameter; checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); varianceTypeParameter = saveVarianceTypeParameter; + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } } } @@ -62826,7 +63617,7 @@ var ts; error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } - if (node.questionToken && ts.isBindingPattern(node.name) && func.body) { + if ((node.questionToken || isJSDocOptionalParameter(node)) && ts.isBindingPattern(node.name) && func.body) { error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature); } if (node.name && ts.isIdentifier(node.name) && (node.name.escapedText === "this" || node.name.escapedText === "new")) { @@ -63119,7 +63910,7 @@ var ts; var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { var indexSignatureMap_1 = new ts.Map(); - var _loop_27 = function (declaration) { + var _loop_29 = function (declaration) { if (declaration.parameters.length === 1 && declaration.parameters[0].type) { forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) { var entry = indexSignatureMap_1.get(getTypeId(type)); @@ -63134,7 +63925,7 @@ var ts; }; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - _loop_27(declaration); + _loop_29(declaration); } indexSignatureMap_1.forEach(function (entry) { if (entry.declarations.length > 1) { @@ -63164,6 +63955,9 @@ var ts; function checkMethodDeclaration(node) { if (!checkGrammarMethod(node)) checkGrammarComputedPropertyName(node.name); + if (ts.isMethodDeclaration(node) && node.asteriskToken && ts.isIdentifier(node.name) && ts.idText(node.name) === "constructor") { + error(node.name, ts.Diagnostics.Class_constructor_may_not_be_a_generator); + } checkFunctionOrMethodDeclaration(node); if (ts.hasSyntacticModifier(node, 128) && node.kind === 169 && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); @@ -63269,6 +64063,9 @@ var ts; return !!ts.forEachChild(node, nodeImmediatelyReferencesSuperOrThis); } function checkAccessorDeclaration(node) { + if (ts.isIdentifier(node.name) && ts.idText(node.name) === "constructor") { + error(node.name, ts.Diagnostics.Class_constructor_may_not_be_an_accessor); + } addLazyDiagnostic(checkAccessorDeclarationDiagnostics); checkSourceElement(node.body); setNodeLinksForPrivateIdentifierScope(node); @@ -63320,6 +64117,12 @@ var ts; function checkMissingDeclaration(node) { checkDecorators(node); } + function getEffectiveTypeArgumentAtIndex(node, typeParameters, index) { + if (index < typeParameters.length) { + return getTypeFromTypeNode(node.typeArguments[index]); + } + return getEffectiveTypeArguments(node, typeParameters)[index]; + } function getEffectiveTypeArguments(node, typeParameters) { return fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(node)); } @@ -63891,7 +64694,7 @@ var ts; var promisedType = getPromisedTypeOfPromise(type, errorNode); return promisedType && getAwaitedType(promisedType, errorNode, diagnosticMessage, arg0); } - function getPromisedTypeOfPromise(type, errorNode) { + function getPromisedTypeOfPromise(type, errorNode, thisTypeForErrorOut) { if (isTypeAny(type)) { return undefined; } @@ -63916,7 +64719,29 @@ var ts; } return undefined; } - var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152); + var thisTypeForError; + var candidates; + for (var _i = 0, thenSignatures_1 = thenSignatures; _i < thenSignatures_1.length; _i++) { + var thenSignature = thenSignatures_1[_i]; + var thisType = getThisTypeOfSignature(thenSignature); + if (thisType && thisType !== voidType && !isTypeRelatedTo(type, thisType, subtypeRelation)) { + thisTypeForError = thisType; + } + else { + candidates = ts.append(candidates, thenSignature); + } + } + if (!candidates) { + ts.Debug.assertIsDefined(thisTypeForError); + if (thisTypeForErrorOut) { + thisTypeForErrorOut.value = thisTypeForError; + } + if (errorNode) { + error(errorNode, ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1, typeToString(type), typeToString(thisTypeForError)); + } + return undefined; + } + var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(candidates, getTypeOfFirstParameterOfSignature)), 2097152); if (isTypeAny(onfulfilledParameterType)) { return undefined; } @@ -63955,20 +64780,32 @@ var ts; isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] : type; } - function createAwaitedTypeIfNeeded(type) { - if (isTypeAny(type)) { - return type; - } - if (isAwaitedTypeInstantiation(type)) { - return type; + function isAwaitedTypeNeeded(type) { + if (isTypeAny(type) || isAwaitedTypeInstantiation(type)) { + return false; } if (isGenericObjectType(type)) { var baseConstraint = getBaseConstraintOfType(type); - if (!baseConstraint || (baseConstraint.flags & 3) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) { - var awaitedSymbol = getGlobalAwaitedSymbol(true); - if (awaitedSymbol) { - return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]); - } + if (baseConstraint ? + baseConstraint.flags & 3 || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) : + maybeTypeOfKind(type, 8650752)) { + return true; + } + } + return false; + } + function tryCreateAwaitedType(type) { + var awaitedSymbol = getGlobalAwaitedSymbol(true); + if (awaitedSymbol) { + return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]); + } + return undefined; + } + function createAwaitedTypeIfNeeded(type) { + if (isAwaitedTypeNeeded(type)) { + var awaitedType = tryCreateAwaitedType(type); + if (awaitedType) { + return awaitedType; } } ts.Debug.assert(getPromisedTypeOfPromise(type) === undefined, "type provided should not be a non-generic 'promise'-like."); @@ -63990,10 +64827,23 @@ var ts; return typeAsAwaitable.awaitedTypeOfType; } if (type.flags & 1048576) { + if (awaitedTypeStack.lastIndexOf(type.id) >= 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method); + } + return undefined; + } var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias; - return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper); + awaitedTypeStack.push(type.id); + var mapped = mapType(type, mapper); + awaitedTypeStack.pop(); + return typeAsAwaitable.awaitedTypeOfType = mapped; } - var promisedType = getPromisedTypeOfPromise(type); + if (isAwaitedTypeNeeded(type)) { + return typeAsAwaitable.awaitedTypeOfType = type; + } + var thisTypeForErrorOut = { value: undefined }; + var promisedType = getPromisedTypeOfPromise(type, undefined, thisTypeForErrorOut); if (promisedType) { if (type.id === promisedType.id || awaitedTypeStack.lastIndexOf(promisedType.id) >= 0) { if (errorNode) { @@ -64012,7 +64862,12 @@ var ts; if (isThenableType(type)) { if (errorNode) { ts.Debug.assertIsDefined(diagnosticMessage); - error(errorNode, diagnosticMessage, arg0); + var chain = void 0; + if (thisTypeForErrorOut.value) { + chain = ts.chainDiagnosticMessages(chain, ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1, typeToString(type), typeToString(thisTypeForErrorOut.value)); + } + chain = ts.chainDiagnosticMessages(chain, diagnosticMessage, arg0); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, chain)); } return undefined; } @@ -64154,8 +65009,8 @@ var ts; } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_22 = types; _i < types_22.length; _i++) { - var typeNode = types_22[_i]; + for (var _i = 0, types_21 = types; _i < types_21.length; _i++) { + var typeNode = types_21[_i]; while (typeNode.kind === 191 || typeNode.kind === 197) { typeNode = typeNode.type; } @@ -64187,16 +65042,16 @@ var ts; return ts.isRestParameter(node) ? ts.getRestParameterElementType(typeNode) : typeNode; } function checkDecorators(node) { - if (!node.decorators) { - return; - } - if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { + if (!ts.canHaveDecorators(node) || !ts.hasDecorators(node) || !node.modifiers || !ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { return; } if (!compilerOptions.experimentalDecorators) { error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning); } - var firstDecorator = node.decorators[0]; + var firstDecorator = ts.find(node.modifiers, ts.isDecorator); + if (!firstDecorator) { + return; + } checkExternalEmitHelpers(firstDecorator, 8); if (node.kind === 164) { checkExternalEmitHelpers(firstDecorator, 32); @@ -64239,7 +65094,12 @@ var ts; break; } } - ts.forEach(node.decorators, checkDecorator); + for (var _f = 0, _g = node.modifiers; _f < _g.length; _f++) { + var modifier = _g[_f]; + if (ts.isDecorator(modifier)) { + checkDecorator(modifier); + } + } } function checkFunctionDeclaration(node) { addLazyDiagnostic(checkFunctionDeclarationDiagnostics); @@ -64269,6 +65129,11 @@ var ts; function checkJSDocTypeTag(node) { checkSourceElement(node.typeExpression); } + function checkJSDocLinkLikeTag(node) { + if (node.name) { + resolveJSDocMemberName(node.name, true); + } + } function checkJSDocParameterTag(node) { checkSourceElement(node.typeExpression); } @@ -64480,8 +65345,8 @@ var ts; return; var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); var seenParentsWithEveryUnused = new ts.Set(); - for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) { - var typeParameter = typeParameters_3[_i]; + for (var _i = 0, typeParameters_4 = typeParameters; _i < typeParameters_4.length; _i++) { + var typeParameter = typeParameters_4[_i]; if (!isTypeParameterUnused(typeParameter)) continue; var name = ts.idText(typeParameter.name); @@ -64629,6 +65494,21 @@ var ts; } }); } + function checkPotentialUncheckedRenamedBindingElementsInTypes() { + var _a; + for (var _i = 0, potentialUnusedRenamedBindingElementsInTypes_1 = potentialUnusedRenamedBindingElementsInTypes; _i < potentialUnusedRenamedBindingElementsInTypes_1.length; _i++) { + var node = potentialUnusedRenamedBindingElementsInTypes_1[_i]; + if (!((_a = getSymbolOfNode(node)) === null || _a === void 0 ? void 0 : _a.isReferenced)) { + var wrappingDeclaration = ts.walkUpBindingElementsAndPatterns(node); + ts.Debug.assert(ts.isParameterDeclaration(wrappingDeclaration), "Only parameter declaration should be checked here"); + var diagnostic = ts.createDiagnosticForNode(node.name, ts.Diagnostics._0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation, ts.declarationNameToString(node.name), ts.declarationNameToString(node.propertyName)); + if (!wrappingDeclaration.type) { + ts.addRelatedInfo(diagnostic, ts.createFileDiagnostic(ts.getSourceFileOfNode(wrappingDeclaration), wrappingDeclaration.end, 1, ts.Diagnostics.We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here, ts.declarationNameToString(node.propertyName))); + } + diagnostics.add(diagnostic); + } + } + } function bindingNameText(name) { switch (name.kind) { case 79: @@ -64866,11 +65746,18 @@ var ts; } if (node.name.kind === 162) { checkComputedPropertyName(node.name); - if (node.initializer) { + if (ts.hasOnlyExpressionInitializer(node) && node.initializer) { checkExpressionCached(node.initializer); } } if (ts.isBindingElement(node)) { + if (node.propertyName && + ts.isIdentifier(node.name) && + ts.isParameterDeclaration(node) && + ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + potentialUnusedRenamedBindingElementsInTypes.push(node); + return; + } if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5) { checkExternalEmitHelpers(node, 4); } @@ -64899,13 +65786,13 @@ var ts; } ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.isParameterDeclaration(node) && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (ts.isParameter(node) && node.initializer && 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)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 243; - var needCheckWidenedType = node.name.elements.length === 0; + var needCheckInitializer = ts.hasOnlyExpressionInitializer(node) && node.initializer && node.parent.parent.kind !== 243; + var needCheckWidenedType = !ts.some(node.name.elements, ts.not(ts.isOmittedExpression)); if (needCheckInitializer || needCheckWidenedType) { var widenedType = getWidenedTypeForVariableLikeDeclaration(node); if (needCheckInitializer) { @@ -64935,7 +65822,7 @@ var ts; } var type = convertAutoToAny(getTypeOfSymbol(symbol)); if (node === symbol.valueDeclaration) { - var initializer = ts.getEffectiveInitializer(node); + var initializer = ts.hasOnlyExpressionInitializer(node) && ts.getEffectiveInitializer(node); if (initializer) { var isJSObjectLiteralInitializer = ts.isInJSFile(node) && ts.isObjectLiteralExpression(initializer) && @@ -64958,7 +65845,7 @@ var ts; !(symbol.flags & 67108864)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType); } - if (node.initializer) { + if (ts.hasOnlyExpressionInitializer(node) && node.initializer) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, undefined); } if (symbol.valueDeclaration && !areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { @@ -65046,7 +65933,7 @@ var ts; return; var type = checkTruthinessExpression(location); var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression); - if (getFalsyFlags(type) || isPropertyExpressionCast) + if (!(getTypeFacts(type) & 4194304) || isPropertyExpressionCast) return; var callSignatures = getSignaturesOfType(type, 0); var isPromise = !!getAwaitedTypeOfPromise(type); @@ -65412,17 +66299,28 @@ var ts; return type[cacheKey] = cachedTypes; } function getIterationTypesOfIterable(type, use, errorNode) { + var _a, _b; if (isTypeAny(type)) { return anyIterationTypes; } if (!(type.flags & 1048576)) { - var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode); + var errorOutputContainer = errorNode ? { errors: undefined } : undefined; + var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer); if (iterationTypes_1 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2)); + var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2)); + if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) { + ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false)); + } } return undefined; } + else if ((_a = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _a === void 0 ? void 0 : _a.length) { + for (var _i = 0, _c = errorOutputContainer.errors; _i < _c.length; _i++) { + var diag = _c[_i]; + diagnostics.add(diag); + } + } return iterationTypes_1; } var cacheKey = use & 2 ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; @@ -65430,19 +66328,27 @@ var ts; if (cachedTypes) return cachedTypes === noIterationTypes ? undefined : cachedTypes; var allIterationTypes; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var constituent = _a[_i]; - var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode); + for (var _d = 0, _e = type.types; _d < _e.length; _d++) { + var constituent = _e[_d]; + var errorOutputContainer = errorNode ? { errors: undefined } : undefined; + var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode, errorOutputContainer); if (iterationTypes_2 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2)); + var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2)); + if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) { + ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false)); + } } setCachedIterationTypes(type, cacheKey, noIterationTypes); return undefined; } - else { - allIterationTypes = ts.append(allIterationTypes, iterationTypes_2); + else if ((_b = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _b === void 0 ? void 0 : _b.length) { + for (var _f = 0, _g = errorOutputContainer.errors; _f < _g.length; _f++) { + var diag = _g[_f]; + diagnostics.add(diag); + } } + allIterationTypes = ts.append(allIterationTypes, iterationTypes_2); } var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes; setCachedIterationTypes(type, cacheKey, iterationTypes); @@ -65459,46 +66365,57 @@ var ts; } return createIterationTypes(getAwaitedType(yieldType, errorNode) || anyType, getAwaitedType(returnType, errorNode) || anyType, nextType); } - function getIterationTypesOfIterableWorker(type, use, errorNode) { + function getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer) { if (isTypeAny(type)) { return anyIterationTypes; } + var noCache = false; if (use & 2) { var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) || getIterationTypesOfIterableFast(type, asyncIterationTypesResolver); if (iterationTypes) { - return use & 8 ? - getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : - iterationTypes; + if (iterationTypes === noIterationTypes && errorNode) { + noCache = true; + } + else { + return use & 8 ? + getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : + iterationTypes; + } } } if (use & 1) { var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) || getIterationTypesOfIterableFast(type, syncIterationTypesResolver); if (iterationTypes) { - if (use & 2) { - if (iterationTypes !== noIterationTypes) { - return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode)); - } + if (iterationTypes === noIterationTypes && errorNode) { + noCache = true; } else { - return iterationTypes; + if (use & 2) { + if (iterationTypes !== noIterationTypes) { + iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode); + return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes); + } + } + else { + return iterationTypes; + } } } } if (use & 2) { - var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode); + var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode, errorOutputContainer, noCache); if (iterationTypes !== noIterationTypes) { return iterationTypes; } } if (use & 1) { - var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode); + var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode, errorOutputContainer, noCache); if (iterationTypes !== noIterationTypes) { if (use & 2) { - return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes - ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode) - : noIterationTypes); + iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode); + return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes); } else { return iterationTypes; @@ -65512,7 +66429,7 @@ var ts; } function getIterationTypesOfGlobalIterableType(globalType, resolver) { var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) || - getIterationTypesOfIterableSlow(globalType, resolver, undefined); + getIterationTypesOfIterableSlow(globalType, resolver, undefined, undefined, false); return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes; } function getIterationTypesOfIterableFast(type, resolver) { @@ -65533,34 +66450,41 @@ var ts; var uniqueType = ctorType && getTypeOfPropertyOfType(getTypeOfSymbol(ctorType), ts.escapeLeadingUnderscores(symbolName)); return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@".concat(symbolName); } - function getIterationTypesOfIterableSlow(type, resolver, errorNode) { + function getIterationTypesOfIterableSlow(type, resolver, errorNode, errorOutputContainer, noCache) { var _a; var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); var methodType = method && !(method.flags & 16777216) ? getTypeOfSymbol(method) : undefined; if (isTypeAny(methodType)) { - return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); + return noCache ? anyIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); } var signatures = methodType ? getSignaturesOfType(methodType, 0) : undefined; if (!ts.some(signatures)) { - return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes); + return noCache ? noIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes); } var iteratorType = getIntersectionType(ts.map(signatures, getReturnTypeOfSignature)); - var iterationTypes = (_a = getIterationTypesOfIterator(iteratorType, resolver, errorNode)) !== null && _a !== void 0 ? _a : noIterationTypes; - return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes); + var iterationTypes = (_a = getIterationTypesOfIteratorWorker(iteratorType, resolver, errorNode, errorOutputContainer, noCache)) !== null && _a !== void 0 ? _a : noIterationTypes; + return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes); } function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) { var message = allowAsyncIterables ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator; - errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type)); + return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type)); } - function getIterationTypesOfIterator(type, resolver, errorNode) { + function getIterationTypesOfIterator(type, resolver, errorNode, errorOutputContainer) { + return getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, false); + } + function getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, noCache) { if (isTypeAny(type)) { return anyIterationTypes; } var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) || - getIterationTypesOfIteratorFast(type, resolver) || - getIterationTypesOfIteratorSlow(type, resolver, errorNode); + getIterationTypesOfIteratorFast(type, resolver); + if (iterationTypes === noIterationTypes && errorNode) { + iterationTypes = undefined; + noCache = true; + } + iterationTypes !== null && iterationTypes !== void 0 ? iterationTypes : (iterationTypes = getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache)); return iterationTypes === noIterationTypes ? undefined : iterationTypes; } function getIterationTypesOfIteratorCached(type, resolver) { @@ -65571,7 +66495,7 @@ var ts; if (isReferenceToType(type, globalType)) { var yieldType = getTypeArguments(type)[0]; var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) || - getIterationTypesOfIteratorSlow(globalType, resolver, undefined); + getIterationTypesOfIteratorSlow(globalType, resolver, undefined, undefined, false); var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType; return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType)); } @@ -65616,8 +66540,8 @@ var ts; } return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(yieldType, returnType || voidType, undefined)); } - function getIterationTypesOfMethod(type, resolver, methodName, errorNode) { - var _a, _b, _c, _d; + function getIterationTypesOfMethod(type, resolver, methodName, errorNode, errorOutputContainer) { + var _a, _b, _c, _d, _e, _f; var method = getPropertyOfType(type, methodName); if (!method && methodName !== "next") { return undefined; @@ -65634,15 +66558,21 @@ var ts; var diagnostic = methodName === "next" ? resolver.mustHaveANextMethodDiagnostic : resolver.mustBeAMethodDiagnostic; - error(errorNode, diagnostic, methodName); + if (errorOutputContainer) { + (_a = errorOutputContainer.errors) !== null && _a !== void 0 ? _a : (errorOutputContainer.errors = []); + errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, diagnostic, methodName)); + } + else { + error(errorNode, diagnostic, methodName); + } } - return methodName === "next" ? anyIterationTypes : undefined; + return methodName === "next" ? noIterationTypes : undefined; } if ((methodType === null || methodType === void 0 ? void 0 : methodType.symbol) && methodSignatures.length === 1) { var globalGeneratorType = resolver.getGlobalGeneratorType(false); var globalIteratorType = resolver.getGlobalIteratorType(false); - var isGeneratorMethod = ((_b = (_a = globalGeneratorType.symbol) === null || _a === void 0 ? void 0 : _a.members) === null || _b === void 0 ? void 0 : _b.get(methodName)) === methodType.symbol; - var isIteratorMethod = !isGeneratorMethod && ((_d = (_c = globalIteratorType.symbol) === null || _c === void 0 ? void 0 : _c.members) === null || _d === void 0 ? void 0 : _d.get(methodName)) === methodType.symbol; + var isGeneratorMethod = ((_c = (_b = globalGeneratorType.symbol) === null || _b === void 0 ? void 0 : _b.members) === null || _c === void 0 ? void 0 : _c.get(methodName)) === methodType.symbol; + var isIteratorMethod = !isGeneratorMethod && ((_e = (_d = globalIteratorType.symbol) === null || _d === void 0 ? void 0 : _d.members) === null || _e === void 0 ? void 0 : _e.get(methodName)) === methodType.symbol; if (isGeneratorMethod || isIteratorMethod) { var globalType = isGeneratorMethod ? globalGeneratorType : globalIteratorType; var mapper = methodType.mapper; @@ -65676,7 +66606,13 @@ var ts; var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType); if (iterationTypes === noIterationTypes) { if (errorNode) { - error(errorNode, resolver.mustHaveAValueDiagnostic, methodName); + if (errorOutputContainer) { + (_f = errorOutputContainer.errors) !== null && _f !== void 0 ? _f : (errorOutputContainer.errors = []); + errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, resolver.mustHaveAValueDiagnostic, methodName)); + } + else { + error(errorNode, resolver.mustHaveAValueDiagnostic, methodName); + } } yieldType = anyType; returnTypes = ts.append(returnTypes, anyType); @@ -65687,13 +66623,13 @@ var ts; } return createIterationTypes(yieldType, getUnionType(returnTypes), nextType); } - function getIterationTypesOfIteratorSlow(type, resolver, errorNode) { + function getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache) { var iterationTypes = combineIterationTypes([ - getIterationTypesOfMethod(type, resolver, "next", errorNode), - getIterationTypesOfMethod(type, resolver, "return", errorNode), - getIterationTypesOfMethod(type, resolver, "throw", errorNode), + getIterationTypesOfMethod(type, resolver, "next", errorNode, errorOutputContainer), + getIterationTypesOfMethod(type, resolver, "return", errorNode, errorOutputContainer), + getIterationTypesOfMethod(type, resolver, "throw", errorNode, errorOutputContainer), ]); - return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes); + return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes); } function getIterationTypeOfGeneratorFunctionReturnType(kind, returnType, isAsyncGenerator) { if (isTypeAny(returnType)) { @@ -65709,7 +66645,7 @@ var ts; var use = isAsyncGenerator ? 2 : 1; var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver; return getIterationTypesOfIterable(type, use, undefined) || - getIterationTypesOfIterator(type, resolver, undefined); + getIterationTypesOfIterator(type, resolver, undefined, undefined); } function checkBreakOrContinueStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) @@ -65718,9 +66654,14 @@ var ts; function unwrapReturnType(returnType, functionFlags) { var isGenerator = !!(functionFlags & 1); var isAsync = !!(functionFlags & 2); - return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1, returnType, isAsync) || errorType : - isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : - returnType; + if (isGenerator) { + var returnIterationType = getIterationTypeOfGeneratorFunctionReturnType(1, returnType, isAsync); + if (!returnIterationType) { + return errorType; + } + return isAsync ? getAwaitedTypeNoAlias(unwrapAwaitedType(returnIterationType)) : returnIterationType; + } + return isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType; } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func)); @@ -65921,19 +66862,24 @@ var ts; } var indexInfos = getApplicableIndexInfos(type, propNameType); var interfaceDeclaration = ts.getObjectFlags(type) & 2 ? ts.getDeclarationOfKind(type.symbol, 258) : undefined; - var localPropDeclaration = declaration && declaration.kind === 221 || - name && name.kind === 162 || getParentOfSymbol(prop) === type.symbol ? declaration : undefined; - var _loop_28 = function (info) { + var propDeclaration = declaration && declaration.kind === 221 || + name && name.kind === 162 ? declaration : undefined; + var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined; + var _loop_30 = function (info) { var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined; var errorNode = localPropDeclaration || localIndexDeclaration || (interfaceDeclaration && !ts.some(getBaseTypes(type), function (base) { return !!getPropertyOfObjectType(base, prop.escapedName) && !!getIndexTypeOfType(base, info.keyType); }) ? interfaceDeclaration : undefined); if (errorNode && !isTypeAssignableTo(propType, info.type)) { - error(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type)); + var diagnostic = createError(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type)); + if (propDeclaration && errorNode !== propDeclaration) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(propDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(prop))); + } + diagnostics.add(diagnostic); } }; for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) { var info = indexInfos_9[_i]; - _loop_28(info); + _loop_30(info); } } function checkIndexConstraintForIndexSignature(type, checkInfo) { @@ -65941,7 +66887,7 @@ var ts; var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType); var interfaceDeclaration = ts.getObjectFlags(type) & 2 ? ts.getDeclarationOfKind(type.symbol, 258) : undefined; var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined; - var _loop_29 = function (info) { + var _loop_31 = function (info) { if (info === checkInfo) return "continue"; var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined; @@ -65953,7 +66899,7 @@ var ts; }; for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) { var info = indexInfos_10[_i]; - _loop_29(info); + _loop_31(info); } } function checkTypeNameIsReserved(name, message) { @@ -66122,8 +67068,9 @@ var ts; registerForUnusedIdentifiersCheck(node); } function checkClassDeclaration(node) { - if (ts.some(node.decorators) && ts.some(node.members, function (p) { return ts.hasStaticModifier(p) && ts.isPrivateIdentifierClassElementDeclaration(p); })) { - grammarErrorOnNode(node.decorators[0], ts.Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator); + var firstDecorator = ts.find(node.modifiers, ts.isDecorator); + if (firstDecorator && ts.some(node.members, function (p) { return ts.hasStaticModifier(p) && ts.isPrivateIdentifierClassElementDeclaration(p); })) { + grammarErrorOnNode(firstDecorator, ts.Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator); } if (!node.name && !ts.hasSyntacticModifier(node, 512)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); @@ -66247,7 +67194,7 @@ var ts; var baseTypes = baseTypeNode && getBaseTypes(type); var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined; var baseStaticType = getBaseConstructorTypeOfClass(type); - var _loop_30 = function (member) { + var _loop_32 = function (member) { if (ts.hasAmbientModifier(member)) { return "continue"; } @@ -66262,7 +67209,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_30(member); + _loop_32(member); } } function checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, member, memberIsParameterProperty, reportErrors) { @@ -66337,7 +67284,7 @@ var ts; } function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { var issuedMemberError = false; - var _loop_31 = function (member) { + var _loop_33 = function (member) { if (ts.isStatic(member)) { return "continue"; } @@ -66355,7 +67302,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_31(member); + _loop_33(member); } if (!issuedMemberError) { checkTypeAssignableTo(typeWithThis, baseWithThis, node.name || node, broadDiag); @@ -66400,17 +67347,16 @@ var ts; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { - var _a, _b; + var _a, _b, _c, _d; var baseProperties = getPropertiesOfType(baseType); - basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { - var baseProperty = baseProperties_1[_i]; + var _loop_34 = function (baseProperty) { var base = getTargetSymbol(baseProperty); if (base.flags & 4194304) { - continue; + return "continue"; } var baseSymbol = getPropertyOfObjectType(type, base.escapedName); if (!baseSymbol) { - continue; + return "continue"; } var derived = getTargetSymbol(baseSymbol); var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base); @@ -66418,14 +67364,14 @@ var ts; if (derived === base) { var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128))) { - for (var _c = 0, _d = getBaseTypes(type); _c < _d.length; _c++) { - var otherBaseType = _d[_c]; + for (var _e = 0, _f = getBaseTypes(type); _e < _f.length; _e++) { + var otherBaseType = _f[_e]; if (otherBaseType === baseType) continue; var baseSymbol_1 = getPropertyOfObjectType(otherBaseType, base.escapedName); var derivedElsewhere = baseSymbol_1 && getTargetSymbol(baseSymbol_1); if (derivedElsewhere && derivedElsewhere !== base) { - continue basePropertyCheck; + return "continue-basePropertyCheck"; } } if (derivedClassDecl.kind === 226) { @@ -66439,16 +67385,18 @@ var ts; else { var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); if (baseDeclarationFlags & 8 || derivedDeclarationFlags & 8) { - continue; + return "continue"; } var errorMessage = void 0; var basePropertyFlags = base.flags & 98308; var derivedPropertyFlags = derived.flags & 98308; if (basePropertyFlags && derivedPropertyFlags) { - if (baseDeclarationFlags & 128 && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) - || base.valueDeclaration && base.valueDeclaration.parent.kind === 258 + if ((ts.getCheckFlags(base) & 6 + ? (_a = base.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return isPropertyAbstractOrInterface(d, baseDeclarationFlags); }) + : (_b = base.declarations) === null || _b === void 0 ? void 0 : _b.every(function (d) { return isPropertyAbstractOrInterface(d, baseDeclarationFlags); })) + || ts.getCheckFlags(base) & 262144 || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { - continue; + return "continue"; } var overriddenInstanceProperty = basePropertyFlags !== 4 && derivedPropertyFlags === 4; var overriddenInstanceAccessor = basePropertyFlags === 4 && derivedPropertyFlags !== 4; @@ -66459,12 +67407,12 @@ var ts; error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type)); } else if (useDefineForClassFields) { - var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 167 && !d.initializer; }); + var uninitialized = (_c = derived.declarations) === null || _c === void 0 ? void 0 : _c.find(function (d) { return d.kind === 167 && !d.initializer; }); if (uninitialized && !(derived.flags & 33554432) && !(baseDeclarationFlags & 128) && !(derivedDeclarationFlags & 128) - && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216); }))) { + && !((_d = derived.declarations) === null || _d === void 0 ? void 0 : _d.some(function (d) { return !!(d.flags & 16777216); }))) { var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); var propName = uninitialized.name; if (uninitialized.exclamationToken @@ -66477,11 +67425,11 @@ var ts; } } } - continue; + return "continue"; } else if (isPrototypeProperty(base)) { if (isPrototypeProperty(derived) || derived.flags & 4) { - continue; + return "continue"; } else { ts.Debug.assert(!!(derived.flags & 98304)); @@ -66496,9 +67444,20 @@ var ts; } error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } + }; + basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { + var baseProperty = baseProperties_1[_i]; + var state_10 = _loop_34(baseProperty); + switch (state_10) { + case "continue-basePropertyCheck": continue basePropertyCheck; + } } } - function getNonInterhitedProperties(type, baseTypes, properties) { + function isPropertyAbstractOrInterface(declaration, baseDeclarationFlags) { + return baseDeclarationFlags & 128 && (!ts.isPropertyDeclaration(declaration) || !declaration.initializer) + || ts.isInterfaceDeclaration(declaration.parent); + } + function getNonInheritedProperties(type, baseTypes, properties) { if (!ts.length(baseTypes)) { return properties; } @@ -66567,7 +67526,7 @@ var ts; var propName = member.name; if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 3 || getFalsyFlags(type) & 32768)) { + if (!(type.flags & 3 || containsUndefinedType(type))) { if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) { error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName)); } @@ -66591,7 +67550,7 @@ var ts; ts.setParent(reference, staticBlock); reference.flowNode = staticBlock.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - if (!(getFalsyFlags(flowType) & 32768)) { + if (!containsUndefinedType(flowType)) { return true; } } @@ -66606,7 +67565,7 @@ var ts; ts.setParent(reference, constructor); reference.flowNode = constructor.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - return !(getFalsyFlags(flowType) & 32768); + return !containsUndefinedType(flowType); } function checkInterfaceDeclaration(node) { if (!checkGrammarDecoratorsAndModifiers(node)) @@ -67075,10 +68034,35 @@ var ts; return true; } function checkAliasSymbol(node) { + var _a, _b, _c, _d, _e; var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); if (target !== unknownSymbol) { symbol = getMergedSymbol(symbol.exportSymbol || symbol); + if (ts.isInJSFile(node) && !(target.flags & 111551) && !ts.isTypeOnlyImportOrExportDeclaration(node)) { + var errorNode = ts.isImportOrExportSpecifier(node) ? node.propertyName || node.name : + ts.isNamedDeclaration(node) ? node.name : + node; + ts.Debug.assert(node.kind !== 274); + if (node.kind === 275) { + var diag = error(errorNode, ts.Diagnostics.Types_cannot_appear_in_export_declarations_in_JavaScript_files); + var alreadyExportedSymbol = (_b = (_a = ts.getSourceFileOfNode(node).symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.get((node.propertyName || node.name).escapedText); + if (alreadyExportedSymbol === target) { + var exportingDeclaration = (_c = alreadyExportedSymbol.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isJSDocNode); + if (exportingDeclaration) { + ts.addRelatedInfo(diag, ts.createDiagnosticForNode(exportingDeclaration, ts.Diagnostics._0_is_automatically_exported_here, ts.unescapeLeadingUnderscores(alreadyExportedSymbol.escapedName))); + } + } + } + else { + ts.Debug.assert(node.kind !== 254); + var importDeclaration = ts.findAncestor(node, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration)); + var moduleSpecifier = (_e = (importDeclaration && ((_d = ts.tryGetModuleSpecifierFromDeclaration(importDeclaration)) === null || _d === void 0 ? void 0 : _d.text))) !== null && _e !== void 0 ? _e : "..."; + var importedIdentifier = ts.unescapeLeadingUnderscores(ts.isIdentifier(errorNode) ? errorNode.escapedText : symbol.escapedName); + error(errorNode, ts.Diagnostics._0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation, importedIdentifier, "import(\"".concat(moduleSpecifier, "\").").concat(importedIdentifier)); + } + return; + } var excludedMeanings = (symbol.flags & (111551 | 1048576) ? 111551 : 0) | (symbol.flags & 788968 ? 788968 : 0) | (symbol.flags & 1920 ? 1920 : 0); @@ -67375,7 +68359,9 @@ var ts; error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { - markExportAsReferenced(node); + if (!node.isTypeOnly && !node.parent.parent.isTypeOnly) { + markExportAsReferenced(node); + } var target = symbol && (symbol.flags & 2097152 ? resolveAlias(symbol) : symbol); if (!target || target === unknownSymbol || target.flags & 111551) { checkExpressionCached(node.propertyName || node.name); @@ -67506,12 +68492,16 @@ var ts; } } function checkSourceElementWorker(node) { - if (ts.isInJSFile(node)) { - ts.forEach(node.jsDoc, function (_a) { - var tags = _a.tags; - return ts.forEach(tags, checkSourceElement); + ts.forEach(node.jsDoc, function (_a) { + var comment = _a.comment, tags = _a.tags; + checkJSDocCommentWorker(comment); + ts.forEach(tags, function (tag) { + checkJSDocCommentWorker(tag.comment); + if (ts.isInJSFile(node)) { + checkSourceElement(tag); + } }); - } + }); var kind = node.kind; if (cancellationToken) { switch (kind) { @@ -67595,6 +68585,10 @@ var ts; return checkJSDocTemplateTag(node); case 343: return checkJSDocTypeTag(node); + case 324: + case 325: + case 326: + return checkJSDocLinkLikeTag(node); case 340: return checkJSDocParameterTag(node); case 347: @@ -67688,6 +68682,15 @@ var ts; return checkMissingDeclaration(node); } } + function checkJSDocCommentWorker(node) { + if (ts.isArray(node)) { + ts.forEach(node, function (tag) { + if (ts.isJSDocLinkLike(tag)) { + checkSourceElement(tag); + } + }); + } + } function checkJSDocTypeIsInJsFile(node) { if (!ts.isInJSFile(node)) { grammarErrorOnNode(node, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); @@ -67831,6 +68834,7 @@ var ts; ts.clear(potentialNewTargetCollisions); ts.clear(potentialWeakMapSetCollisions); ts.clear(potentialReflectCollisions); + ts.clear(potentialUnusedRenamedBindingElementsInTypes); ts.forEach(node.statements, checkSourceElement); checkSourceElement(node.endOfFileToken); checkDeferredNodes(node); @@ -67845,6 +68849,9 @@ var ts; } }); } + if (!node.isDeclarationFile) { + checkPotentialUncheckedRenamedBindingElementsInTypes(); + } }); if (compilerOptions.importsNotUsedAsValues === 2 && !node.isDeclarationFile && @@ -68171,7 +69178,7 @@ var ts; if (!result && isJSDoc_1) { var container = ts.findAncestor(name, ts.or(ts.isClassLike, ts.isInterfaceDeclaration)); if (container) { - return resolveJSDocMemberName(name, getSymbolOfNode(container)); + return resolveJSDocMemberName(name, false, getSymbolOfNode(container)); } } return result; @@ -68209,10 +69216,10 @@ var ts; } return undefined; } - function resolveJSDocMemberName(name, container) { + function resolveJSDocMemberName(name, ignoreErrors, container) { if (ts.isEntityName(name)) { var meaning = 788968 | 1920 | 111551; - var symbol = resolveEntityName(name, meaning, false, true, ts.getHostSignatureFromJSDoc(name)); + var symbol = resolveEntityName(name, meaning, ignoreErrors, true, ts.getHostSignatureFromJSDoc(name)); if (!symbol && ts.isIdentifier(name) && container) { symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning)); } @@ -68220,7 +69227,7 @@ var ts; return symbol; } } - var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left); + var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left, ignoreErrors, container); var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText; if (left) { var proto = left.flags & 111551 && getPropertyOfType(getTypeOfSymbol(left), "prototype"); @@ -69086,10 +70093,16 @@ var ts; if (!fileToDirective) { return undefined; } - var meaning = 788968 | 1920; - if ((node.kind === 79 && isInTypeQuery(node)) || (node.kind === 206 && !isInHeritageClause(node))) { + var meaning; + if (node.parent.kind === 162) { meaning = 111551 | 1048576; } + else { + meaning = 788968 | 1920; + if ((node.kind === 79 && isInTypeQuery(node)) || (node.kind === 206 && !isInHeritageClause(node))) { + meaning = 111551 | 1048576; + } + } var symbol = resolveEntityName(node, meaning, true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; } @@ -69343,7 +70356,10 @@ var ts; return checkGrammarDecorators(node) || checkGrammarModifiers(node); } function checkGrammarDecorators(node) { - if (!node.decorators) { + if (ts.canHaveIllegalDecorators(node) && ts.some(node.illegalDecorators)) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); + } + if (!ts.canHaveDecorators(node) || !ts.hasDecorators(node)) { return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { @@ -69356,7 +70372,7 @@ var ts; } else if (node.kind === 172 || node.kind === 173) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); - if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { + if (ts.hasDecorators(accessors.firstAccessor) && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); } } @@ -69371,6 +70387,8 @@ var ts; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; + if (ts.isDecorator(modifier)) + continue; if (modifier.kind !== 145) { if (node.kind === 166 || node.kind === 168) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); @@ -69650,6 +70668,13 @@ var ts; case 164: case 163: return false; + case 170: + case 296: + case 297: + case 264: + case 179: + case 276: + return true; default: if (node.parent.kind === 262 || node.parent.kind === 305) { return false; @@ -69660,20 +70685,26 @@ var ts; case 257: case 180: return nodeHasAnyModifiersExcept(node, 126); + case 226: case 258: case 237: case 259: - case 170: return true; case 260: return nodeHasAnyModifiersExcept(node, 85); default: - ts.Debug.fail(); + ts.Debug.assertNever(node); } } } function nodeHasAnyModifiersExcept(node, allowedModifier) { - return node.modifiers.length > 1 || node.modifiers[0].kind !== allowedModifier; + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var modifier = _a[_i]; + if (ts.isDecorator(modifier)) + continue; + return modifier.kind !== allowedModifier; + } + return false; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { @@ -69955,19 +70986,25 @@ var ts; if (name.kind === 80) { grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); } - if (prop.modifiers) { + if (ts.canHaveModifiers(prop) && prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 131 || prop.kind !== 169) { + if (ts.isModifier(mod) && (mod.kind !== 131 || prop.kind !== 169)) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } + else if (ts.canHaveIllegalModifiers(prop) && prop.modifiers) { + for (var _d = 0, _e = prop.modifiers; _d < _e.length; _d++) { + var mod = _e[_d]; + grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); + } + } var currentKind = void 0; switch (prop.kind) { case 297: - checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); case 296: + checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8) { checkGrammarNumericLiteral(name); @@ -70381,9 +71418,6 @@ var ts; else { return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } - if (!isConstOrReadonly || isInvalidInitializer) { - return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } } } function checkGrammarVariableDeclaration(node) { @@ -70544,7 +71578,7 @@ var ts; } } function checkGrammarConstructorTypeAnnotation(node) { - var type = ts.getEffectiveReturnTypeNode(node); + var type = node.type || ts.getEffectiveReturnTypeNode(node); if (type) { return grammarErrorOnNode(type, ts.Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration); } @@ -70568,6 +71602,7 @@ var ts; if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } + ts.Debug.assertNode(node, ts.isPropertySignature); if (node.initializer) { return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } @@ -70576,6 +71611,7 @@ var ts; if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } + ts.Debug.assertNode(node, ts.isPropertySignature); if (node.initializer) { return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } @@ -70897,7 +71933,6 @@ var ts; if (nodes === undefined || visitor === undefined) { return nodes; } - var updated; var length = nodes.length; if (start === undefined || start < 0) { start = 0; @@ -70909,18 +71944,48 @@ var ts; var pos = -1; var end = -1; if (start > 0 || count < length) { - updated = []; hasTrailingComma = nodes.hasTrailingComma && start + count === length; } + else { + pos = nodes.pos; + end = nodes.end; + hasTrailingComma = nodes.hasTrailingComma; + } + var updated = visitArrayWorker(nodes, visitor, test, start, count); + if (updated !== nodes) { + var updatedArray = ts.factory.createNodeArray(updated, hasTrailingComma); + ts.setTextRangePosEnd(updatedArray, pos, end); + return updatedArray; + } + return nodes; + } + ts.visitNodes = visitNodes; + function visitArray(nodes, visitor, test, start, count) { + if (nodes === undefined) { + return nodes; + } + var length = nodes.length; + if (start === undefined || start < 0) { + start = 0; + } + if (count === undefined || count > length - start) { + count = length - start; + } + return visitArrayWorker(nodes, visitor, test, start, count); + } + ts.visitArray = visitArray; + function visitArrayWorker(nodes, visitor, test, start, count) { + var updated; + var length = nodes.length; + if (start > 0 || count < length) { + updated = []; + } for (var i = 0; i < count; i++) { var node = nodes[i + start]; var visited = node !== undefined ? visitor(node) : undefined; if (updated !== undefined || visited === undefined || visited !== node) { if (updated === undefined) { updated = nodes.slice(0, i); - hasTrailingComma = nodes.hasTrailingComma; - pos = nodes.pos; - end = nodes.end; } if (visited) { if (ts.isArray(visited)) { @@ -70937,14 +72002,8 @@ var ts; } } } - if (updated) { - var updatedArray = ts.factory.createNodeArray(updated, hasTrailingComma); - ts.setTextRangePosEnd(updatedArray, pos, end); - return updatedArray; - } - return nodes; + return updated !== null && updated !== void 0 ? updated : nodes; } - ts.visitNodes = visitNodes; function visitLexicalEnvironment(statements, visitor, context, start, ensureUseStrict, nodesVisitor) { if (nodesVisitor === void 0) { nodesVisitor = visitNodes; } context.startLexicalEnvironment(); @@ -71000,14 +72059,14 @@ var ts; factory.createConditionalExpression(factory.createStrictEquality(factory.getGeneratedNameForNode(parameter), factory.createVoidZero()), undefined, parameter.initializer, undefined, factory.getGeneratedNameForNode(parameter)) : factory.getGeneratedNameForNode(parameter)), ]))); - return factory.updateParameterDeclaration(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, factory.getGeneratedNameForNode(parameter), parameter.questionToken, parameter.type, undefined); + return factory.updateParameterDeclaration(parameter, parameter.modifiers, parameter.dotDotDotToken, factory.getGeneratedNameForNode(parameter), parameter.questionToken, parameter.type, undefined); } function addDefaultValueAssignmentForInitializer(parameter, name, initializer, context) { var factory = context.factory; context.addInitializationStatement(factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([ factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer) | 1536)), parameter), 1536)) ]), parameter), 1 | 32 | 384 | 1536))); - return factory.updateParameterDeclaration(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, parameter.name, parameter.questionToken, parameter.type, undefined); + return factory.updateParameterDeclaration(parameter, parameter.modifiers, parameter.dotDotDotToken, parameter.name, parameter.questionToken, parameter.type, undefined); } function visitFunctionBody(node, visitor, context, nodeVisitor) { if (nodeVisitor === void 0) { nodeVisitor = visitNode; } @@ -71066,7 +72125,7 @@ var ts; return factory.updateTypeParameterDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode)); case 164: ts.Debug.type(node); - return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); + return factory.updateParameterDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); case 165: ts.Debug.type(node); return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); @@ -71075,27 +72134,27 @@ var ts; return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); case 167: ts.Debug.type(node); - return factory.updatePropertyDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isQuestionOrExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); + return factory.updatePropertyDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isQuestionOrExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); case 168: ts.Debug.type(node); return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); case 169: ts.Debug.type(node); - return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); + return factory.updateMethodDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); case 171: ts.Debug.type(node); - return factory.updateConstructorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); + return factory.updateConstructorDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); case 172: ts.Debug.type(node); - return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); + return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); case 173: ts.Debug.type(node); - return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); + return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); case 170: ts.Debug.type(node); context.startLexicalEnvironment(); context.suspendLexicalEnvironment(); - return factory.updateClassStaticBlockDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitFunctionBody(node.body, visitor, context, nodeVisitor)); + return factory.updateClassStaticBlockDeclaration(node, visitFunctionBody(node.body, visitor, context, nodeVisitor)); case 174: ts.Debug.type(node); return factory.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); @@ -71104,7 +72163,7 @@ var ts; return factory.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); case 176: ts.Debug.type(node); - return factory.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); + return factory.updateIndexSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); case 177: ts.Debug.type(node); return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor, ts.isAssertsKeyword), nodeVisitor(node.parameterName, visitor, ts.isIdentifierOrThisTypeNode), nodeVisitor(node.type, visitor, ts.isTypeNode)); @@ -71149,13 +72208,13 @@ var ts; return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); case 200: ts.Debug.type(node); - return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); + return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); case 295: ts.Debug.type(node); return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine); case 197: ts.Debug.type(node); - return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isDotDotDotToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isQuestionToken), visitNode(node.type, visitor, ts.isTypeNode)); + return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); case 191: ts.Debug.type(node); return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); @@ -71218,7 +72277,7 @@ var ts; return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); case 210: ts.Debug.type(node); - return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); + return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); case 211: ts.Debug.type(node); return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); @@ -71266,7 +72325,7 @@ var ts; return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); case 226: ts.Debug.type(node); - return factory.updateClassExpression(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); + return factory.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); case 228: ts.Debug.type(node); return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); @@ -71345,22 +72404,22 @@ var ts; return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); case 256: ts.Debug.type(node); - return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); + return factory.updateFunctionDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); case 257: ts.Debug.type(node); - return factory.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); + return factory.updateClassDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); case 258: ts.Debug.type(node); - return factory.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); + return factory.updateInterfaceDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); case 259: ts.Debug.type(node); - return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); + return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); case 260: ts.Debug.type(node); - return factory.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); + return factory.updateEnumDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); case 261: ts.Debug.type(node); - return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isModuleName), nodeVisitor(node.body, visitor, ts.isModuleBody)); + return factory.updateModuleDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isModuleName), nodeVisitor(node.body, visitor, ts.isModuleBody)); case 262: ts.Debug.type(node); return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); @@ -71372,10 +72431,10 @@ var ts; return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); case 265: ts.Debug.type(node); - return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference)); + return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference)); case 266: ts.Debug.type(node); - return factory.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); + return factory.updateImportDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); case 293: ts.Debug.type(node); return factory.updateAssertClause(node, nodesVisitor(node.elements, visitor, ts.isAssertEntry), node.multiLine); @@ -71399,10 +72458,10 @@ var ts; return factory.updateImportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); case 271: ts.Debug.type(node); - return factory.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression)); + return factory.updateExportAssignment(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression)); case 272: ts.Debug.type(node); - return factory.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, ts.isNamedExportBindings), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); + return factory.updateExportDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, ts.isNamedExportBindings), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); case 273: ts.Debug.type(node); return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); @@ -72382,6 +73441,92 @@ var ts; return !ts.isStatic(member) && ts.isMethodOrAccessor(member) && ts.isPrivateIdentifier(member.name); } ts.isNonStaticMethodOrAccessorWithPrivateName = isNonStaticMethodOrAccessorWithPrivateName; + function getDecoratorsOfParameters(node) { + var decorators; + if (node) { + var parameters = node.parameters; + var firstParameterIsThis = parameters.length > 0 && ts.parameterIsThisKeyword(parameters[0]); + var firstParameterOffset = firstParameterIsThis ? 1 : 0; + var numParameters = firstParameterIsThis ? parameters.length - 1 : parameters.length; + for (var i = 0; i < numParameters; i++) { + var parameter = parameters[i + firstParameterOffset]; + if (decorators || ts.hasDecorators(parameter)) { + if (!decorators) { + decorators = new Array(numParameters); + } + decorators[i] = ts.getDecorators(parameter); + } + } + } + return decorators; + } + function getAllDecoratorsOfClass(node) { + var decorators = ts.getDecorators(node); + var parameters = getDecoratorsOfParameters(ts.getFirstConstructorWithBody(node)); + if (!ts.some(decorators) && !ts.some(parameters)) { + return undefined; + } + return { + decorators: decorators, + parameters: parameters + }; + } + ts.getAllDecoratorsOfClass = getAllDecoratorsOfClass; + function getAllDecoratorsOfClassElement(member, parent) { + switch (member.kind) { + case 172: + case 173: + return getAllDecoratorsOfAccessors(member, parent); + case 169: + return getAllDecoratorsOfMethod(member); + case 167: + return getAllDecoratorsOfProperty(member); + default: + return undefined; + } + } + ts.getAllDecoratorsOfClassElement = getAllDecoratorsOfClassElement; + function getAllDecoratorsOfAccessors(accessor, parent) { + if (!accessor.body) { + return undefined; + } + var _a = ts.getAllAccessorDeclarations(parent.members, accessor), firstAccessor = _a.firstAccessor, secondAccessor = _a.secondAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + var firstAccessorWithDecorators = ts.hasDecorators(firstAccessor) ? firstAccessor : + secondAccessor && ts.hasDecorators(secondAccessor) ? secondAccessor : + undefined; + if (!firstAccessorWithDecorators || accessor !== firstAccessorWithDecorators) { + return undefined; + } + var decorators = ts.getDecorators(firstAccessorWithDecorators); + var parameters = getDecoratorsOfParameters(setAccessor); + if (!ts.some(decorators) && !ts.some(parameters)) { + return undefined; + } + return { + decorators: decorators, + parameters: parameters, + getDecorators: getAccessor && ts.getDecorators(getAccessor), + setDecorators: setAccessor && ts.getDecorators(setAccessor) + }; + } + function getAllDecoratorsOfMethod(method) { + if (!method.body) { + return undefined; + } + var decorators = ts.getDecorators(method); + var parameters = getDecoratorsOfParameters(method); + if (!ts.some(decorators) && !ts.some(parameters)) { + return undefined; + } + return { decorators: decorators, parameters: parameters }; + } + function getAllDecoratorsOfProperty(property) { + var decorators = ts.getDecorators(property); + if (!ts.some(decorators)) { + return undefined; + } + return { decorators: decorators }; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -72583,8 +73728,8 @@ var ts; if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) { var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element); if (flattenContext.level >= 1 - && !(element.transformFlags & (16384 | 32768)) - && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 | 32768)) + && !(element.transformFlags & (32768 | 65536)) + && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (32768 | 65536)) && !ts.isComputedPropertyName(propertyName)) { bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor)); } @@ -72631,7 +73776,7 @@ var ts; for (var i = 0; i < numElements; i++) { var element = elements[i]; if (flattenContext.level >= 1) { - if (element.transformFlags & 32768 || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { + if (element.transformFlags & 65536 || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { flattenContext.hasTransformedPriorElement = true; var temp = flattenContext.context.factory.createTempVariable(undefined); if (flattenContext.hoistTempVariables) { @@ -72799,9 +73944,9 @@ var ts; var factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); - var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks"); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); + var typeSerializer = compilerOptions.emitDecoratorMetadata ? ts.createRuntimeTypeSerializer(context) : undefined; var previousOnEmitNode = context.onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; @@ -72812,11 +73957,9 @@ var ts; var currentNamespace; var currentNamespaceContainerName; var currentLexicalScope; - var currentNameScope; var currentScopeFirstDeclarationsOfName; var currentClassHasParameterProperties; var enabledSubstitutions; - var classAliases; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { @@ -72845,7 +73988,6 @@ var ts; } function saveStateAndInvoke(node, f) { var savedCurrentScope = currentLexicalScope; - var savedCurrentNameScope = currentNameScope; var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; var savedCurrentClassHasParameterProperties = currentClassHasParameterProperties; onBeforeVisitNode(node); @@ -72854,7 +73996,6 @@ var ts; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; } currentLexicalScope = savedCurrentScope; - currentNameScope = savedCurrentNameScope; currentClassHasParameterProperties = savedCurrentClassHasParameterProperties; return visited; } @@ -72865,7 +74006,6 @@ var ts; case 262: case 235: currentLexicalScope = node; - currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; case 257: @@ -72879,9 +74019,6 @@ var ts; else { ts.Debug.assert(node.kind === 257 || ts.hasSyntacticModifier(node, 512)); } - if (ts.isClassDeclaration(node)) { - currentNameScope = node; - } break; } } @@ -72945,28 +74082,53 @@ var ts; } return node; } - function classElementVisitor(node) { - return saveStateAndInvoke(node, classElementVisitorWorker); + function getClassElementVisitor(parent) { + return function (node) { return saveStateAndInvoke(node, function (n) { return classElementVisitorWorker(n, parent); }); }; } - function classElementVisitorWorker(node) { + function classElementVisitorWorker(node, parent) { switch (node.kind) { case 171: return visitConstructor(node); case 167: - return visitPropertyDeclaration(node); - case 176: + return visitPropertyDeclaration(node, parent); case 172: + return visitGetAccessor(node, parent); case 173: + return visitSetAccessor(node, parent); case 169: + return visitMethodDeclaration(node, parent); case 170: - return visitorWorker(node); + return ts.visitEachChild(node, visitor, context); case 234: return node; + case 176: + return; + default: + return ts.Debug.failBadSyntaxKind(node); + } + } + function getObjectLiteralElementVisitor(parent) { + return function (node) { return saveStateAndInvoke(node, function (n) { return objectLiteralElementVisitorWorker(n, parent); }); }; + } + function objectLiteralElementVisitorWorker(node, parent) { + switch (node.kind) { + case 296: + case 297: + case 298: + return visitor(node); + case 172: + return visitGetAccessor(node, parent); + case 173: + return visitSetAccessor(node, parent); + case 169: + return visitMethodDeclaration(node, parent); default: return ts.Debug.failBadSyntaxKind(node); } } function modifierVisitor(node) { + if (ts.isDecorator(node)) + return undefined; if (ts.modifierToFlag(node.kind) & 116958) { return undefined; } @@ -73022,16 +74184,11 @@ var ts; case 195: case 196: case 176: - case 165: return undefined; case 259: return factory.createNotEmittedStatement(node); - case 167: - return visitPropertyDeclaration(node); case 264: return undefined; - case 171: - return visitConstructor(node); case 258: return factory.createNotEmittedStatement(node); case 257: @@ -73042,12 +74199,15 @@ var ts; return visitHeritageClause(node); case 228: return visitExpressionWithTypeArguments(node); + case 205: + return visitObjectLiteralExpression(node); + case 171: + case 167: case 169: - return visitMethodDeclaration(node); case 172: - return visitGetAccessor(node); case 173: - return visitSetAccessor(node); + case 170: + return ts.Debug.fail("Class and object literal elements must be visited with their respective visitors"); case 256: return visitFunctionDeclaration(node); case 213: @@ -73093,6 +74253,9 @@ var ts; !ts.isJsonSourceFile(node); return factory.updateSourceFile(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, 0, alwaysStrict)); } + function visitObjectLiteralExpression(node) { + return factory.updateObjectLiteralExpression(node, ts.visitNodes(node.properties, getObjectLiteralElementVisitor(node), ts.isObjectLiteralElement)); + } function getClassFacts(node, staticProperties) { var facts = 0; if (ts.some(staticProperties)) @@ -73115,17 +74278,17 @@ var ts; return facts; } function hasTypeScriptClassSyntax(node) { - return !!(node.transformFlags & 4096); + return !!(node.transformFlags & 8192); } function isClassLikeDeclarationWithTypeScriptSyntax(node) { - return ts.some(node.decorators) + return ts.hasDecorators(node) || ts.some(node.typeParameters) || ts.some(node.heritageClauses, hasTypeScriptClassSyntax) || ts.some(node.members, hasTypeScriptClassSyntax); } function visitClassDeclaration(node) { if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1))) { - return ts.visitEachChild(node, visitor, context); + return factory.updateClassDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement)); } var staticProperties = ts.getProperties(node, true, true); var facts = getClassFacts(node, staticProperties); @@ -73133,13 +74296,18 @@ var ts; context.startLexicalEnvironment(); } var name = node.name || (facts & 5 ? factory.getGeneratedNameForNode(node) : undefined); - var classStatement = facts & 2 - ? createClassDeclarationHeadWithDecorators(node, name) - : createClassDeclarationHeadWithoutDecorators(node, name, facts); + var allDecorators = ts.getAllDecoratorsOfClass(node); + var decorators = transformAllDecoratorsOfDeclaration(node, node, allDecorators); + var modifiers = !(facts & 128) + ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier) + : ts.elideNodes(factory, node.modifiers); + var classStatement = factory.updateClassDeclaration(node, ts.concatenate(decorators, modifiers), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node)); + var emitFlags = ts.getEmitFlags(node); + if (facts & 1) { + emitFlags |= 32; + } + ts.setEmitFlags(classStatement, emitFlags); var statements = [classStatement]; - addClassElementDecorationStatements(statements, node, false); - addClassElementDecorationStatements(statements, node, true); - addConstructorDecorationStatement(statements, node); if (facts & 128) { var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19); var localName = factory.getInternalName(node); @@ -73179,47 +74347,12 @@ var ts; } return ts.singleOrMany(statements); } - function createClassDeclarationHeadWithoutDecorators(node, name, facts) { - var modifiers = !(facts & 128) - ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier) - : undefined; - var classDeclaration = factory.createClassDeclaration(undefined, modifiers, name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node)); - var emitFlags = ts.getEmitFlags(node); - if (facts & 1) { - emitFlags |= 32; - } - ts.setTextRange(classDeclaration, node); - ts.setOriginalNode(classDeclaration, node); - ts.setEmitFlags(classDeclaration, emitFlags); - return classDeclaration; - } - function createClassDeclarationHeadWithDecorators(node, name) { - var location = ts.moveRangePastDecorators(node); - var classAlias = getClassAliasIfNeeded(node); - var declName = languageVersion <= 2 ? - factory.getInternalName(node, false, true) : - factory.getLocalName(node, false, true); - var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node); - var classExpression = factory.createClassExpression(undefined, undefined, name, undefined, heritageClauses, members); - ts.setOriginalNode(classExpression, node); - ts.setTextRange(classExpression, location); - var statement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(declName, undefined, undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression) - ], 1)); - ts.setOriginalNode(statement, node); - ts.setTextRange(statement, location); - ts.setCommentRange(statement, node); - return statement; - } function visitClassExpression(node) { - if (!isClassLikeDeclarationWithTypeScriptSyntax(node)) { - return ts.visitEachChild(node, visitor, context); - } - var classExpression = factory.createClassExpression(undefined, undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node)); - ts.setOriginalNode(classExpression, node); - ts.setTextRange(classExpression, node); - return classExpression; + var allDecorators = ts.getAllDecoratorsOfClass(node); + var decorators = transformAllDecoratorsOfDeclaration(node, node, allDecorators); + return factory.updateClassExpression(node, decorators, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), isClassLikeDeclarationWithTypeScriptSyntax(node) ? + transformClassMembers(node) : + ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement)); } function transformClassMembers(node) { var members = []; @@ -73230,225 +74363,86 @@ var ts; for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) { var parameter = parametersWithPropertyAssignments_1[_i]; if (ts.isIdentifier(parameter.name)) { - members.push(ts.setOriginalNode(factory.createPropertyDeclaration(undefined, undefined, parameter.name, undefined, undefined, undefined), parameter)); + members.push(ts.setOriginalNode(factory.createPropertyDeclaration(undefined, parameter.name, undefined, undefined, undefined), parameter)); } } } - ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement)); + ts.addRange(members, ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement)); return ts.setTextRange(factory.createNodeArray(members), node.members); } - function getDecoratedClassElements(node, isStatic) { - return ts.filter(node.members, isStatic ? function (m) { return isStaticDecoratedClassElement(m, node); } : function (m) { return isInstanceDecoratedClassElement(m, node); }); - } - function isStaticDecoratedClassElement(member, parent) { - return isDecoratedClassElement(member, true, parent); - } - function isInstanceDecoratedClassElement(member, parent) { - return isDecoratedClassElement(member, false, parent); - } - function isDecoratedClassElement(member, isStaticElement, parent) { - return ts.nodeOrChildIsDecorated(member, parent) - && isStaticElement === ts.isStatic(member); - } - function getDecoratorsOfParameters(node) { - var decorators; - if (node) { - var parameters = node.parameters; - var firstParameterIsThis = parameters.length > 0 && ts.parameterIsThisKeyword(parameters[0]); - var firstParameterOffset = firstParameterIsThis ? 1 : 0; - var numParameters = firstParameterIsThis ? parameters.length - 1 : parameters.length; - for (var i = 0; i < numParameters; i++) { - var parameter = parameters[i + firstParameterOffset]; - if (decorators || parameter.decorators) { - if (!decorators) { - decorators = new Array(numParameters); - } - decorators[i] = parameter.decorators; - } - } - } - return decorators; - } - function getAllDecoratorsOfConstructor(node) { - var decorators = node.decorators; - var parameters = getDecoratorsOfParameters(ts.getFirstConstructorWithBody(node)); - if (!decorators && !parameters) { - return undefined; - } - return { - decorators: decorators, - parameters: parameters - }; - } - function getAllDecoratorsOfClassElement(node, member) { - switch (member.kind) { - case 172: - case 173: - return getAllDecoratorsOfAccessors(node, member); - case 169: - return getAllDecoratorsOfMethod(member); - case 167: - return getAllDecoratorsOfProperty(member); - default: - return undefined; - } - } - function getAllDecoratorsOfAccessors(node, accessor) { - if (!accessor.body) { - return undefined; - } - var _a = ts.getAllAccessorDeclarations(node.members, accessor), firstAccessor = _a.firstAccessor, secondAccessor = _a.secondAccessor, setAccessor = _a.setAccessor; - var firstAccessorWithDecorators = firstAccessor.decorators ? firstAccessor : secondAccessor && secondAccessor.decorators ? secondAccessor : undefined; - if (!firstAccessorWithDecorators || accessor !== firstAccessorWithDecorators) { - return undefined; - } - var decorators = firstAccessorWithDecorators.decorators; - var parameters = getDecoratorsOfParameters(setAccessor); - if (!decorators && !parameters) { - return undefined; - } - return { decorators: decorators, parameters: parameters }; - } - function getAllDecoratorsOfMethod(method) { - if (!method.body) { - return undefined; - } - var decorators = method.decorators; - var parameters = getDecoratorsOfParameters(method); - if (!decorators && !parameters) { - return undefined; - } - return { decorators: decorators, parameters: parameters }; - } - function getAllDecoratorsOfProperty(property) { - var decorators = property.decorators; - if (!decorators) { - return undefined; - } - return { decorators: decorators }; - } function transformAllDecoratorsOfDeclaration(node, container, allDecorators) { + var _a, _b, _c, _d; if (!allDecorators) { return undefined; } - var decoratorExpressions = []; - ts.addRange(decoratorExpressions, ts.map(allDecorators.decorators, transformDecorator)); - ts.addRange(decoratorExpressions, ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter)); - addTypeMetadata(node, container, decoratorExpressions); - return decoratorExpressions; - } - function addClassElementDecorationStatements(statements, node, isStatic) { - ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), expressionToStatement)); - } - function generateClassElementDecorationExpressions(node, isStatic) { - var members = getDecoratedClassElements(node, isStatic); - var expressions; - for (var _i = 0, members_8 = members; _i < members_8.length; _i++) { - var member = members_8[_i]; - var expression = generateClassElementDecorationExpression(node, member); - if (expression) { - if (!expressions) { - expressions = [expression]; - } - else { - expressions.push(expression); - } - } - } - return expressions; - } - function generateClassElementDecorationExpression(node, member) { - var allDecorators = getAllDecoratorsOfClassElement(node, member); - var decoratorExpressions = transformAllDecoratorsOfDeclaration(member, node, allDecorators); - if (!decoratorExpressions) { - return undefined; - } - var prefix = getClassMemberPrefix(node, member); - var memberName = getExpressionForPropertyName(member, !ts.hasSyntacticModifier(member, 2)); - var descriptor = languageVersion > 0 - ? member.kind === 167 - ? factory.createVoidZero() - : factory.createNull() - : undefined; - var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor); - ts.setTextRange(helper, ts.moveRangePastDecorators(member)); - ts.setEmitFlags(helper, 1536); - return helper; - } - function addConstructorDecorationStatement(statements, node) { - var expression = generateConstructorDecorationExpression(node); - if (expression) { - statements.push(ts.setOriginalNode(factory.createExpressionStatement(expression), node)); - } - } - function generateConstructorDecorationExpression(node) { - var allDecorators = getAllDecoratorsOfConstructor(node); - var decoratorExpressions = transformAllDecoratorsOfDeclaration(node, node, allDecorators); - if (!decoratorExpressions) { - return undefined; - } - var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)]; - var localName = languageVersion <= 2 ? - factory.getInternalName(node, false, true) : - factory.getLocalName(node, false, true); - var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName); - var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate); - ts.setEmitFlags(expression, 1536); - ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node)); - return expression; - } - function transformDecorator(decorator) { - return ts.visitNode(decorator.expression, visitor, ts.isExpression); + var decorators = ts.visitArray(allDecorators.decorators, visitor, ts.isDecorator); + var parameterDecorators = ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter); + var metadataDecorators = ts.some(decorators) || ts.some(parameterDecorators) ? getTypeMetadata(node, container) : undefined; + var result = factory.createNodeArray(ts.concatenate(ts.concatenate(decorators, parameterDecorators), metadataDecorators)); + var pos = (_b = (_a = ts.firstOrUndefined(allDecorators.decorators)) === null || _a === void 0 ? void 0 : _a.pos) !== null && _b !== void 0 ? _b : -1; + var end = (_d = (_c = ts.lastOrUndefined(allDecorators.decorators)) === null || _c === void 0 ? void 0 : _c.end) !== null && _d !== void 0 ? _d : -1; + ts.setTextRangePosEnd(result, pos, end); + return result; } - function transformDecoratorsOfParameter(decorators, parameterOffset) { - var expressions; - if (decorators) { - expressions = []; - for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) { - var decorator = decorators_1[_i]; - var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset); - ts.setTextRange(helper, decorator.expression); + function transformDecoratorsOfParameter(parameterDecorators, parameterOffset) { + if (parameterDecorators) { + var decorators = []; + for (var _i = 0, parameterDecorators_1 = parameterDecorators; _i < parameterDecorators_1.length; _i++) { + var parameterDecorator = parameterDecorators_1[_i]; + var expression = ts.visitNode(parameterDecorator.expression, visitor, ts.isExpression); + var helper = emitHelpers().createParamHelper(expression, parameterOffset); + ts.setTextRange(helper, parameterDecorator.expression); ts.setEmitFlags(helper, 1536); - expressions.push(helper); + var decorator = factory.createDecorator(helper); + ts.setSourceMapRange(decorator, parameterDecorator.expression); + ts.setCommentRange(decorator, parameterDecorator.expression); + ts.setEmitFlags(decorator, 1536); + decorators.push(decorator); } + return decorators; } - return expressions; } - function addTypeMetadata(node, container, decoratorExpressions) { - if (USE_NEW_TYPE_METADATA_FORMAT) { - addNewTypeMetadata(node, container, decoratorExpressions); - } - else { - addOldTypeMetadata(node, container, decoratorExpressions); - } + function getTypeMetadata(node, container) { + return USE_NEW_TYPE_METADATA_FORMAT ? + getNewTypeMetadata(node, container) : + getOldTypeMetadata(node, container); } - function addOldTypeMetadata(node, container, decoratorExpressions) { - if (compilerOptions.emitDecoratorMetadata) { + function getOldTypeMetadata(node, container) { + if (typeSerializer) { + var decorators = void 0; if (shouldAddTypeMetadata(node)) { - decoratorExpressions.push(emitHelpers().createMetadataHelper("design:type", serializeTypeOfNode(node))); + var typeMetadata = emitHelpers().createMetadataHelper("design:type", typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node)); + decorators = ts.append(decorators, factory.createDecorator(typeMetadata)); } if (shouldAddParamTypesMetadata(node)) { - decoratorExpressions.push(emitHelpers().createMetadataHelper("design:paramtypes", serializeParameterTypesOfNode(node, container))); + var paramTypesMetadata = emitHelpers().createMetadataHelper("design:paramtypes", typeSerializer.serializeParameterTypesOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node, container)); + decorators = ts.append(decorators, factory.createDecorator(paramTypesMetadata)); } if (shouldAddReturnTypeMetadata(node)) { - decoratorExpressions.push(emitHelpers().createMetadataHelper("design:returntype", serializeReturnTypeOfNode(node))); + var returnTypeMetadata = emitHelpers().createMetadataHelper("design:returntype", typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node)); + decorators = ts.append(decorators, factory.createDecorator(returnTypeMetadata)); } + return decorators; } } - function addNewTypeMetadata(node, container, decoratorExpressions) { - if (compilerOptions.emitDecoratorMetadata) { + function getNewTypeMetadata(node, container) { + if (typeSerializer) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(factory.createPropertyAssignment("type", factory.createArrowFunction(undefined, undefined, [], undefined, factory.createToken(38), serializeTypeOfNode(node)))); + var typeProperty = factory.createPropertyAssignment("type", factory.createArrowFunction(undefined, undefined, [], undefined, factory.createToken(38), typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); + properties = ts.append(properties, typeProperty); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(undefined, undefined, [], undefined, factory.createToken(38), serializeParameterTypesOfNode(node, container)))); + var paramTypeProperty = factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(undefined, undefined, [], undefined, factory.createToken(38), typeSerializer.serializeParameterTypesOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node, container))); + properties = ts.append(properties, paramTypeProperty); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(undefined, undefined, [], undefined, factory.createToken(38), serializeReturnTypeOfNode(node)))); + var returnTypeProperty = factory.createPropertyAssignment("returnType", factory.createArrowFunction(undefined, undefined, [], undefined, factory.createToken(38), typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); + properties = ts.append(properties, returnTypeProperty); } if (properties) { - decoratorExpressions.push(emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, true))); + var typeInfoMetadata = emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, true)); + return [factory.createDecorator(typeInfoMetadata)]; } } } @@ -73474,262 +74468,6 @@ var ts; } return false; } - function getAccessorTypeNode(node) { - var accessors = resolver.getAllAccessorDeclarations(node); - return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor) - || accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor); - } - function serializeTypeOfNode(node) { - switch (node.kind) { - case 167: - case 164: - return serializeTypeNode(node.type); - case 173: - case 172: - return serializeTypeNode(getAccessorTypeNode(node)); - case 257: - case 226: - case 169: - return factory.createIdentifier("Function"); - default: - return factory.createVoidZero(); - } - } - function serializeParameterTypesOfNode(node, container) { - var valueDeclaration = ts.isClassLike(node) - ? ts.getFirstConstructorWithBody(node) - : ts.isFunctionLike(node) && ts.nodeIsPresent(node.body) - ? node - : undefined; - var expressions = []; - if (valueDeclaration) { - var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container); - var numParameters = parameters.length; - for (var i = 0; i < numParameters; i++) { - var parameter = parameters[i]; - if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") { - continue; - } - if (parameter.dotDotDotToken) { - expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type))); - } - else { - expressions.push(serializeTypeOfNode(parameter)); - } - } - } - return factory.createArrayLiteralExpression(expressions); - } - function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 172) { - var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; - if (setAccessor) { - return setAccessor.parameters; - } - } - return node.parameters; - } - function serializeReturnTypeOfNode(node) { - if (ts.isFunctionLike(node) && node.type) { - return serializeTypeNode(node.type); - } - else if (ts.isAsyncFunction(node)) { - return factory.createIdentifier("Promise"); - } - return factory.createVoidZero(); - } - function serializeTypeNode(node) { - if (node === undefined) { - return factory.createIdentifier("Object"); - } - switch (node.kind) { - case 114: - case 153: - case 143: - return factory.createVoidZero(); - case 191: - return serializeTypeNode(node.type); - case 179: - case 180: - return factory.createIdentifier("Function"); - case 183: - case 184: - return factory.createIdentifier("Array"); - case 177: - case 133: - return factory.createIdentifier("Boolean"); - case 198: - case 150: - return factory.createIdentifier("String"); - case 148: - return factory.createIdentifier("Object"); - case 196: - switch (node.literal.kind) { - case 10: - case 14: - return factory.createIdentifier("String"); - case 219: - case 8: - return factory.createIdentifier("Number"); - case 9: - return getGlobalBigIntNameWithFallback(); - case 110: - case 95: - return factory.createIdentifier("Boolean"); - case 104: - return factory.createVoidZero(); - default: - return ts.Debug.failBadSyntaxKind(node.literal); - } - case 147: - return factory.createIdentifier("Number"); - case 158: - return getGlobalBigIntNameWithFallback(); - case 151: - return languageVersion < 2 - ? getGlobalSymbolNameWithFallback() - : factory.createIdentifier("Symbol"); - case 178: - return serializeTypeReferenceNode(node); - case 188: - case 187: - return serializeTypeList(node.types); - case 189: - return serializeTypeList([node.trueType, node.falseType]); - case 193: - if (node.operator === 145) { - return serializeTypeNode(node.type); - } - break; - case 181: - case 194: - case 195: - case 182: - case 130: - case 155: - case 192: - case 200: - break; - case 312: - case 313: - case 317: - case 318: - case 319: - break; - case 314: - case 315: - case 316: - return serializeTypeNode(node.type); - default: - return ts.Debug.failBadSyntaxKind(node); - } - return factory.createIdentifier("Object"); - } - function serializeTypeList(types) { - var serializedUnion; - for (var _i = 0, types_23 = types; _i < types_23.length; _i++) { - var typeNode = types_23[_i]; - while (typeNode.kind === 191) { - typeNode = typeNode.type; - } - if (typeNode.kind === 143) { - continue; - } - if (!strictNullChecks && (typeNode.kind === 196 && typeNode.literal.kind === 104 || typeNode.kind === 153)) { - continue; - } - var serializedIndividual = serializeTypeNode(typeNode); - if (ts.isIdentifier(serializedIndividual) && serializedIndividual.escapedText === "Object") { - return serializedIndividual; - } - else if (serializedUnion) { - if (!ts.isIdentifier(serializedUnion) || - !ts.isIdentifier(serializedIndividual) || - serializedUnion.escapedText !== serializedIndividual.escapedText) { - return factory.createIdentifier("Object"); - } - } - else { - serializedUnion = serializedIndividual; - } - } - return serializedUnion || factory.createVoidZero(); - } - function serializeTypeReferenceNode(node) { - var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope); - switch (kind) { - case ts.TypeReferenceSerializationKind.Unknown: - if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) { - return factory.createIdentifier("Object"); - } - var serialized = serializeEntityNameAsExpressionFallback(node.typeName); - var temp = factory.createTempVariable(hoistVariableDeclaration); - return factory.createConditionalExpression(factory.createTypeCheck(factory.createAssignment(temp, serialized), "function"), undefined, temp, undefined, factory.createIdentifier("Object")); - case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: - return serializeEntityNameAsExpression(node.typeName); - case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType: - return factory.createVoidZero(); - case ts.TypeReferenceSerializationKind.BigIntLikeType: - return getGlobalBigIntNameWithFallback(); - case ts.TypeReferenceSerializationKind.BooleanType: - return factory.createIdentifier("Boolean"); - case ts.TypeReferenceSerializationKind.NumberLikeType: - return factory.createIdentifier("Number"); - case ts.TypeReferenceSerializationKind.StringLikeType: - return factory.createIdentifier("String"); - case ts.TypeReferenceSerializationKind.ArrayLikeType: - return factory.createIdentifier("Array"); - case ts.TypeReferenceSerializationKind.ESSymbolType: - return languageVersion < 2 - ? getGlobalSymbolNameWithFallback() - : factory.createIdentifier("Symbol"); - case ts.TypeReferenceSerializationKind.TypeWithCallSignature: - return factory.createIdentifier("Function"); - case ts.TypeReferenceSerializationKind.Promise: - return factory.createIdentifier("Promise"); - case ts.TypeReferenceSerializationKind.ObjectType: - return factory.createIdentifier("Object"); - default: - return ts.Debug.assertNever(kind); - } - } - function createCheckedValue(left, right) { - return factory.createLogicalAnd(factory.createStrictInequality(factory.createTypeOfExpression(left), factory.createStringLiteral("undefined")), right); - } - function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 79) { - var copied = serializeEntityNameAsExpression(node); - return createCheckedValue(copied, copied); - } - if (node.left.kind === 79) { - return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); - } - var left = serializeEntityNameAsExpressionFallback(node.left); - var temp = factory.createTempVariable(hoistVariableDeclaration); - return factory.createLogicalAnd(factory.createLogicalAnd(left.left, factory.createStrictInequality(factory.createAssignment(temp, left.right), factory.createVoidZero())), factory.createPropertyAccessExpression(temp, node.right)); - } - function serializeEntityNameAsExpression(node) { - switch (node.kind) { - case 79: - var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent); - name.original = undefined; - ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); - return name; - case 161: - return serializeQualifiedNameAsExpression(node); - } - } - function serializeQualifiedNameAsExpression(node) { - return factory.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left), node.right); - } - function getGlobalSymbolNameWithFallback() { - return factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("Symbol"), "function"), undefined, factory.createIdentifier("Symbol"), undefined, factory.createIdentifier("Object")); - } - function getGlobalBigIntNameWithFallback() { - return languageVersion < 99 - ? factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("BigInt"), "function"), undefined, factory.createIdentifier("BigInt"), undefined, factory.createIdentifier("Object")) - : factory.createIdentifier("BigInt"); - } function getExpressionForPropertyName(member, generateNameForComputedPropertyName) { var name = member.name; if (ts.isPrivateIdentifier(name)) { @@ -73749,7 +74487,7 @@ var ts; } function visitPropertyNameOfClassElement(member) { var name = member.name; - if (ts.isComputedPropertyName(name) && ((!ts.hasStaticModifier(member) && currentClassHasParameterProperties) || ts.some(member.decorators))) { + if (ts.isComputedPropertyName(name) && ((!ts.hasStaticModifier(member) && currentClassHasParameterProperties) || ts.hasDecorators(member))) { var expression = ts.visitNode(name.expression, visitor, ts.isExpression); var innerExpression = ts.skipPartiallyEmittedExpressions(expression); if (!ts.isSimpleInlineableExpression(innerExpression)) { @@ -73772,22 +74510,23 @@ var ts; function shouldEmitFunctionLikeDeclaration(node) { return !ts.nodeIsMissing(node.body); } - function visitPropertyDeclaration(node) { - if (node.flags & 16777216 || ts.hasSyntacticModifier(node, 128)) { + function visitPropertyDeclaration(node, parent) { + var isAmbient = node.flags & 16777216 || ts.hasSyntacticModifier(node, 128); + if (isAmbient && !ts.hasDecorators(node)) { return undefined; } - var updated = factory.updatePropertyDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), undefined, undefined, ts.visitNode(node.initializer, visitor)); - if (updated !== node) { - ts.setCommentRange(updated, node); - ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node)); + var allDecorators = ts.getAllDecoratorsOfClassElement(node, parent); + var decorators = transformAllDecoratorsOfDeclaration(node, parent, allDecorators); + if (isAmbient) { + return factory.updatePropertyDeclaration(node, ts.concatenate(decorators, factory.createModifiersFromModifierFlags(2)), ts.visitNode(node.name, visitor, ts.isPropertyName), undefined, undefined, undefined); } - return updated; + return factory.updatePropertyDeclaration(node, ts.concatenate(decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifierLike)), visitPropertyNameOfClassElement(node), undefined, undefined, ts.visitNode(node.initializer, visitor)); } function visitConstructor(node) { if (!shouldEmitFunctionLikeDeclaration(node)) { return undefined; } - return factory.updateConstructorDeclaration(node, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node)); + return factory.updateConstructorDeclaration(node, undefined, ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node)); } function transformConstructorBody(body, constructor) { var parametersWithPropertyAssignments = constructor && @@ -73809,7 +74548,8 @@ var ts; else { statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true); } - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount)); + var start = superStatementIndex >= 0 ? superStatementIndex + 1 : prologueStatementCount; + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, start)); statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), true); ts.setTextRange(block, body); @@ -73827,47 +74567,49 @@ var ts; ts.setEmitFlags(localName, 1536); return ts.startOnNewLine(ts.removeAllComments(ts.setTextRange(ts.setOriginalNode(factory.createExpressionStatement(factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createThis(), propertyName), node.name), localName)), node), ts.moveRangePos(node, -1)))); } - function visitMethodDeclaration(node) { + function visitMethodDeclaration(node, parent) { + if (!(node.transformFlags & 1)) { + return node; + } if (!shouldEmitFunctionLikeDeclaration(node)) { return undefined; } - var updated = factory.updateMethodDeclaration(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context)); - if (updated !== node) { - ts.setCommentRange(updated, node); - ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node)); - } - return updated; + var allDecorators = ts.isClassLike(parent) ? ts.getAllDecoratorsOfClassElement(node, parent) : undefined; + var decorators = ts.isClassLike(parent) ? transformAllDecoratorsOfDeclaration(node, parent, allDecorators) : undefined; + return factory.updateMethodDeclaration(node, ts.concatenate(decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifierLike)), node.asteriskToken, visitPropertyNameOfClassElement(node), undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context)); } function shouldEmitAccessorDeclaration(node) { return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128)); } - function visitGetAccessor(node) { + function visitGetAccessor(node, parent) { + if (!(node.transformFlags & 1)) { + return node; + } if (!shouldEmitAccessorDeclaration(node)) { return undefined; } - var updated = factory.updateGetAccessorDeclaration(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([])); - if (updated !== node) { - ts.setCommentRange(updated, node); - ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node)); - } - return updated; + var decorators = ts.isClassLike(parent) ? + transformAllDecoratorsOfDeclaration(node, parent, ts.getAllDecoratorsOfClassElement(node, parent)) : + undefined; + return factory.updateGetAccessorDeclaration(node, ts.concatenate(decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifierLike)), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([])); } - function visitSetAccessor(node) { + function visitSetAccessor(node, parent) { + if (!(node.transformFlags & 1)) { + return node; + } if (!shouldEmitAccessorDeclaration(node)) { return undefined; } - var updated = factory.updateSetAccessorDeclaration(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context), ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([])); - if (updated !== node) { - ts.setCommentRange(updated, node); - ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node)); - } - return updated; + var decorators = ts.isClassLike(parent) ? + transformAllDecoratorsOfDeclaration(node, parent, ts.getAllDecoratorsOfClassElement(node, parent)) : + undefined; + return factory.updateSetAccessorDeclaration(node, ts.concatenate(decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifierLike)), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context), ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([])); } function visitFunctionDeclaration(node) { if (!shouldEmitFunctionLikeDeclaration(node)) { return factory.createNotEmittedStatement(node); } - var updated = factory.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([])); + var updated = factory.updateFunctionDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([])); if (isExportOfNamespace(node)) { var statements = [updated]; addExportMemberAssignment(statements, node); @@ -73890,7 +74632,7 @@ var ts; if (ts.parameterIsThisKeyword(node)) { return undefined; } - var updated = factory.updateParameterDeclaration(node, undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); + var updated = factory.updateParameterDeclaration(node, ts.elideNodes(factory, node.modifiers), node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); if (updated !== node) { ts.setCommentRange(updated, node); ts.setTextRange(updated, ts.moveRangePastModifiers(node)); @@ -73984,7 +74726,7 @@ var ts; var localName = factory.getLocalName(node, false, true); moduleArg = factory.createAssignment(localName, moduleArg); } - var enumStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg])); + var enumStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg])); ts.setOriginalNode(enumStatement, node); if (varAdded) { ts.setSyntheticLeadingComments(enumStatement, undefined); @@ -74116,7 +74858,7 @@ var ts; var localName = factory.getLocalName(node, false, true); moduleArg = factory.createAssignment(localName, moduleArg); } - var moduleStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg])); + var moduleStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg])); ts.setOriginalNode(moduleStatement, node); if (varAdded) { ts.setSyntheticLeadingComments(moduleStatement, undefined); @@ -74187,7 +74929,7 @@ var ts; return importClause || compilerOptions.importsNotUsedAsValues === 1 || compilerOptions.importsNotUsedAsValues === 2 - ? factory.updateImportDeclaration(node, undefined, undefined, importClause, node.moduleSpecifier, node.assertClause) + ? factory.updateImportDeclaration(node, undefined, importClause, node.moduleSpecifier, node.assertClause) : undefined; } function visitImportClause(node) { @@ -74226,7 +74968,7 @@ var ts; compilerOptions.importsNotUsedAsValues === 2); var exportClause = ts.visitNode(node.exportClause, function (bindings) { return visitNamedExportBindings(bindings, allowEmpty); }, ts.isNamedExportBindings); return exportClause - ? factory.updateExportDeclaration(node, undefined, undefined, node.isTypeOnly, exportClause, node.moduleSpecifier, node.assertClause) + ? factory.updateExportDeclaration(node, undefined, node.isTypeOnly, exportClause, node.moduleSpecifier, node.assertClause) : undefined; } function visitNamedExports(node, allowEmpty) { @@ -74254,7 +74996,7 @@ var ts; if (ts.isExternalModuleImportEqualsDeclaration(node)) { var isReferenced = shouldEmitAliasDeclaration(node); if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1) { - return ts.setOriginalNode(ts.setTextRange(factory.createImportDeclaration(undefined, undefined, undefined, node.moduleReference.expression, undefined), node), node); + return ts.setOriginalNode(ts.setTextRange(factory.createImportDeclaration(undefined, undefined, node.moduleReference.expression, undefined), node), node); } return isReferenced ? ts.visitEachChild(node, visitor, context) : undefined; } @@ -74286,9 +75028,6 @@ var ts; return isExternalModuleExport(node) && ts.hasSyntacticModifier(node, 512); } - function expressionToStatement(expression) { - return factory.createExpressionStatement(expression); - } function addExportMemberAssignment(statements, node) { var expression = factory.createAssignment(factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true), factory.getLocalName(node)); ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end)); @@ -74313,36 +75052,12 @@ var ts; function getNamespaceContainerName(node) { return factory.getGeneratedNameForNode(node); } - function getClassAliasIfNeeded(node) { - if (resolver.getNodeCheckFlags(node) & 16777216) { - enableSubstitutionForClassAliases(); - var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default"); - classAliases[ts.getOriginalNodeId(node)] = classAlias; - hoistVariableDeclaration(classAlias); - return classAlias; - } - } - function getClassPrototype(node) { - return factory.createPropertyAccessExpression(factory.getDeclarationName(node), "prototype"); - } - function getClassMemberPrefix(node, member) { - return ts.isStatic(member) - ? factory.getDeclarationName(node) - : getClassPrototype(node); - } function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8) === 0) { enabledSubstitutions |= 8; context.enableSubstitution(79); } } - function enableSubstitutionForClassAliases() { - if ((enabledSubstitutions & 1) === 0) { - enabledSubstitutions |= 1; - context.enableSubstitution(79); - classAliases = []; - } - } function enableSubstitutionForNamespaceExports() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; @@ -74409,27 +75124,9 @@ var ts; return node; } function substituteExpressionIdentifier(node) { - return trySubstituteClassAlias(node) - || trySubstituteNamespaceExportedName(node) + return trySubstituteNamespaceExportedName(node) || node; } - function trySubstituteClassAlias(node) { - if (enabledSubstitutions & 1) { - if (resolver.getNodeCheckFlags(node) & 33554432) { - var declaration = resolver.getReferencedValueDeclaration(node); - if (declaration) { - var classAlias = classAliases[declaration.id]; - if (classAlias) { - var clone_2 = factory.cloneNode(classAlias); - ts.setSourceMapRange(clone_2, node); - ts.setCommentRange(clone_2, node); - return clone_2; - } - } - } - } - return undefined; - } function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); @@ -74515,7 +75212,7 @@ var ts; return visited; } function visitorWorker(node, valueIsDiscarded) { - if (node.transformFlags & 8388608) { + if (node.transformFlags & 16777216) { switch (node.kind) { case 226: case 257: @@ -74530,8 +75227,8 @@ var ts; return visitClassStaticBlockDeclaration(node); } } - if (node.transformFlags & 8388608 || - node.transformFlags & 33554432 && + if (node.transformFlags & 16777216 || + node.transformFlags & 134217728 && shouldTransformSuperInStaticInitializers && currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { @@ -74654,7 +75351,7 @@ var ts; return node; } function visitMethodOrAccessorDeclaration(node) { - ts.Debug.assert(!ts.some(node.decorators)); + ts.Debug.assert(!ts.hasDecorators(node)); if (!shouldTransformPrivateElementsOrClassStaticBlocks || !ts.isPrivateIdentifier(node.name)) { return ts.visitEachChild(node, classElementVisitor, context); } @@ -74665,7 +75362,7 @@ var ts; } var functionName = getHoistedFunctionName(node); if (functionName) { - getPendingExpressions().push(factory.createAssignment(functionName, factory.createFunctionExpression(ts.filter(node.modifiers, function (m) { return !ts.isStaticModifier(m); }), node.asteriskToken, functionName, undefined, ts.visitParameterList(node.parameters, classElementVisitor, context), undefined, ts.visitFunctionBody(node.body, classElementVisitor, context)))); + getPendingExpressions().push(factory.createAssignment(functionName, factory.createFunctionExpression(ts.filter(node.modifiers, function (m) { return ts.isModifier(m) && !ts.isStaticModifier(m); }), node.asteriskToken, functionName, undefined, ts.visitParameterList(node.parameters, classElementVisitor, context), undefined, ts.visitFunctionBody(node.body, classElementVisitor, context)))); } return undefined; } @@ -74686,13 +75383,13 @@ var ts; } } function visitPropertyDeclaration(node) { - ts.Debug.assert(!ts.some(node.decorators)); + ts.Debug.assert(!ts.hasDecorators(node)); if (ts.isPrivateIdentifier(node.name)) { if (!shouldTransformPrivateElementsOrClassStaticBlocks) { if (ts.isStatic(node)) { return ts.visitEachChild(node, visitor, context); } - return factory.updatePropertyDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, undefined, undefined); + return factory.updatePropertyDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.name, undefined, undefined, undefined); } var info = accessPrivateIdentifier(node.name); ts.Debug.assert(info, "Undeclared private name for property declaration."); @@ -74707,7 +75404,7 @@ var ts; if (ts.isStatic(node) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) { var initializerStatement = transformPropertyOrClassStaticBlock(node, factory.createThis()); if (initializerStatement) { - var staticBlock = factory.createClassStaticBlockDeclaration(undefined, undefined, factory.createBlock([initializerStatement])); + var staticBlock = factory.createClassStaticBlockDeclaration(factory.createBlock([initializerStatement])); ts.setOriginalNode(staticBlock, node); ts.setCommentRange(staticBlock, node); ts.setCommentRange(initializerStatement, { pos: -1, end: -1 }); @@ -74779,10 +75476,11 @@ var ts; } function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) { if (node.operator === 45 || node.operator === 46) { - if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + var operand = ts.skipParentheses(node.operand); + if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(operand)) { var info = void 0; - if (info = accessPrivateIdentifier(node.operand.name)) { - var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); + if (info = accessPrivateIdentifier(operand.name)) { + var receiver = ts.visitNode(operand.expression, visitor, ts.isExpression); var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; var expression = createPrivateIdentifierAccess(info, readExpression); var temp = ts.isPrefixUnaryExpression(node) || valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); @@ -74798,36 +75496,36 @@ var ts; } } else if (shouldTransformSuperInStaticInitializers && - ts.isSuperProperty(node.operand) && + ts.isSuperProperty(operand) && currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; if (facts & 1) { - var operand = visitInvalidSuperProperty(node.operand); + var expression = visitInvalidSuperProperty(operand); return ts.isPrefixUnaryExpression(node) ? - factory.updatePrefixUnaryExpression(node, operand) : - factory.updatePostfixUnaryExpression(node, operand); + factory.updatePrefixUnaryExpression(node, expression) : + factory.updatePostfixUnaryExpression(node, expression); } if (classConstructor && superClassReference) { var setterName = void 0; var getterName = void 0; - if (ts.isPropertyAccessExpression(node.operand)) { - if (ts.isIdentifier(node.operand.name)) { - getterName = setterName = factory.createStringLiteralFromNode(node.operand.name); + if (ts.isPropertyAccessExpression(operand)) { + if (ts.isIdentifier(operand.name)) { + getterName = setterName = factory.createStringLiteralFromNode(operand.name); } } else { - if (ts.isSimpleInlineableExpression(node.operand.argumentExpression)) { - getterName = setterName = node.operand.argumentExpression; + if (ts.isSimpleInlineableExpression(operand.argumentExpression)) { + getterName = setterName = operand.argumentExpression; } else { getterName = factory.createTempVariable(hoistVariableDeclaration); - setterName = factory.createAssignment(getterName, ts.visitNode(node.operand.argumentExpression, visitor, ts.isExpression)); + setterName = factory.createAssignment(getterName, ts.visitNode(operand.argumentExpression, visitor, ts.isExpression)); } } if (setterName && getterName) { var expression = factory.createReflectGetCall(superClassReference, getterName, classConstructor); - ts.setTextRange(expression, node.operand); + ts.setTextRange(expression, operand); var temp = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp); expression = factory.createReflectSetCall(superClassReference, setterName, expression, classConstructor); @@ -75042,13 +75740,13 @@ var ts; facts |= 2; } if (ts.isPropertyDeclaration(member) || ts.isClassStaticBlockDeclaration(member)) { - if (shouldTransformThisInStaticInitializers && member.transformFlags & 8192) { + if (shouldTransformThisInStaticInitializers && member.transformFlags & 16384) { facts |= 8; if (!(facts & 1)) { facts |= 2; } } - if (shouldTransformSuperInStaticInitializers && member.transformFlags & 33554432) { + if (shouldTransformSuperInStaticInitializers && member.transformFlags & 134217728) { if (!(facts & 1)) { facts |= 2 | 4; } @@ -75083,7 +75781,7 @@ var ts; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104); var statements = [ - factory.updateClassDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitNodes(node.heritageClauses, heritageClauseVisitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)) + factory.updateClassDeclaration(node, node.modifiers, node.name, undefined, ts.visitNodes(node.heritageClauses, heritageClauseVisitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)) ]; if (pendingClassReferenceAssignment) { getPendingExpressions().unshift(pendingClassReferenceAssignment); @@ -75121,7 +75819,7 @@ var ts; temp = createClassTempVar(); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); } - var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), node.modifiers, node.name, undefined, ts.visitNodes(node.heritageClauses, heritageClauseVisitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); + var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.name, undefined, ts.visitNodes(node.heritageClauses, heritageClauseVisitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); var hasTransformableStatics = shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(staticPropertiesOrClassStaticBlocks, function (p) { return ts.isClassStaticBlockDeclaration(p) || !!p.initializer || ts.isPrivateIdentifier(p.name); }); if (hasTransformableStatics || ts.some(pendingExpressions)) { if (isDecoratedClassDeclaration) { @@ -75181,7 +75879,7 @@ var ts; members.push(constructor); } if (!shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(pendingExpressions)) { - members.push(factory.createClassStaticBlockDeclaration(undefined, undefined, factory.createBlock([ + members.push(factory.createClassStaticBlockDeclaration(factory.createBlock([ factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions)) ]))); pendingExpressions = undefined; @@ -75214,7 +75912,7 @@ var ts; if (!body) { return undefined; } - return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(factory.createConstructorDeclaration(undefined, undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor)); + return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(factory.createConstructorDeclaration(undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor)); } function transformConstructorBody(node, constructor, isDerivedClass) { var _a; @@ -75523,10 +76221,10 @@ var ts; if (declaration) { var classAlias = classAliases[declaration.id]; if (classAlias) { - var clone_3 = factory.cloneNode(classAlias); - ts.setSourceMapRange(clone_3, node); - ts.setCommentRange(clone_3, node); - return clone_3; + var clone_2 = factory.cloneNode(classAlias); + ts.setSourceMapRange(clone_2, node); + ts.setCommentRange(clone_2, node); + return clone_2; } } } @@ -75861,6 +76559,659 @@ var ts; } })(ts || (ts = {})); var ts; +(function (ts) { + function createRuntimeTypeSerializer(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks"); + var currentLexicalScope; + var currentNameScope; + return { + serializeTypeNode: function (serializerContext, node) { return setSerializerContextAnd(serializerContext, serializeTypeNode, node); }, + serializeTypeOfNode: function (serializerContext, node) { return setSerializerContextAnd(serializerContext, serializeTypeOfNode, node); }, + serializeParameterTypesOfNode: function (serializerContext, node, container) { return setSerializerContextAnd(serializerContext, serializeParameterTypesOfNode, node, container); }, + serializeReturnTypeOfNode: function (serializerContext, node) { return setSerializerContextAnd(serializerContext, serializeReturnTypeOfNode, node); }, + }; + function setSerializerContextAnd(serializerContext, cb, node, arg) { + var savedCurrentLexicalScope = currentLexicalScope; + var savedCurrentNameScope = currentNameScope; + currentLexicalScope = serializerContext.currentLexicalScope; + currentNameScope = serializerContext.currentNameScope; + var result = arg === undefined ? cb(node) : cb(node, arg); + currentLexicalScope = savedCurrentLexicalScope; + currentNameScope = savedCurrentNameScope; + return result; + } + function getAccessorTypeNode(node) { + var accessors = resolver.getAllAccessorDeclarations(node); + return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor) + || accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor); + } + function serializeTypeOfNode(node) { + switch (node.kind) { + case 167: + case 164: + return serializeTypeNode(node.type); + case 173: + case 172: + return serializeTypeNode(getAccessorTypeNode(node)); + case 257: + case 226: + case 169: + return ts.factory.createIdentifier("Function"); + default: + return ts.factory.createVoidZero(); + } + } + function serializeParameterTypesOfNode(node, container) { + var valueDeclaration = ts.isClassLike(node) + ? ts.getFirstConstructorWithBody(node) + : ts.isFunctionLike(node) && ts.nodeIsPresent(node.body) + ? node + : undefined; + var expressions = []; + if (valueDeclaration) { + var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container); + var numParameters = parameters.length; + for (var i = 0; i < numParameters; i++) { + var parameter = parameters[i]; + if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") { + continue; + } + if (parameter.dotDotDotToken) { + expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type))); + } + else { + expressions.push(serializeTypeOfNode(parameter)); + } + } + } + return ts.factory.createArrayLiteralExpression(expressions); + } + function getParametersOfDecoratedDeclaration(node, container) { + if (container && node.kind === 172) { + var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; + if (setAccessor) { + return setAccessor.parameters; + } + } + return node.parameters; + } + function serializeReturnTypeOfNode(node) { + if (ts.isFunctionLike(node) && node.type) { + return serializeTypeNode(node.type); + } + else if (ts.isAsyncFunction(node)) { + return ts.factory.createIdentifier("Promise"); + } + return ts.factory.createVoidZero(); + } + function serializeTypeNode(node) { + if (node === undefined) { + return ts.factory.createIdentifier("Object"); + } + node = ts.skipTypeParentheses(node); + switch (node.kind) { + case 114: + case 153: + case 143: + return ts.factory.createVoidZero(); + case 179: + case 180: + return ts.factory.createIdentifier("Function"); + case 183: + case 184: + return ts.factory.createIdentifier("Array"); + case 177: + return node.assertsModifier ? + ts.factory.createVoidZero() : + ts.factory.createIdentifier("Boolean"); + case 133: + return ts.factory.createIdentifier("Boolean"); + case 198: + case 150: + return ts.factory.createIdentifier("String"); + case 148: + return ts.factory.createIdentifier("Object"); + case 196: + return serializeLiteralOfLiteralTypeNode(node.literal); + case 147: + return ts.factory.createIdentifier("Number"); + case 158: + return getGlobalConstructor("BigInt", 7); + case 151: + return getGlobalConstructor("Symbol", 2); + case 178: + return serializeTypeReferenceNode(node); + case 188: + return serializeUnionOrIntersectionConstituents(node.types, true); + case 187: + return serializeUnionOrIntersectionConstituents(node.types, false); + case 189: + return serializeUnionOrIntersectionConstituents([node.trueType, node.falseType], false); + case 193: + if (node.operator === 145) { + return serializeTypeNode(node.type); + } + break; + case 181: + case 194: + case 195: + case 182: + case 130: + case 155: + case 192: + case 200: + break; + case 312: + case 313: + case 317: + case 318: + case 319: + break; + case 314: + case 315: + case 316: + return serializeTypeNode(node.type); + default: + return ts.Debug.failBadSyntaxKind(node); + } + return ts.factory.createIdentifier("Object"); + } + function serializeLiteralOfLiteralTypeNode(node) { + switch (node.kind) { + case 10: + case 14: + return ts.factory.createIdentifier("String"); + case 219: { + var operand = node.operand; + switch (operand.kind) { + case 8: + case 9: + return serializeLiteralOfLiteralTypeNode(operand); + default: + return ts.Debug.failBadSyntaxKind(operand); + } + } + case 8: + return ts.factory.createIdentifier("Number"); + case 9: + return getGlobalConstructor("BigInt", 7); + case 110: + case 95: + return ts.factory.createIdentifier("Boolean"); + case 104: + return ts.factory.createVoidZero(); + default: + return ts.Debug.failBadSyntaxKind(node); + } + } + function serializeUnionOrIntersectionConstituents(types, isIntersection) { + var serializedType; + for (var _i = 0, types_22 = types; _i < types_22.length; _i++) { + var typeNode = types_22[_i]; + typeNode = ts.skipTypeParentheses(typeNode); + if (typeNode.kind === 143) { + if (isIntersection) + return ts.factory.createVoidZero(); + continue; + } + if (typeNode.kind === 155) { + if (!isIntersection) + return ts.factory.createIdentifier("Object"); + continue; + } + if (typeNode.kind === 130) { + return ts.factory.createIdentifier("Object"); + } + if (!strictNullChecks && ((ts.isLiteralTypeNode(typeNode) && typeNode.literal.kind === 104) || typeNode.kind === 153)) { + continue; + } + var serializedConstituent = serializeTypeNode(typeNode); + if (ts.isIdentifier(serializedConstituent) && serializedConstituent.escapedText === "Object") { + return serializedConstituent; + } + if (serializedType) { + if (!equateSerializedTypeNodes(serializedType, serializedConstituent)) { + return ts.factory.createIdentifier("Object"); + } + } + else { + serializedType = serializedConstituent; + } + } + return serializedType !== null && serializedType !== void 0 ? serializedType : (ts.factory.createVoidZero()); + } + function equateSerializedTypeNodes(left, right) { + return (ts.isGeneratedIdentifier(left) ? ts.isGeneratedIdentifier(right) : + ts.isIdentifier(left) ? ts.isIdentifier(right) + && left.escapedText === right.escapedText : + ts.isPropertyAccessExpression(left) ? ts.isPropertyAccessExpression(right) + && equateSerializedTypeNodes(left.expression, right.expression) + && equateSerializedTypeNodes(left.name, right.name) : + ts.isVoidExpression(left) ? ts.isVoidExpression(right) + && ts.isNumericLiteral(left.expression) && left.expression.text === "0" + && ts.isNumericLiteral(right.expression) && right.expression.text === "0" : + ts.isStringLiteral(left) ? ts.isStringLiteral(right) + && left.text === right.text : + ts.isTypeOfExpression(left) ? ts.isTypeOfExpression(right) + && equateSerializedTypeNodes(left.expression, right.expression) : + ts.isParenthesizedExpression(left) ? ts.isParenthesizedExpression(right) + && equateSerializedTypeNodes(left.expression, right.expression) : + ts.isConditionalExpression(left) ? ts.isConditionalExpression(right) + && equateSerializedTypeNodes(left.condition, right.condition) + && equateSerializedTypeNodes(left.whenTrue, right.whenTrue) + && equateSerializedTypeNodes(left.whenFalse, right.whenFalse) : + ts.isBinaryExpression(left) ? ts.isBinaryExpression(right) + && left.operatorToken.kind === right.operatorToken.kind + && equateSerializedTypeNodes(left.left, right.left) + && equateSerializedTypeNodes(left.right, right.right) : + false); + } + function serializeTypeReferenceNode(node) { + var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope !== null && currentNameScope !== void 0 ? currentNameScope : currentLexicalScope); + switch (kind) { + case ts.TypeReferenceSerializationKind.Unknown: + if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) { + return ts.factory.createIdentifier("Object"); + } + var serialized = serializeEntityNameAsExpressionFallback(node.typeName); + var temp = ts.factory.createTempVariable(hoistVariableDeclaration); + return ts.factory.createConditionalExpression(ts.factory.createTypeCheck(ts.factory.createAssignment(temp, serialized), "function"), undefined, temp, undefined, ts.factory.createIdentifier("Object")); + case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: + return serializeEntityNameAsExpression(node.typeName); + case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType: + return ts.factory.createVoidZero(); + case ts.TypeReferenceSerializationKind.BigIntLikeType: + return getGlobalConstructor("BigInt", 7); + case ts.TypeReferenceSerializationKind.BooleanType: + return ts.factory.createIdentifier("Boolean"); + case ts.TypeReferenceSerializationKind.NumberLikeType: + return ts.factory.createIdentifier("Number"); + case ts.TypeReferenceSerializationKind.StringLikeType: + return ts.factory.createIdentifier("String"); + case ts.TypeReferenceSerializationKind.ArrayLikeType: + return ts.factory.createIdentifier("Array"); + case ts.TypeReferenceSerializationKind.ESSymbolType: + return getGlobalConstructor("Symbol", 2); + case ts.TypeReferenceSerializationKind.TypeWithCallSignature: + return ts.factory.createIdentifier("Function"); + case ts.TypeReferenceSerializationKind.Promise: + return ts.factory.createIdentifier("Promise"); + case ts.TypeReferenceSerializationKind.ObjectType: + return ts.factory.createIdentifier("Object"); + default: + return ts.Debug.assertNever(kind); + } + } + function createCheckedValue(left, right) { + return ts.factory.createLogicalAnd(ts.factory.createStrictInequality(ts.factory.createTypeOfExpression(left), ts.factory.createStringLiteral("undefined")), right); + } + function serializeEntityNameAsExpressionFallback(node) { + if (node.kind === 79) { + var copied = serializeEntityNameAsExpression(node); + return createCheckedValue(copied, copied); + } + if (node.left.kind === 79) { + return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); + } + var left = serializeEntityNameAsExpressionFallback(node.left); + var temp = ts.factory.createTempVariable(hoistVariableDeclaration); + return ts.factory.createLogicalAnd(ts.factory.createLogicalAnd(left.left, ts.factory.createStrictInequality(ts.factory.createAssignment(temp, left.right), ts.factory.createVoidZero())), ts.factory.createPropertyAccessExpression(temp, node.right)); + } + function serializeEntityNameAsExpression(node) { + switch (node.kind) { + case 79: + var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent); + name.original = undefined; + ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); + return name; + case 161: + return serializeQualifiedNameAsExpression(node); + } + } + function serializeQualifiedNameAsExpression(node) { + return ts.factory.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left), node.right); + } + function getGlobalConstructorWithFallback(name) { + return ts.factory.createConditionalExpression(ts.factory.createTypeCheck(ts.factory.createIdentifier(name), "function"), undefined, ts.factory.createIdentifier(name), undefined, ts.factory.createIdentifier("Object")); + } + function getGlobalConstructor(name, minLanguageVersion) { + return languageVersion < minLanguageVersion ? + getGlobalConstructorWithFallback(name) : + ts.factory.createIdentifier(name); + } + } + ts.createRuntimeTypeSerializer = createRuntimeTypeSerializer; +})(ts || (ts = {})); +var ts; +(function (ts) { + function transformLegacyDecorators(context) { + var factory = context.factory, emitHelpers = context.getEmitHelperFactory, hoistVariableDeclaration = context.hoistVariableDeclaration; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + var classAliases; + return ts.chainBundle(context, transformSourceFile); + function transformSourceFile(node) { + var visited = ts.visitEachChild(node, visitor, context); + ts.addEmitHelpers(visited, context.readEmitHelpers()); + return visited; + } + function modifierVisitor(node) { + return ts.isDecorator(node) ? undefined : node; + } + function visitor(node) { + if (!(node.transformFlags & 33554432)) { + return node; + } + switch (node.kind) { + case 165: + return undefined; + case 257: + return visitClassDeclaration(node); + case 226: + return visitClassExpression(node); + case 171: + return visitConstructorDeclaration(node); + case 169: + return visitMethodDeclaration(node); + case 173: + return visitSetAccessorDeclaration(node); + case 172: + return visitGetAccessorDeclaration(node); + case 167: + return visitPropertyDeclaration(node); + case 164: + return visitParameterDeclaration(node); + default: + return ts.visitEachChild(node, visitor, context); + } + } + function visitClassDeclaration(node) { + if (!(ts.classOrConstructorParameterIsDecorated(node) || ts.childIsDecorated(node))) + return ts.visitEachChild(node, visitor, context); + var statements = ts.hasDecorators(node) ? + transformClassDeclarationWithClassDecorators(node, node.name) : + transformClassDeclarationWithoutClassDecorators(node, node.name); + if (statements.length > 1) { + statements.push(factory.createEndOfDeclarationMarker(node)); + ts.setEmitFlags(statements[0], ts.getEmitFlags(statements[0]) | 4194304); + } + return ts.singleOrMany(statements); + } + function decoratorContainsPrivateIdentifierInExpression(decorator) { + return !!(decorator.transformFlags & 536870912); + } + function parameterDecoratorsContainPrivateIdentifierInExpression(parameterDecorators) { + return ts.some(parameterDecorators, decoratorContainsPrivateIdentifierInExpression); + } + function hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (!ts.canHaveDecorators(member)) + continue; + var allDecorators = ts.getAllDecoratorsOfClassElement(member, node); + if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.decorators, decoratorContainsPrivateIdentifierInExpression)) + return true; + if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.parameters, parameterDecoratorsContainPrivateIdentifierInExpression)) + return true; + } + return false; + } + function transformDecoratorsOfClassElements(node, members) { + var decorationStatements = []; + addClassElementDecorationStatements(decorationStatements, node, false); + addClassElementDecorationStatements(decorationStatements, node, true); + if (hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node)) { + members = ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray([], members, true), [ + factory.createClassStaticBlockDeclaration(factory.createBlock(decorationStatements, true)) + ], false)), members); + decorationStatements = undefined; + } + return { decorationStatements: decorationStatements, members: members }; + } + function transformClassDeclarationWithoutClassDecorators(node, name) { + var _a; + var modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); + var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); + var members = ts.visitNodes(node.members, visitor, ts.isClassElement); + var decorationStatements = []; + (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements); + var updated = factory.updateClassDeclaration(node, modifiers, name, undefined, heritageClauses, members); + return ts.addRange([updated], decorationStatements); + } + function transformClassDeclarationWithClassDecorators(node, name) { + var _a; + var location = ts.moveRangePastModifiers(node); + var classAlias = getClassAliasIfNeeded(node); + var declName = languageVersion <= 2 ? + factory.getInternalName(node, false, true) : + factory.getLocalName(node, false, true); + var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); + var members = ts.visitNodes(node.members, visitor, ts.isClassElement); + var decorationStatements = []; + (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements); + var classExpression = factory.createClassExpression(undefined, name, undefined, heritageClauses, members); + ts.setOriginalNode(classExpression, node); + ts.setTextRange(classExpression, location); + var statement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([ + factory.createVariableDeclaration(declName, undefined, undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression) + ], 1)); + ts.setOriginalNode(statement, node); + ts.setTextRange(statement, location); + ts.setCommentRange(statement, node); + var statements = [statement]; + ts.addRange(statements, decorationStatements); + addConstructorDecorationStatement(statements, node); + return statements; + } + function visitClassExpression(node) { + return factory.updateClassExpression(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement)); + } + function visitConstructorDeclaration(node) { + return factory.updateConstructorDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), ts.visitNode(node.body, visitor, ts.isBlock)); + } + function finishClassElement(updated, original) { + if (updated !== original) { + ts.setCommentRange(updated, original); + ts.setSourceMapRange(updated, ts.moveRangePastModifiers(original)); + } + return updated; + } + function visitMethodDeclaration(node) { + return finishClassElement(factory.updateMethodDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), undefined, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), undefined, ts.visitNode(node.body, visitor, ts.isBlock)), node); + } + function visitGetAccessorDeclaration(node) { + return finishClassElement(factory.updateGetAccessorDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), undefined, ts.visitNode(node.body, visitor, ts.isBlock)), node); + } + function visitSetAccessorDeclaration(node) { + return finishClassElement(factory.updateSetAccessorDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), ts.visitNode(node.body, visitor, ts.isBlock)), node); + } + function visitPropertyDeclaration(node) { + if (node.flags & 16777216 || ts.hasSyntacticModifier(node, 2)) { + return undefined; + } + return finishClassElement(factory.updatePropertyDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.visitNode(node.name, visitor, ts.isPropertyName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)), node); + } + function visitParameterDeclaration(node) { + var updated = factory.updateParameterDeclaration(node, ts.elideNodes(factory, node.modifiers), node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); + if (updated !== node) { + ts.setCommentRange(updated, node); + ts.setTextRange(updated, ts.moveRangePastModifiers(node)); + ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node)); + ts.setEmitFlags(updated.name, 32); + } + return updated; + } + function transformAllDecoratorsOfDeclaration(allDecorators) { + if (!allDecorators) { + return undefined; + } + var decoratorExpressions = []; + ts.addRange(decoratorExpressions, ts.map(allDecorators.decorators, transformDecorator)); + ts.addRange(decoratorExpressions, ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter)); + return decoratorExpressions; + } + function addClassElementDecorationStatements(statements, node, isStatic) { + ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), function (expr) { return factory.createExpressionStatement(expr); })); + } + function isDecoratedClassElement(member, isStaticElement, parent) { + return ts.nodeOrChildIsDecorated(member, parent) + && isStaticElement === ts.isStatic(member); + } + function getDecoratedClassElements(node, isStatic) { + return ts.filter(node.members, function (m) { return isDecoratedClassElement(m, isStatic, node); }); + } + function generateClassElementDecorationExpressions(node, isStatic) { + var members = getDecoratedClassElements(node, isStatic); + var expressions; + for (var _i = 0, members_8 = members; _i < members_8.length; _i++) { + var member = members_8[_i]; + expressions = ts.append(expressions, generateClassElementDecorationExpression(node, member)); + } + return expressions; + } + function generateClassElementDecorationExpression(node, member) { + var allDecorators = ts.getAllDecoratorsOfClassElement(member, node); + var decoratorExpressions = transformAllDecoratorsOfDeclaration(allDecorators); + if (!decoratorExpressions) { + return undefined; + } + var prefix = getClassMemberPrefix(node, member); + var memberName = getExpressionForPropertyName(member, !ts.hasSyntacticModifier(member, 2)); + var descriptor = languageVersion > 0 + ? member.kind === 167 + ? factory.createVoidZero() + : factory.createNull() + : undefined; + var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor); + ts.setEmitFlags(helper, 1536); + ts.setSourceMapRange(helper, ts.moveRangePastModifiers(member)); + return helper; + } + function addConstructorDecorationStatement(statements, node) { + var expression = generateConstructorDecorationExpression(node); + if (expression) { + statements.push(ts.setOriginalNode(factory.createExpressionStatement(expression), node)); + } + } + function generateConstructorDecorationExpression(node) { + var allDecorators = ts.getAllDecoratorsOfClass(node); + var decoratorExpressions = transformAllDecoratorsOfDeclaration(allDecorators); + if (!decoratorExpressions) { + return undefined; + } + var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)]; + var localName = languageVersion <= 2 ? + factory.getInternalName(node, false, true) : + factory.getLocalName(node, false, true); + var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName); + var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate); + ts.setEmitFlags(expression, 1536); + ts.setSourceMapRange(expression, ts.moveRangePastModifiers(node)); + return expression; + } + function transformDecorator(decorator) { + return ts.visitNode(decorator.expression, visitor, ts.isExpression); + } + function transformDecoratorsOfParameter(decorators, parameterOffset) { + var expressions; + if (decorators) { + expressions = []; + for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) { + var decorator = decorators_1[_i]; + var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset); + ts.setTextRange(helper, decorator.expression); + ts.setEmitFlags(helper, 1536); + expressions.push(helper); + } + } + return expressions; + } + function getExpressionForPropertyName(member, generateNameForComputedPropertyName) { + var name = member.name; + if (ts.isPrivateIdentifier(name)) { + return factory.createIdentifier(""); + } + else if (ts.isComputedPropertyName(name)) { + return generateNameForComputedPropertyName && !ts.isSimpleInlineableExpression(name.expression) + ? factory.getGeneratedNameForNode(name) + : name.expression; + } + else if (ts.isIdentifier(name)) { + return factory.createStringLiteral(ts.idText(name)); + } + else { + return factory.cloneNode(name); + } + } + function enableSubstitutionForClassAliases() { + if (!classAliases) { + context.enableSubstitution(79); + classAliases = []; + } + } + function getClassAliasIfNeeded(node) { + if (resolver.getNodeCheckFlags(node) & 16777216) { + enableSubstitutionForClassAliases(); + var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default"); + classAliases[ts.getOriginalNodeId(node)] = classAlias; + hoistVariableDeclaration(classAlias); + return classAlias; + } + } + function getClassPrototype(node) { + return factory.createPropertyAccessExpression(factory.getDeclarationName(node), "prototype"); + } + function getClassMemberPrefix(node, member) { + return ts.isStatic(member) + ? factory.getDeclarationName(node) + : getClassPrototype(node); + } + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1) { + return substituteExpression(node); + } + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 79: + return substituteExpressionIdentifier(node); + } + return node; + } + function substituteExpressionIdentifier(node) { + var _a; + return (_a = trySubstituteClassAlias(node)) !== null && _a !== void 0 ? _a : node; + } + function trySubstituteClassAlias(node) { + if (classAliases) { + if (resolver.getNodeCheckFlags(node) & 33554432) { + var declaration = resolver.getReferencedValueDeclaration(node); + if (declaration) { + var classAlias = classAliases[declaration.id]; + if (classAlias) { + var clone_3 = factory.cloneNode(classAlias); + ts.setSourceMapRange(clone_3, node); + ts.setCommentRange(clone_3, node); + return clone_3; + } + } + } + } + return undefined; + } + } + ts.transformLegacyDecorators = transformLegacyDecorators; +})(ts || (ts = {})); +var ts; (function (ts) { function transformES2017(context) { var factory = context.factory, emitHelpers = context.getEmitHelperFactory, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; @@ -76035,22 +77386,22 @@ var ts; return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node); } function visitMethodDeclaration(node) { - return factory.updateMethodDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2 + return factory.updateMethodDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.asteriskToken, node.name, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2 ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } function visitFunctionDeclaration(node) { - return factory.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2 + return factory.updateFunctionDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2 ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } function visitFunctionExpression(node) { - return factory.updateFunctionExpression(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2 + return factory.updateFunctionExpression(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2 ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } function visitArrowFunction(node) { - return factory.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 + return factory.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -76307,7 +77658,7 @@ var ts; getterAndSetter.push(factory.createPropertyAssignment("get", factory.createArrowFunction(undefined, undefined, [], undefined, undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4), name), 4)))); if (hasBinding) { getterAndSetter.push(factory.createPropertyAssignment("set", factory.createArrowFunction(undefined, undefined, [ - factory.createParameterDeclaration(undefined, undefined, undefined, "v", undefined, undefined, undefined) + factory.createParameterDeclaration(undefined, undefined, "v", undefined, undefined, undefined) ], undefined, undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4), name), 4), factory.createIdentifier("v"))))); } accessors.push(factory.createPropertyAssignment(name, factory.createObjectLiteralExpression(getterAndSetter))); @@ -76526,7 +77877,7 @@ var ts; return objects; } function visitObjectLiteralExpression(node) { - if (node.transformFlags & 32768) { + if (node.transformFlags & 65536) { var objects = chunkObjectLiteralElements(node.properties); if (objects.length && objects[0].kind !== 205) { objects.unshift(factory.createObjectLiteralExpression()); @@ -76567,7 +77918,7 @@ var ts; return ts.processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, ts.ProcessLevel.LiftRestriction); } function visitBinaryExpression(node, expressionResultIsUnused) { - if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768) { + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 65536) { return ts.flattenDestructuringAssignment(node, visitor, context, 1, !expressionResultIsUnused); } if (node.operatorToken.kind === 27) { @@ -76594,7 +77945,7 @@ var ts; function visitCatchClause(node) { if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name) && - node.variableDeclaration.name.transformFlags & 32768) { + node.variableDeclaration.name.transformFlags & 65536) { var name = factory.getGeneratedNameForNode(node.variableDeclaration.name); var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, undefined, undefined, name); var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1); @@ -76629,7 +77980,7 @@ var ts; return visitVariableDeclarationWorker(node, false); } function visitVariableDeclarationWorker(node, exportedVariableStatement) { - if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768) { + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 65536) { return ts.flattenDestructuringBinding(node, visitor, context, 1, undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); @@ -76642,7 +77993,7 @@ var ts; } function visitForOfStatement(node, outermostLabeledStatement) { var ancestorFacts = enterSubtree(0, 2); - if (node.initializer.transformFlags & 32768) { + if (node.initializer.transformFlags & 65536) { node = transformForOfStatementWithObjectRest(node); } var result = node.awaitModifier ? @@ -76737,10 +78088,10 @@ var ts; } function visitParameter(node) { if (parametersWithPrecedingObjectRestOrSpread === null || parametersWithPrecedingObjectRestOrSpread === void 0 ? void 0 : parametersWithPrecedingObjectRestOrSpread.has(node)) { - return factory.updateParameterDeclaration(node, undefined, undefined, node.dotDotDotToken, ts.isBindingPattern(node.name) ? factory.getGeneratedNameForNode(node) : node.name, undefined, undefined, undefined); + return factory.updateParameterDeclaration(node, undefined, node.dotDotDotToken, ts.isBindingPattern(node.name) ? factory.getGeneratedNameForNode(node) : node.name, undefined, undefined, undefined); } - if (node.transformFlags & 32768) { - return factory.updateParameterDeclaration(node, undefined, undefined, node.dotDotDotToken, factory.getGeneratedNameForNode(node), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); + if (node.transformFlags & 65536) { + return factory.updateParameterDeclaration(node, undefined, node.dotDotDotToken, factory.getGeneratedNameForNode(node), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); } @@ -76751,7 +78102,7 @@ var ts; if (parameters) { parameters.add(parameter); } - else if (parameter.transformFlags & 32768) { + else if (parameter.transformFlags & 65536) { parameters = new ts.Set(); } } @@ -76762,7 +78113,7 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateConstructorDeclaration(node, undefined, node.modifiers, ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node)); + var updated = factory.updateConstructorDeclaration(node, node.modifiers, ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread; return updated; @@ -76772,7 +78123,7 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateGetAccessorDeclaration(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context), undefined, transformFunctionBody(node)); + var updated = factory.updateGetAccessorDeclaration(node, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context), undefined, transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread; return updated; @@ -76782,7 +78133,7 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateSetAccessorDeclaration(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node)); + var updated = factory.updateSetAccessorDeclaration(node, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread; return updated; @@ -76792,8 +78143,8 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateMethodDeclaration(node, undefined, enclosingFunctionFlags & 1 - ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) + var updated = factory.updateMethodDeclaration(node, enclosingFunctionFlags & 1 + ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifierLike) : node.modifiers, enclosingFunctionFlags & 2 ? undefined : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(undefined, visitor, ts.isToken), undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1 @@ -76808,7 +78159,7 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateFunctionDeclaration(node, undefined, enclosingFunctionFlags & 1 + var updated = factory.updateFunctionDeclaration(node, enclosingFunctionFlags & 1 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) : node.modifiers, enclosingFunctionFlags & 2 ? undefined @@ -76940,7 +78291,7 @@ var ts; statements = ts.append(statements, statement); } } - else if (parameter.transformFlags & 32768) { + else if (parameter.transformFlags & 65536) { containsPrecedingObjectRestOrSpread = true; var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1, factory.getGeneratedNameForNode(parameter), false, true); if (ts.some(declarations)) { @@ -77392,7 +78743,7 @@ var ts; for (var _i = 0, _a = ts.arrayFrom(currentFileState.utilizedImplicitRuntimeImports.entries()); _i < _a.length; _i++) { var _b = _a[_i], importSource = _b[0], importSpecifiersMap = _b[1]; if (ts.isExternalModule(node)) { - var importStatement = factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamedImports(ts.arrayFrom(importSpecifiersMap.values()))), factory.createStringLiteral(importSource), undefined); + var importStatement = factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports(ts.arrayFrom(importSpecifiersMap.values()))), factory.createStringLiteral(importSource), undefined); ts.setParentRecursive(importStatement, false); statements = ts.insertStatementAfterCustomPrologue(statements.slice(), importStatement); } @@ -77603,20 +78954,27 @@ var ts; if (node === undefined) { return factory.createTrue(); } - else if (node.kind === 10) { + if (node.kind === 10) { var singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return ts.setTextRange(literal, node); } - else if (node.kind === 288) { + if (node.kind === 288) { if (node.expression === undefined) { return factory.createTrue(); } return ts.visitNode(node.expression, visitor, ts.isExpression); } - else { - return ts.Debug.failBadSyntaxKind(node); + if (ts.isJsxElement(node)) { + return visitJsxElement(node, false); + } + if (ts.isJsxSelfClosingElement(node)) { + return visitJsxSelfClosingElement(node, false); } + if (ts.isJsxFragment(node)) { + return visitJsxFragment(node, false); + } + return ts.Debug.failBadSyntaxKind(node); } function visitJsxText(node) { var fixed = fixupWhitespaceAndDecodeEntities(node.text); @@ -78066,7 +79424,7 @@ var ts; && !node.expression; } function isOrMayContainReturnCompletion(node) { - return node.transformFlags & 2097152 + return node.transformFlags & 4194304 && (ts.isReturnStatement(node) || ts.isIfStatement(node) || ts.isWithStatement(node) @@ -78369,7 +79727,7 @@ var ts; enableSubstitutionsForBlockScopedBindings(); } var extendsClauseElement = ts.getClassExtendsHeritageElement(node); - var classFunction = factory.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [factory.createParameterDeclaration(undefined, undefined, undefined, factory.createUniqueName("_super", 16 | 32))] : [], undefined, transformClassBody(node, extendsClauseElement)); + var classFunction = factory.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [factory.createParameterDeclaration(undefined, undefined, factory.createUniqueName("_super", 16 | 32))] : [], undefined, transformClassBody(node, extendsClauseElement)); ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536) | 524288); var inner = factory.createPartiallyEmittedExpression(classFunction); ts.setTextRangeEnd(inner, node.end); @@ -78415,7 +79773,7 @@ var ts; var ancestorFacts = enterSubtree(32662, 73); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - var constructorFunction = factory.createFunctionDeclaration(undefined, undefined, undefined, name, undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); + var constructorFunction = factory.createFunctionDeclaration(undefined, undefined, name, undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { ts.setEmitFlags(constructorFunction, 8); @@ -78473,7 +79831,7 @@ var ts; factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureNewTargetIfNeeded(prologue, constructor, false); if (isDerivedClass || superCallExpression) { - if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192)) { + if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 16384)) { var superCall_1 = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression); var returnStatement = factory.createReturnStatement(superCallExpression); ts.setCommentRange(returnStatement, ts.getCommentRange(superCall_1)); @@ -78546,10 +79904,10 @@ var ts; return undefined; } else if (ts.isBindingPattern(node.name)) { - return ts.setOriginalNode(ts.setTextRange(factory.createParameterDeclaration(undefined, undefined, undefined, factory.getGeneratedNameForNode(node), undefined, undefined, undefined), node), node); + return ts.setOriginalNode(ts.setTextRange(factory.createParameterDeclaration(undefined, undefined, factory.getGeneratedNameForNode(node), undefined, undefined, undefined), node), node); } else if (node.initializer) { - return ts.setOriginalNode(ts.setTextRange(factory.createParameterDeclaration(undefined, undefined, undefined, node.name, undefined, undefined, undefined), node), node); + return ts.setOriginalNode(ts.setTextRange(factory.createParameterDeclaration(undefined, undefined, node.name, undefined, undefined, undefined), node), node); } else { return node; @@ -78788,7 +80146,7 @@ var ts; return call; } function visitArrowFunction(node) { - if (node.transformFlags & 8192 && !(hierarchyFacts & 16384)) { + if (node.transformFlags & 16384 && !(hierarchyFacts & 16384)) { hierarchyFacts |= 65536; } var savedConvertedLoopState = convertedLoopState; @@ -78828,7 +80186,7 @@ var ts; : node.name; exitSubtree(ancestorFacts, 98304, 0); convertedLoopState = savedConvertedLoopState; - return factory.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, undefined, parameters, undefined, body); + return factory.updateFunctionDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, undefined, parameters, undefined, body); } function transformFunctionLikeToExpression(node, location, name, container) { var savedConvertedLoopState = convertedLoopState; @@ -78992,7 +80350,7 @@ var ts; return updated; } function visitVariableDeclarationList(node) { - if (node.flags & 3 || node.transformFlags & 262144) { + if (node.flags & 3 || node.transformFlags & 524288) { if (node.flags & 3) { enableSubstitutionsForBlockScopedBindings(); } @@ -79003,7 +80361,7 @@ var ts; ts.setOriginalNode(declarationList, node); ts.setTextRange(declarationList, node); ts.setCommentRange(declarationList, node); - if (node.transformFlags & 262144 + if (node.transformFlags & 524288 && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { ts.setSourceMapRange(declarationList, getRangeUnion(declarations)); } @@ -79205,7 +80563,7 @@ var ts; var numInitialProperties = -1, hasComputed = false; for (var i = 0; i < properties.length; i++) { var property = properties[i]; - if ((property.transformFlags & 524288 && + if ((property.transformFlags & 1048576 && hierarchyFacts & 4) || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162)) { numInitialProperties = i; @@ -79431,7 +80789,7 @@ var ts; } function createFunctionForInitializerOfForStatement(node, currentState) { var functionName = factory.createUniqueName("_loop_init"); - var containsYield = (node.initializer.transformFlags & 524288) !== 0; + var containsYield = (node.initializer.transformFlags & 1048576) !== 0; var emitFlags = 0; if (currentState.containsLexicalThis) emitFlags |= 8; @@ -79475,7 +80833,7 @@ var ts; var loopBody = factory.createBlock(statements, true); if (ts.isBlock(statement)) ts.setOriginalNode(loopBody, statement); - var containsYield = (node.statement.transformFlags & 524288) !== 0; + var containsYield = (node.statement.transformFlags & 1048576) !== 0; var emitFlags = 524288; if (currentState.containsLexicalThis) emitFlags |= 8; @@ -79590,7 +80948,7 @@ var ts; } } else { - loopParameters.push(factory.createParameterDeclaration(undefined, undefined, undefined, name)); + loopParameters.push(factory.createParameterDeclaration(undefined, undefined, name)); var checkFlags = resolver.getNodeCheckFlags(decl); if (checkFlags & 4194304 || hasCapturedBindingsInForHead) { var outParamName = factory.createUniqueName("out_" + ts.idText(name)); @@ -79702,10 +81060,10 @@ var ts; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); if (node.kind === 172) { - updated = factory.updateGetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); + updated = factory.updateGetAccessorDeclaration(node, node.modifiers, node.name, parameters, node.type, body); } else { - updated = factory.updateSetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, body); + updated = factory.updateSetAccessorDeclaration(node, node.modifiers, node.name, parameters, body); } exitSubtree(ancestorFacts, 98304, 0); convertedLoopState = savedConvertedLoopState; @@ -79785,7 +81143,7 @@ var ts; return visitCallExpressionWithPotentialCapturedThisAssignment(node, false); } function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { - if (node.transformFlags & 16384 || + if (node.transformFlags & 32768 || node.expression.kind === 106 || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; @@ -79793,7 +81151,7 @@ var ts; ts.setEmitFlags(thisArg, 4); } var resultingCall = void 0; - if (node.transformFlags & 16384) { + if (node.transformFlags & 32768) { resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, true, false, false)); } else { @@ -80224,10 +81582,10 @@ var ts; case 247: return visitReturnStatement(node); default: - if (node.transformFlags & 524288) { + if (node.transformFlags & 1048576) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (2048 | 2097152)) { + else if (node.transformFlags & (2048 | 4194304)) { return ts.visitEachChild(node, visitor, context); } else { @@ -80271,7 +81629,7 @@ var ts; } function visitFunctionDeclaration(node) { if (node.asteriskToken) { - node = ts.setOriginalNode(ts.setTextRange(factory.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(factory.createFunctionDeclaration(node.modifiers, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node); } else { var savedInGeneratorFunctionBody = inGeneratorFunctionBody; @@ -80365,7 +81723,7 @@ var ts; return ts.setTextRange(factory.createBlock(statements, body.multiLine), body); } function visitVariableStatement(node) { - if (node.transformFlags & 524288) { + if (node.transformFlags & 1048576) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -81038,7 +82396,7 @@ var ts; } } function containsYield(node) { - return !!node && (node.transformFlags & 524288) !== 0; + return !!node && (node.transformFlags & 1048576) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -81467,7 +82825,7 @@ var ts; currentExceptionBlock = undefined; withBlockStack = undefined; var buildResult = buildStatements(); - return emitHelpers().createGeneratorHelper(ts.setEmitFlags(factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, state)], undefined, factory.createBlock(buildResult, buildResult.length > 0)), 524288)); + return emitHelpers().createGeneratorHelper(ts.setEmitFlags(factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, state)], undefined, factory.createBlock(buildResult, buildResult.length > 0)), 524288)); } function buildStatements() { if (operations) { @@ -81768,7 +83126,7 @@ var ts; function transformSourceFile(node) { if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || - node.transformFlags & 4194304 || + node.transformFlags & 8388608 || (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) { return node; } @@ -81824,8 +83182,8 @@ var ts; jsonSourceFile ? jsonSourceFile.statements.length ? jsonSourceFile.statements[0].expression : factory.createObjectLiteralExpression() : factory.createFunctionExpression(undefined, undefined, undefined, undefined, __spreadArray([ - factory.createParameterDeclaration(undefined, undefined, undefined, "require"), - factory.createParameterDeclaration(undefined, undefined, undefined, "exports") + factory.createParameterDeclaration(undefined, undefined, "require"), + factory.createParameterDeclaration(undefined, undefined, "exports") ], importAliasNames, true), undefined, transformAsynchronousModuleBody(node)) ], false))) ]), node.statements)); @@ -81835,7 +83193,7 @@ var ts; function transformUMDModule(node) { var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; var moduleName = ts.tryGetModuleNameFromFile(factory, node, host, compilerOptions); - var umdHeader = factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, "factory")], undefined, ts.setTextRange(factory.createBlock([ + var umdHeader = factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, "factory")], undefined, ts.setTextRange(factory.createBlock([ factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("module"), "object"), factory.createTypeCheck(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), "object")), factory.createBlock([ factory.createVariableStatement(undefined, [ factory.createVariableDeclaration("v", undefined, undefined, factory.createCallExpression(factory.createIdentifier("factory"), undefined, [ @@ -81857,8 +83215,8 @@ var ts; var updated = factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray([ factory.createExpressionStatement(factory.createCallExpression(umdHeader, undefined, [ factory.createFunctionExpression(undefined, undefined, undefined, undefined, __spreadArray([ - factory.createParameterDeclaration(undefined, undefined, undefined, "require"), - factory.createParameterDeclaration(undefined, undefined, undefined, "exports") + factory.createParameterDeclaration(undefined, undefined, "require"), + factory.createParameterDeclaration(undefined, undefined, "exports") ], importAliasNames, true), undefined, transformAsynchronousModuleBody(node)) ])) ]), node.statements)); @@ -81873,7 +83231,7 @@ var ts; var amdDependency = _a[_i]; if (amdDependency.name) { aliasedModuleNames.push(factory.createStringLiteral(amdDependency.path)); - importAliasNames.push(factory.createParameterDeclaration(undefined, undefined, undefined, amdDependency.name)); + importAliasNames.push(factory.createParameterDeclaration(undefined, undefined, amdDependency.name)); } else { unaliasedModuleNames.push(factory.createStringLiteral(amdDependency.path)); @@ -81887,7 +83245,7 @@ var ts; if (includeNonAmdDependencies && importAliasName) { ts.setEmitFlags(importAliasName, 4); aliasedModuleNames.push(externalModuleName); - importAliasNames.push(factory.createParameterDeclaration(undefined, undefined, undefined, importAliasName)); + importAliasNames.push(factory.createParameterDeclaration(undefined, undefined, importAliasName)); } else { unaliasedModuleNames.push(externalModuleName); @@ -81974,7 +83332,7 @@ var ts; } } function visitorWorker(node, valueIsDiscarded) { - if (!(node.transformFlags & (4194304 | 4096 | 67108864))) { + if (!(node.transformFlags & (8388608 | 4096 | 268435456))) { return node; } switch (node.kind) { @@ -82115,7 +83473,7 @@ var ts; var externalModuleName = ts.getExternalModuleNameLiteral(factory, node, currentSourceFile, host, resolver, compilerOptions); var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor); var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument; - var containsLexicalThis = !!(node.transformFlags & 8192); + var containsLexicalThis = !!(node.transformFlags & 16384); switch (compilerOptions.module) { case ts.ModuleKind.AMD: return createImportCallExpressionAMD(argument, containsLexicalThis); @@ -82141,8 +83499,8 @@ var ts; var resolve = factory.createUniqueName("resolve"); var reject = factory.createUniqueName("reject"); var parameters = [ - factory.createParameterDeclaration(undefined, undefined, undefined, resolve), - factory.createParameterDeclaration(undefined, undefined, undefined, reject) + factory.createParameterDeclaration(undefined, undefined, resolve), + factory.createParameterDeclaration(undefined, undefined, reject) ]; var body = factory.createBlock([ factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("require"), undefined, [factory.createArrayLiteralExpression([arg || factory.createOmittedExpression()]), resolve, reject])) @@ -82329,7 +83687,7 @@ var ts; function visitFunctionDeclaration(node) { var statements; if (ts.hasSyntacticModifier(node, 1)) { - statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, true, true), undefined, ts.visitNodes(node.parameters, visitor), undefined, ts.visitEachChild(node.body, visitor, context)), node), node)); + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createFunctionDeclaration(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, true, true), undefined, ts.visitNodes(node.parameters, visitor), undefined, ts.visitEachChild(node.body, visitor, context)), node), node)); } else { statements = ts.append(statements, ts.visitEachChild(node, visitor, context)); @@ -82346,7 +83704,7 @@ var ts; function visitClassDeclaration(node) { var statements; if (ts.hasSyntacticModifier(node, 1)) { - statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.getDeclarationName(node, true, true), undefined, ts.visitNodes(node.heritageClauses, visitor), ts.visitNodes(node.members, visitor)), node), node)); + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createClassDeclaration(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifierLike), factory.getDeclarationName(node, true, true), undefined, ts.visitNodes(node.heritageClauses, visitor), ts.visitNodes(node.members, visitor)), node), node)); } else { statements = ts.append(statements, ts.visitEachChild(node, visitor, context)); @@ -82746,7 +84104,7 @@ var ts; var noSubstitution; return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304)) { + if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 8388608)) { return node; } var id = ts.getOriginalNodeId(node); @@ -82759,8 +84117,8 @@ var ts; var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups); var moduleBodyFunction = factory.createFunctionExpression(undefined, undefined, undefined, undefined, [ - factory.createParameterDeclaration(undefined, undefined, undefined, exportFunction), - factory.createParameterDeclaration(undefined, undefined, undefined, contextObject) + factory.createParameterDeclaration(undefined, undefined, exportFunction), + factory.createParameterDeclaration(undefined, undefined, contextObject) ], undefined, moduleBodyBlock); var moduleName = ts.tryGetModuleNameFromFile(factory, node, host, compilerOptions); var dependencies = factory.createArrayLiteralExpression(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); @@ -82820,7 +84178,7 @@ var ts; ts.addRange(statements, hoistedStatements); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); - var modifiers = node.transformFlags & 1048576 ? + var modifiers = node.transformFlags & 2097152 ? factory.createModifiersFromModifierFlags(256) : undefined; var moduleObject = factory.createObjectLiteralExpression([ @@ -82876,7 +84234,7 @@ var ts; if (localNames) { condition = factory.createLogicalAnd(condition, factory.createLogicalNot(factory.createCallExpression(factory.createPropertyAccessExpression(localNames, "hasOwnProperty"), undefined, [n]))); } - return factory.createFunctionDeclaration(undefined, undefined, undefined, exportStarFunction, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, m)], undefined, factory.createBlock([ + return factory.createFunctionDeclaration(undefined, undefined, exportStarFunction, undefined, [factory.createParameterDeclaration(undefined, undefined, m)], undefined, factory.createBlock([ factory.createVariableStatement(undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(exports, undefined, undefined, factory.createObjectLiteralExpression([])) ])), @@ -82931,7 +84289,7 @@ var ts; break; } } - setters.push(factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, parameterName)], undefined, factory.createBlock(statements, true))); + setters.push(factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, parameterName)], undefined, factory.createBlock(statements, true))); } return factory.createArrayLiteralExpression(setters, true); } @@ -82996,7 +84354,7 @@ var ts; } function visitFunctionDeclaration(node) { if (ts.hasSyntacticModifier(node, 1)) { - hoistedStatements = ts.append(hoistedStatements, factory.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, true, true), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), undefined, ts.visitNode(node.body, visitor, ts.isBlock))); + hoistedStatements = ts.append(hoistedStatements, factory.updateFunctionDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifierLike), node.asteriskToken, factory.getDeclarationName(node, true, true), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), undefined, ts.visitNode(node.body, visitor, ts.isBlock))); } else { hoistedStatements = ts.append(hoistedStatements, ts.visitEachChild(node, visitor, context)); @@ -83014,7 +84372,7 @@ var ts; var statements; var name = factory.getLocalName(node); hoistVariableDeclaration(name); - statements = ts.append(statements, ts.setTextRange(factory.createExpressionStatement(factory.createAssignment(name, ts.setTextRange(factory.createClassExpression(ts.visitNodes(node.decorators, visitor, ts.isDecorator), undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement)), node))), node)); + statements = ts.append(statements, ts.setTextRange(factory.createExpressionStatement(factory.createAssignment(name, ts.setTextRange(factory.createClassExpression(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifierLike), node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); @@ -83361,7 +84719,7 @@ var ts; return node; } function visitorWorker(node, valueIsDiscarded) { - if (!(node.transformFlags & (4096 | 4194304 | 67108864))) { + if (!(node.transformFlags & (4096 | 8388608 | 268435456))) { return node; } switch (node.kind) { @@ -83682,7 +85040,7 @@ var ts; function visitor(node) { switch (node.kind) { case 265: - return ts.getEmitScriptTarget(compilerOptions) >= ts.ModuleKind.ES2020 ? visitImportEqualsDeclaration(node) : undefined; + return ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.Node16 ? visitImportEqualsDeclaration(node) : undefined; case 271: return visitExportAssignment(node); case 272: @@ -83699,7 +85057,7 @@ var ts; } if (!importRequireStatements) { var createRequireName = factory.createUniqueName("_createRequire", 16 | 32); - var importStatement = factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamedImports([ + var importStatement = factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports([ factory.createImportSpecifier(false, factory.createIdentifier("createRequire"), createRequireName) ])), factory.createStringLiteral("module")); var requireHelperName = factory.createUniqueName("__require", 16 | 32); @@ -83725,7 +85083,7 @@ var ts; } function appendExportsOfImportEqualsDeclaration(statements, node) { if (ts.hasSyntacticModifier(node, 1)) { - statements = ts.append(statements, factory.createExportDeclaration(undefined, undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(false, undefined, ts.idText(node.name))]))); + statements = ts.append(statements, factory.createExportDeclaration(undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(false, undefined, ts.idText(node.name))]))); } return statements; } @@ -83741,9 +85099,9 @@ var ts; } var oldIdentifier = node.exportClause.name; var synthName = factory.getGeneratedNameForNode(oldIdentifier); - var importDecl = factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamespaceImport(synthName)), node.moduleSpecifier, node.assertClause); + var importDecl = factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamespaceImport(synthName)), node.moduleSpecifier, node.assertClause); ts.setOriginalNode(importDecl, node.exportClause); - var exportDecl = ts.isExportNamespaceAsDefaultDeclaration(node) ? factory.createExportDefault(synthName) : factory.createExportDeclaration(undefined, undefined, false, factory.createNamedExports([factory.createExportSpecifier(false, synthName, oldIdentifier)])); + var exportDecl = ts.isExportNamespaceAsDefaultDeclaration(node) ? factory.createExportDefault(synthName) : factory.createExportDeclaration(undefined, false, factory.createNamedExports([factory.createExportSpecifier(false, synthName, oldIdentifier)])); ts.setOriginalNode(exportDecl, node); return [importDecl, exportDecl]; } @@ -83969,7 +85327,7 @@ var ts; return getTypeAliasDeclarationVisibilityError; } else { - return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: ".concat(ts.SyntaxKind[node.kind])); + return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: ".concat(ts.Debug.formatSyntaxKind(node.kind))); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (node.kind === 254 || node.kind === 203) { @@ -84166,7 +85524,7 @@ var ts; ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: - return ts.Debug.fail("Unknown parent for parameter: ".concat(ts.SyntaxKind[node.parent.kind])); + return ts.Debug.fail("Unknown parent for parameter: ".concat(ts.Debug.formatSyntaxKind(node.parent.kind))); } } function getTypeParameterConstraintVisibilityError() { @@ -84483,7 +85841,7 @@ var ts; resultHasExternalModuleIndicator = false; needsDeclare = false; var statements = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile, true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([], [factory.createModifier(135)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], true, [], [], false, []); + var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([factory.createModifier(135)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], true, [], [], false, []); return newFile; } needsDeclare = true; @@ -84618,7 +85976,7 @@ var ts; }); return ret; } - function filterBindingPatternInitializers(name) { + function filterBindingPatternInitializersAndRenamings(name) { if (name.kind === 79) { return name; } @@ -84634,7 +85992,10 @@ var ts; if (elem.kind === 227) { return elem; } - return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); + if (elem.propertyName && ts.isIdentifier(elem.propertyName) && ts.isIdentifier(elem.name) && !elem.symbol.isReferenced) { + return factory.updateBindingElement(elem, elem.dotDotDotToken, undefined, elem.propertyName, shouldPrintWithInitializer(elem) ? elem.initializer : undefined); + } + return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializersAndRenamings(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); } } function ensureParameter(p, modifierMask, type) { @@ -84643,7 +86004,7 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } - var newParam = factory.updateParameterDeclaration(p, undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57)) : undefined, ensureType(p, type || p.type, true), ensureNoInitializer(p)); + var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializersAndRenamings(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57)) : undefined, ensureType(p, type || p.type, true), ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } @@ -84689,7 +86050,7 @@ var ts; if (node.kind === 164 || node.kind === 167 || node.kind === 166) { - if (!node.initializer) + if (ts.isPropertySignature(node) || !node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } @@ -84771,7 +86132,7 @@ var ts; } } if (!newValueParameter) { - newValueParameter = factory.createParameterDeclaration(undefined, undefined, undefined, "value"); + newValueParameter = factory.createParameterDeclaration(undefined, undefined, "value"); } newParams = ts.append(newParams, newValueParameter); } @@ -84826,7 +86187,7 @@ var ts; return; if (decl.moduleReference.kind === 277) { var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); - return factory.updateImportEqualsDeclaration(decl, undefined, decl.modifiers, decl.isTypeOnly, decl.name, factory.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier))); + return factory.updateImportEqualsDeclaration(decl, decl.modifiers, decl.isTypeOnly, decl.name, factory.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier))); } else { var oldDiag = getSymbolAccessibilityDiagnostic; @@ -84838,22 +86199,22 @@ var ts; } function transformImportDeclaration(decl) { if (!decl.importClause) { - return factory.updateImportDeclaration(decl, undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); + return factory.updateImportDeclaration(decl, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined; if (!decl.importClause.namedBindings) { - return visibleDefaultBinding && factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); + return visibleDefaultBinding && factory.updateImportDeclaration(decl, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } if (decl.importClause.namedBindings.kind === 268) { var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : undefined; - return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)) : undefined; + return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)) : undefined; } var bindingList = ts.mapDefined(decl.importClause.namedBindings.elements, function (b) { return resolver.isDeclarationVisible(b) ? b : undefined; }); if ((bindingList && bindingList.length) || visibleDefaultBinding) { - return factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); + return factory.updateImportDeclaration(decl, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } if (resolver.isImportRequiredByAugmentation(decl)) { - return factory.updateImportDeclaration(decl, undefined, decl.modifiers, undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); + return factory.updateImportDeclaration(decl, decl.modifiers, undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } } function getResolutionModeOverrideForClauseInNightly(assertClause) { @@ -84870,7 +86231,7 @@ var ts; while (ts.length(lateMarkedStatements)) { var i = lateMarkedStatements.shift(); if (!ts.isLateVisibilityPaintedStatement(i)) { - return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: ".concat(ts.SyntaxKind ? ts.SyntaxKind[i.kind] : i.kind)); + return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: ".concat(ts.Debug.formatSyntaxKind(i.kind))); } var priorNeedsDeclare = needsDeclare; needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit); @@ -84926,7 +86287,7 @@ var ts; if (ts.hasEffectiveModifier(input, 8)) { if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) return; - return cleanup(factory.createPropertyDeclaration(undefined, ensureModifiers(input), input.name, undefined, undefined, undefined)); + return cleanup(factory.createPropertyDeclaration(ensureModifiers(input), input.name, undefined, undefined, undefined)); } } if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { @@ -84955,14 +86316,14 @@ var ts; case 175: return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); case 171: { - var ctor = factory.createConstructorDeclaration(undefined, ensureModifiers(input), updateParamsList(input, input.parameters, 0), undefined); + var ctor = factory.createConstructorDeclaration(ensureModifiers(input), updateParamsList(input, input.parameters, 0), undefined); return cleanup(ctor); } case 169: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(undefined); } - var sig = factory.createMethodDeclaration(undefined, ensureModifiers(input), undefined, input.name, input.questionToken, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), undefined); + var sig = factory.createMethodDeclaration(ensureModifiers(input), undefined, input.name, input.questionToken, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), undefined); return cleanup(sig); } case 172: { @@ -84970,19 +86331,19 @@ var ts; return cleanup(undefined); } var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); - return cleanup(factory.updateGetAccessorDeclaration(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8)), ensureType(input, accessorType), undefined)); + return cleanup(factory.updateGetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8)), ensureType(input, accessorType), undefined)); } case 173: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(undefined); } - return cleanup(factory.updateSetAccessorDeclaration(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8)), undefined)); + return cleanup(factory.updateSetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8)), undefined)); } case 167: if (ts.isPrivateIdentifier(input.name)) { return cleanup(undefined); } - return cleanup(factory.updatePropertyDeclaration(input, undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input))); + return cleanup(factory.updatePropertyDeclaration(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input))); case 166: if (ts.isPrivateIdentifier(input.name)) { return cleanup(undefined); @@ -84998,7 +86359,7 @@ var ts; return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } case 176: { - return cleanup(factory.updateIndexSignature(input, undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130))); + return cleanup(factory.updateIndexSignature(input, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130))); } case 254: { if (ts.isBindingPattern(input.name)) { @@ -85035,7 +86396,7 @@ var ts; return cleanup(input); return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.assertions, input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); } - default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: ".concat(ts.SyntaxKind[input.kind])); + default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: ".concat(ts.Debug.formatSyntaxKind(input.kind))); } } if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) { @@ -85076,7 +86437,7 @@ var ts; resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; - return factory.updateExportDeclaration(input, undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier), ts.getResolutionModeOverrideForClause(input.assertClause) ? input.assertClause : undefined); + return factory.updateExportDeclaration(input, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier), ts.getResolutionModeOverrideForClause(input.assertClause) ? input.assertClause : undefined); } case 271: { if (ts.isSourceFile(input.parent)) { @@ -85098,7 +86459,7 @@ var ts; var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135)] : [], factory.createVariableDeclarationList([varDecl], 2)); preserveJsDoc(statement, input); ts.removeAllComments(input); - return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; + return [statement, factory.updateExportAssignment(input, input.modifiers, newId)]; } } } @@ -85110,7 +86471,7 @@ var ts; if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512) || !ts.canHaveModifiers(statement)) { return statement; } - var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (125951 ^ 1)); + var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (257023 ^ 1)); return factory.updateModifiers(statement, modifiers); } function transformTopLevelDeclaration(input) { @@ -85145,15 +86506,15 @@ var ts; var previousNeedsDeclare = needsDeclare; switch (input.kind) { case 259: - return cleanup(factory.updateTypeAliasDeclaration(input, undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); + return cleanup(factory.updateTypeAliasDeclaration(input, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); case 258: { - return cleanup(factory.updateInterfaceDeclaration(input, undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); + return cleanup(factory.updateInterfaceDeclaration(input, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } case 256: { - var clean = cleanup(factory.updateFunctionDeclaration(input, undefined, ensureModifiers(input), undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), undefined)); + var clean = cleanup(factory.updateFunctionDeclaration(input, ensureModifiers(input), undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), undefined)); if (clean && resolver.isExpandoFunctionDeclaration(input) && shouldEmitFunctionProperties(input)) { var props = resolver.getPropertiesOfContainerFunction(input); - var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(undefined, undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16); + var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16); ts.setParent(fakespace_1, enclosingDeclaration); fakespace_1.locals = ts.createSymbolTable(props); fakespace_1.symbol = props[0].parent; @@ -85178,19 +86539,19 @@ var ts; declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0); }); } else { - declarations.push(factory.createExportDeclaration(undefined, undefined, false, factory.createNamedExports(ts.map(exportMappings_1, function (_a) { + declarations.push(factory.createExportDeclaration(undefined, false, factory.createNamedExports(ts.map(exportMappings_1, function (_a) { var gen = _a[0], exp = _a[1]; return factory.createExportSpecifier(false, gen, exp); })))); } - var namespaceDecl = factory.createModuleDeclaration(undefined, ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16); + var namespaceDecl = factory.createModuleDeclaration(ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16); if (!ts.hasEffectiveModifier(clean, 512)) { return [clean, namespaceDecl]; } var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513) | 2); - var cleanDeclaration = factory.updateFunctionDeclaration(clean, undefined, modifiers, undefined, clean.name, clean.typeParameters, clean.parameters, clean.type, undefined); - var namespaceDeclaration = factory.updateModuleDeclaration(namespaceDecl, undefined, modifiers, namespaceDecl.name, namespaceDecl.body); - var exportDefaultDeclaration = factory.createExportAssignment(undefined, undefined, false, namespaceDecl.name); + var cleanDeclaration = factory.updateFunctionDeclaration(clean, modifiers, undefined, clean.name, clean.typeParameters, clean.parameters, clean.type, undefined); + var namespaceDeclaration = factory.updateModuleDeclaration(namespaceDecl, modifiers, namespaceDecl.name, namespaceDecl.body); + var exportDefaultDeclaration = factory.createExportAssignment(undefined, false, namespaceDecl.name); if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -85227,7 +86588,7 @@ var ts; needsScopeFixMarker = oldNeedsScopeFix; resultHasScopeMarker = oldHasScopeFix; var mods = ensureModifiers(input); - return cleanup(factory.updateModuleDeclaration(input, undefined, mods, ts.isExternalModuleAugmentation(input) ? rewriteModuleSpecifier(input, input.name) : input.name, body)); + return cleanup(factory.updateModuleDeclaration(input, mods, ts.isExternalModuleAugmentation(input) ? rewriteModuleSpecifier(input, input.name) : input.name, body)); } else { needsDeclare = previousNeedsDeclare; @@ -85237,7 +86598,7 @@ var ts; var id = ts.getOriginalNodeId(inner); var body = lateStatementReplacementMap.get(id); lateStatementReplacementMap.delete(id); - return cleanup(factory.updateModuleDeclaration(input, undefined, mods, input.name, body)); + return cleanup(factory.updateModuleDeclaration(input, mods, input.name, body)); } } case 257: { @@ -85254,7 +86615,7 @@ var ts; return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); if (param.name.kind === 79) { - return preserveJsDoc(factory.createPropertyDeclaration(undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); + return preserveJsDoc(factory.createPropertyDeclaration(ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } else { return walkBindingPattern(param.name); @@ -85269,7 +86630,7 @@ var ts; elems = ts.concatenate(elems, walkBindingPattern(elem.name)); } elems = elems || []; - elems.push(factory.createPropertyDeclaration(undefined, ensureModifiers(param), elem.name, undefined, ensureType(elem, undefined), undefined)); + elems.push(factory.createPropertyDeclaration(ensureModifiers(param), elem.name, undefined, ensureType(elem, undefined), undefined)); } return elems; } @@ -85278,7 +86639,7 @@ var ts; } var hasPrivateIdentifier = ts.some(input.members, function (member) { return !!member.name && ts.isPrivateIdentifier(member.name); }); var privateIdentifier = hasPrivateIdentifier ? [ - factory.createPropertyDeclaration(undefined, undefined, factory.createPrivateIdentifier("#private"), undefined, undefined, undefined) + factory.createPropertyDeclaration(undefined, factory.createPrivateIdentifier("#private"), undefined, undefined, undefined) ] : undefined; var memberNodes = ts.concatenate(ts.concatenate(privateIdentifier, parameterProperties), ts.visitNodes(input.members, visitDeclarationSubtree)); var members = factory.createNodeArray(memberNodes); @@ -85303,18 +86664,18 @@ var ts; } return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104; })), visitDeclarationSubtree)); })); - return [statement, cleanup(factory.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; + return [statement, cleanup(factory.updateClassDeclaration(input, modifiers, input.name, typeParameters, heritageClauses, members))]; } else { var heritageClauses = transformHeritageClauses(input.heritageClauses); - return cleanup(factory.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members)); + return cleanup(factory.updateClassDeclaration(input, modifiers, input.name, typeParameters, heritageClauses, members)); } } case 237: { return cleanup(transformVariableStatement(input)); } case 260: { - return cleanup(factory.updateEnumDeclaration(input, undefined, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) { + return cleanup(factory.updateEnumDeclaration(input, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; var constValue = resolver.getConstantValue(m); @@ -85322,7 +86683,7 @@ var ts; })))); } } - return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: ".concat(ts.SyntaxKind[input.kind])); + return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: ".concat(ts.Debug.formatSyntaxKind(input.kind))); function cleanup(node) { if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; @@ -85396,12 +86757,12 @@ var ts; var currentFlags = ts.getEffectiveModifierFlags(node); var newFlags = ensureModifierFlags(node); if (currentFlags === newFlags) { - return node.modifiers; + return ts.visitArray(node.modifiers, function (n) { return ts.tryCast(n, ts.isModifier); }, ts.isModifier); } return factory.createModifiersFromModifierFlags(newFlags); } function ensureModifierFlags(node) { - var mask = 125951 ^ (4 | 256 | 16384); + var mask = 257023 ^ (4 | 256 | 16384); var additions = (needsDeclare && !isAlwaysType(node)) ? 2 : 0; var parentIsFile = node.parent.kind === 305; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { @@ -85439,7 +86800,7 @@ var ts; return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); } function maskModifierFlags(node, modifierMask, modifierAdditions) { - if (modifierMask === void 0) { modifierMask = 125951 ^ 4; } + if (modifierMask === void 0) { modifierMask = 257023 ^ 4; } if (modifierAdditions === void 0) { modifierAdditions = 0; } var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions; if (flags & 512 && !(flags & 1)) { @@ -85546,6 +86907,7 @@ var ts; var transformers = []; ts.addRange(transformers, customTransformers && ts.map(customTransformers.before, wrapScriptTransformerFactory)); transformers.push(ts.transformTypeScript); + transformers.push(ts.transformLegacyDecorators); transformers.push(ts.transformClassFields); if (ts.getJSXTransformEnabled(compilerOptions)) { transformers.push(ts.transformJsx); @@ -86190,7 +87552,6 @@ var ts; var _b = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _b.enter, exit = _b.exit; var bundleBuildInfo; var emitSkipped = false; - var exportedModulesFromDeclarationEmit; enter(); forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile); exit(); @@ -86199,7 +87560,6 @@ var ts; diagnostics: emitterDiagnostics.getDiagnostics(), emittedFiles: emittedFilesList, sourceMaps: sourceMapDataList, - exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit }; function emitSourceFileOrBundle(_a, sourceFileOrBundle) { var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; @@ -86252,13 +87612,14 @@ var ts; return; } var version = ts.version; - ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program, version: version }), false); + var buildInfo = { bundle: bundle, program: program, version: version }; + ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText(buildInfo), false, undefined, { buildInfo: buildInfo }); } function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo) { if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) { return; } - if ((jsFilePath && host.isEmitBlocked(jsFilePath)) || compilerOptions.noEmit) { + if (host.isEmitBlocked(jsFilePath) || compilerOptions.noEmit) { emitSkipped = true; return; } @@ -86283,7 +87644,7 @@ var ts; substituteNode: transform.substituteNode, }); ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform"); - printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, compilerOptions); transform.dispose(); if (bundleBuildInfo) bundleBuildInfo.js = printer.bundleFileInfo; @@ -86315,7 +87676,7 @@ var ts; noEmitHelpers: true, module: compilerOptions.module, target: compilerOptions.target, - sourceMap: compilerOptions.sourceMap, + sourceMap: !forceDtsEmit && compilerOptions.declarationMap, inlineSourceMap: compilerOptions.inlineSourceMap, extendedDiagnostics: compilerOptions.extendedDiagnostics, onlyPrintJsDocStyle: true, @@ -86333,16 +87694,12 @@ var ts; emitSkipped = emitSkipped || declBlocked; if (!declBlocked || forceDtsEmit) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); - printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { - sourceMap: !forceDtsEmit && compilerOptions.declarationMap, + printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform, declarationPrinter, { + sourceMap: printerOptions.sourceMap, sourceRoot: compilerOptions.sourceRoot, mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 305) { - var sourceFile = declarationTransform.transformed[0]; - exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; - } } declarationTransform.dispose(); if (bundleBuildInfo) @@ -86361,7 +87718,8 @@ var ts; } ts.forEachChild(node, collectLinkedAliases); } - function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, mapOptions) { + var sourceFileOrBundle = transform.transformed[0]; var bundle = sourceFileOrBundle.kind === 306 ? sourceFileOrBundle : undefined; var sourceFile = sourceFileOrBundle.kind === 305 ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; @@ -86393,12 +87751,17 @@ var ts; if (sourceMapFilePath) { var sourceMap = sourceMapGenerator.toString(); ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, false, sourceFiles); + if (printer.bundleFileInfo) + printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, ts.maybeBind(host, host.createHash)); } } else { writer.writeLine(); } - ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos }); + var text = writer.getText(); + ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos, diagnostics: transform.diagnostics }); + if (printer.bundleFileInfo) + printer.bundleFileInfo.hash = ts.computeSignature(text, ts.maybeBind(host, host.createHash)); writer.clear(); } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { @@ -86523,30 +87886,50 @@ var ts; }); } function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) { + var createHash = ts.maybeBind(host, host.createHash); var _a = getOutputPathsForBundle(config.options, false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath; - var buildInfoText = host.readFile(ts.Debug.checkDefined(buildInfoPath)); - if (!buildInfoText) + var buildInfo; + if (host.getBuildInfo) { + var hostBuildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath); + if (!hostBuildInfo) + return buildInfoPath; + buildInfo = hostBuildInfo; + } + else { + var buildInfoText = host.readFile(buildInfoPath); + if (!buildInfoText) + return buildInfoPath; + buildInfo = getBuildInfo(buildInfoText); + } + if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationFilePath && !buildInfo.bundle.dts)) return buildInfoPath; var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath)); if (!jsFileText) return jsFilePath; + if (ts.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash) + return jsFilePath; var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath); if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap) return sourceMapFilePath || "inline sourcemap decoding"; + if (sourceMapFilePath && ts.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash) + return sourceMapFilePath; var declarationText = declarationFilePath && host.readFile(declarationFilePath); if (declarationFilePath && !declarationText) return declarationFilePath; + if (declarationFilePath && ts.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash) + return declarationFilePath; var declarationMapText = declarationMapPath && host.readFile(declarationMapPath); if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap) return declarationMapPath || "inline sourcemap decoding"; - var buildInfo = getBuildInfo(buildInfoText); - if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts)) - return buildInfoPath; + if (declarationMapPath && ts.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash) + return declarationMapPath; var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory())); var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, true); var outputFiles = []; var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); }); var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host); + var changedDtsText; + var changedDtsData; var emitHost = { getPrependNodes: ts.memoize(function () { return __spreadArray(__spreadArray([], prependNodes, true), [ownPrependInput], false); }), getCanonicalFileName: host.getCanonicalFileName, @@ -86562,7 +87945,7 @@ var ts; getResolvedProjectReferenceToRedirect: ts.returnUndefined, getProjectReferenceRedirect: ts.returnUndefined, isSourceOfProjectReferenceRedirect: ts.returnFalse, - writeFile: function (name, text, writeByteOrderMark) { + writeFile: function (name, text, writeByteOrderMark, _onError, _sourceFiles, data) { switch (name) { case jsFilePath: if (jsFileText === text) @@ -86573,19 +87956,24 @@ var ts; return; break; case buildInfoPath: - var newBuildInfo = getBuildInfo(text); + var newBuildInfo = data.buildInfo; newBuildInfo.program = buildInfo.program; + if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) { + newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData); + } var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles; newBuildInfo.bundle.js.sources = js.sources; if (dts) { newBuildInfo.bundle.dts.sources = dts.sources; } newBuildInfo.bundle.sourceFiles = sourceFiles; - outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark }); + outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark, buildInfo: newBuildInfo }); return; case declarationFilePath: if (declarationText === text) return; + changedDtsText = text; + changedDtsData = data; break; case declarationMapPath: if (declarationMapText === text) @@ -86604,6 +87992,7 @@ var ts; getSourceFileFromReference: ts.returnUndefined, redirectTargetsMap: ts.createMultiMap(), getFileIncludeReasons: ts.notImplemented, + createHash: createHash, }; emitFiles(ts.notImplementedResolver, emitHost, undefined, ts.getTransformers(config.options, customTransformers)); return outputFiles; @@ -87598,8 +88987,7 @@ var ts; } } function emitParameter(node) { - emitDecorators(node, node.decorators); - emitModifiers(node, node.modifiers); + emitDecoratorsAndModifiers(node, node.modifiers); emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); @@ -87609,14 +88997,13 @@ var ts; else { emitTypeAnnotation(node.type); } - emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name ? node.name.end : node.modifiers ? node.modifiers.end : node.decorators ? node.decorators.end : node.pos, node, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name ? node.name.end : node.modifiers ? node.modifiers.end : node.pos, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitDecorator(decorator) { writePunctuation("@"); emitExpression(decorator.expression, parenthesizer.parenthesizeLeftSideOfAccess); } function emitPropertySignature(node) { - emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emitNodeWithWriter(node.name, writeProperty); emit(node.questionToken); @@ -87624,8 +89011,7 @@ var ts; writeTrailingSemicolon(); } function emitPropertyDeclaration(node) { - emitDecorators(node, node.decorators); - emitModifiers(node, node.modifiers); + emitDecoratorsAndModifiers(node, node.modifiers); emit(node.name); emit(node.questionToken); emit(node.exclamationToken); @@ -87635,7 +89021,6 @@ var ts; } function emitMethodSignature(node) { pushNameGenerationScope(node); - emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); emit(node.questionToken); @@ -87646,16 +89031,13 @@ var ts; popNameGenerationScope(node); } function emitMethodDeclaration(node) { - emitDecorators(node, node.decorators); - emitModifiers(node, node.modifiers); + emitDecoratorsAndModifiers(node, node.modifiers); emit(node.asteriskToken); emit(node.name); emit(node.questionToken); emitSignatureAndBody(node, emitSignatureHead); } function emitClassStaticBlockDeclaration(node) { - emitDecorators(node, node.decorators); - emitModifiers(node, node.modifiers); writeKeyword("static"); emitBlockFunctionBody(node.body); } @@ -87665,8 +89047,7 @@ var ts; emitSignatureAndBody(node, emitSignatureHead); } function emitAccessorDeclaration(node) { - emitDecorators(node, node.decorators); - emitModifiers(node, node.modifiers); + emitDecoratorsAndModifiers(node, node.modifiers); writeKeyword(node.kind === 172 ? "get" : "set"); writeSpace(); emit(node.name); @@ -87674,8 +89055,6 @@ var ts; } function emitCallSignature(node) { pushNameGenerationScope(node); - emitDecorators(node, node.decorators); - emitModifiers(node, node.modifiers); emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitTypeAnnotation(node.type); @@ -87684,8 +89063,6 @@ var ts; } function emitConstructSignature(node) { pushNameGenerationScope(node); - emitDecorators(node, node.decorators); - emitModifiers(node, node.modifiers); writeKeyword("new"); writeSpace(); emitTypeParameters(node, node.typeParameters); @@ -87695,7 +89072,6 @@ var ts; popNameGenerationScope(node); } function emitIndexSignature(node) { - emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emitParametersForIndexSignature(node, node.parameters); emitTypeAnnotation(node.type); @@ -88072,7 +89448,6 @@ var ts; emitFunctionDeclarationOrExpression(node); } function emitArrowFunction(node) { - emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emitSignatureAndBody(node, emitArrowFunctionHead); } @@ -88523,7 +89898,6 @@ var ts; emitFunctionDeclarationOrExpression(node); } function emitFunctionDeclarationOrExpression(node) { - emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); writeKeyword("function"); emit(node.asteriskToken); @@ -88575,8 +89949,8 @@ var ts; if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) { return false; } - if (getLeadingLineTerminatorCount(body, body.statements, 2) - || getClosingLineTerminatorCount(body, body.statements, 2)) { + if (getLeadingLineTerminatorCount(body, ts.firstOrUndefined(body.statements), 2) + || getClosingLineTerminatorCount(body, ts.lastOrUndefined(body.statements), 2, body.statements)) { return false; } var previousStatement; @@ -88623,8 +89997,7 @@ var ts; } function emitClassDeclarationOrExpression(node) { ts.forEach(node.members, generateMemberNames); - emitDecorators(node, node.decorators); - emitModifiers(node, node.modifiers); + emitDecoratorsAndModifiers(node, node.modifiers); writeKeyword("class"); if (node.name) { writeSpace(); @@ -88645,7 +90018,6 @@ var ts; } } function emitInterfaceDeclaration(node) { - emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); writeKeyword("interface"); writeSpace(); @@ -88658,7 +90030,6 @@ var ts; writePunctuation("}"); } function emitTypeAliasDeclaration(node) { - emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); writeKeyword("type"); writeSpace(); @@ -89252,8 +90623,8 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference", data: directive.fileName }); writeLine(); } - for (var _d = 0, types_24 = types; _d < types_24.length; _d++) { - var directive = types_24[_d]; + for (var _d = 0, types_23 = types; _d < types_23.length; _d++) { + var directive = types_23[_d]; var pos = writer.getTextPos(); var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat) ? "resolution-mode=\"".concat(directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require", "\"") @@ -89417,12 +90788,47 @@ var ts; emit(node); write = savedWrite; } - function emitModifiers(node, modifiers) { - if (modifiers && modifiers.length) { - emitList(node, modifiers, 262656); - writeSpace(); + function emitDecoratorsAndModifiers(node, modifiers) { + if (modifiers === null || modifiers === void 0 ? void 0 : modifiers.length) { + if (ts.every(modifiers, ts.isModifier)) { + return emitModifiers(node, modifiers); + } + if (ts.every(modifiers, ts.isDecorator)) { + return emitDecorators(node, modifiers); + } + onBeforeEmitNodeArray === null || onBeforeEmitNodeArray === void 0 ? void 0 : onBeforeEmitNodeArray(modifiers); + var lastMode = void 0; + var mode = void 0; + var start = 0; + var pos = 0; + while (start < modifiers.length) { + while (pos < modifiers.length) { + var modifier = modifiers[pos]; + mode = ts.isDecorator(modifier) ? "decorators" : "modifiers"; + if (lastMode === undefined) { + lastMode = mode; + } + else if (mode !== lastMode) { + break; + } + pos++; + } + var textRange = { pos: -1, end: -1 }; + if (start === 0) + textRange.pos = modifiers.pos; + if (pos === modifiers.length - 1) + textRange.end = modifiers.end; + emitNodeListItems(emit, node, modifiers, lastMode === "modifiers" ? 2359808 : 2146305, undefined, start, pos - start, false, textRange); + start = pos; + lastMode = mode; + pos++; + } + onAfterEmitNodeArray === null || onAfterEmitNodeArray === void 0 ? void 0 : onAfterEmitNodeArray(modifiers); } } + function emitModifiers(node, modifiers) { + emitList(node, modifiers, 2359808); + } function emitTypeAnnotation(node) { if (node) { writePunctuation(":"); @@ -89500,10 +90906,8 @@ var ts; && parameter.pos === parentNode.pos && ts.isArrowFunction(parentNode) && !parentNode.type - && !ts.some(parentNode.decorators) && !ts.some(parentNode.modifiers) && !ts.some(parentNode.typeParameters) - && !ts.some(parameter.decorators) && !ts.some(parameter.modifiers) && !parameter.dotDotDotToken && !parameter.questionToken @@ -89559,12 +90963,8 @@ var ts; } var isEmpty = children === undefined || start >= children.length || count === 0; if (isEmpty && format & 32768) { - if (onBeforeEmitNodeArray) { - onBeforeEmitNodeArray(children); - } - if (onAfterEmitNodeArray) { - onAfterEmitNodeArray(children); - } + onBeforeEmitNodeArray === null || onBeforeEmitNodeArray === void 0 ? void 0 : onBeforeEmitNodeArray(children); + onAfterEmitNodeArray === null || onAfterEmitNodeArray === void 0 ? void 0 : onAfterEmitNodeArray(children); return; } if (format & 15360) { @@ -89573,9 +90973,7 @@ var ts; emitTrailingCommentsOfPosition(children.pos, true); } } - if (onBeforeEmitNodeArray) { - onBeforeEmitNodeArray(children); - } + onBeforeEmitNodeArray === null || onBeforeEmitNodeArray === void 0 ? void 0 : onBeforeEmitNodeArray(children); if (isEmpty) { if (format & 1 && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { writeLine(); @@ -89585,99 +90983,99 @@ var ts; } } else { - ts.Debug.type(children); - var mayEmitInterveningComments = (format & 262144) === 0; - var shouldEmitInterveningComments = mayEmitInterveningComments; - var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children, format); - if (leadingLineTerminatorCount) { - writeLine(leadingLineTerminatorCount); - shouldEmitInterveningComments = false; - } - else if (format & 256) { - writeSpace(); + emitNodeListItems(emit, parentNode, children, format, parenthesizerRule, start, count, children.hasTrailingComma, children); + } + onAfterEmitNodeArray === null || onAfterEmitNodeArray === void 0 ? void 0 : onAfterEmitNodeArray(children); + if (format & 15360) { + if (isEmpty && children) { + emitLeadingCommentsOfPosition(children.end); } - if (format & 128) { - increaseIndent(); + writePunctuation(getClosingBracket(format)); + } + } + function emitNodeListItems(emit, parentNode, children, format, parenthesizerRule, start, count, hasTrailingComma, childrenTextRange) { + var mayEmitInterveningComments = (format & 262144) === 0; + var shouldEmitInterveningComments = mayEmitInterveningComments; + var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children[start], format); + if (leadingLineTerminatorCount) { + writeLine(leadingLineTerminatorCount); + shouldEmitInterveningComments = false; + } + else if (format & 256) { + writeSpace(); + } + if (format & 128) { + increaseIndent(); + } + var emitListItem = getEmitListItem(emit, parenthesizerRule); + var previousSibling; + var previousSourceFileTextKind; + var shouldDecreaseIndentAfterEmit = false; + for (var i = 0; i < count; i++) { + var child = children[start + i]; + if (format & 32) { + writeLine(); + writeDelimiter(format); } - var emitListItem = getEmitListItem(emit, parenthesizerRule); - var previousSibling = void 0; - var previousSourceFileTextKind = void 0; - var shouldDecreaseIndentAfterEmit = false; - for (var i = 0; i < count; i++) { - var child = children[start + i]; - if (format & 32) { - writeLine(); - writeDelimiter(format); - } - else if (previousSibling) { - if (format & 60 && previousSibling.end !== (parentNode ? parentNode.end : -1)) { - emitLeadingCommentsOfPosition(previousSibling.end); - } - writeDelimiter(format); - recordBundleFileInternalSectionEnd(previousSourceFileTextKind); - var separatingLineTerminatorCount = getSeparatingLineTerminatorCount(previousSibling, child, format); - if (separatingLineTerminatorCount > 0) { - if ((format & (3 | 128)) === 0) { - increaseIndent(); - shouldDecreaseIndentAfterEmit = true; - } - writeLine(separatingLineTerminatorCount); - shouldEmitInterveningComments = false; - } - else if (previousSibling && format & 512) { - writeSpace(); - } - } - previousSourceFileTextKind = recordBundleFileInternalSectionStart(child); - if (shouldEmitInterveningComments) { - var commentRange = ts.getCommentRange(child); - emitTrailingCommentsOfPosition(commentRange.pos); + else if (previousSibling) { + if (format & 60 && previousSibling.end !== (parentNode ? parentNode.end : -1)) { + emitLeadingCommentsOfPosition(previousSibling.end); } - else { - shouldEmitInterveningComments = mayEmitInterveningComments; + writeDelimiter(format); + recordBundleFileInternalSectionEnd(previousSourceFileTextKind); + var separatingLineTerminatorCount = getSeparatingLineTerminatorCount(previousSibling, child, format); + if (separatingLineTerminatorCount > 0) { + if ((format & (3 | 128)) === 0) { + increaseIndent(); + shouldDecreaseIndentAfterEmit = true; + } + writeLine(separatingLineTerminatorCount); + shouldEmitInterveningComments = false; } - nextListElementPos = child.pos; - emitListItem(child, emit, parenthesizerRule, i); - if (shouldDecreaseIndentAfterEmit) { - decreaseIndent(); - shouldDecreaseIndentAfterEmit = false; + else if (previousSibling && format & 512) { + writeSpace(); } - previousSibling = child; } - var emitFlags = previousSibling ? ts.getEmitFlags(previousSibling) : 0; - var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024); - var hasTrailingComma = (children === null || children === void 0 ? void 0 : children.hasTrailingComma) && (format & 64) && (format & 16); - if (hasTrailingComma) { - if (previousSibling && !skipTrailingComments) { - emitTokenWithComment(27, previousSibling.end, writePunctuation, previousSibling); - } - else { - writePunctuation(","); - } + previousSourceFileTextKind = recordBundleFileInternalSectionStart(child); + if (shouldEmitInterveningComments) { + var commentRange = ts.getCommentRange(child); + emitTrailingCommentsOfPosition(commentRange.pos); } - if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60) && !skipTrailingComments) { - emitLeadingCommentsOfPosition(hasTrailingComma && (children === null || children === void 0 ? void 0 : children.end) ? children.end : previousSibling.end); + else { + shouldEmitInterveningComments = mayEmitInterveningComments; } - if (format & 128) { + nextListElementPos = child.pos; + emitListItem(child, emit, parenthesizerRule, i); + if (shouldDecreaseIndentAfterEmit) { decreaseIndent(); + shouldDecreaseIndentAfterEmit = false; } - recordBundleFileInternalSectionEnd(previousSourceFileTextKind); - var closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children, format); - if (closingLineTerminatorCount) { - writeLine(closingLineTerminatorCount); + previousSibling = child; + } + var emitFlags = previousSibling ? ts.getEmitFlags(previousSibling) : 0; + var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024); + var emitTrailingComma = hasTrailingComma && (format & 64) && (format & 16); + if (emitTrailingComma) { + if (previousSibling && !skipTrailingComments) { + emitTokenWithComment(27, previousSibling.end, writePunctuation, previousSibling); } - else if (format & (2097152 | 256)) { - writeSpace(); + else { + writePunctuation(","); } } - if (onAfterEmitNodeArray) { - onAfterEmitNodeArray(children); + if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60) && !skipTrailingComments) { + emitLeadingCommentsOfPosition(emitTrailingComma && (childrenTextRange === null || childrenTextRange === void 0 ? void 0 : childrenTextRange.end) ? childrenTextRange.end : previousSibling.end); } - if (format & 15360) { - if (isEmpty && children) { - emitLeadingCommentsOfPosition(children.end); - } - writePunctuation(getClosingBracket(format)); + if (format & 128) { + decreaseIndent(); + } + recordBundleFileInternalSectionEnd(previousSourceFileTextKind); + var closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children[start + count - 1], format, childrenTextRange); + if (closingLineTerminatorCount) { + writeLine(closingLineTerminatorCount); + } + else if (format & (2097152 | 256)) { + writeSpace(); } } function writeLiteral(s) { @@ -89801,31 +91199,30 @@ var ts; decreaseIndent(); } } - function getLeadingLineTerminatorCount(parentNode, children, format) { + function getLeadingLineTerminatorCount(parentNode, firstChild, format) { if (format & 2 || preserveSourceNewlines) { if (format & 65536) { return 1; } - var firstChild_1 = children[0]; - if (firstChild_1 === undefined) { + if (firstChild === undefined) { return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } - if (firstChild_1.pos === nextListElementPos) { + if (firstChild.pos === nextListElementPos) { return 0; } - if (firstChild_1.kind === 11) { + if (firstChild.kind === 11) { return 0; } if (currentSourceFile && parentNode && !ts.positionIsSynthesized(parentNode.pos) && - !ts.nodeIsSynthesized(firstChild_1) && - (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) { + !ts.nodeIsSynthesized(firstChild) && + (!firstChild.parent || ts.getOriginalNode(firstChild.parent) === ts.getOriginalNode(parentNode))) { if (preserveSourceNewlines) { - return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(firstChild_1.pos, parentNode.pos, currentSourceFile, includeComments); }); + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(firstChild.pos, parentNode.pos, currentSourceFile, includeComments); }); } - return ts.rangeStartPositionsAreOnSameLine(parentNode, firstChild_1, currentSourceFile) ? 0 : 1; + return ts.rangeStartPositionsAreOnSameLine(parentNode, firstChild, currentSourceFile) ? 0 : 1; } - if (synthesizedNodeStartsOnNewLine(firstChild_1, format)) { + if (synthesizedNodeStartsOnNewLine(firstChild, format)) { return 1; } } @@ -89857,18 +91254,17 @@ var ts; } return format & 1 ? 1 : 0; } - function getClosingLineTerminatorCount(parentNode, children, format) { + function getClosingLineTerminatorCount(parentNode, lastChild, format, childrenTextRange) { if (format & 2 || preserveSourceNewlines) { if (format & 65536) { return 1; } - var lastChild = ts.lastOrUndefined(children); if (lastChild === undefined) { return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } if (currentSourceFile && parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { if (preserveSourceNewlines) { - var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end; + var end_1 = childrenTextRange && !ts.positionIsSynthesized(childrenTextRange.end) ? childrenTextRange.end : lastChild.end; return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); }); } return ts.rangeEndPositionsAreOnSameLine(parentNode, lastChild, currentSourceFile) ? 0 : 1; @@ -89891,14 +91287,14 @@ var ts; return lines; } function writeLineSeparatorsAndIndentBefore(node, parent) { - var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0); + var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, node, 0); if (leadingNewlines) { writeLinesAndIndent(leadingNewlines, false); } return !!leadingNewlines; } function writeLineSeparatorsAfter(node, parent) { - var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0); + var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, node, 0, undefined); if (trailingNewlines) { writeLine(trailingNewlines); } @@ -91296,7 +92692,7 @@ var ts; originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false)); }; } - if (originalDirectoryExists && originalCreateDirectory) { + if (originalDirectoryExists) { host.directoryExists = function (directory) { var key = toPath(directory); var value = directoryExistsCache.get(key); @@ -91306,11 +92702,13 @@ var ts; directoryExistsCache.set(key, !!newValue); return newValue; }; - host.createDirectory = function (directory) { - var key = toPath(directory); - directoryExistsCache.delete(key); - originalCreateDirectory.call(host, directory); - }; + if (originalCreateDirectory) { + host.createDirectory = function (directory) { + var key = toPath(directory); + directoryExistsCache.delete(key); + originalCreateDirectory.call(host, directory); + }; + } } return { originalReadFile: originalReadFile, @@ -91743,6 +93141,11 @@ var ts; } ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) { + var result = getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options); + return typeof result === "object" ? result.impliedNodeFormat : result; + } + ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile; + function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options) { switch (ts.getEmitModuleResolutionKind(options)) { case ts.ModuleResolutionKind.Node16: case ts.ModuleResolutionKind.NodeNext: @@ -91754,11 +93157,16 @@ var ts; return undefined; } function lookupFromPackageJson() { - var scope = ts.getPackageScopeForPath(fileName, packageJsonInfoCache, host, options); - return (scope === null || scope === void 0 ? void 0 : scope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS; + var state = ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options); + var packageJsonLocations = []; + state.failedLookupLocations = packageJsonLocations; + state.affectingLocations = packageJsonLocations; + var packageJsonScope = ts.getPackageScopeForPath(fileName, state); + var impliedNodeFormat = (packageJsonScope === null || packageJsonScope === void 0 ? void 0 : packageJsonScope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS; + return { impliedNodeFormat: impliedNodeFormat, packageJsonLocations: packageJsonLocations, packageJsonScope: packageJsonScope }; } } - ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile; + ts.getImpliedNodeFormatForFileWorker = getImpliedNodeFormatForFileWorker; ts.plainJSErrors = new ts.Set([ ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0.code, ts.Diagnostics.A_module_cannot_have_multiple_default_exports.code, @@ -91848,6 +93256,9 @@ var ts; ts.Diagnostics.extends_clause_already_seen.code, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block.code, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations.code, + ts.Diagnostics.Class_constructor_may_not_be_a_generator.code, + ts.Diagnostics.Class_constructor_may_not_be_an_accessor.code, + ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code, ]); function shouldProgramCreateNewSourceFiles(program, newOptions) { if (!program) @@ -92033,7 +93444,7 @@ var ts; for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { var oldSourceFile = oldSourceFiles_1[_i]; var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); - if (shouldCreateNewSourceFile || !newFile || + if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat || (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) { host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path)); } @@ -92363,7 +93774,7 @@ var ts; }); } function tryReuseStructureFromOldProgram() { - var _a; + var _a, _b; if (!oldProgram) { return 0; } @@ -92391,12 +93802,15 @@ var ts; var seenPackageNames = new ts.Map(); for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) { var oldSourceFile = oldSourceFiles_2[_i]; + var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options); var newSourceFile = host.getSourceFileByPath - ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), undefined, shouldCreateNewSourceFile) - : host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), undefined, shouldCreateNewSourceFile); + ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, sourceFileOptions, undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat) + : host.getSourceFile(oldSourceFile.fileName, sourceFileOptions, undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat); if (!newSourceFile) { return 0; } + newSourceFile.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined; + newSourceFile.packageJsonScope = sourceFileOptions.packageJsonScope; ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`"); var fileChanged = void 0; if (oldSourceFile.redirectInfo) { @@ -92429,27 +93843,32 @@ var ts; seenPackageNames.set(packageName, newKind); } if (fileChanged) { - if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { + if (oldSourceFile.impliedNodeFormat !== newSourceFile.impliedNodeFormat) { structureIsReused = 1; } - if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + else if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { structureIsReused = 1; } - if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + else if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { structureIsReused = 1; } - collectExternalModuleReferences(newSourceFile); - if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + else if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { structureIsReused = 1; } - if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { - structureIsReused = 1; - } - if ((oldSourceFile.flags & 6291456) !== (newSourceFile.flags & 6291456)) { - structureIsReused = 1; - } - if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { - structureIsReused = 1; + else { + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + structureIsReused = 1; + } + else if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { + structureIsReused = 1; + } + else if ((oldSourceFile.flags & 6291456) !== (newSourceFile.flags & 6291456)) { + structureIsReused = 1; + } + else if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { + structureIsReused = 1; + } } modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } @@ -92463,17 +93882,17 @@ var ts; return structureIsReused; } var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; }); - for (var _b = 0, oldSourceFiles_3 = oldSourceFiles; _b < oldSourceFiles_3.length; _b++) { - var oldFile = oldSourceFiles_3[_b]; + for (var _c = 0, oldSourceFiles_3 = oldSourceFiles; _c < oldSourceFiles_3.length; _c++) { + var oldFile = oldSourceFiles_3[_c]; if (!ts.contains(modifiedFiles, oldFile)) { - for (var _c = 0, _d = oldFile.ambientModuleNames; _c < _d.length; _c++) { - var moduleName = _d[_c]; + for (var _d = 0, _e = oldFile.ambientModuleNames; _d < _e.length; _d++) { + var moduleName = _e[_d]; ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName); } } } - for (var _e = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _e < modifiedSourceFiles_1.length; _e++) { - var _f = modifiedSourceFiles_1[_e], oldSourceFile = _f.oldFile, newSourceFile = _f.newFile; + for (var _f = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _f < modifiedSourceFiles_1.length; _f++) { + var _g = modifiedSourceFiles_1[_f], oldSourceFile = _g.oldFile, newSourceFile = _g.newFile; var moduleNames = getModuleNames(newSourceFile); var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile); var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo); @@ -92498,13 +93917,13 @@ var ts; if (structureIsReused !== 2) { return structureIsReused; } - if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) { + if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_b = host.hasChangedAutomaticTypeDirectiveNames) === null || _b === void 0 ? void 0 : _b.call(host))) { return 1; } missingFilePaths = oldProgram.getMissingFilePaths(); ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length); - for (var _g = 0, newSourceFiles_1 = newSourceFiles; _g < newSourceFiles_1.length; _g++) { - var newSourceFile = newSourceFiles_1[_g]; + for (var _h = 0, newSourceFiles_1 = newSourceFiles; _h < newSourceFiles_1.length; _h++) { + var newSourceFile = newSourceFiles_1[_h]; filesByName.set(newSourceFile.path, newSourceFile); } var oldFilesByNameMap = oldProgram.getFilesByNameMap(); @@ -92563,6 +93982,7 @@ var ts; getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); }, redirectTargetsMap: redirectTargetsMap, getFileIncludeReasons: program.getFileIncludeReasons, + createHash: ts.maybeBind(host, host.createHash), }; } function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) { @@ -92875,7 +94295,7 @@ var ts; } } function walkArray(nodes, parent) { - if (parent.decorators === nodes && !options.experimentalDecorators) { + if (ts.canHaveModifiers(parent) && parent.modifiers === nodes && ts.some(nodes, ts.isDecorator) && !options.experimentalDecorators) { 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_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { @@ -92902,7 +94322,7 @@ var ts; if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 124) { + if (ts.isModifier(modifier) && modifier.kind !== 124) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); } } @@ -92910,7 +94330,7 @@ var ts; } break; case 164: - if (nodes === parent.modifiers) { + if (nodes === parent.modifiers && ts.some(nodes, ts.isModifier)) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)); return "skip"; } @@ -93022,7 +94442,7 @@ var ts; } function createSyntheticImport(text, file) { var externalHelpersModuleReference = ts.factory.createStringLiteral(text); - var importDecl = ts.factory.createImportDeclaration(undefined, undefined, undefined, externalHelpersModuleReference, undefined); + var importDecl = ts.factory.createImportDeclaration(undefined, undefined, externalHelpersModuleReference, undefined); ts.addEmitFlags(importDecl, 67108864); ts.setParent(externalHelpersModuleReference, importDecl); ts.setParent(importDecl, file); @@ -93203,13 +94623,16 @@ var ts; addFilePreprocessingFileExplainingDiagnostic(existingFile, reason, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, [fileName, existingFile.fileName]); } } - function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { + function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName, sourceFileOptions) { + var _a; var redirect = Object.create(redirectTarget); redirect.fileName = fileName; redirect.path = path; redirect.resolvedPath = resolvedPath; redirect.originalFileName = originalFileName; redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected }; + redirect.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined; + redirect.packageJsonScope = sourceFileOptions.packageJsonScope; sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); Object.defineProperties(redirect, { id: { @@ -93234,14 +94657,14 @@ var ts; return result; } function getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options) { - var impliedNodeFormat = getImpliedNodeFormatForFile(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options); - return { - languageVersion: ts.getEmitScriptTarget(options), - impliedNodeFormat: impliedNodeFormat, - setExternalModuleIndicator: ts.getSetExternalModuleIndicator(options) - }; + var result = getImpliedNodeFormatForFileWorker(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options); + var languageVersion = ts.getEmitScriptTarget(options); + var setExternalModuleIndicator = ts.getSetExternalModuleIndicator(options); + return typeof result === "object" ? __assign(__assign({}, result), { languageVersion: languageVersion, setExternalModuleIndicator: setExternalModuleIndicator }) : + { languageVersion: languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator }; } function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { + var _a, _b; var path = toPath(fileName); if (useSourceOfProjectReferenceRedirect) { var source = getSourceOfProjectReferenceRedirect(path); @@ -93311,12 +94734,13 @@ var ts; redirectedPath = toPath(redirect); } } - var file = host.getSourceFile(fileName, getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options), function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile); + var sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options); + var file = host.getSourceFile(fileName, sourceFileOptions, function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile || (((_a = oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getSourceFileByPath(toPath(fileName))) === null || _a === void 0 ? void 0 : _a.impliedNodeFormat) !== sourceFileOptions.impliedNodeFormat)); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); if (fileFromPackageId) { - var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName); + var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName, sourceFileOptions); redirectTargetsMap.add(fileFromPackageId.path, fileName); addFileToFilesByName(dupFile, path, redirectedPath); addFileIncludeReason(dupFile, reason); @@ -93336,6 +94760,8 @@ var ts; file.path = path; file.resolvedPath = toPath(fileName); file.originalFileName = originalFileName; + file.packageJsonLocations = ((_b = sourceFileOptions.packageJsonLocations) === null || _b === void 0 ? void 0 : _b.length) ? sourceFileOptions.packageJsonLocations : undefined; + file.packageJsonScope = sourceFileOptions.packageJsonScope; addFileIncludeReason(file, reason); if (host.useCaseSensitiveFileNames()) { var pathLowerCase = ts.toFileNameLowerCase(path); @@ -93468,7 +94894,7 @@ var ts; } } function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } @@ -93912,7 +95338,7 @@ var ts; fileIncludeReasons = undefined; var location = locationReason && getReferencedFileLocation(getSourceFileByPath, locationReason); var fileIncludeReasonDetails = fileIncludeReasons && ts.chainDiagnosticMessages(fileIncludeReasons, ts.Diagnostics.The_file_is_in_the_program_because_Colon); - var redirectInfo = file && ts.explainIfFileIsRedirect(file); + var redirectInfo = file && ts.explainIfFileIsRedirectAndImpliedFormat(file); var chain = ts.chainDiagnosticMessages.apply(void 0, __spreadArray([redirectInfo ? fileIncludeReasonDetails ? __spreadArray([fileIncludeReasonDetails], redirectInfo, true) : redirectInfo : fileIncludeReasonDetails, diagnostic], args || ts.emptyArray, false)); return location && isReferenceFileLocation(location) ? ts.createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) : @@ -93979,7 +95405,7 @@ var ts; break; } var matchedByInclude = ts.getMatchedIncludeSpec(program, fileName); - if (!matchedByInclude) + if (!matchedByInclude || !ts.isString(matchedByInclude)) return undefined; configFileNode = ts.getTsConfigPropArrayElementValue(options.configFile, "include", matchedByInclude); message = ts.Diagnostics.File_is_matched_by_include_pattern_specified_here; @@ -94457,8 +95883,8 @@ var ts; (function (ts) { function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics, exportedModulesFromDeclarationEmit = _a.exportedModulesFromDeclarationEmit; - return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics, exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit }; + var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics; + return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); } @@ -94469,13 +95895,9 @@ var ts; function createManyToManyPathMap() { function create(forward, reverse, deleted) { var map = { - clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); }, - forEach: function (fn) { return forward.forEach(fn); }, getKeys: function (v) { return reverse.get(v); }, getValues: function (k) { return forward.get(k); }, - hasKey: function (k) { return forward.has(k); }, keys: function () { return forward.keys(); }, - deletedKeys: function () { return deleted; }, deleteKey: function (k) { (deleted || (deleted = new ts.Set())).add(k); var set = forward.get(k); @@ -94502,11 +95924,6 @@ var ts; }); return map; }, - clear: function () { - forward.clear(); - reverse.clear(); - deleted === null || deleted === void 0 ? void 0 : deleted.clear(); - } }; return map; } @@ -94610,35 +96027,45 @@ var ts; } BuilderState.canReuseOldState = canReuseOldState; function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) { + var _a, _b, _c; var fileInfos = new ts.Map(); var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? createManyToManyPathMap() : undefined; var exportedModulesMap = referencedMap ? createManyToManyPathMap() : undefined; - var hasCalledUpdateShapeSignature = new ts.Set(); var useOldState = canReuseOldState(referencedMap, oldState); newProgram.getTypeChecker(); - for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; + for (var _i = 0, _d = newProgram.getSourceFiles(); _i < _d.length; _i++) { + var sourceFile = _d[_i]; var version_2 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set"); - var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.resolvedPath) : undefined; + var oldUncommittedSignature = useOldState ? (_a = oldState.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(sourceFile.resolvedPath) : undefined; + var signature = oldUncommittedSignature === undefined ? + useOldState ? (_b = oldState.fileInfos.get(sourceFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.signature : undefined : + oldUncommittedSignature || undefined; if (referencedMap) { var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName); if (newReferences) { referencedMap.set(sourceFile.resolvedPath, newReferences); } if (useOldState) { - var exportedModules = oldState.exportedModulesMap.getValues(sourceFile.resolvedPath); + var oldUncommittedExportedModules = (_c = oldState.oldExportedModulesMap) === null || _c === void 0 ? void 0 : _c.get(sourceFile.resolvedPath); + var exportedModules = oldUncommittedExportedModules === undefined ? + oldState.exportedModulesMap.getValues(sourceFile.resolvedPath) : + oldUncommittedExportedModules || undefined; if (exportedModules) { exportedModulesMap.set(sourceFile.resolvedPath, exportedModules); } } } - fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined, impliedFormat: sourceFile.impliedNodeFormat }); + fileInfos.set(sourceFile.resolvedPath, { + version: version_2, + signature: signature, + affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined, + impliedFormat: sourceFile.impliedNodeFormat + }); } return { fileInfos: fileInfos, referencedMap: referencedMap, exportedModulesMap: exportedModulesMap, - hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature, useFileVersionAsSignature: !disableUseFileVersionAsSignature && !useOldState }; } @@ -94648,93 +96075,81 @@ var ts; state.allFileNames = undefined; } BuilderState.releaseCache = releaseCache; - function clone(state) { + function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) { var _a, _b; - return { - fileInfos: new ts.Map(state.fileInfos), - referencedMap: (_a = state.referencedMap) === null || _a === void 0 ? void 0 : _a.clone(), - exportedModulesMap: (_b = state.exportedModulesMap) === null || _b === void 0 ? void 0 : _b.clone(), - hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature), - useFileVersionAsSignature: state.useFileVersionAsSignature, - }; + var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName); + (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear(); + (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear(); + return result; } - BuilderState.clone = clone; - function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, cacheToUpdateSignature, exportedModulesMapCache) { - var signatureCache = cacheToUpdateSignature || new ts.Map(); + BuilderState.getFilesAffectedBy = getFilesAffectedBy; + function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) { var sourceFile = programOfThisState.getSourceFileByPath(path); if (!sourceFile) { return ts.emptyArray; } - if (!updateShapeSignature(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache)) { + if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) { return [sourceFile]; } - var result = (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache); - if (!cacheToUpdateSignature) { - updateSignaturesFromCache(state, signatureCache); - } - return result; - } - BuilderState.getFilesAffectedBy = getFilesAffectedBy; - function updateSignaturesFromCache(state, signatureCache) { - signatureCache.forEach(function (signature, path) { return updateSignatureOfFile(state, signature, path); }); + return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName); } - BuilderState.updateSignaturesFromCache = updateSignaturesFromCache; + BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState; function updateSignatureOfFile(state, signature, path) { state.fileInfos.get(path).signature = signature; - state.hasCalledUpdateShapeSignature.add(path); + (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(path); } BuilderState.updateSignatureOfFile = updateSignatureOfFile; - function updateShapeSignature(state, programOfThisState, sourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache, useFileVersionAsSignature) { + function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName, useFileVersionAsSignature) { + var _a; if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; } - ts.Debug.assert(!!sourceFile); - ts.Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state"); - if (state.hasCalledUpdateShapeSignature.has(sourceFile.resolvedPath) || cacheToUpdateSignature.has(sourceFile.resolvedPath)) { + if ((_a = state.hasCalledUpdateShapeSignature) === null || _a === void 0 ? void 0 : _a.has(sourceFile.resolvedPath)) return false; - } var info = state.fileInfos.get(sourceFile.resolvedPath); - if (!info) - return ts.Debug.fail(); var prevSignature = info.signature; var latestSignature; if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) { - var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, true, cancellationToken, undefined, true); - var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles); - if (firstDts_1) { - ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: ".concat(ts.getAnyExtensionFromPath(firstDts_1.name), " for ").concat(firstDts_1.name, ":: All output files: ").concat(JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; }))); }); - latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text); - if (exportedModulesMapCache && latestSignature !== prevSignature) { - updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); + programOfThisState.emit(sourceFile, function (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) { + ts.Debug.assert(ts.isDeclarationFileName(fileName), "File extension for signature expected to be dts: Got:: ".concat(fileName)); + latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data); + if (latestSignature !== prevSignature) { + updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit); } - } + }, cancellationToken, true, undefined, true); } if (latestSignature === undefined) { latestSignature = sourceFile.version; - if (exportedModulesMapCache && latestSignature !== prevSignature) { + if (state.exportedModulesMap && latestSignature !== prevSignature) { + (state.oldExportedModulesMap || (state.oldExportedModulesMap = new ts.Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false); var references = state.referencedMap ? state.referencedMap.getValues(sourceFile.resolvedPath) : undefined; if (references) { - exportedModulesMapCache.set(sourceFile.resolvedPath, references); + state.exportedModulesMap.set(sourceFile.resolvedPath, references); } else { - exportedModulesMapCache.deleteKey(sourceFile.resolvedPath); + state.exportedModulesMap.deleteKey(sourceFile.resolvedPath); } } } - cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature); + (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(sourceFile.resolvedPath, prevSignature || false); + (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(sourceFile.resolvedPath); + info.signature = latestSignature; return latestSignature !== prevSignature; } BuilderState.updateShapeSignature = updateShapeSignature; - function updateExportedModules(sourceFile, exportedModulesFromDeclarationEmit, exportedModulesMapCache) { + function updateExportedModules(state, sourceFile, exportedModulesFromDeclarationEmit) { + if (!state.exportedModulesMap) + return; + (state.oldExportedModulesMap || (state.oldExportedModulesMap = new ts.Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false); if (!exportedModulesFromDeclarationEmit) { - exportedModulesMapCache.deleteKey(sourceFile.resolvedPath); + state.exportedModulesMap.deleteKey(sourceFile.resolvedPath); return; } var exportedModules; exportedModulesFromDeclarationEmit.forEach(function (symbol) { return addExportedModule(getReferencedFilesFromImportedModuleSymbol(symbol)); }); if (exportedModules) { - exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules); + state.exportedModulesMap.set(sourceFile.resolvedPath, exportedModules); } else { - exportedModulesMapCache.deleteKey(sourceFile.resolvedPath); + state.exportedModulesMap.deleteKey(sourceFile.resolvedPath); } function addExportedModule(exportedModulePaths) { if (exportedModulePaths === null || exportedModulePaths === void 0 ? void 0 : exportedModulePaths.length) { @@ -94746,15 +96161,6 @@ var ts; } } BuilderState.updateExportedModules = updateExportedModules; - function updateExportedFilesMapFromCache(state, exportedModulesMapCache) { - var _a; - if (exportedModulesMapCache) { - ts.Debug.assert(!!state.exportedModulesMap); - (_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); }); - exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); }); - } - } - BuilderState.updateExportedFilesMapFromCache = updateExportedFilesMapFromCache; function getAllDependencies(state, programOfThisState, sourceFile) { var compilerOptions = programOfThisState.getCompilerOptions(); if (ts.outFile(compilerOptions)) { @@ -94838,7 +96244,7 @@ var ts; } return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape); } - function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) { + function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash, getCanonicalFileName) { if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) { return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape); } @@ -94854,7 +96260,7 @@ var ts; if (!seenFileNamesMap.has(currentPath)) { var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath); seenFileNamesMap.set(currentPath, currentSourceFile); - if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache)) { + if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) { queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath)); } } @@ -94869,29 +96275,31 @@ var ts; return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); } function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) { + var _a, _b; var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature); state.program = newProgram; var compilerOptions = newProgram.getCompilerOptions(); state.compilerOptions = compilerOptions; - if (!ts.outFile(compilerOptions)) { + var outFilePath = ts.outFile(compilerOptions); + if (!outFilePath) { state.semanticDiagnosticsPerFile = new ts.Map(); } + else if (compilerOptions.composite && (oldState === null || oldState === void 0 ? void 0 : oldState.outSignature) && outFilePath === ts.outFile(oldState === null || oldState === void 0 ? void 0 : oldState.compilerOptions)) { + state.outSignature = oldState === null || oldState === void 0 ? void 0 : oldState.outSignature; + } state.changedFilesSet = new ts.Set(); + state.latestChangedDtsFile = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.latestChangedDtsFile : undefined; var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState); var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined; var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile && !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions); + var canCopyEmitSignatures = compilerOptions.composite && + (oldState === null || oldState === void 0 ? void 0 : oldState.emitSignatures) && + !outFilePath && + !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldCompilerOptions); if (useOldState) { - if (!oldState.currentChangedFilePath) { - var affectedSignatures = oldState.currentAffectedFilesSignatures; - ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated"); - } - var changedFilesSet = oldState.changedFilesSet; - if (canCopySemanticDiagnostics) { - ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files"); - } - changedFilesSet === null || changedFilesSet === void 0 ? void 0 : changedFilesSet.forEach(function (value) { return state.changedFilesSet.add(value); }); - if (!ts.outFile(compilerOptions) && oldState.affectedFilesPendingEmit) { + (_a = oldState.changedFilesSet) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return state.changedFilesSet.add(value); }); + if (!outFilePath && oldState.affectedFilesPendingEmit) { state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice(); state.affectedFilesPendingEmitKind = oldState.affectedFilesPendingEmitKind && new ts.Map(oldState.affectedFilesPendingEmitKind); state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; @@ -94908,6 +96316,7 @@ var ts; if (!useOldState || !(oldInfo = oldState.fileInfos.get(sourceFilePath)) || oldInfo.version !== info.version || + oldInfo.impliedFormat !== info.impliedFormat || !hasSameKeys(newReferences = referencedMap && referencedMap.getValues(sourceFilePath), oldReferencedMap && oldReferencedMap.getValues(sourceFilePath)) || newReferences && ts.forEachKey(newReferences, function (path) { return !state.fileInfos.has(path) && oldState.fileInfos.has(path); })) { state.changedFilesSet.add(sourceFilePath); @@ -94927,24 +96336,22 @@ var ts; state.semanticDiagnosticsFromOldState.add(sourceFilePath); } } + if (canCopyEmitSignatures) { + var oldEmitSignature = oldState.emitSignatures.get(sourceFilePath); + if (oldEmitSignature) + (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(sourceFilePath, oldEmitSignature); + } }); if (useOldState && ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { return info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath); })) { ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, undefined) .forEach(function (file) { return state.changedFilesSet.add(file.resolvedPath); }); } - else if (oldCompilerOptions && !ts.outFile(compilerOptions) && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { + else if (oldCompilerOptions && !outFilePath && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1); }); ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size); state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set(); } - if (useOldState) { - ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { - if (state.fileInfos.has(sourceFilePath) && state.fileInfos.get(sourceFilePath).impliedFormat !== info.impliedFormat) { - state.changedFilesSet.add(sourceFilePath); - } - }); - } - state.buildInfoEmitPending = !!state.changedFilesSet.size; + state.buildInfoEmitPending = !useOldState || state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0); return state; } function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) { @@ -94977,33 +96384,40 @@ var ts; ts.BuilderState.releaseCache(state); state.program = undefined; } - function cloneBuilderProgramState(state) { - var _a; - var newState = ts.BuilderState.clone(state); - newState.semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile && new ts.Map(state.semanticDiagnosticsPerFile); - newState.changedFilesSet = new ts.Set(state.changedFilesSet); - newState.affectedFiles = state.affectedFiles; - newState.affectedFilesIndex = state.affectedFilesIndex; - newState.currentChangedFilePath = state.currentChangedFilePath; - newState.currentAffectedFilesSignatures = state.currentAffectedFilesSignatures && new ts.Map(state.currentAffectedFilesSignatures); - newState.currentAffectedFilesExportedModulesMap = (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clone(); - newState.seenAffectedFiles = state.seenAffectedFiles && new ts.Set(state.seenAffectedFiles); - newState.cleanedDiagnosticsOfLibFiles = state.cleanedDiagnosticsOfLibFiles; - newState.semanticDiagnosticsFromOldState = state.semanticDiagnosticsFromOldState && new ts.Set(state.semanticDiagnosticsFromOldState); - newState.program = state.program; - newState.compilerOptions = state.compilerOptions; - newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); - newState.affectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind); - newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; - newState.seenEmittedFiles = state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles); - newState.programEmitComplete = state.programEmitComplete; - return newState; + function backupBuilderProgramEmitState(state) { + var outFilePath = ts.outFile(state.compilerOptions); + ts.Debug.assert(!state.changedFilesSet.size || outFilePath); + return { + affectedFilesPendingEmit: state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(), + affectedFilesPendingEmitKind: state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind), + affectedFilesPendingEmitIndex: state.affectedFilesPendingEmitIndex, + seenEmittedFiles: state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles), + programEmitComplete: state.programEmitComplete, + emitSignatures: state.emitSignatures && new ts.Map(state.emitSignatures), + outSignature: state.outSignature, + latestChangedDtsFile: state.latestChangedDtsFile, + hasChangedEmitSignature: state.hasChangedEmitSignature, + changedFilesSet: outFilePath ? new ts.Set(state.changedFilesSet) : undefined, + }; + } + function restoreBuilderProgramEmitState(state, savedEmitState) { + state.affectedFilesPendingEmit = savedEmitState.affectedFilesPendingEmit; + state.affectedFilesPendingEmitKind = savedEmitState.affectedFilesPendingEmitKind; + state.affectedFilesPendingEmitIndex = savedEmitState.affectedFilesPendingEmitIndex; + state.seenEmittedFiles = savedEmitState.seenEmittedFiles; + state.programEmitComplete = savedEmitState.programEmitComplete; + state.emitSignatures = savedEmitState.emitSignatures; + state.outSignature = savedEmitState.outSignature; + state.latestChangedDtsFile = savedEmitState.latestChangedDtsFile; + state.hasChangedEmitSignature = savedEmitState.hasChangedEmitSignature; + if (savedEmitState.changedFilesSet) + state.changedFilesSet = savedEmitState.changedFilesSet; } function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) { ts.Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath)); } - function getNextAffectedFile(state, cancellationToken, computeHash, host) { - var _a; + function getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host) { + var _a, _b; while (true) { var affectedFiles = state.affectedFiles; if (affectedFiles) { @@ -95013,17 +96427,15 @@ var ts; var affectedFile = affectedFiles[affectedFilesIndex]; if (!seenAffectedFiles.has(affectedFile.resolvedPath)) { state.affectedFilesIndex = affectedFilesIndex; - handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); + handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host); return affectedFile; } affectedFilesIndex++; } state.changedFilesSet.delete(state.currentChangedFilePath); state.currentChangedFilePath = undefined; - ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures); - state.currentAffectedFilesSignatures.clear(); - ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap); - (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clear(); + (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear(); + (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear(); state.affectedFiles = undefined; } var nextKey = state.changedFilesSet.keys().next(); @@ -95036,12 +96448,7 @@ var ts; ts.Debug.assert(!state.semanticDiagnosticsPerFile); return program; } - if (!state.currentAffectedFilesSignatures) - state.currentAffectedFilesSignatures = new ts.Map(); - if (state.exportedModulesMap) { - state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()); - } - state.affectedFiles = ts.BuilderState.getFilesAffectedBy(state, program, nextKey.value, cancellationToken, computeHash, state.currentAffectedFilesSignatures, state.currentAffectedFilesExportedModulesMap); + state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash, getCanonicalFileName); state.currentChangedFilePath = nextKey.value; state.affectedFilesIndex = 0; if (!state.seenAffectedFiles) @@ -95084,26 +96491,24 @@ var ts; }); } } - function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { - var _a; + function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) { removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath); if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { removeDiagnosticsOfLibraryFiles(state); - ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); + ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash, getCanonicalFileName); return; } - ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: ".concat(affectedFile.fileName)); if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) return; - handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); + handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host); } - function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) { + function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCanonicalFileName, host) { removeSemanticDiagnosticsOf(state, path); if (!state.changedFilesSet.has(path)) { var program = ts.Debug.checkDefined(state.program); var sourceFile = program.getSourceFileByPath(path); if (sourceFile) { - ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature); + ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, getCanonicalFileName, !host.disableUseFileVersionAsSignature); if (ts.getEmitDeclarations(state.compilerOptions)) { addToAffectedFilesPendingEmit(state, path, 0); } @@ -95119,34 +96524,21 @@ var ts; return !state.semanticDiagnosticsFromOldState.size; } function isChangedSignature(state, path) { - var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path); - var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature; + var oldSignature = ts.Debug.checkDefined(state.oldSignatures).get(path) || undefined; + var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature; return newSignature !== oldSignature; } - function forEachKeyOfExportedModulesMap(state, filePath, fn) { - var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath); - var result = keys && ts.forEachKey(keys, fn); - if (result) - return result; - keys = state.exportedModulesMap.getKeys(filePath); - return keys && ts.forEachKey(keys, function (exportedFromPath) { - var _a; - return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) && - !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ? - fn(exportedFromPath) : - undefined; - }); - } - function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host) { var _a; if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope)) return false; ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, undefined) - .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); }); + .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, getCanonicalFileName, host); }); removeDiagnosticsOfLibraryFiles(state); return true; } - function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) { + var _a; if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) return; if (!isChangedSignature(state, affectedFile.resolvedPath)) @@ -95159,9 +96551,9 @@ var ts; var currentPath = queue.pop(); if (!seenFileNamesMap.has(currentPath)) { seenFileNamesMap.set(currentPath, true); - if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host)) + if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host)) return; - handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host); + handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host); if (isChangedSignature(state, currentPath)) { var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath); queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); @@ -95169,31 +96561,29 @@ var ts; } } } - ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); var seenFileAndExportsOfFile = new ts.Set(); - forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) { - if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host)) + (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { + if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host)) return true; var references = state.referencedMap.getKeys(exportedFromPath); return references && ts.forEachKey(references, function (filePath) { - return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); + return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host); }); }); } - function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) { - var _a; + function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host) { + var _a, _b; if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) return undefined; - if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host)) + if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host)) return true; - handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host); - ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); - forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) { - return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); + handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host); + (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { + return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host); }); - (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) { + (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) { return !seenFileAndExportsOfFile.has(referencingFilePath) && - handleDtsMayChangeOf(state, referencingFilePath, cancellationToken, computeHash, host); + handleDtsMayChangeOf(state, referencingFilePath, cancellationToken, computeHash, getCanonicalFileName, host); }); return undefined; } @@ -95207,12 +96597,12 @@ var ts; } else { state.seenAffectedFiles.add(affected.resolvedPath); + state.buildInfoEmitPending = true; if (emitKind !== undefined) { (state.seenEmittedFiles || (state.seenEmittedFiles = new ts.Map())).set(affected.resolvedPath, emitKind); } if (isPendingEmit) { state.affectedFilesPendingEmitIndex++; - state.buildInfoEmitPending = true; } else { state.affectedFilesIndex++; @@ -95244,29 +96634,65 @@ var ts; } return ts.filterSemanticDiagnostics(diagnostics, state.compilerOptions); } + function isProgramBundleEmitBuildInfo(info) { + return !!ts.outFile(info.options || {}); + } + ts.isProgramBundleEmitBuildInfo = isProgramBundleEmitBuildInfo; function getProgramBuildInfo(state, getCanonicalFileName) { - if (ts.outFile(state.compilerOptions)) - return undefined; + var outFilePath = ts.outFile(state.compilerOptions); + if (outFilePath && !state.compilerOptions.composite) + return; var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory(); var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); + var latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : undefined; + if (outFilePath) { + var fileNames_1 = []; + var fileInfos_1 = []; + state.program.getRootFileNames().forEach(function (f) { + var sourceFile = state.program.getSourceFile(f); + if (!sourceFile) + return; + fileNames_1.push(relativeToBuildInfo(sourceFile.resolvedPath)); + fileInfos_1.push(sourceFile.version); + }); + var result_15 = { + fileNames: fileNames_1, + fileInfos: fileInfos_1, + options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"), + outSignature: state.outSignature, + latestChangedDtsFile: latestChangedDtsFile, + }; + return result_15; + } var fileNames = []; var fileNameToFileId = new ts.Map(); var fileIdsList; var fileNamesToFileIdListId; + var emitSignatures; var fileInfos = ts.arrayFrom(state.fileInfos.entries(), function (_a) { + var _b, _c; var key = _a[0], value = _a[1]; var fileId = toFileId(key); ts.Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key)); - var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); - var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature; + var oldSignature = (_b = state.oldSignatures) === null || _b === void 0 ? void 0 : _b.get(key); + var actualSignature = oldSignature !== undefined ? oldSignature || undefined : value.signature; + if (state.compilerOptions.composite) { + var file = state.program.getSourceFileByPath(key); + if (!ts.isJsonSourceFile(file) && ts.sourceFileMayBeEmitted(file, state.program)) { + var emitSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(key); + if (emitSignature !== actualSignature) { + (emitSignatures || (emitSignatures = [])).push(emitSignature === undefined ? fileId : [fileId, emitSignature]); + } + } + } return value.version === actualSignature ? value.affectsGlobalScope || value.impliedFormat ? { version: value.version, signature: undefined, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } : value.version : actualSignature !== undefined ? - signature === undefined ? + oldSignature === undefined ? value : - { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } : + { version: value.version, signature: actualSignature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } : { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat }; }); var referencedMap; @@ -95280,16 +96706,12 @@ var ts; if (state.exportedModulesMap) { exportedModulesMap = ts.mapDefined(ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive), function (key) { var _a; - if (state.currentAffectedFilesExportedModulesMap) { - if ((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(key)) { - return undefined; - } - var newValue = state.currentAffectedFilesExportedModulesMap.getValues(key); - if (newValue) { - return [toFileId(key), toFileIdListId(newValue)]; - } - } - return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))]; + var oldValue = (_a = state.oldExportedModulesMap) === null || _a === void 0 ? void 0 : _a.get(key); + if (oldValue === undefined) + return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))]; + if (oldValue) + return [toFileId(key), toFileIdListId(oldValue)]; + return undefined; }); } var semanticDiagnosticsPerFile; @@ -95300,9 +96722,7 @@ var ts; (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ? [ toFileId(key), - state.hasReusableDiagnostic ? - value : - convertToReusableDiagnostics(value, relativeToBuildInfo) + convertToReusableDiagnostics(value, relativeToBuildInfo) ] : toFileId(key)); } @@ -95317,16 +96737,27 @@ var ts; } } } - return { + var changeFileSet; + if (state.changedFilesSet.size) { + for (var _d = 0, _e = ts.arrayFrom(state.changedFilesSet.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) { + var path = _e[_d]; + (changeFileSet || (changeFileSet = [])).push(toFileId(path)); + } + } + var result = { fileNames: fileNames, fileInfos: fileInfos, - options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath), + options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo"), fileIdsList: fileIdsList, referencedMap: referencedMap, exportedModulesMap: exportedModulesMap, semanticDiagnosticsPerFile: semanticDiagnosticsPerFile, affectedFilesPendingEmit: affectedFilesPendingEmit, + changeFileSet: changeFileSet, + emitSignatures: emitSignatures, + latestChangedDtsFile: latestChangedDtsFile, }; + return result; function relativeToBuildInfoEnsuringAbsolutePath(path) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory)); } @@ -95351,21 +96782,18 @@ var ts; } return fileIdListId; } - } - function convertToProgramBuildInfoCompilerOptions(options, relativeToBuildInfo) { - var result; - var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; - for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { - var name = _a[_i]; - var optionKey = name.toLowerCase(); - var optionInfo = optionsNameMap.get(optionKey); - if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || - optionKey === "strict" || - optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") { - (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo); + function convertToProgramBuildInfoCompilerOptions(options, optionKey) { + var result; + var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; + for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { + var name = _a[_i]; + var optionInfo = optionsNameMap.get(name.toLowerCase()); + if (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey]) { + (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfoEnsuringAbsolutePath); + } } + return result; } - return result; } function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) { if (option) { @@ -95439,6 +96867,41 @@ var ts; return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray }; } ts.getBuilderCreationParameters = getBuilderCreationParameters; + function getTextHandlingSourceMapForSignature(text, data) { + return (data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text; + } + function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data) { + var _a; + text = getTextHandlingSourceMapForSignature(text, data); + var sourceFileDirectory; + if ((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length) { + text += data.diagnostics.map(function (diagnostic) { + return "".concat(locationInfo(diagnostic)).concat(ts.DiagnosticCategory[diagnostic.category]).concat(diagnostic.code, ": ").concat(flattenDiagnosticMessageText(diagnostic.messageText)); + }).join("\n"); + } + return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(text); + function flattenDiagnosticMessageText(diagnostic) { + return ts.isString(diagnostic) ? + diagnostic : + diagnostic === undefined ? + "" : + !diagnostic.next ? + diagnostic.messageText : + diagnostic.messageText + diagnostic.next.map(flattenDiagnosticMessageText).join("\n"); + } + function locationInfo(diagnostic) { + if (diagnostic.file.resolvedPath === sourceFile.resolvedPath) + return "(".concat(diagnostic.start, ",").concat(diagnostic.length, ")"); + if (sourceFileDirectory === undefined) + sourceFileDirectory = ts.getDirectoryPath(sourceFile.resolvedPath); + return "".concat(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceFileDirectory, diagnostic.file.resolvedPath, getCanonicalFileName)), "(").concat(diagnostic.start, ",").concat(diagnostic.length, ")"); + } + } + ts.computeSignatureWithDiagnostics = computeSignatureWithDiagnostics; + function computeSignature(text, computeHash, data) { + return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data)); + } + ts.computeSignature = computeSignature; function createBuilderProgram(kind, _a) { var newProgram = _a.newProgram, host = _a.host, oldProgram = _a.oldProgram, configFileParsingDiagnostics = _a.configFileParsingDiagnostics; var oldState = oldProgram && oldProgram.getState(); @@ -95450,7 +96913,6 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()); var computeHash = ts.maybeBind(host, host.createHash); var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature); - var backupState; newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); }; newProgram = undefined; oldProgram = undefined; @@ -95458,21 +96920,13 @@ var ts; var getState = function () { return state; }; var builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics); builderProgram.getState = getState; - builderProgram.backupState = function () { - ts.Debug.assert(backupState === undefined); - backupState = cloneBuilderProgramState(state); - }; - builderProgram.restoreState = function () { - state = ts.Debug.checkDefined(backupState); - backupState = undefined; - }; + builderProgram.saveEmitState = function () { return backupBuilderProgramEmitState(state); }; + builderProgram.restoreEmitState = function (saved) { return restoreBuilderProgramEmitState(state, saved); }; + builderProgram.hasChangedEmitSignature = function () { return !!state.hasChangedEmitSignature; }; builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); }; builderProgram.getSemanticDiagnostics = getSemanticDiagnostics; builderProgram.emit = emit; - builderProgram.releaseProgram = function () { - releaseCache(state); - backupState = undefined; - }; + builderProgram.releaseProgram = function () { return releaseCache(state); }; if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) { builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile; } @@ -95494,7 +96948,7 @@ var ts; return ts.emitSkippedWithNoDiagnostics; } function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); + var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host); var emitKind = 1; var isPendingEmitFile = false; if (!affected) { @@ -95517,34 +96971,60 @@ var ts; affected = program; } } - return toAffectedFileEmitResult(state, ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ? - getWriteFileUpdatingSignatureCallback(writeFile) : + return toAffectedFileEmitResult(state, ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, ts.getEmitDeclarations(state.compilerOptions) ? + getWriteFileCallback(writeFile, customTransformers) : writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0, customTransformers), affected, emitKind, isPendingEmitFile); } - function getWriteFileUpdatingSignatureCallback(writeFile) { + function getWriteFileCallback(writeFile, customTransformers) { return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) { - var _a; + var _a, _b, _c, _d, _e, _f, _g; if (ts.isDeclarationFileName(fileName)) { - ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1); - var file = sourceFiles[0]; - var info = state.fileInfos.get(file.resolvedPath); - var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature; - if (signature === file.version) { - var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text); - if (newSignature !== file.version) { - if (host.storeFilesChangingSignatureDuringEmit) - (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath); - if (state.exportedModulesMap) - ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap())); - if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) { - state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature); - } - else { - info.signature = newSignature; - if (state.exportedModulesMap) - ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap); + if (!ts.outFile(state.compilerOptions)) { + ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1); + var emitSignature = void 0; + if (!customTransformers) { + var file = sourceFiles[0]; + var info = state.fileInfos.get(file.resolvedPath); + if (info.signature === file.version) { + var signature = computeSignatureWithDiagnostics(file, text, computeHash, getCanonicalFileName, data); + if (!((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length)) + emitSignature = signature; + if (signature !== file.version) { + if (host.storeFilesChangingSignatureDuringEmit) + ((_b = state.filesChangingSignature) !== null && _b !== void 0 ? _b : (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath); + if (state.exportedModulesMap) + ts.BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit); + if (state.affectedFiles) { + var existing = (_c = state.oldSignatures) === null || _c === void 0 ? void 0 : _c.get(file.resolvedPath); + if (existing === undefined) + ((_d = state.oldSignatures) !== null && _d !== void 0 ? _d : (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false); + info.signature = signature; + } + else { + info.signature = signature; + (_e = state.oldExportedModulesMap) === null || _e === void 0 ? void 0 : _e.clear(); + } + } } } + if (state.compilerOptions.composite) { + var filePath = sourceFiles[0].resolvedPath; + var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath); + emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data)); + if (emitSignature === oldSignature) + return; + ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature); + state.hasChangedEmitSignature = true; + state.latestChangedDtsFile = fileName; + } + } + else if (state.compilerOptions.composite) { + var newSignature = computeSignature(text, computeHash, data); + if (newSignature === state.outSignature) + return; + state.outSignature = newSignature; + state.hasChangedEmitSignature = true; + state.latestChangedDtsFile = fileName; } } if (writeFile) @@ -95594,13 +97074,13 @@ var ts; } } } - return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ? - getWriteFileUpdatingSignatureCallback(writeFile) : + return ts.Debug.checkDefined(state.program).emit(targetSourceFile, ts.getEmitDeclarations(state.compilerOptions) ? + getWriteFileCallback(writeFile, customTransformers) : writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers); } function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) { while (true) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); + var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host); if (!affected) { return undefined; } @@ -95658,29 +97138,59 @@ var ts; { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat }; } ts.toBuilderStateFileInfo = toBuilderStateFileInfo; - function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) { - var _a; + function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) { + var _a, _b, _c, _d; var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory())); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()); - var filePaths = program.fileNames.map(toPath); - var filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); }); - var fileInfos = new ts.Map(); - program.fileInfos.forEach(function (fileInfo, index) { return fileInfos.set(toFilePath(index + 1), toBuilderStateFileInfo(fileInfo)); }); - var state = { - fileInfos: fileInfos, - compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {}, - referencedMap: toManyToManyPathMap(program.referencedMap), - exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap), - semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toFilePath(ts.isNumber(value) ? value : value[0]); }, function (value) { return ts.isNumber(value) ? ts.emptyArray : value[1]; }), - hasReusableDiagnostic: true, - affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }), - affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }), - affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0, - }; + var state; + var filePaths; + var filePathsSetList; + var latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : undefined; + if (isProgramBundleEmitBuildInfo(program)) { + state = { + fileInfos: new ts.Map(), + compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {}, + latestChangedDtsFile: latestChangedDtsFile, + outSignature: program.outSignature, + }; + } + else { + filePaths = (_a = program.fileNames) === null || _a === void 0 ? void 0 : _a.map(toPath); + filePathsSetList = (_b = program.fileIdsList) === null || _b === void 0 ? void 0 : _b.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); }); + var fileInfos_2 = new ts.Map(); + var emitSignatures_1 = ((_c = program.options) === null || _c === void 0 ? void 0 : _c.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined; + program.fileInfos.forEach(function (fileInfo, index) { + var path = toFilePath(index + 1); + var stateFileInfo = toBuilderStateFileInfo(fileInfo); + fileInfos_2.set(path, stateFileInfo); + if (emitSignatures_1 && stateFileInfo.signature) + emitSignatures_1.set(path, stateFileInfo.signature); + }); + (_d = program.emitSignatures) === null || _d === void 0 ? void 0 : _d.forEach(function (value) { + if (ts.isNumber(value)) + emitSignatures_1.delete(toFilePath(value)); + else + emitSignatures_1.set(toFilePath(value[0]), value[1]); + }); + state = { + fileInfos: fileInfos_2, + compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {}, + referencedMap: toManyToManyPathMap(program.referencedMap), + exportedModulesMap: toManyToManyPathMap(program.exportedModulesMap), + semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toFilePath(ts.isNumber(value) ? value : value[0]); }, function (value) { return ts.isNumber(value) ? ts.emptyArray : value[1]; }), + hasReusableDiagnostic: true, + affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }), + affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }), + affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0, + changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)), + latestChangedDtsFile: latestChangedDtsFile, + emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined, + }; + } return { getState: function () { return state; }, - backupState: ts.noop, - restoreState: ts.noop, + saveEmitState: ts.noop, + restoreEmitState: ts.noop, getProgram: ts.notImplemented, getProgramOrUndefined: ts.returnUndefined, releaseProgram: ts.noop, @@ -95700,6 +97210,7 @@ var ts; getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented, emitBuildInfo: ts.notImplemented, close: ts.noop, + hasChangedEmitSignature: ts.returnFalse, }; function toPath(path) { return ts.toPath(path, buildInfoDirectory, getCanonicalFileName); @@ -95725,12 +97236,24 @@ var ts; return map; } } - ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo; + ts.createBuilderProgramUsingProgramBuildInfo = createBuilderProgramUsingProgramBuildInfo; + function getBuildInfoFileVersionMap(program, buildInfoPath, host) { + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory())); + var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()); + var fileInfos = new ts.Map(); + program.fileInfos.forEach(function (fileInfo, index) { + var path = ts.toPath(program.fileNames[index], buildInfoDirectory, getCanonicalFileName); + var version = ts.isString(fileInfo) ? fileInfo : fileInfo.version; + fileInfos.set(path, version); + }); + return fileInfos; + } + ts.getBuildInfoFileVersionMap = getBuildInfoFileVersionMap; function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) { return { getState: ts.notImplemented, - backupState: ts.noop, - restoreState: ts.noop, + saveEmitState: ts.noop, + restoreEmitState: ts.noop, getProgram: getProgram, getProgramOrUndefined: function () { return getState().program; }, releaseProgram: function () { return getState().program = undefined; }, @@ -95782,7 +97305,7 @@ var ts; path; } ts.removeIgnoredPath = removeIgnoredPath; - function canWatchDirectory(dirPath) { + function canWatchDirectoryOrFile(dirPath) { var rootLength = ts.getRootLength(dirPath); if (dirPath.length === rootLength) { return false; @@ -95814,15 +97337,19 @@ var ts; } return true; } - ts.canWatchDirectory = canWatchDirectory; + ts.canWatchDirectoryOrFile = canWatchDirectoryOrFile; function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) { var filesWithChangedSetOfUnresolvedImports; var filesWithInvalidatedResolutions; var filesWithInvalidatedNonRelativeUnresolvedImports; var nonRelativeExternalModuleResolutions = ts.createMultiMap(); var resolutionsWithFailedLookups = []; + var resolutionsWithOnlyAffectingLocations = []; var resolvedFileToResolution = ts.createMultiMap(); + var impliedFormatPackageJsons = new ts.Map(); var hasChangedAutomaticTypeDirectiveNames = false; + var affectingPathChecksForFile; + var affectingPathChecks; var failedLookupChecks; var startsWithPathChecks; var isInDirectoryChecks; @@ -95838,6 +97365,7 @@ var ts; var failedLookupDefaultExtensions = [".ts", ".tsx", ".js", ".jsx", ".json"]; var customFailedLookupPaths = new ts.Map(); var directoryWatchesOfFailedLookups = new ts.Map(); + var fileWatchesOfAffectingLocations = new ts.Map(); var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory())); var rootPath = (rootDir && resolutionHost.toPath(rootDir)); var rootSplitLength = rootPath !== undefined ? rootPath.split(ts.directorySeparator).length : 0; @@ -95846,7 +97374,7 @@ var ts; getModuleResolutionCache: function () { return moduleResolutionCache; }, startRecordingFilesWithChangedResolutions: startRecordingFilesWithChangedResolutions, finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions, - startCachingPerDirectoryResolution: clearPerDirectoryResolutions, + startCachingPerDirectoryResolution: startCachingPerDirectoryResolution, finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution, resolveModuleNames: resolveModuleNames, getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache, @@ -95877,6 +97405,7 @@ var ts; } function clear() { ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf); + ts.clearMap(fileWatchesOfAffectingLocations, ts.closeFileWatcherOf); customFailedLookupPaths.clear(); nonRelativeExternalModuleResolutions.clear(); closeTypeRootsWatch(); @@ -95884,10 +97413,15 @@ var ts; resolvedTypeReferenceDirectives.clear(); resolvedFileToResolution.clear(); resolutionsWithFailedLookups.length = 0; + resolutionsWithOnlyAffectingLocations.length = 0; failedLookupChecks = undefined; startsWithPathChecks = undefined; isInDirectoryChecks = undefined; - clearPerDirectoryResolutions(); + affectingPathChecks = undefined; + affectingPathChecksForFile = undefined; + moduleResolutionCache.clear(); + typeReferenceDirectiveResolutionCache.clear(); + impliedFormatPackageJsons.clear(); hasChangedAutomaticTypeDirectiveNames = false; } function startRecordingFilesWithChangedResolutions() { @@ -95916,35 +97450,68 @@ var ts; return function (path) { return (!!collected && collected.has(path)) || isFileWithInvalidatedNonRelativeUnresolvedImports(path); }; } - function clearPerDirectoryResolutions() { - moduleResolutionCache.clear(); - typeReferenceDirectiveResolutionCache.clear(); + function startCachingPerDirectoryResolution() { + moduleResolutionCache.clearAllExceptPackageJsonInfoCache(); + typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache(); nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); } - function finishCachingPerDirectoryResolution() { + function finishCachingPerDirectoryResolution(newProgram, oldProgram) { filesWithInvalidatedNonRelativeUnresolvedImports = undefined; - clearPerDirectoryResolutions(); + nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); + nonRelativeExternalModuleResolutions.clear(); + if (newProgram !== oldProgram) { + newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFiles().forEach(function (newFile) { + var _a, _b, _c; + var expected = ts.isExternalOrCommonJsModule(newFile) ? (_b = (_a = newFile.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 : 0; + var existing = (_c = impliedFormatPackageJsons.get(newFile.path)) !== null && _c !== void 0 ? _c : ts.emptyArray; + for (var i = existing.length; i < expected; i++) { + createFileWatcherOfAffectingLocation(newFile.packageJsonLocations[i], false); + } + if (existing.length > expected) { + for (var i = expected; i < existing.length; i++) { + fileWatchesOfAffectingLocations.get(existing[i]).files--; + } + } + if (expected) + impliedFormatPackageJsons.set(newFile.path, newFile.packageJsonLocations); + else + impliedFormatPackageJsons.delete(newFile.path); + }); + impliedFormatPackageJsons.forEach(function (existing, path) { + if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) { + existing.forEach(function (location) { return fileWatchesOfAffectingLocations.get(location).files--; }); + impliedFormatPackageJsons.delete(path); + } + }); + } directoryWatchesOfFailedLookups.forEach(function (watcher, path) { if (watcher.refCount === 0) { directoryWatchesOfFailedLookups.delete(path); watcher.watcher.close(); } }); + fileWatchesOfAffectingLocations.forEach(function (watcher, path) { + if (watcher.files === 0 && watcher.resolutions === 0) { + fileWatchesOfAffectingLocations.delete(path); + watcher.watcher.close(); + } + }); hasChangedAutomaticTypeDirectiveNames = false; } function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) { - var _a; + var _a, _b; var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode); if (!resolutionHost.getGlobalCache) { return primaryResult; } var globalCache = resolutionHost.getGlobalCache(); if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) { - var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache, moduleResolutionCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations; + var _c = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache, moduleResolutionCache), resolvedModule = _c.resolvedModule, failedLookupLocations = _c.failedLookupLocations, affectingLocations = _c.affectingLocations; if (resolvedModule) { primaryResult.resolvedModule = resolvedModule; (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations); + (_b = primaryResult.affectingLocations).push.apply(_b, affectingLocations); return primaryResult; } } @@ -96133,7 +97700,7 @@ var ts; dirPath = ts.getDirectoryPath(dirPath); } if (ts.isNodeModulesDirectory(dirPath)) { - return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined; + return canWatchDirectoryOrFile(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined; } var nonRecursive = true; var subDirectoryPath, subDirectory; @@ -96150,7 +97717,7 @@ var ts; dir = ts.getDirectoryPath(dir); } } - return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined; + return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined; } function isPathWithDefaultFailedLookupExtension(path) { return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions); @@ -96178,10 +97745,11 @@ var ts; } function watchFailedLookupLocationOfResolution(resolution) { ts.Debug.assert(!!resolution.refCount); - var failedLookupLocations = resolution.failedLookupLocations; - if (!failedLookupLocations.length) + var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations; + if (!failedLookupLocations.length && !affectingLocations.length) return; - resolutionsWithFailedLookups.push(resolution); + if (failedLookupLocations.length) + resolutionsWithFailedLookups.push(resolution); var setAtRoot = false; for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) { var failedLookupLocation = failedLookupLocations_1[_i]; @@ -96205,12 +97773,85 @@ var ts; if (setAtRoot) { setDirectoryWatcher(rootDir, rootPath, true); } + watchAffectingLocationsOfResolution(resolution, !failedLookupLocations.length); + } + function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) { + ts.Debug.assert(!!resolution.refCount); + var affectingLocations = resolution.affectingLocations; + if (!affectingLocations.length) + return; + if (addToResolutionsWithOnlyAffectingLocations) + resolutionsWithOnlyAffectingLocations.push(resolution); + for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) { + var affectingLocation = affectingLocations_1[_i]; + createFileWatcherOfAffectingLocation(affectingLocation, true); + } + } + function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) { + var fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation); + if (fileWatcher) { + if (forResolution) + fileWatcher.resolutions++; + else + fileWatcher.files++; + return; + } + var locationToWatch = affectingLocation; + if (resolutionHost.realpath) { + locationToWatch = resolutionHost.realpath(affectingLocation); + if (affectingLocation !== locationToWatch) { + var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatch); + if (fileWatcher_1) { + if (forResolution) + fileWatcher_1.resolutions++; + else + fileWatcher_1.files++; + fileWatcher_1.paths.add(affectingLocation); + fileWatchesOfAffectingLocations.set(affectingLocation, fileWatcher_1); + return; + } + } + } + var paths = new ts.Set(); + paths.add(locationToWatch); + var actualWatcher = canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ? + resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) { + cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind); + var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap(); + paths.forEach(function (path) { + if (watcher.resolutions) + (affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path); + if (watcher.files) + (affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path); + packageJsonMap === null || packageJsonMap === void 0 ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path)); + }); + resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations(); + }) : ts.noopFileWatcher; + var watcher = { + watcher: actualWatcher !== ts.noopFileWatcher ? { + close: function () { + actualWatcher.close(); + actualWatcher = ts.noopFileWatcher; + } + } : actualWatcher, + resolutions: forResolution ? 1 : 0, + files: forResolution ? 0 : 1, + paths: paths, + }; + fileWatchesOfAffectingLocations.set(locationToWatch, watcher); + if (affectingLocation !== locationToWatch) { + fileWatchesOfAffectingLocations.set(affectingLocation, watcher); + paths.add(affectingLocation); + } } function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) { var program = resolutionHost.getCurrentProgram(); if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) { resolutions.forEach(watchFailedLookupLocationOfResolution); } + else { + resolutions.forEach(function (resolution) { return watchAffectingLocationsOfResolution(resolution, true); }); + } } function setDirectoryWatcher(dir, dirPath, nonRecursive) { var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath); @@ -96232,37 +97873,44 @@ var ts; if (resolved && resolved.resolvedFileName) { resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution); } - if (!ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) { - return; - } - var failedLookupLocations = resolution.failedLookupLocations; - var removeAtRoot = false; - for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) { - var failedLookupLocation = failedLookupLocations_2[_i]; - var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath); - if (toWatch) { - var dirPath = toWatch.dirPath; - var refCount = customFailedLookupPaths.get(failedLookupLocationPath); - if (refCount) { - if (refCount === 1) { - customFailedLookupPaths.delete(failedLookupLocationPath); + var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations; + if (ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) { + var removeAtRoot = false; + for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) { + var failedLookupLocation = failedLookupLocations_2[_i]; + var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); + var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath); + if (toWatch) { + var dirPath = toWatch.dirPath; + var refCount = customFailedLookupPaths.get(failedLookupLocationPath); + if (refCount) { + if (refCount === 1) { + customFailedLookupPaths.delete(failedLookupLocationPath); + } + else { + ts.Debug.assert(refCount > 1); + customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1); + } + } + if (dirPath === rootPath) { + removeAtRoot = true; } else { - ts.Debug.assert(refCount > 1); - customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1); + removeDirectoryWatcher(dirPath); } } - if (dirPath === rootPath) { - removeAtRoot = true; - } - else { - removeDirectoryWatcher(dirPath); - } + } + if (removeAtRoot) { + removeDirectoryWatcher(rootPath); } } - if (removeAtRoot) { - removeDirectoryWatcher(rootPath); + else if (affectingLocations.length) { + ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution); + } + for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) { + var affectingLocation = affectingLocations_2[_a]; + var watcher = fileWatchesOfAffectingLocations.get(affectingLocation); + watcher.resolutions--; } } function removeDirectoryWatcher(dirPath) { @@ -96311,7 +97959,7 @@ var ts; resolution.isInvalidated = invalidated = true; for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) { var containingFilePath = _b[_a]; - (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath); + (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath); hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile); } } @@ -96332,7 +97980,7 @@ var ts; } function scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, isCreatingWatchedDirectory) { if (isCreatingWatchedDirectory) { - (isInDirectoryChecks || (isInDirectoryChecks = [])).push(fileOrDirectoryPath); + (isInDirectoryChecks || (isInDirectoryChecks = new ts.Set())).add(fileOrDirectoryPath); } else { var updatedPath = removeIgnoredPath(fileOrDirectoryPath); @@ -96345,7 +97993,7 @@ var ts; var dirOfFileOrDirectory = ts.getDirectoryPath(fileOrDirectoryPath); if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) || isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) { - (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath); + (failedLookupChecks || (failedLookupChecks = new ts.Set())).add(fileOrDirectoryPath); (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(fileOrDirectoryPath); } else { @@ -96355,7 +98003,7 @@ var ts; if (ts.isEmittedFileOfProgram(resolutionHost.getCurrentProgram(), fileOrDirectoryPath)) { return false; } - (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath); + (failedLookupChecks || (failedLookupChecks = new ts.Set())).add(fileOrDirectoryPath); var packagePath = ts.parseNodeModuleFromPath(fileOrDirectoryPath); if (packagePath) (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(packagePath); @@ -96364,22 +98012,46 @@ var ts; resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations(); } function invalidateResolutionsOfFailedLookupLocations() { - if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) { - return false; + var _a; + var invalidated = false; + if (affectingPathChecksForFile) { + (_a = resolutionHost.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getSourceFiles().forEach(function (f) { + if (ts.some(f.packageJsonLocations, function (location) { return affectingPathChecksForFile.has(location); })) { + (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(f.path); + invalidated = true; + } + }); + affectingPathChecksForFile = undefined; + } + if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) { + return invalidated; + } + invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution) || invalidated; + var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap(); + if (packageJsonMap && (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks)) { + packageJsonMap.forEach(function (_value, path) { return isInvalidatedFailedLookup(path) ? packageJsonMap.delete(path) : undefined; }); } - var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution); failedLookupChecks = undefined; startsWithPathChecks = undefined; isInDirectoryChecks = undefined; + invalidated = invalidateResolutions(resolutionsWithOnlyAffectingLocations, canInvalidatedFailedLookupResolutionWithAffectingLocation) || invalidated; + affectingPathChecks = undefined; return invalidated; } function canInvalidateFailedLookupResolution(resolution) { - return resolution.failedLookupLocations.some(function (location) { - var locationPath = resolutionHost.toPath(location); - return ts.contains(failedLookupChecks, locationPath) || - ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) || - (isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); })); - }); + if (canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution)) + return true; + if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) + return false; + return resolution.failedLookupLocations.some(function (location) { return isInvalidatedFailedLookup(resolutionHost.toPath(location)); }); + } + function isInvalidatedFailedLookup(locationPath) { + return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) || + ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) || + ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; }); + } + function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) { + return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { return affectingPathChecks.has(location); }); } function closeTypeRootsWatch() { ts.clearMap(typeRootsWatches, ts.closeFileWatcher); @@ -96425,7 +98097,7 @@ var ts; function directoryExistsForTypeRootWatch(nodeTypesDirectory) { var dir = ts.getDirectoryPath(ts.getDirectoryPath(nodeTypesDirectory)); var dirPath = resolutionHost.toPath(dir); - return dirPath === rootPath || canWatchDirectory(dirPath); + return dirPath === rootPath || canWatchDirectoryOrFile(dirPath); } } ts.createResolutionCache = createResolutionCache; @@ -96510,7 +98182,7 @@ var ts; var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options); return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, undefined, options.overrideImportMode); }) || - getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences); + getLocalModuleSpecifier(toFileName, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences); } function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) { if (options === void 0) { options = {}; } @@ -96581,7 +98253,7 @@ var ts; return nodeModulesSpecifiers; } if (!specifier && !modulePath.isRedirect) { - var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences); + var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences); if (ts.pathIsBareSpecifier(local)) { pathsSpecifiers = ts.append(pathsSpecifiers, local); } @@ -96599,7 +98271,7 @@ var ts; var sourceDirectory = ts.getDirectoryPath(importingSourceFileName); return { getCanonicalFileName: getCanonicalFileName, importingSourceFileName: importingSourceFileName, sourceDirectory: sourceDirectory }; } - function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, _a) { + function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, _a) { var ending = _a.ending, relativePreference = _a.relativePreference; var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName; @@ -96613,9 +98285,8 @@ var ts; if (!relativeToBaseUrl) { return relativePath; } - var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions); - var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); - var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths; + var fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, getAllowedEndings(ending, compilerOptions, importMode), host, compilerOptions); + var nonRelative = fromPaths === undefined && baseUrl !== undefined ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths; if (!nonRelative) { return relativePath; } @@ -96681,9 +98352,9 @@ var ts; var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); var shouldFilterIgnoredPaths = !ts.every(targets, ts.containsIgnoredPath); if (!preferSymlinks) { - var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); }); - if (result_15) - return result_15; + var result_16 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); }); + if (result_16) + return result_16; } var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath(); var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd); @@ -96702,10 +98373,10 @@ var ts; for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) { var symlinkDirectory = symlinkDirectories_1[_i]; var option = ts.resolvePath(symlinkDirectory, relative); - var result_16 = cb(option, target === referenceRedirect); + var result_17 = cb(option, target === referenceRedirect); shouldFilterIgnoredPaths = true; - if (result_16) - return result_16; + if (result_17) + return result_17; } }); }); @@ -96740,7 +98411,7 @@ var ts; importedFileFromNodeModules = importedFileFromNodeModules || isInNodeModules; }); var sortedPaths = []; - var _loop_32 = function (directory) { + var _loop_35 = function (directory) { var directoryStart = ts.ensureTrailingDirectorySeparator(directory); var pathsInDirectory; allFileNames.forEach(function (_a, fileName) { @@ -96764,9 +98435,9 @@ var ts; }; var out_directory_1; for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) { - var state_10 = _loop_32(directory); + var state_11 = _loop_35(directory); directory = out_directory_1; - if (state_10 === "break") + if (state_11 === "break") break; } if (allFileNames.size) { @@ -96812,28 +98483,59 @@ var ts; return ambientModuleDeclare.name.text; } } - function tryGetModuleNameFromPaths(relativeToBaseUrlWithIndex, relativeToBaseUrl, paths) { + function getAllowedEndings(preferredEnding, compilerOptions, importMode) { + if (ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && importMode === ts.ModuleKind.ESNext) { + return [2]; + } + switch (preferredEnding) { + case 2: return [2, 0, 1]; + case 1: return [1, 0, 2]; + case 0: return [0, 1, 2]; + default: ts.Debug.assertNever(preferredEnding); + } + } + function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) { for (var key in paths) { - for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) { - var patternText_1 = _a[_i]; - var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1)); + var _loop_36 = function (patternText_1) { + var pattern = ts.normalizePath(patternText_1); var indexOfStar = pattern.indexOf("*"); + var candidates = allowedEndings.map(function (ending) { return ({ + ending: ending, + value: removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) + }); }); + if (ts.tryGetExtensionFromPath(pattern)) { + candidates.push({ ending: undefined, value: relativeToBaseUrl }); + } if (indexOfStar !== -1) { - var prefix = pattern.substr(0, indexOfStar); - var suffix = pattern.substr(indexOfStar + 1); - if (relativeToBaseUrl.length >= prefix.length + suffix.length && - ts.startsWith(relativeToBaseUrl, prefix) && - ts.endsWith(relativeToBaseUrl, suffix) || - !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) { - var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length - prefix.length); - return key.replace("*", matchedStar); + var prefix = pattern.substring(0, indexOfStar); + var suffix = pattern.substring(indexOfStar + 1); + for (var _b = 0, candidates_3 = candidates; _b < candidates_3.length; _b++) { + var _c = candidates_3[_b], ending = _c.ending, value = _c.value; + if (value.length >= prefix.length + suffix.length && + ts.startsWith(value, prefix) && + ts.endsWith(value, suffix) && + validateEnding({ ending: ending, value: value })) { + var matchedStar = value.substring(prefix.length, value.length - suffix.length); + return { value: key.replace("*", matchedStar) }; + } } } - else if (pattern === relativeToBaseUrl || pattern === relativeToBaseUrlWithIndex) { - return key; + else if (ts.some(candidates, function (c) { return c.ending !== 0 && pattern === c.value; }) || + ts.some(candidates, function (c) { return c.ending === 0 && pattern === c.value && validateEnding(c); })) { + return { value: key }; } + }; + for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) { + var patternText_1 = _a[_i]; + var state_12 = _loop_36(patternText_1); + if (typeof state_12 === "object") + return state_12.value; } } + function validateEnding(_a) { + var ending = _a.ending, value = _a.value; + return ending !== 0 || value === removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions, host); + } } function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) { if (mode === void 0) { mode = 0; } @@ -96916,10 +98618,10 @@ var ts; if (!parts) { return undefined; } + var preferences = getPreferences(host, userPreferences, options, importingSourceFile); var moduleSpecifier = path; var isPackageRootPath = false; if (!packageNameOnly) { - var preferences = getPreferences(host, userPreferences, options, importingSourceFile); var packageRootIndex = parts.packageRootIndex; var moduleFileName = void 0; while (true) { @@ -96962,11 +98664,13 @@ var ts; var packageRootPath = path.substring(0, packageRootIndex); var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); var moduleFileToTry = path; + var maybeBlockedByTypesVersions = false; var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath); if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) { var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath)); + var importMode = overrideMode || importingSourceFile.impliedNodeFormat; if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) { - var conditions = ["node", overrideMode || importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"]; + var conditions = ["node", importMode === ts.ModuleKind.ESNext ? "import" : "require", "types"]; var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions) : undefined; @@ -96985,13 +98689,16 @@ var ts; : undefined; if (versionPaths) { var subModuleName = path.slice(packageRootPath.length + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0, options), versionPaths.paths); - if (fromPaths !== undefined) { + var fromPaths = tryGetModuleNameFromPaths(subModuleName, versionPaths.paths, getAllowedEndings(preferences.ending, options, importMode), host, options); + if (fromPaths === undefined) { + maybeBlockedByTypesVersions = true; + } + else { moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths); } } var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js"; - if (ts.isString(mainFileRelative)) { + if (ts.isString(mainFileRelative) && !(maybeBlockedByTypesVersions && ts.matchPatternOrExact(ts.tryParsePatterns(versionPaths.paths), mainFileRelative))) { var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName); if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) { return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry }; diff --git a/src/BundleTransformer.TypeScript/readme.txt b/src/BundleTransformer.TypeScript/readme.txt index 4124755bd..84d957d5d 100644 --- a/src/BundleTransformer.TypeScript/readme.txt +++ b/src/BundleTransformer.TypeScript/readme.txt @@ -13,7 +13,7 @@ =========== BundleTransformer.TypeScript contains one translator-adapter - `TypeScriptTranslator` (supports the TypeScript (https://www.typescriptlang.org) - version 4.7.4). This adapter makes translation of TypeScript code to JS code. + version 4.8 RTM). This adapter makes translation of TypeScript code to JS code. Also contains the `TypeScriptAssetHandler` debugging HTTP handler, which is responsible for text output of translated TypeScript asset. @@ -26,7 +26,8 @@ ============= RELEASE NOTES ============= - Added support of the TypeScript version 4.7.4. + Added support of the TypeScript version 4.8 RTM (please note: The 4.8 RTM + release is also called '4.8.2'). ==================== POST-INSTALL ACTIONS