summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2022-06-01 10:19:18 +1000
committerGitHub <noreply@github.com>2022-06-01 10:19:18 +1000
commit7eee521199e9735ab7c347d99e9d90ba3046be1a (patch)
tree2528f05c15f6e689c1cb409a6bbe554b2507fc40
parentc41544ac7b502fbdb6c1ee96a604490b72eb7770 (diff)
feat: update to TypeScript 4.7 (#14242)
-rw-r--r--Cargo.lock1
-rw-r--r--cli/Cargo.toml1
-rw-r--r--cli/build.rs3
-rw-r--r--cli/dts/lib.dom.d.ts435
-rw-r--r--cli/dts/lib.dom.extras.d.ts4
-rw-r--r--cli/dts/lib.dom.iterable.d.ts19
-rw-r--r--cli/dts/lib.es2015.core.d.ts6
-rw-r--r--cli/dts/lib.es2015.reflect.d.ts2
-rw-r--r--cli/dts/lib.es2020.bigint.d.ts12
-rw-r--r--cli/dts/lib.es2020.d.ts2
-rw-r--r--cli/dts/lib.es2020.date.d.ts44
-rw-r--r--cli/dts/lib.es2020.intl.d.ts51
-rw-r--r--cli/dts/lib.es2020.number.d.ts30
-rw-r--r--cli/dts/lib.es2021.intl.d.ts20
-rw-r--r--cli/dts/lib.es2022.d.ts1
-rw-r--r--cli/dts/lib.es2022.intl.d.ts111
-rw-r--r--cli/dts/lib.es2022.object.d.ts2
-rw-r--r--cli/dts/lib.es5.d.ts40
-rw-r--r--cli/dts/lib.esnext.intl.d.ts5
-rw-r--r--cli/dts/lib.webworker.d.ts135
-rw-r--r--cli/dts/lib.webworker.iterable.d.ts6
-rw-r--r--cli/dts/typescript.d.ts697
-rw-r--r--cli/lsp/tsc.rs49
-rw-r--r--cli/tests/integration/lsp_tests.rs2
-rw-r--r--cli/tests/testdata/lsp/code_lens_resolve_response.json15
-rw-r--r--cli/tsc/00_typescript.js43632
-rw-r--r--cli/tsc/99_main_compiler.js17
-rw-r--r--cli/tsc/compiler.d.ts6
-rw-r--r--ext/web/lib.deno_web.d.ts2
m---------test_util/std0
30 files changed, 24483 insertions, 20867 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 28077bc56..3389ecaca 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -792,6 +792,7 @@ dependencies = [
"rustyline-derive",
"semver-parser 0.10.2",
"serde",
+ "serde_repr",
"shell-escape",
"tempfile",
"test_util",
diff --git a/cli/Cargo.toml b/cli/Cargo.toml
index 062f0cf70..5520462cd 100644
--- a/cli/Cargo.toml
+++ b/cli/Cargo.toml
@@ -91,6 +91,7 @@ rustyline-derive = "=0.6.0"
secure_tempfile = { version = "=3.3.0", package = "tempfile" } # different name to discourage use in tests
semver-parser = "=0.10.2"
serde = { version = "=1.0.136", features = ["derive"] }
+serde_repr = "=0.1.8"
shell-escape = "=0.1.5"
text-size = "=1.1.0"
text_lines = "=0.4.1"
diff --git a/cli/build.rs b/cli/build.rs
index e7a2da236..1a4eaa425 100644
--- a/cli/build.rs
+++ b/cli/build.rs
@@ -141,7 +141,9 @@ fn create_compiler_snapshot(
"es2019.symbol",
"es2020.bigint",
"es2020",
+ "es2020.date",
"es2020.intl",
+ "es2020.number",
"es2020.promise",
"es2020.sharedmemory",
"es2020.string",
@@ -154,6 +156,7 @@ fn create_compiler_snapshot(
"es2022",
"es2022.array",
"es2022.error",
+ "es2022.intl",
"es2022.object",
"es2022.string",
"esnext",
diff --git a/cli/dts/lib.dom.d.ts b/cli/dts/lib.dom.d.ts
index 997e731b5..7d8f7e3e1 100644
--- a/cli/dts/lib.dom.d.ts
+++ b/cli/dts/lib.dom.d.ts
@@ -721,6 +721,19 @@ 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;
}
@@ -951,6 +964,11 @@ interface MutationObserverInit {
subtree?: boolean;
}
+interface NavigationPreloadState {
+ enabled?: boolean;
+ headerValue?: string;
+}
+
interface NotificationAction {
action: string;
icon?: string;
@@ -1263,6 +1281,35 @@ interface RTCDtlsFingerprint {
value?: string;
}
+interface RTCEncodedAudioFrameMetadata {
+ contributingSources?: number[];
+ synchronizationSource?: number;
+}
+
+interface RTCEncodedVideoFrameMetadata {
+ contributingSources?: number[];
+ dependencies?: number[];
+ frameId?: number;
+ height?: number;
+ spatialIndex?: number;
+ synchronizationSource?: number;
+ temporalIndex?: number;
+ width?: number;
+}
+
+interface RTCErrorEventInit extends EventInit {
+ error: RTCError;
+}
+
+interface RTCErrorInit {
+ errorDetail: RTCErrorDetailType;
+ httpRequestStatusCode?: number;
+ receivedAlert?: number;
+ sctpCauseCode?: number;
+ sdpLineNumber?: number;
+ sentAlert?: number;
+}
+
interface RTCIceCandidateInit {
candidate?: string;
sdpMLineIndex?: number | null;
@@ -1768,6 +1815,13 @@ interface UnderlyingSource<R = any> {
type?: undefined;
}
+interface VideoColorSpaceInit {
+ fullRange?: boolean;
+ matrix?: VideoMatrixCoefficients;
+ primaries?: VideoColorPrimaries;
+ transfer?: VideoTransferCharacteristics;
+}
+
interface VideoConfiguration {
bitrate: number;
colorGamut?: ColorGamut;
@@ -1780,6 +1834,19 @@ interface VideoConfiguration {
width: number;
}
+interface VideoFrameMetadata {
+ captureTime?: DOMHighResTimeStamp;
+ expectedDisplayTime: DOMHighResTimeStamp;
+ height: number;
+ mediaTime: number;
+ presentationTime: DOMHighResTimeStamp;
+ presentedFrames: number;
+ processingDuration?: number;
+ receiveTime?: DOMHighResTimeStamp;
+ rtpTimestamp?: number;
+ width: number;
+}
+
interface WaveShaperOptions extends AudioNodeOptions {
curve?: number[] | Float32Array;
oversample?: OverSampleType;
@@ -1914,6 +1981,8 @@ interface AbortSignal extends EventTarget {
/** Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise. */
readonly aborted: boolean;
onabort: ((this: AbortSignal, ev: Event) => any) | null;
+ readonly reason: any;
+ throwIfAborted(): void;
addEventListener<K extends keyof AbortSignalEventMap>(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof AbortSignalEventMap>(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
@@ -2409,7 +2478,7 @@ interface Blob {
readonly type: string;
arrayBuffer(): Promise<ArrayBuffer>;
slice(start?: number, end?: number, contentType?: string): Blob;
- stream(): ReadableStream;
+ stream(): ReadableStream<Uint8Array>;
text(): Promise<string>;
}
@@ -2784,6 +2853,7 @@ interface CSSStyleDeclaration {
columns: string;
contain: string;
content: string;
+ contentVisibility: string;
counterIncrement: string;
counterReset: string;
counterSet: string;
@@ -2819,7 +2889,6 @@ interface CSSStyleDeclaration {
fontStyle: string;
fontSynthesis: string;
fontVariant: string;
- /** @deprecated */
fontVariantAlternates: string;
fontVariantCaps: string;
fontVariantEastAsian: string;
@@ -2893,6 +2962,14 @@ interface CSSStyleDeclaration {
markerMid: string;
markerStart: string;
mask: string;
+ maskClip: string;
+ maskComposite: string;
+ maskImage: string;
+ maskMode: string;
+ maskOrigin: string;
+ maskPosition: string;
+ maskRepeat: string;
+ maskSize: string;
maskType: string;
maxBlockSize: string;
maxHeight: string;
@@ -2906,7 +2983,6 @@ interface CSSStyleDeclaration {
objectFit: string;
objectPosition: string;
offset: string;
- offsetAnchor: string;
offsetDistance: string;
offsetPath: string;
offsetRotate: string;
@@ -2951,6 +3027,7 @@ interface CSSStyleDeclaration {
placeSelf: string;
pointerEvents: string;
position: string;
+ printColorAdjust: string;
quotes: string;
resize: string;
right: string;
@@ -3251,13 +3328,13 @@ declare var CSSTransition: {
* Available only in secure contexts.
*/
interface Cache {
- add(request: RequestInfo): Promise<void>;
+ add(request: RequestInfo | URL): Promise<void>;
addAll(requests: RequestInfo[]): Promise<void>;
- delete(request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>;
- keys(request?: RequestInfo, options?: CacheQueryOptions): Promise<ReadonlyArray<Request>>;
- match(request: RequestInfo, options?: CacheQueryOptions): Promise<Response | undefined>;
- matchAll(request?: RequestInfo, options?: CacheQueryOptions): Promise<ReadonlyArray<Response>>;
- put(request: RequestInfo, response: Response): Promise<void>;
+ delete(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<boolean>;
+ keys(request?: RequestInfo | URL, options?: CacheQueryOptions): Promise<ReadonlyArray<Request>>;
+ match(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<Response | undefined>;
+ matchAll(request?: RequestInfo | URL, options?: CacheQueryOptions): Promise<ReadonlyArray<Response>>;
+ put(request: RequestInfo | URL, response: Response): Promise<void>;
}
declare var Cache: {
@@ -3273,7 +3350,7 @@ interface CacheStorage {
delete(cacheName: string): Promise<boolean>;
has(cacheName: string): Promise<boolean>;
keys(): Promise<string[]>;
- match(request: RequestInfo, options?: MultiCacheQueryOptions): Promise<Response | undefined>;
+ match(request: RequestInfo | URL, options?: MultiCacheQueryOptions): Promise<Response | undefined>;
open(cacheName: string): Promise<Cache>;
}
@@ -3538,6 +3615,7 @@ declare var ClipboardEvent: {
new(type: string, eventInitDict?: ClipboardEventInit): ClipboardEvent;
};
+/** Available only in secure contexts. */
interface ClipboardItem {
readonly types: ReadonlyArray<string>;
getType(type: string): Promise<Blob>;
@@ -3545,7 +3623,7 @@ interface ClipboardItem {
declare var ClipboardItem: {
prototype: ClipboardItem;
- new(items: Record<string, ClipboardItemDataType | PromiseLike<ClipboardItemDataType>>, options?: ClipboardItemOptions): ClipboardItem;
+ new(items: Record<string, string | Blob | PromiseLike<string | Blob>>, options?: ClipboardItemOptions): ClipboardItem;
};
/** A CloseEvent is sent to clients using WebSockets when the connection is closed. This is delivered to the listener indicated by the WebSocket object's onclose attribute. */
@@ -4215,6 +4293,7 @@ declare var DeviceOrientationEvent: {
};
interface DocumentEventMap extends DocumentAndElementEventHandlersEventMap, GlobalEventHandlersEventMap {
+ "DOMContentLoaded": Event;
"fullscreenchange": Event;
"fullscreenerror": Event;
"pointerlockchange": Event;
@@ -4432,6 +4511,8 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad
createEvent(eventInterface: "DeviceOrientationEvent"): DeviceOrientationEvent;
createEvent(eventInterface: "DragEvent"): DragEvent;
createEvent(eventInterface: "ErrorEvent"): ErrorEvent;
+ createEvent(eventInterface: "Event"): Event;
+ createEvent(eventInterface: "Events"): Event;
createEvent(eventInterface: "FocusEvent"): FocusEvent;
createEvent(eventInterface: "FontFaceSetLoadEvent"): FontFaceSetLoadEvent;
createEvent(eventInterface: "FormDataEvent"): FormDataEvent;
@@ -4440,6 +4521,8 @@ 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;
@@ -4460,6 +4543,7 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad
createEvent(eventInterface: "PromiseRejectionEvent"): PromiseRejectionEvent;
createEvent(eventInterface: "RTCDTMFToneChangeEvent"): RTCDTMFToneChangeEvent;
createEvent(eventInterface: "RTCDataChannelEvent"): RTCDataChannelEvent;
+ createEvent(eventInterface: "RTCErrorEvent"): RTCErrorEvent;
createEvent(eventInterface: "RTCPeerConnectionIceErrorEvent"): RTCPeerConnectionIceErrorEvent;
createEvent(eventInterface: "RTCPeerConnectionIceEvent"): RTCPeerConnectionIceEvent;
createEvent(eventInterface: "RTCTrackEvent"): RTCTrackEvent;
@@ -4891,8 +4975,20 @@ interface ElementContentEditable {
}
interface ElementInternals extends ARIAMixin {
+ /** Returns the form owner of internals's target element. */
+ readonly form: HTMLFormElement | null;
+ /** Returns a NodeList of all the label elements that internals's target element is associated with. */
+ 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 true if internals's target element will be validated when the form is submitted; false otherwise. */
+ readonly willValidate: 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;
}
declare var ElementInternals: {
@@ -4966,6 +5062,15 @@ declare var Event: {
readonly NONE: number;
};
+interface EventCounts {
+ forEach(callbackfn: (value: number, key: string, parent: EventCounts) => void, thisArg?: any): void;
+}
+
+declare var EventCounts: {
+ prototype: EventCounts;
+ new(): EventCounts;
+};
+
interface EventListener {
(evt: Event): void;
}
@@ -6159,14 +6264,29 @@ declare var HTMLDetailsElement: {
new(): HTMLDetailsElement;
};
-/** @deprecated this is not available in most browsers */
interface HTMLDialogElement extends HTMLElement {
+ open: boolean;
+ returnValue: string;
+ /**
+ * Closes the dialog element.
+ *
+ * The argument, if provided, provides a return value.
+ */
+ close(returnValue?: string): void;
+ /** Displays the dialog element. */
+ show(): void;
+ showModal(): void;
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLDialogElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLDialogElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
+declare var HTMLDialogElement: {
+ prototype: HTMLDialogElement;
+ new(): HTMLDialogElement;
+};
+
/** @deprecated */
interface HTMLDirectoryElement extends HTMLElement {
/** @deprecated */
@@ -7614,6 +7734,7 @@ interface HTMLScriptElement extends HTMLElement {
declare var HTMLScriptElement: {
prototype: HTMLScriptElement;
new(): HTMLScriptElement;
+ supports(type: string): boolean;
};
/** A <select> HTML Element. These elements also share all of the properties and methods of other HTML elements via the HTMLElement interface. */
@@ -7745,6 +7866,8 @@ declare var HTMLSpanElement: {
/** A <style> element. It inherits properties and methods from its parent, HTMLElement, and from LinkStyle. */
interface HTMLStyleElement extends HTMLElement, LinkStyle {
+ /** Enables or disables the style sheet. */
+ disabled: boolean;
/** Sets or retrieves the media type. */
media: string;
/**
@@ -8251,8 +8374,10 @@ interface HTMLVideoElement extends HTMLMediaElement {
readonly videoWidth: number;
/** Gets or sets the width of the video element. */
width: number;
+ cancelVideoFrameCallback(handle: number): void;
getVideoPlaybackQuality(): VideoPlaybackQuality;
requestPictureInPicture(): Promise<PictureInPictureWindow>;
+ requestVideoFrameCallback(callback: VideoFrameRequestCallback): number;
addEventListener<K extends keyof HTMLVideoElementEventMap>(type: K, listener: (this: HTMLVideoElement, ev: HTMLVideoElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof HTMLVideoElementEventMap>(type: K, listener: (this: HTMLVideoElement, ev: HTMLVideoElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
@@ -8759,6 +8884,7 @@ declare var ImageBitmapRenderingContext: {
/** The underlying pixel data of an area of a <canvas> element. It is created using the ImageData() constructor or creator methods on the CanvasRenderingContext2D object associated with a canvas: createImageData() and getImageData(). It can also be used to set a part of the canvas by using putImageData(). */
interface ImageData {
+ readonly colorSpace: PredefinedColorSpace;
/** Returns the one-dimensional array containing the data in RGBA order, as integers in the range 0 to 255. */
readonly data: Uint8ClampedArray;
/** Returns the actual dimensions of the data in the ImageData object, in pixels. */
@@ -8977,6 +9103,126 @@ 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<K extends keyof MIDIAccessEventMap>(type: K, listener: (this: MIDIAccess, ev: MIDIAccessEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
+ removeEventListener<K extends keyof MIDIAccessEventMap>(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<K extends keyof MIDIInputEventMap>(type: K, listener: (this: MIDIInput, ev: MIDIInputEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
+ removeEventListener<K extends keyof MIDIInputEventMap>(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<K extends keyof MIDIPortEventMap>(type: K, listener: (this: MIDIOutput, ev: MIDIPortEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
+ removeEventListener<K extends keyof MIDIPortEventMap>(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<MIDIPort>;
+ open(): Promise<MIDIPort>;
+ addEventListener<K extends keyof MIDIPortEventMap>(type: K, listener: (this: MIDIPort, ev: MIDIPortEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
+ removeEventListener<K extends keyof MIDIPortEventMap>(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 {
}
@@ -9665,8 +9911,21 @@ declare var NamedNodeMap: {
new(): NamedNodeMap;
};
+/** Available only in secure contexts. */
+interface NavigationPreloadManager {
+ disable(): Promise<void>;
+ enable(): Promise<void>;
+ getState(): Promise<NavigationPreloadState>;
+ setHeaderValue(value: string): Promise<void>;
+}
+
+declare var NavigationPreloadManager: {
+ prototype: NavigationPreloadManager;
+ new(): 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, NavigatorNetworkInformation, NavigatorOnLine, NavigatorPlugins, NavigatorStorage {
+interface Navigator extends NavigatorAutomationInformation, NavigatorConcurrentHardware, NavigatorContentUtils, NavigatorCookies, NavigatorID, NavigatorLanguage, NavigatorLocks, NavigatorNetworkInformation, NavigatorOnLine, NavigatorPlugins, NavigatorStorage {
/** Available only in secure contexts. */
readonly clipboard: Clipboard;
/** Available only in secure contexts. */
@@ -9685,6 +9944,8 @@ interface Navigator extends NavigatorAutomationInformation, NavigatorConcurrentH
canShare(data?: ShareData): boolean;
getGamepads(): (Gamepad | null)[];
/** Available only in secure contexts. */
+ requestMIDIAccess(options?: MIDIOptions): Promise<MIDIAccess>;
+ /** Available only in secure contexts. */
requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): Promise<MediaKeySystemAccess>;
sendBeacon(url: string | URL, data?: BodyInit | null): boolean;
/** Available only in secure contexts. */
@@ -9738,6 +9999,11 @@ interface NavigatorLanguage {
readonly languages: ReadonlyArray<string>;
}
+/** Available only in secure contexts. */
+interface NavigatorLocks {
+ readonly locks: LockManager;
+}
+
interface NavigatorNetworkInformation {
readonly connection: NetworkInformation;
}
@@ -9749,6 +10015,7 @@ interface NavigatorOnLine {
interface NavigatorPlugins {
/** @deprecated */
readonly mimeTypes: MimeTypeArray;
+ readonly pdfViewerEnabled: boolean;
/** @deprecated */
readonly plugins: PluginArray;
/** @deprecated */
@@ -10256,6 +10523,7 @@ interface PerformanceEventMap {
/** Provides access to performance-related information for the current page. It's part of the High Resolution Time API, but is enhanced by the Performance Timeline API, the Navigation Timing API, the User Timing API, and the Resource Timing API. */
interface Performance extends EventTarget {
+ readonly eventCounts: EventCounts;
/** @deprecated */
readonly navigation: PerformanceNavigation;
onresourcetimingbufferfull: ((this: Performance, ev: Event) => any) | null;
@@ -10367,7 +10635,7 @@ interface PerformanceNavigationTiming extends PerformanceResourceTiming {
readonly loadEventEnd: DOMHighResTimeStamp;
readonly loadEventStart: DOMHighResTimeStamp;
readonly redirectCount: number;
- readonly type: NavigationType;
+ readonly type: NavigationTimingType;
readonly unloadEventEnd: DOMHighResTimeStamp;
readonly unloadEventStart: DOMHighResTimeStamp;
toJSON(): any;
@@ -10790,6 +11058,7 @@ declare var RTCDTMFToneChangeEvent: {
interface RTCDataChannelEventMap {
"bufferedamountlow": Event;
"close": Event;
+ "closing": Event;
"error": Event;
"message": MessageEvent;
"open": Event;
@@ -10806,6 +11075,7 @@ interface RTCDataChannel extends EventTarget {
readonly negotiated: boolean;
onbufferedamountlow: ((this: RTCDataChannel, ev: Event) => any) | null;
onclose: ((this: RTCDataChannel, ev: Event) => any) | null;
+ onclosing: ((this: RTCDataChannel, ev: Event) => any) | null;
onerror: ((this: RTCDataChannel, ev: Event) => any) | null;
onmessage: ((this: RTCDataChannel, ev: MessageEvent) => any) | null;
onopen: ((this: RTCDataChannel, ev: Event) => any) | null;
@@ -10838,12 +11108,16 @@ declare var RTCDataChannelEvent: {
};
interface RTCDtlsTransportEventMap {
+ "error": Event;
"statechange": Event;
}
interface RTCDtlsTransport extends EventTarget {
+ readonly iceTransport: RTCIceTransport;
+ onerror: ((this: RTCDtlsTransport, ev: Event) => any) | null;
onstatechange: ((this: RTCDtlsTransport, ev: Event) => any) | null;
readonly state: RTCDtlsTransportState;
+ getRemoteCertificates(): ArrayBuffer[];
addEventListener<K extends keyof RTCDtlsTransportEventMap>(type: K, listener: (this: RTCDtlsTransport, ev: RTCDtlsTransportEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof RTCDtlsTransportEventMap>(type: K, listener: (this: RTCDtlsTransport, ev: RTCDtlsTransportEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
@@ -10855,6 +11129,51 @@ declare var RTCDtlsTransport: {
new(): RTCDtlsTransport;
};
+interface RTCEncodedAudioFrame {
+ data: ArrayBuffer;
+ readonly timestamp: number;
+ getMetadata(): RTCEncodedAudioFrameMetadata;
+}
+
+declare var RTCEncodedAudioFrame: {
+ prototype: RTCEncodedAudioFrame;
+ new(): RTCEncodedAudioFrame;
+};
+
+interface RTCEncodedVideoFrame {
+ data: ArrayBuffer;
+ readonly timestamp: number;
+ readonly type: RTCEncodedVideoFrameType;
+ getMetadata(): RTCEncodedVideoFrameMetadata;
+}
+
+declare var RTCEncodedVideoFrame: {
+ prototype: RTCEncodedVideoFrame;
+ new(): RTCEncodedVideoFrame;
+};
+
+interface RTCError extends DOMException {
+ readonly errorDetail: RTCErrorDetailType;
+ readonly receivedAlert: number | null;
+ readonly sctpCauseCode: number | null;
+ readonly sdpLineNumber: number | null;
+ readonly sentAlert: number | null;
+}
+
+declare var RTCError: {
+ prototype: RTCError;
+ new(init: RTCErrorInit, message?: string): RTCError;
+};
+
+interface RTCErrorEvent extends Event {
+ readonly error: RTCError;
+}
+
+declare var RTCErrorEvent: {
+ prototype: RTCErrorEvent;
+ new(type: string, eventInitDict: RTCErrorEventInit): RTCErrorEvent;
+};
+
/** The RTCIceCandidate interface—part of the WebRTC API—represents a candidate Internet Connectivity Establishment (ICE) configuration which may be used to establish an RTCPeerConnection. */
interface RTCIceCandidate {
readonly address: string | null;
@@ -10879,10 +11198,21 @@ declare var RTCIceCandidate: {
new(candidateInitDict?: RTCIceCandidateInit): RTCIceCandidate;
};
+interface RTCIceTransportEventMap {
+ "gatheringstatechange": Event;
+ "statechange": Event;
+}
+
/** Provides access to information about the ICE transport layer over which the data is being sent and received. */
interface RTCIceTransport extends EventTarget {
readonly gatheringState: RTCIceGathererState;
+ ongatheringstatechange: ((this: RTCIceTransport, ev: Event) => any) | null;
+ onstatechange: ((this: RTCIceTransport, ev: Event) => any) | null;
readonly state: RTCIceTransportState;
+ addEventListener<K extends keyof RTCIceTransportEventMap>(type: K, listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
+ removeEventListener<K extends keyof RTCIceTransportEventMap>(type: K, listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
declare var RTCIceTransport: {
@@ -10923,6 +11253,7 @@ interface RTCPeerConnection extends EventTarget {
readonly pendingLocalDescription: RTCSessionDescription | null;
readonly pendingRemoteDescription: RTCSessionDescription | null;
readonly remoteDescription: RTCSessionDescription | null;
+ readonly sctp: RTCSctpTransport | null;
readonly signalingState: RTCSignalingState;
addIceCandidate(candidate?: RTCIceCandidateInit): Promise<void>;
/** @deprecated */
@@ -11035,6 +11366,27 @@ declare var RTCRtpTransceiver: {
new(): RTCRtpTransceiver;
};
+interface RTCSctpTransportEventMap {
+ "statechange": Event;
+}
+
+interface RTCSctpTransport extends EventTarget {
+ readonly maxChannels: number | null;
+ readonly maxMessageSize: number;
+ onstatechange: ((this: RTCSctpTransport, ev: Event) => any) | null;
+ readonly state: RTCSctpTransportState;
+ readonly transport: RTCDtlsTransport;
+ addEventListener<K extends keyof RTCSctpTransportEventMap>(type: K, listener: (this: RTCSctpTransport, ev: RTCSctpTransportEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
+ removeEventListener<K extends keyof RTCSctpTransportEventMap>(type: K, listener: (this: RTCSctpTransport, ev: RTCSctpTransportEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
+}
+
+declare var RTCSctpTransport: {
+ prototype: RTCSctpTransport;
+ new(): RTCSctpTransport;
+};
+
/** One end of a connection—or potential connection—and how it's configured. Each RTCSessionDescription consists of a description type indicating which part of the offer/answer negotiation process it describes and of the SDP descriptor of the session. */
interface RTCSessionDescription {
readonly sdp: string;
@@ -11223,7 +11575,7 @@ interface Request extends Body {
declare var Request: {
prototype: Request;
- new(input: RequestInfo, init?: RequestInit): Request;
+ new(input: RequestInfo | URL, init?: RequestInit): Request;
};
interface ResizeObserver {
@@ -13183,6 +13535,7 @@ interface ServiceWorkerRegistrationEventMap {
interface ServiceWorkerRegistration extends EventTarget {
readonly active: ServiceWorker | null;
readonly installing: ServiceWorker | null;
+ readonly navigationPreload: NavigationPreloadManager;
onupdatefound: ((this: ServiceWorkerRegistration, ev: Event) => any) | null;
readonly pushManager: PushManager;
readonly scope: string;
@@ -13576,10 +13929,10 @@ interface SubtleCrypto {
encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<any>;
exportKey(format: "jwk", key: CryptoKey): Promise<JsonWebKey>;
exportKey(format: Exclude<KeyFormat, "jwk">, key: CryptoKey): Promise<ArrayBuffer>;
- generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKeyPair>;
- generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
+ generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKeyPair>;
+ generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>;
generateKey(algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKeyPair | CryptoKey>;
- importKey(format: "jwk", keyData: JsonWebKey, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
+ importKey(format: "jwk", keyData: JsonWebKey, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>;
importKey(format: Exclude<KeyFormat, "jwk">, keyData: BufferSource, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
sign(algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, unwrappedKeyAlgorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
@@ -14097,6 +14450,19 @@ declare var ValidityState: {
new(): ValidityState;
};
+interface VideoColorSpace {
+ readonly fullRange: boolean | null;
+ readonly matrix: VideoMatrixCoefficients | null;
+ readonly primaries: VideoColorPrimaries | null;
+ readonly transfer: VideoTransferCharacteristics | null;
+ toJSON(): VideoColorSpaceInit;
+}
+
+declare var VideoColorSpace: {
+ prototype: VideoColorSpace;
+ new(init?: VideoColorSpaceInit): VideoColorSpace;
+};
+
/** Returned by the HTMLVideoElement.getVideoPlaybackQuality() method and contains metrics that can be used to determine the playback quality of a video. */
interface VideoPlaybackQuality {
/** @deprecated */
@@ -14192,13 +14558,6 @@ interface WEBGL_compressed_texture_etc1 {
readonly COMPRESSED_RGB_ETC1_WEBGL: GLenum;
}
-interface WEBGL_compressed_texture_pvrtc {
- readonly COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: GLenum;
- readonly COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: GLenum;
- readonly COMPRESSED_RGB_PVRTC_2BPPV1_IMG: GLenum;
- readonly COMPRESSED_RGB_PVRTC_4BPPV1_IMG: GLenum;
-}
-
/** The WEBGL_compressed_texture_s3tc extension is part of the WebGL API and exposes four S3TC compressed texture formats. */
interface WEBGL_compressed_texture_s3tc {
readonly COMPRESSED_RGBA_S3TC_DXT1_EXT: GLenum;
@@ -15701,7 +16060,6 @@ interface WebGLRenderingContextBase {
getExtension(extensionName: "WEBGL_compressed_texture_astc"): WEBGL_compressed_texture_astc | null;
getExtension(extensionName: "WEBGL_compressed_texture_etc"): WEBGL_compressed_texture_etc | null;
getExtension(extensionName: "WEBGL_compressed_texture_etc1"): WEBGL_compressed_texture_etc1 | null;
- getExtension(extensionName: "WEBGL_compressed_texture_pvrtc"): WEBGL_compressed_texture_pvrtc | null;
getExtension(extensionName: "WEBGL_compressed_texture_s3tc_srgb"): WEBGL_compressed_texture_s3tc_srgb | null;
getExtension(extensionName: "WEBGL_debug_shaders"): WEBGL_debug_shaders | null;
getExtension(extensionName: "WEBGL_draw_buffers"): WEBGL_draw_buffers | null;
@@ -16249,6 +16607,7 @@ declare var WheelEvent: {
};
interface WindowEventMap extends GlobalEventHandlersEventMap, WindowEventHandlersEventMap {
+ "DOMContentLoaded": Event;
"devicemotion": DeviceMotionEvent;
"deviceorientation": DeviceOrientationEvent;
"gamepadconnected": GamepadEvent;
@@ -16448,11 +16807,12 @@ interface WindowOrWorkerGlobalScope {
clearTimeout(id?: number): void;
createImageBitmap(image: ImageBitmapSource, options?: ImageBitmapOptions): Promise<ImageBitmap>;
createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
- fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
+ fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
queueMicrotask(callback: VoidFunction): void;
reportError(e: any): void;
setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
+ structuredClone(value: any, options?: StructuredSerializeOptions): any;
}
interface WindowSessionStorage {
@@ -17097,6 +17457,10 @@ interface UnderlyingSourceStartCallback<R> {
(controller: ReadableStreamController<R>): any;
}
+interface VideoFrameRequestCallback {
+ (now: DOMHighResTimeStamp, metadata: VideoFrameMetadata): void;
+}
+
interface VoidFunction {
(): void;
}
@@ -17729,11 +18093,12 @@ declare function clearInterval(id?: number): void;
declare function clearTimeout(id?: number): void;
declare function createImageBitmap(image: ImageBitmapSource, options?: ImageBitmapOptions): Promise<ImageBitmap>;
declare function createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
-declare function fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
+declare function fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
declare function queueMicrotask(callback: VoidFunction): void;
declare function reportError(e: any): void;
declare function setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
declare function setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
+declare function structuredClone(value: any, options?: StructuredSerializeOptions): any;
declare var sessionStorage: Storage;
declare function addEventListener<K extends keyof WindowEventMap>(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
@@ -17748,8 +18113,7 @@ type BufferSource = ArrayBufferView | ArrayBuffer;
type COSEAlgorithmIdentifier = number;
type CSSNumberish = number;
type CanvasImageSource = HTMLOrSVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap;
-type ClipboardItemData = Promise<ClipboardItemDataType>;
-type ClipboardItemDataType = string | Blob;
+type ClipboardItemData = Promise<string | Blob>;
type ClipboardItems = ClipboardItem[];
type ConstrainBoolean = boolean | ConstrainBooleanParameters;
type ConstrainDOMString = string | string[] | ConstrainDOMStringParameters;
@@ -17864,6 +18228,9 @@ 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";
@@ -17875,7 +18242,7 @@ type MediaKeysRequirement = "not-allowed" | "optional" | "required";
type MediaSessionAction = "hangup" | "nexttrack" | "pause" | "play" | "previoustrack" | "seekbackward" | "seekforward" | "seekto" | "skipad" | "stop" | "togglecamera" | "togglemicrophone";
type MediaSessionPlaybackState = "none" | "paused" | "playing";
type MediaStreamTrackState = "ended" | "live";
-type NavigationType = "back_forward" | "navigate" | "prerender" | "reload";
+type NavigationTimingType = "back_forward" | "navigate" | "prerender" | "reload";
type NotificationDirection = "auto" | "ltr" | "rtl";
type NotificationPermission = "default" | "denied" | "granted";
type OrientationLockType = "any" | "landscape" | "landscape-primary" | "landscape-secondary" | "natural" | "portrait" | "portrait-primary" | "portrait-secondary";
@@ -17897,6 +18264,8 @@ type RTCBundlePolicy = "balanced" | "max-bundle" | "max-compat";
type RTCDataChannelState = "closed" | "closing" | "connecting" | "open";
type RTCDegradationPreference = "balanced" | "maintain-framerate" | "maintain-resolution";
type RTCDtlsTransportState = "closed" | "connected" | "connecting" | "failed" | "new";
+type RTCEncodedVideoFrameType = "delta" | "empty" | "key";
+type RTCErrorDetailType = "data-channel-failure" | "dtls-failure" | "fingerprint-failure" | "hardware-encoder-error" | "hardware-encoder-not-available" | "sctp-failure" | "sdp-syntax-error";
type RTCIceCandidateType = "host" | "prflx" | "relay" | "srflx";
type RTCIceComponent = "rtcp" | "rtp";
type RTCIceConnectionState = "checking" | "closed" | "completed" | "connected" | "disconnected" | "failed" | "new";
@@ -17911,6 +18280,7 @@ type RTCPeerConnectionState = "closed" | "connected" | "connecting" | "disconnec
type RTCPriorityType = "high" | "low" | "medium" | "very-low";
type RTCRtcpMuxPolicy = "require";
type RTCRtpTransceiverDirection = "inactive" | "recvonly" | "sendonly" | "sendrecv" | "stopped";
+type RTCSctpTransportState = "closed" | "connected" | "connecting";
type RTCSdpType = "answer" | "offer" | "pranswer" | "rollback";
type RTCSignalingState = "closed" | "have-local-offer" | "have-local-pranswer" | "have-remote-offer" | "have-remote-pranswer" | "stable";
type RTCStatsIceCandidatePairState = "failed" | "frozen" | "in-progress" | "inprogress" | "succeeded" | "waiting";
@@ -17944,7 +18314,10 @@ type TextTrackMode = "disabled" | "hidden" | "showing";
type TouchType = "direct" | "stylus";
type TransferFunction = "hlg" | "pq" | "srgb";
type UserVerificationRequirement = "discouraged" | "preferred" | "required";
+type VideoColorPrimaries = "bt470bg" | "bt709" | "smpte170m";
type VideoFacingModeEnum = "environment" | "left" | "right" | "user";
+type VideoMatrixCoefficients = "bt470bg" | "bt709" | "rgb" | "smpte170m";
+type VideoTransferCharacteristics = "bt709" | "iec61966-2-1" | "smpte170m";
type WebGLPowerPreference = "default" | "high-performance" | "low-power";
type WorkerType = "classic" | "module";
type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text";
diff --git a/cli/dts/lib.dom.extras.d.ts b/cli/dts/lib.dom.extras.d.ts
index e9a6ab84c..b80435a78 100644
--- a/cli/dts/lib.dom.extras.d.ts
+++ b/cli/dts/lib.dom.extras.d.ts
@@ -7,10 +7,6 @@
/// <reference no-default-lib="true"/>
-interface AbortSignal extends EventTarget {
- readonly reason?: unknown;
-}
-
declare interface URLPatternInit {
protocol?: string;
username?: string;
diff --git a/cli/dts/lib.dom.iterable.d.ts b/cli/dts/lib.dom.iterable.d.ts
index 667eaad63..4fcd2a2db 100644
--- a/cli/dts/lib.dom.iterable.d.ts
+++ b/cli/dts/lib.dom.iterable.d.ts
@@ -69,6 +69,9 @@ interface DataTransferItemList {
[Symbol.iterator](): IterableIterator<DataTransferItem>;
}
+interface EventCounts extends ReadonlyMap<string, number> {
+}
+
interface FileList {
[Symbol.iterator](): IterableIterator<File>;
}
@@ -130,6 +133,16 @@ interface IDBObjectStore {
createIndex(name: string, keyPath: string | Iterable<string>, options?: IDBIndexParameters): IDBIndex;
}
+interface MIDIInputMap extends ReadonlyMap<string, MIDIInput> {
+}
+
+interface MIDIOutput {
+ send(data: Iterable<number>, timestamp?: DOMHighResTimeStamp): void;
+}
+
+interface MIDIOutputMap extends ReadonlyMap<string, MIDIOutput> {
+}
+
interface MediaKeyStatusMap {
[Symbol.iterator](): IterableIterator<[BufferSource, MediaKeyStatus]>;
entries(): IterableIterator<[BufferSource, MediaKeyStatus]>;
@@ -233,10 +246,10 @@ interface StyleSheetList {
interface SubtleCrypto {
deriveKey(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params, extractable: boolean, keyUsages: Iterable<KeyUsage>): Promise<CryptoKey>;
- generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKeyPair>;
- generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
+ generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKeyPair>;
+ generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>;
generateKey(algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: Iterable<KeyUsage>): Promise<CryptoKeyPair | CryptoKey>;
- importKey(format: "jwk", keyData: JsonWebKey, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
+ importKey(format: "jwk", keyData: JsonWebKey, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>;
importKey(format: Exclude<KeyFormat, "jwk">, keyData: BufferSource, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: Iterable<KeyUsage>): Promise<CryptoKey>;
unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, unwrappedKeyAlgorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: Iterable<KeyUsage>): Promise<CryptoKey>;
}
diff --git a/cli/dts/lib.es2015.core.d.ts b/cli/dts/lib.es2015.core.d.ts
index eec8dde90..e55dc65c8 100644
--- a/cli/dts/lib.es2015.core.d.ts
+++ b/cli/dts/lib.es2015.core.d.ts
@@ -283,7 +283,7 @@ interface ObjectConstructor {
* @param target The target object to copy to.
* @param source The source object from which to copy properties.
*/
- assign<T, U>(target: T, source: U): T & U;
+ assign<T extends {}, U>(target: T, source: U): T & U;
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
@@ -292,7 +292,7 @@ interface ObjectConstructor {
* @param source1 The first source object from which to copy properties.
* @param source2 The second source object from which to copy properties.
*/
- assign<T, U, V>(target: T, source1: U, source2: V): T & U & V;
+ assign<T extends {}, U, V>(target: T, source1: U, source2: V): T & U & V;
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
@@ -302,7 +302,7 @@ interface ObjectConstructor {
* @param source2 The second source object from which to copy properties.
* @param source3 The third source object from which to copy properties.
*/
- assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
+ assign<T extends {}, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
diff --git a/cli/dts/lib.es2015.reflect.d.ts b/cli/dts/lib.es2015.reflect.d.ts
index d022a2b77..d1beb6862 100644
--- a/cli/dts/lib.es2015.reflect.d.ts
+++ b/cli/dts/lib.es2015.reflect.d.ts
@@ -44,7 +44,7 @@ declare namespace Reflect {
* @param propertyKey The property name.
* @param attributes Descriptor for the property. It can be for a data property or an accessor property.
*/
- function defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
+ function defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor & ThisType<any>): boolean;
/**
* Removes a property from an object, equivalent to `delete target[propertyKey]`,
diff --git a/cli/dts/lib.es2020.bigint.d.ts b/cli/dts/lib.es2020.bigint.d.ts
index 4d2cc2ad1..a0ebccaf9 100644
--- a/cli/dts/lib.es2020.bigint.d.ts
+++ b/cli/dts/lib.es2020.bigint.d.ts
@@ -18,6 +18,8 @@ and limitations under the License.
/// <reference no-default-lib="true"/>
+/// <reference lib="es2020.intl" />
+
interface BigIntToLocaleStringOptions {
/**
* The locale matching algorithm to use.The default is "best fit". For information about this option, see the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation Intl page}.
@@ -112,7 +114,7 @@ interface BigInt {
toString(radix?: number): string;
/** Returns a string representation appropriate to the host environment's current locale. */
- toLocaleString(locales?: string, options?: BigIntToLocaleStringOptions): string;
+ toLocaleString(locales?: Intl.LocalesArgument, options?: BigIntToLocaleStringOptions): string;
/** Returns the primitive value of the specified object. */
valueOf(): bigint;
@@ -691,6 +693,7 @@ interface DataView {
* Gets the BigInt64 value at the specified byte offset from the start of the view. There is
* no alignment constraint; multi-byte values may be fetched from any offset.
* @param byteOffset The place in the buffer at which the value should be retrieved.
+ * @param littleEndian If false or undefined, a big-endian value should be read.
*/
getBigInt64(byteOffset: number, littleEndian?: boolean): bigint;
@@ -698,6 +701,7 @@ interface DataView {
* Gets the BigUint64 value at the specified byte offset from the start of the view. There is
* no alignment constraint; multi-byte values may be fetched from any offset.
* @param byteOffset The place in the buffer at which the value should be retrieved.
+ * @param littleEndian If false or undefined, a big-endian value should be read.
*/
getBigUint64(byteOffset: number, littleEndian?: boolean): bigint;
@@ -705,8 +709,7 @@ interface DataView {
* Stores a BigInt64 value at the specified byte offset from the start of the view.
* @param byteOffset The place in the buffer at which the value should be set.
* @param value The value to set.
- * @param littleEndian If false or undefined, a big-endian value should be written,
- * otherwise a little-endian value should be written.
+ * @param littleEndian If false or undefined, a big-endian value should be written.
*/
setBigInt64(byteOffset: number, value: bigint, littleEndian?: boolean): void;
@@ -714,8 +717,7 @@ interface DataView {
* Stores a BigUint64 value at the specified byte offset from the start of the view.
* @param byteOffset The place in the buffer at which the value should be set.
* @param value The value to set.
- * @param littleEndian If false or undefined, a big-endian value should be written,
- * otherwise a little-endian value should be written.
+ * @param littleEndian If false or undefined, a big-endian value should be written.
*/
setBigUint64(byteOffset: number, value: bigint, littleEndian?: boolean): void;
}
diff --git a/cli/dts/lib.es2020.d.ts b/cli/dts/lib.es2020.d.ts
index 3e739ac7f..ae81c40b4 100644
--- a/cli/dts/lib.es2020.d.ts
+++ b/cli/dts/lib.es2020.d.ts
@@ -20,6 +20,8 @@ and limitations under the License.
/// <reference lib="es2019" />
/// <reference lib="es2020.bigint" />
+/// <reference lib="es2020.date" />
+/// <reference lib="es2020.number" />
/// <reference lib="es2020.promise" />
/// <reference lib="es2020.sharedmemory" />
/// <reference lib="es2020.string" />
diff --git a/cli/dts/lib.es2020.date.d.ts b/cli/dts/lib.es2020.date.d.ts
new file mode 100644
index 000000000..8eeb6b981
--- /dev/null
+++ b/cli/dts/lib.es2020.date.d.ts
@@ -0,0 +1,44 @@
+/*! *****************************************************************************
+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.
+***************************************************************************** */
+
+
+
+/// <reference no-default-lib="true"/>
+
+
+/// <reference lib="es2020.intl" />
+
+interface Date {
+ /**
+ * Converts a date and time to a string by using the current or specified locale.
+ * @param locales A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
+ * @param options An object that contains one or more properties that specify comparison options.
+ */
+ toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
+
+ /**
+ * Converts a date to a string by using the current or specified locale.
+ * @param locales A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
+ * @param options An object that contains one or more properties that specify comparison options.
+ */
+ toLocaleDateString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
+
+ /**
+ * Converts a time to a string by using the current or specified locale.
+ * @param locales A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
+ * @param options An object that contains one or more properties that specify comparison options.
+ */
+ toLocaleTimeString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
+} \ No newline at end of file
diff --git a/cli/dts/lib.es2020.intl.d.ts b/cli/dts/lib.es2020.intl.d.ts
index 3e47f89cf..af981e31c 100644
--- a/cli/dts/lib.es2020.intl.d.ts
+++ b/cli/dts/lib.es2020.intl.d.ts
@@ -79,6 +79,13 @@ declare namespace Intl {
type BCP47LanguageTag = string;
/**
+ * The locale(s) to use
+ *
+ * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument).
+ */
+ type LocalesArgument = UnicodeBCP47LocaleIdentifier | Locale | (UnicodeBCP47LocaleIdentifier | Locale)[] | undefined;
+
+ /**
* An object with some or all of properties of `options` parameter
* of `Intl.RelativeTimeFormat` constructor.
*
@@ -274,6 +281,10 @@ declare namespace Intl {
}
interface Locale extends LocaleOptions {
+ /** A string containing the language, and the script and region if available. */
+ baseName: string;
+ /** The primary language subtag associated with the locale. */
+ language: string;
/** Gets the most likely values for the language, script, and region of the locale based on existing values. */
maximize(): Locale;
/** Attempts to remove information about the locale that would be added by calling `Locale.maximize()`. */
@@ -297,15 +308,39 @@ declare namespace Intl {
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale).
*/
const Locale: {
- new (tag?: BCP47LanguageTag, options?: LocaleOptions): Locale;
+ new (tag: BCP47LanguageTag | Locale, options?: LocaleOptions): Locale;
};
- interface DisplayNamesOptions {
+ type DisplayNamesFallback =
+ | "code"
+ | "none";
+
+ type DisplayNamesType =
+ | "language"
+ | "region"
+ | "script"
+ | "calendar"
+ | "dateTimeField"
+ | "currency";
+
+ type DisplayNamesLanguageDisplay =
+ | "dialect"
+ | "standard";
+
+ interface DisplayNamesOptions {
+ localeMatcher?: RelativeTimeFormatLocaleMatcher;
+ style?: RelativeTimeFormatStyle;
+ type: DisplayNamesType;
+ languageDisplay?: DisplayNamesLanguageDisplay;
+ fallback?: DisplayNamesFallback;
+ }
+
+ interface ResolvedDisplayNamesOptions {
locale: UnicodeBCP47LocaleIdentifier;
- localeMatcher: RelativeTimeFormatLocaleMatcher;
style: RelativeTimeFormatStyle;
- type: "language" | "region" | "script" | "currency";
- fallback: "code" | "none";
+ type: DisplayNamesType;
+ fallback: DisplayNamesFallback;
+ languageDisplay?: DisplayNamesLanguageDisplay;
}
interface DisplayNames {
@@ -331,7 +366,7 @@ declare namespace Intl {
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/resolvedOptions).
*/
- resolvedOptions(): DisplayNamesOptions;
+ resolvedOptions(): ResolvedDisplayNamesOptions;
}
/**
@@ -352,7 +387,7 @@ declare namespace Intl {
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames).
*/
- new(locales?: BCP47LanguageTag | BCP47LanguageTag[], options?: Partial<DisplayNamesOptions>): DisplayNames;
+ new(locales: LocalesArgument, options: DisplayNamesOptions): DisplayNames;
/**
* Returns an array containing those of the provided locales that are supported in display names without having to fall back to the runtime's default locale.
@@ -367,7 +402,7 @@ declare namespace Intl {
*
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/supportedLocalesOf).
*/
- supportedLocalesOf(locales: BCP47LanguageTag | BCP47LanguageTag[], options?: {localeMatcher: RelativeTimeFormatLocaleMatcher}): BCP47LanguageTag[];
+ supportedLocalesOf(locales?: LocalesArgument, options?: { localeMatcher?: RelativeTimeFormatLocaleMatcher }): BCP47LanguageTag[];
};
}
diff --git a/cli/dts/lib.es2020.number.d.ts b/cli/dts/lib.es2020.number.d.ts
new file mode 100644
index 000000000..89f6a2723
--- /dev/null
+++ b/cli/dts/lib.es2020.number.d.ts
@@ -0,0 +1,30 @@
+/*! *****************************************************************************
+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.
+***************************************************************************** */
+
+
+
+/// <reference no-default-lib="true"/>
+
+
+/// <reference lib="es2020.intl" />
+
+interface Number {
+ /**
+ * Converts a number to a string by using the current or specified locale.
+ * @param locales A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
+ * @param options An object that contains one or more properties that specify comparison options.
+ */
+ toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string;
+}
diff --git a/cli/dts/lib.es2021.intl.d.ts b/cli/dts/lib.es2021.intl.d.ts
index 6380bf6fb..1e8cec37a 100644
--- a/cli/dts/lib.es2021.intl.d.ts
+++ b/cli/dts/lib.es2021.intl.d.ts
@@ -28,6 +28,11 @@ declare namespace Intl {
fractionalSecondDigits?: 0 | 1 | 2 | 3 | undefined;
}
+ interface DateTimeFormat {
+ formatRange(startDate: Date | number | bigint, endDate: Date | number | bigint): string;
+ formatRangeToParts(startDate: Date | number | bigint, endDate: Date | number | bigint): DateTimeFormatPart[];
+ }
+
interface ResolvedDateTimeFormatOptions {
formatMatcher?: "basic" | "best fit" | "best fit";
dateStyle?: "full" | "long" | "medium" | "short";
@@ -37,15 +42,10 @@ declare namespace Intl {
fractionalSecondDigits?: 0 | 1 | 2 | 3;
}
- interface NumberFormat {
- formatRange(startDate: number | bigint, endDate: number | bigint): string;
- formatRangeToParts(startDate: number | bigint, endDate: number | bigint): NumberFormatPart[];
- }
-
/**
* The locale matching algorithm to use.
*
- * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation).
+ * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#parameters).
*/
type ListFormatLocaleMatcher = "lookup" | "best fit";
@@ -70,11 +70,11 @@ declare namespace Intl {
*/
interface ListFormatOptions {
/** The locale matching algorithm to use. For information about this option, see [Intl page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation). */
- localeMatcher?: ListFormatLocaleMatcher;
+ localeMatcher?: ListFormatLocaleMatcher | undefined;
/** The format of output message. */
- type?: ListFormatType;
+ type?: ListFormatType | undefined;
/** The length of the internationalized message. */
- style?: ListFormatStyle;
+ style?: ListFormatStyle | undefined;
}
interface ListFormat {
@@ -143,4 +143,4 @@ declare namespace Intl {
*/
supportedLocalesOf(locales: BCP47LanguageTag | BCP47LanguageTag[], options?: Pick<ListFormatOptions, "localeMatcher">): BCP47LanguageTag[];
};
-} \ No newline at end of file
+}
diff --git a/cli/dts/lib.es2022.d.ts b/cli/dts/lib.es2022.d.ts
index 73558c811..6d4283d28 100644
--- a/cli/dts/lib.es2022.d.ts
+++ b/cli/dts/lib.es2022.d.ts
@@ -21,5 +21,6 @@ and limitations under the License.
/// <reference lib="es2021" />
/// <reference lib="es2022.array" />
/// <reference lib="es2022.error" />
+/// <reference lib="es2022.intl" />
/// <reference lib="es2022.object" />
/// <reference lib="es2022.string" />
diff --git a/cli/dts/lib.es2022.intl.d.ts b/cli/dts/lib.es2022.intl.d.ts
new file mode 100644
index 000000000..ff487a11c
--- /dev/null
+++ b/cli/dts/lib.es2022.intl.d.ts
@@ -0,0 +1,111 @@
+/*! *****************************************************************************
+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.
+***************************************************************************** */
+
+
+
+/// <reference no-default-lib="true"/>
+
+
+declare namespace Intl {
+
+ /**
+ * An object with some or all properties of the `Intl.Segmenter` constructor `options` parameter.
+ *
+ * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter#parameters)
+ */
+ interface SegmenterOptions {
+ /** The locale matching algorithm to use. For information about this option, see [Intl page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation). */
+ localeMatcher?: "best fit" | "lookup" | undefined;
+ /** The type of input to be split */
+ granularity?: "grapheme" | "word" | "sentence" | undefined;
+ }
+
+ interface Segmenter {
+ /**
+ * Returns `Segments` object containing the segments of the input string, using the segmenter's locale and granularity.
+ *
+ * @param input - The text to be segmented as a `string`.
+ *
+ * @returns A new iterable Segments object containing the segments of the input string, using the segmenter's locale and granularity.
+ */
+ segment(input: string): Segments;
+ resolvedOptions(): ResolvedSegmenterOptions;
+ }
+
+ interface ResolvedSegmenterOptions {
+ locale: string;
+ granularity: "grapheme" | "word" | "sentence";
+ }
+
+ interface Segments {
+ /**
+ * Returns an object describing the segment in the original string that includes the code unit at a specified index.
+ *
+ * @param codeUnitIndex - A number specifying the index of the code unit in the original input string. If the value is omitted, it defaults to `0`.
+ */
+ containing(codeUnitIndex?: number): SegmentData;
+
+ /** Returns an iterator to iterate over the segments. */
+ [Symbol.iterator](): IterableIterator<SegmentData>;
+ }
+
+ interface SegmentData {
+ /** A string containing the segment extracted from the original input string. */
+ segment: string;
+ /** The code unit index in the original input string at which the segment begins. */
+ index: number;
+ /** The complete input string that was segmented. */
+ input: string;
+ /**
+ * A boolean value only if granularity is "word"; otherwise, undefined.
+ * If granularity is "word", then isWordLike is true when the segment is word-like (i.e., consists of letters/numbers/ideographs/etc.); otherwise, false.
+ */
+ isWordLike?: boolean;
+ }
+
+ const Segmenter: {
+ prototype: Segmenter;
+
+ /**
+ * Creates a new `Intl.Segmenter` object.
+ *
+ * @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings.
+ * For the general form and interpretation of the `locales` argument,
+ * see the [`Intl` page](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
+ *
+ * @param options - An [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter#parameters)
+ * with some or all options of `SegmenterOptions`.
+ *
+ * @returns [Intl.Segmenter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segments) object.
+ *
+ * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter).
+ */
+ new(locales?: BCP47LanguageTag | BCP47LanguageTag[], options?: SegmenterOptions): Segmenter;
+
+ /**
+ * Returns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale.
+ *
+ * @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings.
+ * For the general form and interpretation of the `locales` argument,
+ * see the [`Intl` page](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
+ *
+ * @param options An [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf#parameters).
+ * with some or all possible options.
+ *
+ * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf)
+ */
+ supportedLocalesOf(locales: BCP47LanguageTag | BCP47LanguageTag[], options?: Pick<SegmenterOptions, "localeMatcher">): BCP47LanguageTag[];
+ };
+}
diff --git a/cli/dts/lib.es2022.object.d.ts b/cli/dts/lib.es2022.object.d.ts
index 634601006..2fe2a1917 100644
--- a/cli/dts/lib.es2022.object.d.ts
+++ b/cli/dts/lib.es2022.object.d.ts
@@ -18,7 +18,7 @@ and limitations under the License.
/// <reference no-default-lib="true"/>
-interface Object {
+interface ObjectConstructor {
/**
* Determines whether an object has a property with the specified name.
* @param o An object.
diff --git a/cli/dts/lib.es5.d.ts b/cli/dts/lib.es5.d.ts
index 9f27ff527..d45132b5b 100644
--- a/cli/dts/lib.es5.d.ts
+++ b/cli/dts/lib.es5.d.ts
@@ -72,13 +72,13 @@ declare function decodeURIComponent(encodedURIComponent: string): string;
/**
* Encodes a text string as a valid Uniform Resource Identifier (URI)
- * @param uri A value representing an encoded URI.
+ * @param uri A value representing an unencoded URI.
*/
declare function encodeURI(uri: string): string;
/**
* Encodes a text string as a valid component of a Uniform Resource Identifier (URI).
- * @param uriComponent A value representing an encoded URI component.
+ * @param uriComponent A value representing an unencoded URI component.
*/
declare function encodeURIComponent(uriComponent: string | number | boolean): string;
@@ -230,6 +230,12 @@ interface ObjectConstructor {
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
+ freeze<T extends {[idx: string]: U | null | undefined | object}, U extends string | bigint | number | boolean | symbol>(o: T): Readonly<T>;
+
+ /**
+ * Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
+ * @param o Object on which to lock the attributes.
+ */
freeze<T>(o: T): Readonly<T>;
/**
@@ -320,7 +326,7 @@ declare var Function: FunctionConstructor;
/**
* Extracts the type of the 'this' parameter of a function type, or 'unknown' if the function type has no 'this' parameter.
*/
-type ThisParameterType<T> = T extends (this: infer U, ...args: any[]) => any ? U : unknown;
+type ThisParameterType<T> = T extends (this: infer U, ...args: never) => any ? U : unknown;
/**
* Removes the 'this' parameter from a function type.
@@ -1683,6 +1689,7 @@ interface DataView {
* Gets the Float32 value at the specified byte offset from the start of the view. There is
* no alignment constraint; multi-byte values may be fetched from any offset.
* @param byteOffset The place in the buffer at which the value should be retrieved.
+ * @param littleEndian If false or undefined, a big-endian value should be read.
*/
getFloat32(byteOffset: number, littleEndian?: boolean): number;
@@ -1690,6 +1697,7 @@ interface DataView {
* Gets the Float64 value at the specified byte offset from the start of the view. There is
* no alignment constraint; multi-byte values may be fetched from any offset.
* @param byteOffset The place in the buffer at which the value should be retrieved.
+ * @param littleEndian If false or undefined, a big-endian value should be read.
*/
getFloat64(byteOffset: number, littleEndian?: boolean): number;
@@ -1704,12 +1712,14 @@ interface DataView {
* Gets the Int16 value at the specified byte offset from the start of the view. There is
* no alignment constraint; multi-byte values may be fetched from any offset.
* @param byteOffset The place in the buffer at which the value should be retrieved.
+ * @param littleEndian If false or undefined, a big-endian value should be read.
*/
getInt16(byteOffset: number, littleEndian?: boolean): number;
/**
* Gets the Int32 value at the specified byte offset from the start of the view. There is
* no alignment constraint; multi-byte values may be fetched from any offset.
* @param byteOffset The place in the buffer at which the value should be retrieved.
+ * @param littleEndian If false or undefined, a big-endian value should be read.
*/
getInt32(byteOffset: number, littleEndian?: boolean): number;
@@ -1724,6 +1734,7 @@ interface DataView {
* Gets the Uint16 value at the specified byte offset from the start of the view. There is
* no alignment constraint; multi-byte values may be fetched from any offset.
* @param byteOffset The place in the buffer at which the value should be retrieved.
+ * @param littleEndian If false or undefined, a big-endian value should be read.
*/
getUint16(byteOffset: number, littleEndian?: boolean): number;
@@ -1731,6 +1742,7 @@ interface DataView {
* Gets the Uint32 value at the specified byte offset from the start of the view. There is
* no alignment constraint; multi-byte values may be fetched from any offset.
* @param byteOffset The place in the buffer at which the value should be retrieved.
+ * @param littleEndian If false or undefined, a big-endian value should be read.
*/
getUint32(byteOffset: number, littleEndian?: boolean): number;
@@ -1738,8 +1750,7 @@ interface DataView {
* Stores an Float32 value at the specified byte offset from the start of the view.
* @param byteOffset The place in the buffer at which the value should be set.
* @param value The value to set.
- * @param littleEndian If false or undefined, a big-endian value should be written,
- * otherwise a little-endian value should be written.
+ * @param littleEndian If false or undefined, a big-endian value should be written.
*/
setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void;
@@ -1747,8 +1758,7 @@ interface DataView {
* Stores an Float64 value at the specified byte offset from the start of the view.
* @param byteOffset The place in the buffer at which the value should be set.
* @param value The value to set.
- * @param littleEndian If false or undefined, a big-endian value should be written,
- * otherwise a little-endian value should be written.
+ * @param littleEndian If false or undefined, a big-endian value should be written.
*/
setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void;
@@ -1763,8 +1773,7 @@ interface DataView {
* Stores an Int16 value at the specified byte offset from the start of the view.
* @param byteOffset The place in the buffer at which the value should be set.
* @param value The value to set.
- * @param littleEndian If false or undefined, a big-endian value should be written,
- * otherwise a little-endian value should be written.
+ * @param littleEndian If false or undefined, a big-endian value should be written.
*/
setInt16(byteOffset: number, value: number, littleEndian?: boolean): void;
@@ -1772,8 +1781,7 @@ interface DataView {
* Stores an Int32 value at the specified byte offset from the start of the view.
* @param byteOffset The place in the buffer at which the value should be set.
* @param value The value to set.
- * @param littleEndian If false or undefined, a big-endian value should be written,
- * otherwise a little-endian value should be written.
+ * @param littleEndian If false or undefined, a big-endian value should be written.
*/
setInt32(byteOffset: number, value: number, littleEndian?: boolean): void;
@@ -1788,8 +1796,7 @@ interface DataView {
* Stores an Uint16 value at the specified byte offset from the start of the view.
* @param byteOffset The place in the buffer at which the value should be set.
* @param value The value to set.
- * @param littleEndian If false or undefined, a big-endian value should be written,
- * otherwise a little-endian value should be written.
+ * @param littleEndian If false or undefined, a big-endian value should be written.
*/
setUint16(byteOffset: number, value: number, littleEndian?: boolean): void;
@@ -1797,8 +1804,7 @@ interface DataView {
* Stores an Uint32 value at the specified byte offset from the start of the view.
* @param byteOffset The place in the buffer at which the value should be set.
* @param value The value to set.
- * @param littleEndian If false or undefined, a big-endian value should be written,
- * otherwise a little-endian value should be written.
+ * @param littleEndian If false or undefined, a big-endian value should be written.
*/
setUint32(byteOffset: number, value: number, littleEndian?: boolean): void;
}
@@ -4405,6 +4411,7 @@ declare namespace Intl {
new(locales?: string | string[], options?: NumberFormatOptions): NumberFormat;
(locales?: string | string[], options?: NumberFormatOptions): NumberFormat;
supportedLocalesOf(locales: string | string[], options?: NumberFormatOptions): string[];
+ readonly prototype: NumberFormat;
};
interface DateTimeFormatOptions {
@@ -4417,7 +4424,7 @@ declare namespace Intl {
hour?: "numeric" | "2-digit" | undefined;
minute?: "numeric" | "2-digit" | undefined;
second?: "numeric" | "2-digit" | undefined;
- timeZoneName?: "long" | "short" | undefined;
+ timeZoneName?: "short" | "long" | "shortOffset" | "longOffset" | "shortGeneric" | "longGeneric" | undefined;
formatMatcher?: "best fit" | "basic" | undefined;
hour12?: boolean | undefined;
timeZone?: string | undefined;
@@ -4448,6 +4455,7 @@ declare namespace Intl {
new(locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat;
(locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat;
supportedLocalesOf(locales: string | string[], options?: DateTimeFormatOptions): string[];
+ readonly prototype: DateTimeFormat;
};
}
diff --git a/cli/dts/lib.esnext.intl.d.ts b/cli/dts/lib.esnext.intl.d.ts
index ebb42fc37..954679457 100644
--- a/cli/dts/lib.esnext.intl.d.ts
+++ b/cli/dts/lib.esnext.intl.d.ts
@@ -19,5 +19,8 @@ and limitations under the License.
declare namespace Intl {
- // Empty for now
+ interface NumberFormat {
+ formatRange(start: number | bigint, end: number | bigint): string;
+ formatRangeToParts(start: number | bigint, end: number | bigint): NumberFormatPart[];
+ }
}
diff --git a/cli/dts/lib.webworker.d.ts b/cli/dts/lib.webworker.d.ts
index f6b3d43b3..6f9a2eaf5 100644
--- a/cli/dts/lib.webworker.d.ts
+++ b/cli/dts/lib.webworker.d.ts
@@ -379,6 +379,11 @@ interface MultiCacheQueryOptions extends CacheQueryOptions {
cacheName?: string;
}
+interface NavigationPreloadState {
+ enabled?: boolean;
+ headerValue?: string;
+}
+
interface NotificationAction {
action: string;
icon?: string;
@@ -475,6 +480,22 @@ interface QueuingStrategyInit {
highWaterMark: number;
}
+interface RTCEncodedAudioFrameMetadata {
+ contributingSources?: number[];
+ synchronizationSource?: number;
+}
+
+interface RTCEncodedVideoFrameMetadata {
+ contributingSources?: number[];
+ dependencies?: number[];
+ frameId?: number;
+ height?: number;
+ spatialIndex?: number;
+ synchronizationSource?: number;
+ temporalIndex?: number;
+ width?: number;
+}
+
interface ReadableStreamDefaultReadDoneResult {
done: true;
value?: undefined;
@@ -648,6 +669,13 @@ interface UnderlyingSource<R = any> {
type?: undefined;
}
+interface VideoColorSpaceInit {
+ fullRange?: boolean;
+ matrix?: VideoMatrixCoefficients;
+ primaries?: VideoColorPrimaries;
+ transfer?: VideoTransferCharacteristics;
+}
+
interface VideoConfiguration {
bitrate: number;
colorGamut?: ColorGamut;
@@ -695,7 +723,7 @@ interface AbortController {
/** Returns the AbortSignal object associated with this object. */
readonly signal: AbortSignal;
/** Invoking this method will set this object's AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted. */
- abort(reason?: any): void;
+ // abort(): AbortSignal; - To be re-added in the future
}
declare var AbortController: {
@@ -712,6 +740,8 @@ interface AbortSignal extends EventTarget {
/** Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise. */
readonly aborted: boolean;
onabort: ((this: AbortSignal, ev: Event) => any) | null;
+ readonly reason: any;
+ throwIfAborted(): void;
addEventListener<K extends keyof AbortSignalEventMap>(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof AbortSignalEventMap>(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
@@ -721,7 +751,7 @@ interface AbortSignal extends EventTarget {
declare var AbortSignal: {
prototype: AbortSignal;
new(): AbortSignal;
- // abort(): AbortSignal; - To be re-added in the future
+ abort(reason?: any): AbortSignal;
};
interface AbstractWorkerEventMap {
@@ -747,7 +777,7 @@ interface Blob {
readonly type: string;
arrayBuffer(): Promise<ArrayBuffer>;
slice(start?: number, end?: number, contentType?: string): Blob;
- stream(): ReadableStream;
+ stream(): ReadableStream<Uint8Array>;
text(): Promise<string>;
}
@@ -807,13 +837,13 @@ declare var ByteLengthQueuingStrategy: {
* Available only in secure contexts.
*/
interface Cache {
- add(request: RequestInfo): Promise<void>;
+ add(request: RequestInfo | URL): Promise<void>;
addAll(requests: RequestInfo[]): Promise<void>;
- delete(request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>;
- keys(request?: RequestInfo, options?: CacheQueryOptions): Promise<ReadonlyArray<Request>>;
- match(request: RequestInfo, options?: CacheQueryOptions): Promise<Response | undefined>;
- matchAll(request?: RequestInfo, options?: CacheQueryOptions): Promise<ReadonlyArray<Response>>;
- put(request: RequestInfo, response: Response): Promise<void>;
+ delete(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<boolean>;
+ keys(request?: RequestInfo | URL, options?: CacheQueryOptions): Promise<ReadonlyArray<Request>>;
+ match(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<Response | undefined>;
+ matchAll(request?: RequestInfo | URL, options?: CacheQueryOptions): Promise<ReadonlyArray<Response>>;
+ put(request: RequestInfo | URL, response: Response): Promise<void>;
}
declare var Cache: {
@@ -829,7 +859,7 @@ interface CacheStorage {
delete(cacheName: string): Promise<boolean>;
has(cacheName: string): Promise<boolean>;
keys(): Promise<string[]>;
- match(request: RequestInfo, options?: MultiCacheQueryOptions): Promise<Response | undefined>;
+ match(request: RequestInfo | URL, options?: MultiCacheQueryOptions): Promise<Response | undefined>;
open(cacheName: string): Promise<Cache>;
}
@@ -1462,6 +1492,7 @@ declare var ExtendableMessageEvent: {
interface FetchEvent extends ExtendableEvent {
readonly clientId: string;
readonly handled: Promise<undefined>;
+ readonly preloadResponse: Promise<any>;
readonly request: Request;
readonly resultingClientId: string;
respondWith(r: Response | PromiseLike<Response>): void;
@@ -2115,6 +2146,7 @@ declare var ImageBitmapRenderingContext: {
/** The underlying pixel data of an area of a <canvas> element. It is created using the ImageData() constructor or creator methods on the CanvasRenderingContext2D object associated with a canvas: createImageData() and getImageData(). It can also be used to set a part of the canvas by using putImageData(). */
interface ImageData {
+ readonly colorSpace: PredefinedColorSpace;
/** Returns the one-dimensional array containing the data in RGBA order, as integers in the range 0 to 255. */
readonly data: Uint8ClampedArray;
/** Returns the actual dimensions of the data in the ImageData object, in pixels. */
@@ -2231,6 +2263,19 @@ declare var MessagePort: {
new(): MessagePort;
};
+/** Available only in secure contexts. */
+interface NavigationPreloadManager {
+ disable(): Promise<void>;
+ enable(): Promise<void>;
+ getState(): Promise<NavigationPreloadState>;
+ setHeaderValue(value: string): Promise<void>;
+}
+
+declare var NavigationPreloadManager: {
+ prototype: NavigationPreloadManager;
+ new(): NavigationPreloadManager;
+};
+
interface NavigatorConcurrentHardware {
readonly hardwareConcurrency: number;
}
@@ -2254,6 +2299,11 @@ interface NavigatorLanguage {
readonly languages: ReadonlyArray<string>;
}
+/** Available only in secure contexts. */
+interface NavigatorLocks {
+ readonly locks: LockManager;
+}
+
interface NavigatorNetworkInformation {
readonly connection: NetworkInformation;
}
@@ -2629,6 +2679,29 @@ declare var PushSubscriptionOptions: {
new(): PushSubscriptionOptions;
};
+interface RTCEncodedAudioFrame {
+ data: ArrayBuffer;
+ readonly timestamp: number;
+ getMetadata(): RTCEncodedAudioFrameMetadata;
+}
+
+declare var RTCEncodedAudioFrame: {
+ prototype: RTCEncodedAudioFrame;
+ new(): RTCEncodedAudioFrame;
+};
+
+interface RTCEncodedVideoFrame {
+ data: ArrayBuffer;
+ readonly timestamp: number;
+ readonly type: RTCEncodedVideoFrameType;
+ getMetadata(): RTCEncodedVideoFrameMetadata;
+}
+
+declare var RTCEncodedVideoFrame: {
+ prototype: RTCEncodedVideoFrame;
+ new(): RTCEncodedVideoFrame;
+};
+
/** 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<R = any> {
readonly locked: boolean;
@@ -2704,7 +2777,7 @@ interface Request extends Body {
declare var Request: {
prototype: Request;
- new(input: RequestInfo, init?: RequestInit): Request;
+ new(input: RequestInfo | URL, init?: RequestInit): Request;
};
/** This Fetch API interface represents the response to a request. */
@@ -2849,6 +2922,7 @@ interface ServiceWorkerRegistrationEventMap {
interface ServiceWorkerRegistration extends EventTarget {
readonly active: ServiceWorker | null;
readonly installing: ServiceWorker | null;
+ readonly navigationPreload: NavigationPreloadManager;
onupdatefound: ((this: ServiceWorkerRegistration, ev: Event) => any) | null;
readonly pushManager: PushManager;
readonly scope: string;
@@ -2914,10 +2988,10 @@ interface SubtleCrypto {
encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<any>;
exportKey(format: "jwk", key: CryptoKey): Promise<JsonWebKey>;
exportKey(format: Exclude<KeyFormat, "jwk">, key: CryptoKey): Promise<ArrayBuffer>;
- generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKeyPair>;
- generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
+ generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKeyPair>;
+ generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>;
generateKey(algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKeyPair | CryptoKey>;
- importKey(format: "jwk", keyData: JsonWebKey, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
+ importKey(format: "jwk", keyData: JsonWebKey, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>;
importKey(format: Exclude<KeyFormat, "jwk">, keyData: BufferSource, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
sign(algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, unwrappedKeyAlgorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
@@ -3095,6 +3169,19 @@ declare var URLSearchParams: {
toString(): string;
};
+interface VideoColorSpace {
+ readonly fullRange: boolean | null;
+ readonly matrix: VideoMatrixCoefficients | null;
+ readonly primaries: VideoColorPrimaries | null;
+ readonly transfer: VideoTransferCharacteristics | null;
+ toJSON(): VideoColorSpaceInit;
+}
+
+declare var VideoColorSpace: {
+ prototype: VideoColorSpace;
+ new(init?: VideoColorSpaceInit): VideoColorSpace;
+};
+
interface WEBGL_color_buffer_float {
readonly FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT: GLenum;
readonly RGBA32F_EXT: GLenum;
@@ -3150,13 +3237,6 @@ interface WEBGL_compressed_texture_etc1 {
readonly COMPRESSED_RGB_ETC1_WEBGL: GLenum;
}
-interface WEBGL_compressed_texture_pvrtc {
- readonly COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: GLenum;
- readonly COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: GLenum;
- readonly COMPRESSED_RGB_PVRTC_2BPPV1_IMG: GLenum;
- readonly COMPRESSED_RGB_PVRTC_4BPPV1_IMG: GLenum;
-}
-
/** The WEBGL_compressed_texture_s3tc extension is part of the WebGL API and exposes four S3TC compressed texture formats. */
interface WEBGL_compressed_texture_s3tc {
readonly COMPRESSED_RGBA_S3TC_DXT1_EXT: GLenum;
@@ -4647,7 +4727,6 @@ interface WebGLRenderingContextBase {
getExtension(extensionName: "WEBGL_compressed_texture_astc"): WEBGL_compressed_texture_astc | null;
getExtension(extensionName: "WEBGL_compressed_texture_etc"): WEBGL_compressed_texture_etc | null;
getExtension(extensionName: "WEBGL_compressed_texture_etc1"): WEBGL_compressed_texture_etc1 | null;
- getExtension(extensionName: "WEBGL_compressed_texture_pvrtc"): WEBGL_compressed_texture_pvrtc | null;
getExtension(extensionName: "WEBGL_compressed_texture_s3tc_srgb"): WEBGL_compressed_texture_s3tc_srgb | null;
getExtension(extensionName: "WEBGL_debug_shaders"): WEBGL_debug_shaders | null;
getExtension(extensionName: "WEBGL_draw_buffers"): WEBGL_draw_buffers | null;
@@ -5203,11 +5282,12 @@ interface WindowOrWorkerGlobalScope {
clearTimeout(id?: number): void;
createImageBitmap(image: ImageBitmapSource, options?: ImageBitmapOptions): Promise<ImageBitmap>;
createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
- fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
+ fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
queueMicrotask(callback: VoidFunction): void;
reportError(e: any): void;
setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
+ structuredClone(value: any, options?: StructuredSerializeOptions): any;
}
interface WorkerEventMap extends AbstractWorkerEventMap {
@@ -5291,7 +5371,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, NavigatorNetworkInformation, NavigatorOnLine, NavigatorStorage {
+interface WorkerNavigator extends NavigatorConcurrentHardware, NavigatorID, NavigatorLanguage, NavigatorLocks, NavigatorNetworkInformation, NavigatorOnLine, NavigatorStorage {
readonly mediaCapabilities: MediaCapabilities;
}
@@ -5742,11 +5822,12 @@ declare function clearInterval(id?: number): void;
declare function clearTimeout(id?: number): void;
declare function createImageBitmap(image: ImageBitmapSource, options?: ImageBitmapOptions): Promise<ImageBitmap>;
declare function createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
-declare function fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
+declare function fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
declare function queueMicrotask(callback: VoidFunction): void;
declare function reportError(e: any): void;
declare function setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
declare function setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
+declare function structuredClone(value: any, options?: StructuredSerializeOptions): any;
declare function cancelAnimationFrame(handle: number): void;
declare function requestAnimationFrame(callback: FrameRequestCallback): number;
declare function addEventListener<K extends keyof DedicatedWorkerGlobalScopeEventMap>(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
@@ -5827,6 +5908,7 @@ type PermissionState = "denied" | "granted" | "prompt";
type PredefinedColorSpace = "display-p3" | "srgb";
type PremultiplyAlpha = "default" | "none" | "premultiply";
type PushEncryptionKeyName = "auth" | "p256dh";
+type RTCEncodedVideoFrameType = "delta" | "empty" | "key";
type ReferrerPolicy = "" | "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
type RequestCache = "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload";
type RequestCredentials = "include" | "omit" | "same-origin";
@@ -5839,6 +5921,9 @@ type SecurityPolicyViolationEventDisposition = "enforce" | "report";
type ServiceWorkerState = "activated" | "activating" | "installed" | "installing" | "parsed" | "redundant";
type ServiceWorkerUpdateViaCache = "all" | "imports" | "none";
type TransferFunction = "hlg" | "pq" | "srgb";
+type VideoColorPrimaries = "bt470bg" | "bt709" | "smpte170m";
+type VideoMatrixCoefficients = "bt470bg" | "bt709" | "rgb" | "smpte170m";
+type VideoTransferCharacteristics = "bt709" | "iec61966-2-1" | "smpte170m";
type WebGLPowerPreference = "default" | "high-performance" | "low-power";
type WorkerType = "classic" | "module";
type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text";
diff --git a/cli/dts/lib.webworker.iterable.d.ts b/cli/dts/lib.webworker.iterable.d.ts
index 9f39fc026..af2588150 100644
--- a/cli/dts/lib.webworker.iterable.d.ts
+++ b/cli/dts/lib.webworker.iterable.d.ts
@@ -78,10 +78,10 @@ interface MessageEvent<T = any> {
interface SubtleCrypto {
deriveKey(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params, extractable: boolean, keyUsages: Iterable<KeyUsage>): Promise<CryptoKey>;
- generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKeyPair>;
- generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
+ generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKeyPair>;
+ generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>;
generateKey(algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: Iterable<KeyUsage>): Promise<CryptoKeyPair | CryptoKey>;
- importKey(format: "jwk", keyData: JsonWebKey, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
+ importKey(format: "jwk", keyData: JsonWebKey, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>;
importKey(format: Exclude<KeyFormat, "jwk">, keyData: BufferSource, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: Iterable<KeyUsage>): Promise<CryptoKey>;
unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, unwrappedKeyAlgorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: Iterable<KeyUsage>): Promise<CryptoKey>;
}
diff --git a/cli/dts/typescript.d.ts b/cli/dts/typescript.d.ts
index 0c1763205..fb0a5a0c1 100644
--- a/cli/dts/typescript.d.ts
+++ b/cli/dts/typescript.d.ts
@@ -14,7 +14,7 @@ and limitations under the License.
***************************************************************************** */
declare namespace ts {
- const versionMajorMinor = "4.6";
+ const versionMajorMinor = "4.7";
/** The version of the TypeScript compiler release */
const version: string;
/**
@@ -249,216 +249,219 @@ declare namespace ts {
ModuleKeyword = 141,
NamespaceKeyword = 142,
NeverKeyword = 143,
- ReadonlyKeyword = 144,
- RequireKeyword = 145,
- NumberKeyword = 146,
- ObjectKeyword = 147,
- SetKeyword = 148,
- StringKeyword = 149,
- SymbolKeyword = 150,
- TypeKeyword = 151,
- UndefinedKeyword = 152,
- UniqueKeyword = 153,
- UnknownKeyword = 154,
- FromKeyword = 155,
- GlobalKeyword = 156,
- BigIntKeyword = 157,
- OverrideKeyword = 158,
- OfKeyword = 159,
- QualifiedName = 160,
- ComputedPropertyName = 161,
- TypeParameter = 162,
- Parameter = 163,
- Decorator = 164,
- PropertySignature = 165,
- PropertyDeclaration = 166,
- MethodSignature = 167,
- MethodDeclaration = 168,
- ClassStaticBlockDeclaration = 169,
- Constructor = 170,
- GetAccessor = 171,
- SetAccessor = 172,
- CallSignature = 173,
- ConstructSignature = 174,
- IndexSignature = 175,
- TypePredicate = 176,
- TypeReference = 177,
- FunctionType = 178,
- ConstructorType = 179,
- TypeQuery = 180,
- TypeLiteral = 181,
- ArrayType = 182,
- TupleType = 183,
- OptionalType = 184,
- RestType = 185,
- UnionType = 186,
- IntersectionType = 187,
- ConditionalType = 188,
- InferType = 189,
- ParenthesizedType = 190,
- ThisType = 191,
- TypeOperator = 192,
- IndexedAccessType = 193,
- MappedType = 194,
- LiteralType = 195,
- NamedTupleMember = 196,
- TemplateLiteralType = 197,
- TemplateLiteralTypeSpan = 198,
- ImportType = 199,
- ObjectBindingPattern = 200,
- ArrayBindingPattern = 201,
- BindingElement = 202,
- ArrayLiteralExpression = 203,
- ObjectLiteralExpression = 204,
- PropertyAccessExpression = 205,
- ElementAccessExpression = 206,
- CallExpression = 207,
- NewExpression = 208,
- TaggedTemplateExpression = 209,
- TypeAssertionExpression = 210,
- ParenthesizedExpression = 211,
- FunctionExpression = 212,
- ArrowFunction = 213,
- DeleteExpression = 214,
- TypeOfExpression = 215,
- VoidExpression = 216,
- AwaitExpression = 217,
- PrefixUnaryExpression = 218,
- PostfixUnaryExpression = 219,
- BinaryExpression = 220,
- ConditionalExpression = 221,
- TemplateExpression = 222,
- YieldExpression = 223,
- SpreadElement = 224,
- ClassExpression = 225,
- OmittedExpression = 226,
- ExpressionWithTypeArguments = 227,
- AsExpression = 228,
- NonNullExpression = 229,
- MetaProperty = 230,
- SyntheticExpression = 231,
- TemplateSpan = 232,
- SemicolonClassElement = 233,
- Block = 234,
- EmptyStatement = 235,
- VariableStatement = 236,
- ExpressionStatement = 237,
- IfStatement = 238,
- DoStatement = 239,
- WhileStatement = 240,
- ForStatement = 241,
- ForInStatement = 242,
- ForOfStatement = 243,
- ContinueStatement = 244,
- BreakStatement = 245,
- ReturnStatement = 246,
- WithStatement = 247,
- SwitchStatement = 248,
- LabeledStatement = 249,
- ThrowStatement = 250,
- TryStatement = 251,
- DebuggerStatement = 252,
- VariableDeclaration = 253,
- VariableDeclarationList = 254,
- FunctionDeclaration = 255,
- ClassDeclaration = 256,
- InterfaceDeclaration = 257,
- TypeAliasDeclaration = 258,
- EnumDeclaration = 259,
- ModuleDeclaration = 260,
- ModuleBlock = 261,
- CaseBlock = 262,
- NamespaceExportDeclaration = 263,
- ImportEqualsDeclaration = 264,
- ImportDeclaration = 265,
- ImportClause = 266,
- NamespaceImport = 267,
- NamedImports = 268,
- ImportSpecifier = 269,
- ExportAssignment = 270,
- ExportDeclaration = 271,
- NamedExports = 272,
- NamespaceExport = 273,
- ExportSpecifier = 274,
- MissingDeclaration = 275,
- ExternalModuleReference = 276,
- JsxElement = 277,
- JsxSelfClosingElement = 278,
- JsxOpeningElement = 279,
- JsxClosingElement = 280,
- JsxFragment = 281,
- JsxOpeningFragment = 282,
- JsxClosingFragment = 283,
- JsxAttribute = 284,
- JsxAttributes = 285,
- JsxSpreadAttribute = 286,
- JsxExpression = 287,
- CaseClause = 288,
- DefaultClause = 289,
- HeritageClause = 290,
- CatchClause = 291,
- AssertClause = 292,
- AssertEntry = 293,
- PropertyAssignment = 294,
- ShorthandPropertyAssignment = 295,
- SpreadAssignment = 296,
- EnumMember = 297,
- UnparsedPrologue = 298,
- UnparsedPrepend = 299,
- UnparsedText = 300,
- UnparsedInternalText = 301,
- UnparsedSyntheticReference = 302,
- SourceFile = 303,
- Bundle = 304,
- UnparsedSource = 305,
- InputFiles = 306,
- JSDocTypeExpression = 307,
- JSDocNameReference = 308,
- JSDocMemberName = 309,
- JSDocAllType = 310,
- JSDocUnknownType = 311,
- JSDocNullableType = 312,
- JSDocNonNullableType = 313,
- JSDocOptionalType = 314,
- JSDocFunctionType = 315,
- JSDocVariadicType = 316,
- JSDocNamepathType = 317,
- JSDocComment = 318,
- JSDocText = 319,
- JSDocTypeLiteral = 320,
- JSDocSignature = 321,
- JSDocLink = 322,
- JSDocLinkCode = 323,
- JSDocLinkPlain = 324,
- JSDocTag = 325,
- JSDocAugmentsTag = 326,
- JSDocImplementsTag = 327,
- JSDocAuthorTag = 328,
- JSDocDeprecatedTag = 329,
- JSDocClassTag = 330,
- JSDocPublicTag = 331,
- JSDocPrivateTag = 332,
- JSDocProtectedTag = 333,
- JSDocReadonlyTag = 334,
- JSDocOverrideTag = 335,
- JSDocCallbackTag = 336,
- JSDocEnumTag = 337,
- JSDocParameterTag = 338,
- JSDocReturnTag = 339,
- JSDocThisTag = 340,
- JSDocTypeTag = 341,
- JSDocTemplateTag = 342,
- JSDocTypedefTag = 343,
- JSDocSeeTag = 344,
- JSDocPropertyTag = 345,
- SyntaxList = 346,
- NotEmittedStatement = 347,
- PartiallyEmittedExpression = 348,
- CommaListExpression = 349,
- MergeDeclarationMarker = 350,
- EndOfDeclarationMarker = 351,
- SyntheticReferenceExpression = 352,
- Count = 353,
+ OutKeyword = 144,
+ ReadonlyKeyword = 145,
+ RequireKeyword = 146,
+ NumberKeyword = 147,
+ ObjectKeyword = 148,
+ SetKeyword = 149,
+ StringKeyword = 150,
+ SymbolKeyword = 151,
+ TypeKeyword = 152,
+ UndefinedKeyword = 153,
+ UniqueKeyword = 154,
+ UnknownKeyword = 155,
+ FromKeyword = 156,
+ GlobalKeyword = 157,
+ BigIntKeyword = 158,
+ OverrideKeyword = 159,
+ OfKeyword = 160,
+ QualifiedName = 161,
+ ComputedPropertyName = 162,
+ TypeParameter = 163,
+ Parameter = 164,
+ Decorator = 165,
+ PropertySignature = 166,
+ PropertyDeclaration = 167,
+ MethodSignature = 168,
+ MethodDeclaration = 169,
+ ClassStaticBlockDeclaration = 170,
+ Constructor = 171,
+ GetAccessor = 172,
+ SetAccessor = 173,
+ CallSignature = 174,
+ ConstructSignature = 175,
+ IndexSignature = 176,
+ TypePredicate = 177,
+ TypeReference = 178,
+ FunctionType = 179,
+ ConstructorType = 180,
+ TypeQuery = 181,
+ TypeLiteral = 182,
+ ArrayType = 183,
+ TupleType = 184,
+ OptionalType = 185,
+ RestType = 186,
+ UnionType = 187,
+ IntersectionType = 188,
+ ConditionalType = 189,
+ InferType = 190,
+ ParenthesizedType = 191,
+ ThisType = 192,
+ TypeOperator = 193,
+ IndexedAccessType = 194,
+ MappedType = 195,
+ LiteralType = 196,
+ NamedTupleMember = 197,
+ TemplateLiteralType = 198,
+ TemplateLiteralTypeSpan = 199,
+ ImportType = 200,
+ ObjectBindingPattern = 201,
+ ArrayBindingPattern = 202,
+ BindingElement = 203,
+ ArrayLiteralExpression = 204,
+ ObjectLiteralExpression = 205,
+ PropertyAccessExpression = 206,
+ ElementAccessExpression = 207,
+ CallExpression = 208,
+ NewExpression = 209,
+ TaggedTemplateExpression = 210,
+ TypeAssertionExpression = 211,
+ ParenthesizedExpression = 212,
+ FunctionExpression = 213,
+ ArrowFunction = 214,
+ DeleteExpression = 215,
+ TypeOfExpression = 216,
+ VoidExpression = 217,
+ AwaitExpression = 218,
+ PrefixUnaryExpression = 219,
+ PostfixUnaryExpression = 220,
+ BinaryExpression = 221,
+ ConditionalExpression = 222,
+ TemplateExpression = 223,
+ YieldExpression = 224,
+ SpreadElement = 225,
+ ClassExpression = 226,
+ OmittedExpression = 227,
+ ExpressionWithTypeArguments = 228,
+ AsExpression = 229,
+ NonNullExpression = 230,
+ MetaProperty = 231,
+ SyntheticExpression = 232,
+ TemplateSpan = 233,
+ SemicolonClassElement = 234,
+ Block = 235,
+ EmptyStatement = 236,
+ VariableStatement = 237,
+ ExpressionStatement = 238,
+ IfStatement = 239,
+ DoStatement = 240,
+ WhileStatement = 241,
+ ForStatement = 242,
+ ForInStatement = 243,
+ ForOfStatement = 244,
+ ContinueStatement = 245,
+ BreakStatement = 246,
+ ReturnStatement = 247,
+ WithStatement = 248,
+ SwitchStatement = 249,
+ LabeledStatement = 250,
+ ThrowStatement = 251,
+ TryStatement = 252,
+ DebuggerStatement = 253,
+ VariableDeclaration = 254,
+ VariableDeclarationList = 255,
+ FunctionDeclaration = 256,
+ ClassDeclaration = 257,
+ InterfaceDeclaration = 258,
+ TypeAliasDeclaration = 259,
+ EnumDeclaration = 260,
+ ModuleDeclaration = 261,
+ ModuleBlock = 262,
+ CaseBlock = 263,
+ NamespaceExportDeclaration = 264,
+ ImportEqualsDeclaration = 265,
+ ImportDeclaration = 266,
+ ImportClause = 267,
+ NamespaceImport = 268,
+ NamedImports = 269,
+ ImportSpecifier = 270,
+ ExportAssignment = 271,
+ ExportDeclaration = 272,
+ NamedExports = 273,
+ NamespaceExport = 274,
+ ExportSpecifier = 275,
+ MissingDeclaration = 276,
+ ExternalModuleReference = 277,
+ JsxElement = 278,
+ JsxSelfClosingElement = 279,
+ JsxOpeningElement = 280,
+ JsxClosingElement = 281,
+ JsxFragment = 282,
+ JsxOpeningFragment = 283,
+ JsxClosingFragment = 284,
+ JsxAttribute = 285,
+ JsxAttributes = 286,
+ JsxSpreadAttribute = 287,
+ JsxExpression = 288,
+ CaseClause = 289,
+ DefaultClause = 290,
+ HeritageClause = 291,
+ CatchClause = 292,
+ AssertClause = 293,
+ AssertEntry = 294,
+ ImportTypeAssertionContainer = 295,
+ PropertyAssignment = 296,
+ ShorthandPropertyAssignment = 297,
+ SpreadAssignment = 298,
+ EnumMember = 299,
+ UnparsedPrologue = 300,
+ UnparsedPrepend = 301,
+ UnparsedText = 302,
+ UnparsedInternalText = 303,
+ UnparsedSyntheticReference = 304,
+ SourceFile = 305,
+ Bundle = 306,
+ UnparsedSource = 307,
+ InputFiles = 308,
+ JSDocTypeExpression = 309,
+ JSDocNameReference = 310,
+ JSDocMemberName = 311,
+ JSDocAllType = 312,
+ JSDocUnknownType = 313,
+ JSDocNullableType = 314,
+ JSDocNonNullableType = 315,
+ JSDocOptionalType = 316,
+ JSDocFunctionType = 317,
+ JSDocVariadicType = 318,
+ JSDocNamepathType = 319,
+ /** @deprecated Use SyntaxKind.JSDoc */
+ JSDocComment = 320,
+ JSDocText = 321,
+ JSDocTypeLiteral = 322,
+ JSDocSignature = 323,
+ JSDocLink = 324,
+ JSDocLinkCode = 325,
+ JSDocLinkPlain = 326,
+ JSDocTag = 327,
+ JSDocAugmentsTag = 328,
+ JSDocImplementsTag = 329,
+ JSDocAuthorTag = 330,
+ JSDocDeprecatedTag = 331,
+ JSDocClassTag = 332,
+ JSDocPublicTag = 333,
+ JSDocPrivateTag = 334,
+ JSDocProtectedTag = 335,
+ JSDocReadonlyTag = 336,
+ JSDocOverrideTag = 337,
+ JSDocCallbackTag = 338,
+ JSDocEnumTag = 339,
+ JSDocParameterTag = 340,
+ JSDocReturnTag = 341,
+ JSDocThisTag = 342,
+ JSDocTypeTag = 343,
+ JSDocTemplateTag = 344,
+ JSDocTypedefTag = 345,
+ JSDocSeeTag = 346,
+ JSDocPropertyTag = 347,
+ SyntaxList = 348,
+ NotEmittedStatement = 349,
+ PartiallyEmittedExpression = 350,
+ CommaListExpression = 351,
+ MergeDeclarationMarker = 352,
+ EndOfDeclarationMarker = 353,
+ SyntheticReferenceExpression = 354,
+ Count = 355,
FirstAssignment = 63,
LastAssignment = 78,
FirstCompoundAssignment = 64,
@@ -466,15 +469,15 @@ declare namespace ts {
FirstReservedWord = 81,
LastReservedWord = 116,
FirstKeyword = 81,
- LastKeyword = 159,
+ LastKeyword = 160,
FirstFutureReservedWord = 117,
LastFutureReservedWord = 125,
- FirstTypeNode = 176,
- LastTypeNode = 199,
+ FirstTypeNode = 177,
+ LastTypeNode = 200,
FirstPunctuation = 18,
LastPunctuation = 78,
FirstToken = 0,
- LastToken = 159,
+ LastToken = 160,
FirstTriviaToken = 2,
LastTriviaToken = 7,
FirstLiteralToken = 8,
@@ -483,20 +486,21 @@ declare namespace ts {
LastTemplateToken = 17,
FirstBinaryOperator = 29,
LastBinaryOperator = 78,
- FirstStatement = 236,
- LastStatement = 252,
- FirstNode = 160,
- FirstJSDocNode = 307,
- LastJSDocNode = 345,
- FirstJSDocTagNode = 325,
- LastJSDocTagNode = 345,
+ FirstStatement = 237,
+ LastStatement = 253,
+ FirstNode = 161,
+ FirstJSDocNode = 309,
+ LastJSDocNode = 347,
+ FirstJSDocTagNode = 327,
+ LastJSDocTagNode = 347,
+ JSDoc = 320
}
export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia;
export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral;
export type PseudoLiteralSyntaxKind = SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail;
export type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken;
- export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword;
- export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword;
+ export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword;
+ export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.InKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword;
export type KeywordTypeSyntaxKind = SyntaxKind.AnyKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VoidKeyword;
export type TokenSyntaxKind = SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | TriviaSyntaxKind | LiteralSyntaxKind | PseudoLiteralSyntaxKind | PunctuationSyntaxKind | SyntaxKind.Identifier | KeywordSyntaxKind;
export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken;
@@ -519,16 +523,17 @@ declare namespace ts {
YieldContext = 8192,
DecoratorContext = 16384,
AwaitContext = 32768,
- ThisNodeHasError = 65536,
- JavaScriptFile = 131072,
- ThisNodeOrAnySubNodesHasError = 262144,
- HasAggregatedChildData = 524288,
- JSDoc = 4194304,
- JsonFile = 33554432,
+ DisallowConditionalTypesContext = 65536,
+ ThisNodeHasError = 131072,
+ JavaScriptFile = 262144,
+ ThisNodeOrAnySubNodesHasError = 524288,
+ HasAggregatedChildData = 1048576,
+ JSDoc = 8388608,
+ JsonFile = 67108864,
BlockScoped = 3,
ReachabilityCheckFlags = 768,
ReachabilityAndEmitFlags = 2816,
- ContextFlags = 25358336,
+ ContextFlags = 50720768,
TypeExcludesFlags = 40960,
}
export enum ModifierFlags {
@@ -547,13 +552,15 @@ declare namespace ts {
HasComputedJSDocModifiers = 4096,
Deprecated = 8192,
Override = 16384,
+ In = 32768,
+ Out = 65536,
HasComputedFlags = 536870912,
AccessibilityModifier = 28,
ParameterPropertyModifier = 16476,
NonPublicAccessibilityModifier = 24,
- TypeScriptModifier = 18654,
+ TypeScriptModifier = 116958,
ExportDefault = 513,
- All = 27647
+ All = 125951
}
export enum JsxFlags {
None = 0,
@@ -572,7 +579,7 @@ declare namespace ts {
}
export interface JSDocContainer {
}
- export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ClassStaticBlockDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | EmptyStatement | DebuggerStatement | Block | VariableStatement | ExpressionStatement | IfStatement | DoStatement | WhileStatement | ForStatement | ForInStatement | ForOfStatement | BreakStatement | ContinueStatement | ReturnStatement | WithStatement | SwitchStatement | LabeledStatement | ThrowStatement | TryStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | VariableDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | ImportDeclaration | NamespaceExportDeclaration | ExportAssignment | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | NamedTupleMember | ExportSpecifier | EndOfFileToken;
+ export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ClassStaticBlockDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | EmptyStatement | DebuggerStatement | Block | VariableStatement | ExpressionStatement | IfStatement | DoStatement | WhileStatement | ForStatement | ForInStatement | ForOfStatement | BreakStatement | ContinueStatement | ReturnStatement | WithStatement | SwitchStatement | LabeledStatement | ThrowStatement | TryStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | VariableDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | ImportDeclaration | NamespaceExportDeclaration | ExportAssignment | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | NamedTupleMember | ExportSpecifier | CaseClause | EndOfFileToken;
export type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType;
export type HasTypeArguments = CallExpression | NewExpression | TaggedTemplateExpression | JsxOpeningElement | JsxSelfClosingElement;
export type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute;
@@ -614,15 +621,17 @@ declare namespace ts {
export type DeclareKeyword = ModifierToken<SyntaxKind.DeclareKeyword>;
export type DefaultKeyword = ModifierToken<SyntaxKind.DefaultKeyword>;
export type ExportKeyword = ModifierToken<SyntaxKind.ExportKeyword>;
+ export type InKeyword = ModifierToken<SyntaxKind.InKeyword>;
export type PrivateKeyword = ModifierToken<SyntaxKind.PrivateKeyword>;
export type ProtectedKeyword = ModifierToken<SyntaxKind.ProtectedKeyword>;
export type PublicKeyword = ModifierToken<SyntaxKind.PublicKeyword>;
export type ReadonlyKeyword = ModifierToken<SyntaxKind.ReadonlyKeyword>;
+ export type OutKeyword = ModifierToken<SyntaxKind.OutKeyword>;
export type OverrideKeyword = ModifierToken<SyntaxKind.OverrideKeyword>;
export type StaticKeyword = ModifierToken<SyntaxKind.StaticKeyword>;
/** @deprecated Use `ReadonlyKeyword` instead. */
export type ReadonlyToken = ReadonlyKeyword;
- export type Modifier = AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword;
+ export type Modifier = AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | InKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OutKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword;
export type AccessibilityModifier = PublicKeyword | PrivateKeyword | ProtectedKeyword;
export type ParameterPropertyModifier = AccessibilityModifier | ReadonlyKeyword;
export type ClassMemberModifier = AccessibilityModifier | ReadonlyKeyword | StaticKeyword;
@@ -866,10 +875,17 @@ declare namespace ts {
export interface KeywordTypeNode<TKind extends KeywordTypeSyntaxKind = KeywordTypeSyntaxKind> extends KeywordToken<TKind>, TypeNode {
readonly kind: TKind;
}
+ export interface ImportTypeAssertionContainer extends Node {
+ readonly kind: SyntaxKind.ImportTypeAssertionContainer;
+ readonly parent: ImportTypeNode;
+ readonly assertClause: AssertClause;
+ readonly multiLine?: boolean;
+ }
export interface ImportTypeNode extends NodeWithTypeArguments {
readonly kind: SyntaxKind.ImportType;
readonly isTypeOf: boolean;
readonly argument: TypeNode;
+ readonly assertions?: ImportTypeAssertionContainer;
readonly qualifier?: EntityName;
}
export interface ThisTypeNode extends TypeNode {
@@ -901,7 +917,7 @@ declare namespace ts {
readonly parameterName: Identifier | ThisTypeNode;
readonly type?: TypeNode;
}
- export interface TypeQueryNode extends TypeNode {
+ export interface TypeQueryNode extends NodeWithTypeArguments {
readonly kind: SyntaxKind.TypeQuery;
readonly exprName: EntityName;
}
@@ -1285,9 +1301,8 @@ declare namespace ts {
export interface ImportCall extends CallExpression {
readonly expression: ImportExpression;
}
- export interface ExpressionWithTypeArguments extends NodeWithTypeArguments {
+ export interface ExpressionWithTypeArguments extends MemberExpression, NodeWithTypeArguments {
readonly kind: SyntaxKind.ExpressionWithTypeArguments;
- readonly parent: HeritageClause | JSDocAugmentsTag | JSDocImplementsTag;
readonly expression: LeftHandSideExpression;
}
export interface NewExpression extends PrimaryExpression, Declaration {
@@ -1498,7 +1513,7 @@ declare namespace ts {
readonly parent: SwitchStatement;
readonly clauses: NodeArray<CaseOrDefaultClause>;
}
- export interface CaseClause extends Node {
+ export interface CaseClause extends Node, JSDocContainer {
readonly kind: SyntaxKind.CaseClause;
readonly parent: CaseBlock;
readonly expression: Expression;
@@ -1749,6 +1764,7 @@ declare namespace ts {
}
export interface FileReference extends TextRange {
fileName: string;
+ resolutionMode?: SourceFile["impliedNodeFormat"];
}
export interface CheckJsDirective extends TextRange {
enabled: boolean;
@@ -1790,10 +1806,12 @@ declare namespace ts {
export interface JSDocNonNullableType extends JSDocType {
readonly kind: SyntaxKind.JSDocNonNullableType;
readonly type: TypeNode;
+ readonly postfix: boolean;
}
export interface JSDocNullableType extends JSDocType {
readonly kind: SyntaxKind.JSDocNullableType;
readonly type: TypeNode;
+ readonly postfix: boolean;
}
export interface JSDocOptionalType extends JSDocType {
readonly kind: SyntaxKind.JSDocOptionalType;
@@ -1812,7 +1830,7 @@ declare namespace ts {
}
export type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType;
export interface JSDoc extends Node {
- readonly kind: SyntaxKind.JSDocComment;
+ readonly kind: SyntaxKind.JSDoc;
readonly parent: HasJSDoc;
readonly tags?: NodeArray<JSDocTag>;
readonly comment?: string | NodeArray<JSDocComment>;
@@ -1968,7 +1986,7 @@ declare namespace ts {
Label = 12,
Condition = 96
}
- export type FlowNode = FlowStart | FlowLabel | FlowAssignment | FlowCall | FlowCondition | FlowSwitchClause | FlowArrayMutation | FlowCall | FlowReduceLabel;
+ export type FlowNode = FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation | FlowCall | FlowReduceLabel;
export interface FlowNodeBase {
flags: FlowFlags;
id?: number;
@@ -2015,6 +2033,12 @@ declare namespace ts {
path: string;
name?: string;
}
+ /**
+ * Subset of properties from SourceFile that are used in multiple utility functions
+ */
+ export interface SourceFileLike {
+ readonly text: string;
+ }
export interface SourceFile extends Declaration {
readonly kind: SyntaxKind.SourceFile;
readonly statements: NodeArray<Statement>;
@@ -2039,7 +2063,7 @@ declare namespace ts {
hasNoDefaultLib: boolean;
languageVersion: ScriptTarget;
/**
- * When `module` is `Node12` or `NodeNext`, this field controls whether the
+ * When `module` is `Node16` or `NodeNext`, this field controls whether the
* source file in question is an ESNext-output-format file, or a CommonJS-output-format
* module. This is derived by the module resolver as it looks up the file, since
* it is derived from either the file extension of the module, or the containing
@@ -2074,7 +2098,7 @@ declare namespace ts {
readonly prologues: readonly UnparsedPrologue[];
helpers: readonly UnscopedEmitHelper[] | undefined;
referencedFiles: readonly FileReference[];
- typeReferenceDirectives: readonly string[] | undefined;
+ typeReferenceDirectives: readonly FileReference[] | undefined;
libReferenceDirectives: readonly FileReference[];
hasNoDefaultLib?: boolean;
sourceMapPath?: string;
@@ -2148,7 +2172,9 @@ declare namespace ts {
export type ResolvedConfigFileName = string & {
_isResolvedConfigFileName: never;
};
- export type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[]) => void;
+ export interface WriteFileCallbackData {
+ }
+ export type WriteFileCallback = (fileName: string, text: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[], data?: WriteFileCallbackData) => void;
export class OperationCanceledException {
}
export interface CancellationToken {
@@ -2370,7 +2396,6 @@ declare namespace ts {
UseAliasDefinedOutsideCurrentScope = 16384,
UseSingleQuotesForStringLiteralType = 268435456,
NoTypeReduction = 536870912,
- NoUndefinedOptionalParameterType = 1073741824,
AllowThisInObjectLiteral = 32768,
AllowQualifiedNameInPlaceOfIdentifier = 65536,
/** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */
@@ -2654,13 +2679,13 @@ declare namespace ts {
ObjectLiteralPatternWithComputedProperties = 512,
ReverseMapped = 1024,
JsxAttributes = 2048,
- MarkerType = 4096,
- JSLiteral = 8192,
- FreshLiteral = 16384,
- ArrayLiteral = 32768,
+ JSLiteral = 4096,
+ FreshLiteral = 8192,
+ ArrayLiteral = 16384,
ClassOrInterface = 3,
- ContainsSpread = 4194304,
- ObjectRestType = 8388608,
+ ContainsSpread = 2097152,
+ ObjectRestType = 4194304,
+ InstantiationExpressionType = 8388608,
}
export interface ObjectType extends Type {
objectFlags: ObjectFlags;
@@ -2868,9 +2893,23 @@ declare namespace ts {
export enum ModuleResolutionKind {
Classic = 1,
NodeJs = 2,
- Node12 = 3,
+ Node16 = 3,
NodeNext = 99
}
+ export enum ModuleDetectionKind {
+ /**
+ * Files with imports, exports and/or import.meta are considered modules
+ */
+ Legacy = 1,
+ /**
+ * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node16+
+ */
+ Auto = 2,
+ /**
+ * Consider all non-declaration files modules, regardless of present syntax
+ */
+ Force = 3
+ }
export interface PluginImport {
name: string;
}
@@ -2942,6 +2981,8 @@ declare namespace ts {
maxNodeModuleJsDepth?: number;
module?: ModuleKind;
moduleResolution?: ModuleResolutionKind;
+ moduleSuffixes?: string[];
+ moduleDetection?: ModuleDetectionKind;
newLine?: NewLineKind;
noEmit?: boolean;
noEmitHelpers?: boolean;
@@ -3033,7 +3074,7 @@ declare namespace ts {
ES2020 = 6,
ES2022 = 7,
ESNext = 99,
- Node12 = 100,
+ Node16 = 100,
NodeNext = 199
}
export enum JsxEmit {
@@ -3127,7 +3168,14 @@ declare namespace ts {
realpath?(path: string): string;
getCurrentDirectory?(): string;
getDirectories?(path: string): string[];
- useCaseSensitiveFileNames?: boolean | (() => boolean);
+ useCaseSensitiveFileNames?: boolean | (() => boolean) | undefined;
+ }
+ /**
+ * Used by services to specify the minimum host area required to set up source files under any compilation settings
+ */
+ export interface MinimalResolutionCacheHost extends ModuleResolutionHost {
+ getCompilationSettings(): CompilerOptions;
+ getCompilerHost?(): CompilerHost | undefined;
}
/**
* Represents the result of module resolution.
@@ -3204,8 +3252,8 @@ declare namespace ts {
readonly failedLookupLocations: string[];
}
export interface CompilerHost extends ModuleResolutionHost {
- getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined;
- getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined;
+ getSourceFile(fileName: string, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined;
+ getSourceFileByPath?(fileName: string, path: Path, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined;
getCancellationToken?(): CancellationToken;
getDefaultLibFileName(options: CompilerOptions): string;
getDefaultLibLocation?(): string;
@@ -3223,7 +3271,7 @@ declare namespace ts {
/**
* This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files
*/
- resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[];
+ resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[];
getEnvironmentVariable?(name: string): string | undefined;
createHash?(data: string): string;
getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined;
@@ -3353,7 +3401,11 @@ declare namespace ts {
updateQualifiedName(node: QualifiedName, left: EntityName, right: Identifier): QualifiedName;
createComputedPropertyName(expression: Expression): ComputedPropertyName;
updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName;
+ createTypeParameterDeclaration(modifiers: readonly Modifier[] | undefined, name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration;
+ /** @deprecated */
createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration;
+ updateTypeParameterDeclaration(node: TypeParameterDeclaration, modifiers: readonly Modifier[] | undefined, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
+ /** @deprecated */
updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
createParameterDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration;
updateParameterDeclaration(node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration;
@@ -3396,8 +3448,8 @@ declare namespace ts {
updateConstructorTypeNode(node: ConstructorTypeNode, modifiers: readonly Modifier[] | undefined, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode): ConstructorTypeNode;
/** @deprecated */
updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode): ConstructorTypeNode;
- createTypeQueryNode(exprName: EntityName): TypeQueryNode;
- updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode;
+ createTypeQueryNode(exprName: EntityName, typeArguments?: readonly TypeNode[]): TypeQueryNode;
+ updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName, typeArguments?: readonly TypeNode[]): TypeQueryNode;
createTypeLiteralNode(members: readonly TypeElement[] | undefined): TypeLiteralNode;
updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray<TypeElement>): TypeLiteralNode;
createArrayTypeNode(elementType: TypeNode): ArrayTypeNode;
@@ -3419,7 +3471,9 @@ declare namespace ts {
createInferTypeNode(typeParameter: TypeParameterDeclaration): InferTypeNode;
updateInferTypeNode(node: InferTypeNode, typeParameter: TypeParameterDeclaration): InferTypeNode;
createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode;
+ createImportTypeNode(argument: TypeNode, assertions?: ImportTypeAssertionContainer, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode;
updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean): ImportTypeNode;
+ updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, assertions: ImportTypeAssertionContainer | undefined, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean): ImportTypeNode;
createParenthesizedType(type: TypeNode): ParenthesizedTypeNode;
updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode;
createThisTypeNode(): ThisTypeNode;
@@ -3582,6 +3636,8 @@ declare namespace ts {
updateAssertClause(node: AssertClause, elements: NodeArray<AssertEntry>, multiLine?: boolean): AssertClause;
createAssertEntry(name: AssertionKey, value: Expression): AssertEntry;
updateAssertEntry(node: AssertEntry, name: AssertionKey, value: Expression): AssertEntry;
+ createImportTypeAssertionContainer(clause: AssertClause, multiLine?: boolean): ImportTypeAssertionContainer;
+ updateImportTypeAssertionContainer(node: ImportTypeAssertionContainer, clause: AssertClause, multiLine?: boolean): ImportTypeAssertionContainer;
createNamespaceImport(name: Identifier): NamespaceImport;
updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport;
createNamespaceExport(name: Identifier): NamespaceExport;
@@ -3602,9 +3658,9 @@ declare namespace ts {
updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference;
createJSDocAllType(): JSDocAllType;
createJSDocUnknownType(): JSDocUnknownType;
- createJSDocNonNullableType(type: TypeNode): JSDocNonNullableType;
+ createJSDocNonNullableType(type: TypeNode, postfix?: boolean): JSDocNonNullableType;
updateJSDocNonNullableType(node: JSDocNonNullableType, type: TypeNode): JSDocNonNullableType;
- createJSDocNullableType(type: TypeNode): JSDocNullableType;
+ createJSDocNullableType(type: TypeNode, postfix?: boolean): JSDocNullableType;
updateJSDocNullableType(node: JSDocNullableType, type: TypeNode): JSDocNullableType;
createJSDocOptionalType(type: TypeNode): JSDocOptionalType;
updateJSDocOptionalType(node: JSDocOptionalType, type: TypeNode): JSDocOptionalType;
@@ -4048,6 +4104,8 @@ declare namespace ts {
readonly includeAutomaticOptionalChainCompletions?: boolean;
readonly includeCompletionsWithInsertText?: boolean;
readonly includeCompletionsWithClassMemberSnippets?: boolean;
+ readonly includeCompletionsWithObjectLiteralMethodSnippets?: boolean;
+ readonly useLabelDetailsInCompletionEntries?: boolean;
readonly allowIncompleteCompletions?: boolean;
readonly importModuleSpecifierPreference?: "shortest" | "project-relative" | "relative" | "non-relative";
/** Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" */
@@ -4057,6 +4115,13 @@ declare namespace ts {
readonly includePackageJsonAutoImports?: "auto" | "on" | "off";
readonly provideRefactorNotApplicableReason?: boolean;
readonly jsxAttributeCompletionStyle?: "auto" | "braces" | "none";
+ readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
+ readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
+ readonly includeInlayFunctionParameterTypeHints?: boolean;
+ readonly includeInlayVariableTypeHints?: boolean;
+ readonly includeInlayPropertyDeclarationTypeHints?: boolean;
+ readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
+ readonly includeInlayEnumMemberValueHints?: boolean;
}
/** Represents a bigint literal value without requiring bigint support */
export interface PseudoBigInt {
@@ -4748,7 +4813,22 @@ declare namespace ts {
* that they appear in the source code. The language service depends on this property to locate nodes by position.
*/
export function forEachChild<T>(node: Node, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray<Node>) => T | undefined): T | undefined;
- export function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile;
+ export interface CreateSourceFileOptions {
+ languageVersion: ScriptTarget;
+ /**
+ * Controls the format the file is detected as - this can be derived from only the path
+ * and files on disk, but needs to be done with a module resolution cache in scope to be performant.
+ * This is usually `undefined` for compilations that do not have `moduleResolution` values of `node16` or `nodenext`.
+ */
+ impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS;
+ /**
+ * Controls how module-y-ness is set for the given file. Usually the result of calling
+ * `getSetExternalModuleIndicator` on a valid `CompilerOptions` object. If not present, the default
+ * check specified by `isFileProbablyExternalModule` will be used to set the field.
+ */
+ setExternalModuleIndicator?: (file: SourceFile) => void;
+ }
+ export function createSourceFile(fileName: string, sourceText: string, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile;
export function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName | undefined;
/**
* Parse json text into SyntaxTree and return node and parse errors if any
@@ -4855,7 +4935,7 @@ declare namespace ts {
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
* is assumed to be the same as root directory of the project.
*/
- export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference, cache?: TypeReferenceDirectiveResolutionCache): ResolvedTypeReferenceDirectiveWithFailedLookupLocations;
+ export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference, cache?: TypeReferenceDirectiveResolutionCache, resolutionMode?: SourceFile["impliedNodeFormat"]): ResolvedTypeReferenceDirectiveWithFailedLookupLocations;
/**
* Given a set of options, returns the set of type directive names
* that should be included for this program automatically.
@@ -5276,7 +5356,7 @@ declare namespace ts {
/** If provided, used to resolve the module names, otherwise typescript's default module resolution */
resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
/** If provided, used to resolve type reference directives, otherwise typescript's default resolution */
- resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[];
+ resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[];
}
interface WatchCompilerHost<T extends BuilderProgram> extends ProgramHost<T>, WatchHost {
/** Instead of using output d.ts file from project reference, use its source file */
@@ -5648,7 +5728,7 @@ declare namespace ts {
set(response: CompletionInfo): void;
clear(): void;
}
- interface LanguageServiceHost extends GetEffectiveTypeRootsHost {
+ interface LanguageServiceHost extends GetEffectiveTypeRootsHost, MinimalResolutionCacheHost {
getCompilationSettings(): CompilerOptions;
getNewLine?(): string;
getProjectVersion?(): string;
@@ -5666,13 +5746,13 @@ declare namespace ts {
error?(s: string): void;
useCaseSensitiveFileNames?(): boolean;
readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[];
- readFile?(path: string, encoding?: string): string | undefined;
realpath?(path: string): string;
- fileExists?(path: string): boolean;
+ readFile(path: string, encoding?: string): string | undefined;
+ fileExists(path: string): boolean;
getTypeRootsVersion?(): number;
resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined;
- resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[];
+ resolveTypeReferenceDirectives?(typeDirectiveNames: string[] | FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[];
getDirectories?(directoryName: string): string[];
/**
* Gets a set of custom transformers to use during emit.
@@ -5881,15 +5961,6 @@ declare namespace ts {
/** @deprecated Use includeCompletionsWithInsertText */
includeInsertTextCompletions?: boolean;
}
- interface InlayHintsOptions extends UserPreferences {
- readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
- readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
- readonly includeInlayFunctionParameterTypeHints?: boolean;
- readonly includeInlayVariableTypeHints?: boolean;
- readonly includeInlayPropertyDeclarationTypeHints?: boolean;
- readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
- readonly includeInlayEnumMemberValueHints?: boolean;
- }
type SignatureHelpTriggerCharacter = "," | "(" | "<";
type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")";
interface SignatureHelpItemsOptions {
@@ -6139,7 +6210,6 @@ declare namespace ts {
}
interface ReferenceEntry extends DocumentSpan {
isWriteAccess: boolean;
- isDefinition: boolean;
isInString?: true;
}
interface ImplementationLocation extends DocumentSpan {
@@ -6253,7 +6323,10 @@ declare namespace ts {
}
interface ReferencedSymbol {
definition: ReferencedSymbolDefinitionInfo;
- references: ReferenceEntry[];
+ references: ReferencedSymbolEntry[];
+ }
+ interface ReferencedSymbolEntry extends ReferenceEntry {
+ isDefinition?: boolean;
}
enum SymbolDisplayPartKind {
aliasName = 0,
@@ -6362,7 +6435,18 @@ declare namespace ts {
argumentIndex: number;
argumentCount: number;
}
+ enum CompletionInfoFlags {
+ None = 0,
+ MayIncludeAutoImports = 1,
+ IsImportStatementCompletion = 2,
+ IsContinuation = 4,
+ ResolvedModuleSpecifiers = 8,
+ ResolvedModuleSpecifiersBeyondLimit = 16,
+ MayIncludeMethodSnippets = 32
+ }
interface CompletionInfo {
+ /** For performance telemetry. */
+ flags?: CompletionInfoFlags;
/** Not true for all global completions. This will be true if the enclosing scope matches a few syntax kinds. See `isSnippetScope`. */
isGlobalCompletion: boolean;
isMemberCompletion: boolean;
@@ -6420,6 +6504,7 @@ declare namespace ts {
hasAction?: true;
source?: string;
sourceDisplay?: SymbolDisplayPart[];
+ labelDetails?: CompletionEntryLabelDetails;
isRecommended?: true;
isFromUncheckedFile?: true;
isPackageJsonImport?: true;
@@ -6434,6 +6519,10 @@ declare namespace ts {
*/
data?: CompletionEntryData;
}
+ interface CompletionEntryLabelDetails {
+ detail?: string;
+ description?: string;
+ }
interface CompletionEntryDetails {
name: string;
kind: ScriptElementKind;
@@ -6693,7 +6782,7 @@ declare namespace ts {
cancellationToken: CancellationToken;
host: LanguageServiceHost;
span: TextSpan;
- preferences: InlayHintsOptions;
+ preferences: UserPreferences;
}
}
declare namespace ts {
@@ -6729,30 +6818,36 @@ declare namespace ts {
* the SourceFile if was not found in the registry.
*
* @param fileName The name of the file requested
- * @param compilationSettings Some compilation settings like target affects the
+ * @param compilationSettingsOrHost Some compilation settings like target affects the
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
- * multiple copies of the same file for different compilation settings.
+ * multiple copies of the same file for different compilation settings. A minimal
+ * resolution cache is needed to fully define a source file's shape when
+ * the compilation settings include `module: node16`+, so providing a cache host
+ * object should be preferred. A common host is a language service `ConfiguredProject`.
* @param scriptSnapshot Text of the file. Only used if the file was not found
* in the registry and a new one was created.
* @param version Current version of the file. Only used if the file was not found
* in the registry and a new one was created.
*/
- acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
- acquireDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
+ acquireDocument(fileName: string, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
+ acquireDocumentWithKey(fileName: string, path: Path, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
/**
* Request an updated version of an already existing SourceFile with a given fileName
* and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile
* to get an updated SourceFile.
*
* @param fileName The name of the file requested
- * @param compilationSettings Some compilation settings like target affects the
+ * @param compilationSettingsOrHost Some compilation settings like target affects the
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
- * multiple copies of the same file for different compilation settings.
+ * multiple copies of the same file for different compilation settings. A minimal
+ * resolution cache is needed to fully define a source file's shape when
+ * the compilation settings include `module: node16`+, so providing a cache host
+ * object should be preferred. A common host is a language service `ConfiguredProject`.
* @param scriptSnapshot Text of the file.
* @param version Current version of the file.
*/
- updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
- updateDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
+ updateDocument(fileName: string, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
+ updateDocumentWithKey(fileName: string, path: Path, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey;
/**
* Informs the DocumentRegistry that a file is not needed any longer.
@@ -6814,7 +6909,7 @@ declare namespace ts {
function displayPartsToString(displayParts: SymbolDisplayPart[] | undefined): string;
function getDefaultCompilerOptions(): CompilerOptions;
function getSupportedCodeFixes(): string[];
- function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean, scriptKind?: ScriptKind): SourceFile;
+ function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTargetOrOptions: ScriptTarget | CreateSourceFileOptions, version: string, setNodeParents: boolean, scriptKind?: ScriptKind): SourceFile;
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange | undefined, aggressiveChecks?: boolean): SourceFile;
function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry, syntaxOnlyOrLanguageServiceMode?: boolean | LanguageServiceMode): LanguageService;
/**
@@ -6878,9 +6973,15 @@ declare namespace ts {
/** @deprecated Use `factory.updateComputedPropertyName` or the factory supplied by your transformation context instead. */
const updateComputedPropertyName: (node: ComputedPropertyName, expression: Expression) => ComputedPropertyName;
/** @deprecated Use `factory.createTypeParameterDeclaration` or the factory supplied by your transformation context instead. */
- const createTypeParameterDeclaration: (name: string | Identifier, constraint?: TypeNode | undefined, defaultType?: TypeNode | undefined) => TypeParameterDeclaration;
+ const createTypeParameterDeclaration: {
+ (modifiers: readonly Modifier[] | undefined, name: string | Identifier, constraint?: TypeNode | undefined, defaultType?: TypeNode | undefined): TypeParameterDeclaration;
+ (name: string | Identifier, constraint?: TypeNode | undefined, defaultType?: TypeNode | undefined): TypeParameterDeclaration;
+ };
/** @deprecated Use `factory.updateTypeParameterDeclaration` or the factory supplied by your transformation context instead. */
- const updateTypeParameterDeclaration: (node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined) => TypeParameterDeclaration;
+ const updateTypeParameterDeclaration: {
+ (node: TypeParameterDeclaration, modifiers: readonly Modifier[] | undefined, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
+ (node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
+ };
/** @deprecated Use `factory.createParameterDeclaration` or the factory supplied by your transformation context instead. */
const createParameter: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken | undefined, type?: TypeNode | undefined, initializer?: Expression | undefined) => ParameterDeclaration;
/** @deprecated Use `factory.updateParameterDeclaration` or the factory supplied by your transformation context instead. */
@@ -6938,9 +7039,9 @@ declare namespace ts {
/** @deprecated Use `factory.updateConstructorTypeNode` or the factory supplied by your transformation context instead. */
const updateConstructorTypeNode: (node: ConstructorTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode) => ConstructorTypeNode;
/** @deprecated Use `factory.createTypeQueryNode` or the factory supplied by your transformation context instead. */
- const createTypeQueryNode: (exprName: EntityName) => TypeQueryNode;
+ const createTypeQueryNode: (exprName: EntityName, typeArguments?: readonly TypeNode[] | undefined) => TypeQueryNode;
/** @deprecated Use `factory.updateTypeQueryNode` or the factory supplied by your transformation context instead. */
- const updateTypeQueryNode: (node: TypeQueryNode, exprName: EntityName) => TypeQueryNode;
+ const updateTypeQueryNode: (node: TypeQueryNode, exprName: EntityName, typeArguments?: readonly TypeNode[] | undefined) => TypeQueryNode;
/** @deprecated Use `factory.createTypeLiteralNode` or the factory supplied by your transformation context instead. */
const createTypeLiteralNode: (members: readonly TypeElement[] | undefined) => TypeLiteralNode;
/** @deprecated Use `factory.updateTypeLiteralNode` or the factory supplied by your transformation context instead. */
@@ -6978,9 +7079,15 @@ declare namespace ts {
/** @deprecated Use `factory.updateInferTypeNode` or the factory supplied by your transformation context instead. */
const updateInferTypeNode: (node: InferTypeNode, typeParameter: TypeParameterDeclaration) => InferTypeNode;
/** @deprecated Use `factory.createImportTypeNode` or the factory supplied by your transformation context instead. */
- const createImportTypeNode: (argument: TypeNode, qualifier?: EntityName | undefined, typeArguments?: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined) => ImportTypeNode;
+ const createImportTypeNode: {
+ (argument: TypeNode, qualifier?: EntityName | undefined, typeArguments?: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined): ImportTypeNode;
+ (argument: TypeNode, assertions?: ImportTypeAssertionContainer | undefined, qualifier?: EntityName | undefined, typeArguments?: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined): ImportTypeNode;
+ };
/** @deprecated Use `factory.updateImportTypeNode` or the factory supplied by your transformation context instead. */
- const updateImportTypeNode: (node: ImportTypeNode, argument: TypeNode, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined) => ImportTypeNode;
+ const updateImportTypeNode: {
+ (node: ImportTypeNode, argument: TypeNode, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined): ImportTypeNode;
+ (node: ImportTypeNode, argument: TypeNode, assertions: ImportTypeAssertionContainer | undefined, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined): ImportTypeNode;
+ };
/** @deprecated Use `factory.createParenthesizedType` or the factory supplied by your transformation context instead. */
const createParenthesizedType: (type: TypeNode) => ParenthesizedTypeNode;
/** @deprecated Use `factory.updateParenthesizedType` or the factory supplied by your transformation context instead. */
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs
index 40efcb99a..a2189f52c 100644
--- a/cli/lsp/tsc.rs
+++ b/cli/lsp/tsc.rs
@@ -46,6 +46,8 @@ use log::warn;
use once_cell::sync::Lazy;
use regex::Captures;
use regex::Regex;
+use serde_repr::Deserialize_repr;
+use serde_repr::Serialize_repr;
use std::cmp;
use std::collections::HashMap;
use std::collections::HashSet;
@@ -623,7 +625,7 @@ impl TextSpan {
}
}
-#[derive(Debug, Deserialize, Clone)]
+#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct SymbolDisplayPart {
text: String,
@@ -785,7 +787,7 @@ impl QuickInfo {
}
}
-#[derive(Debug, Clone, Deserialize)]
+#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DocumentSpan {
text_span: TextSpan,
@@ -1618,6 +1620,7 @@ pub struct CombinedCodeActions {
#[serde(rename_all = "camelCase")]
pub struct ReferenceEntry {
// is_write_access: bool,
+ #[serde(default)]
pub is_definition: bool,
// is_in_string: Option<bool>,
#[serde(flatten)]
@@ -1816,14 +1819,14 @@ impl CallHierarchyOutgoingCall {
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CompletionEntryDetails {
- // name: String,
- // kind: ScriptElementKind,
- // kind_modifiers: String,
display_parts: Vec<SymbolDisplayPart>,
documentation: Option<Vec<SymbolDisplayPart>>,
tags: Option<Vec<JsDocTagInfo>>,
+ // name: String,
+ // kind: ScriptElementKind,
+ // kind_modifiers: String,
// code_actions: Option<Vec<CodeAction>>,
- // source: Option<Vec<SymbolDisplayPart>>,
+ // source_display: Option<Vec<SymbolDisplayPart>>,
}
impl CompletionEntryDetails {
@@ -1871,10 +1874,23 @@ impl CompletionEntryDetails {
}
}
+#[derive(Debug, Deserialize_repr, Serialize_repr)]
+#[repr(u32)]
+pub enum CompletionInfoFlags {
+ None = 0,
+ MayIncludeAutoImports = 1,
+ IsImportStatementCompletion = 2,
+ IsContinuation = 4,
+ ResolvedModuleSpecifiers = 8,
+ ResolvedModuleSpecifiersBeyondLimit = 16,
+ MayIncludeMethodSnippets = 32,
+}
+
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CompletionInfo {
entries: Vec<CompletionEntry>,
+ flags: Option<CompletionInfoFlags>,
is_global_completion: bool,
is_member_completion: bool,
is_new_identifier_location: bool,
@@ -1946,16 +1962,26 @@ pub struct CompletionEntry {
#[serde(skip_serializing_if = "Option::is_none")]
insert_text: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
+ is_snippet: Option<bool>,
+ #[serde(skip_serializing_if = "Option::is_none")]
replacement_span: Option<TextSpan>,
#[serde(skip_serializing_if = "Option::is_none")]
has_action: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
source: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
+ source_display: Option<Vec<SymbolDisplayPart>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ label_details: Option<CompletionEntryLabelDetails>,
+ #[serde(skip_serializing_if = "Option::is_none")]
is_recommended: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
is_from_unchecked_file: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
+ is_package_json_import: Option<bool>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ is_import_statement_completion: Option<bool>,
+ #[serde(skip_serializing_if = "Option::is_none")]
data: Option<Value>,
}
@@ -2140,6 +2166,15 @@ impl CompletionEntry {
}
}
+#[derive(Debug, Default, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+struct CompletionEntryLabelDetails {
+ #[serde(skip_serializing_if = "Option::is_none")]
+ detail: Option<String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ description: Option<String>,
+}
+
#[derive(Debug, Deserialize)]
pub enum OutliningSpanKind {
#[serde(rename = "comment")]
@@ -3560,7 +3595,7 @@ mod tests {
// You might have found this assertion starts failing after upgrading TypeScript.
// Just update the new number of assets (declaration files) for this number.
- assert_eq!(assets.len(), 66);
+ assert_eq!(assets.len(), 69);
// get some notification when the size of the assets grows
let mut total_size = 0;
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs
index be2283080..213827057 100644
--- a/cli/tests/integration/lsp_tests.rs
+++ b/cli/tests/integration/lsp_tests.rs
@@ -2056,7 +2056,7 @@ fn lsp_hover_jsdoc_symbol_link() {
"language": "typescript",
"value": "function a(): void"
},
- "JSDoc [hello](file:///a/b.ts#L1,1) and [`b`](file:///a/file.ts#L5,7)"
+ "JSDoc [hello](file:///a/file.ts#L1,10) and [`b`](file:///a/file.ts#L5,7)"
],
"range": {
"start": {
diff --git a/cli/tests/testdata/lsp/code_lens_resolve_response.json b/cli/tests/testdata/lsp/code_lens_resolve_response.json
index 1400eb4e6..a958b4db4 100644
--- a/cli/tests/testdata/lsp/code_lens_resolve_response.json
+++ b/cli/tests/testdata/lsp/code_lens_resolve_response.json
@@ -10,7 +10,7 @@
}
},
"command": {
- "title": "1 reference",
+ "title": "2 references",
"command": "deno.showReferences",
"arguments": [
"file:///a/file.ts",
@@ -23,6 +23,19 @@
"uri": "file:///a/file.ts",
"range": {
"start": {
+ "line": 0,
+ "character": 6
+ },
+ "end": {
+ "line": 0,
+ "character": 7
+ }
+ }
+ },
+ {
+ "uri": "file:///a/file.ts",
+ "range": {
+ "start": {
"line": 12,
"character": 14
},
diff --git a/cli/tsc/00_typescript.js b/cli/tsc/00_typescript.js
index 360278539..cb7c28678 100644
--- a/cli/tsc/00_typescript.js
+++ b/cli/tsc/00_typescript.js
@@ -290,11 +290,11 @@ var ts;
(function (ts) {
// WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
// If changing the text in this section, be sure to test `configurePrerelease` too.
- ts.versionMajorMinor = "4.6";
+ ts.versionMajorMinor = "4.7";
// The following is baselined as a literal template type without intervention
/** The version of the TypeScript compiler release */
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
- ts.version = "4.6.2";
+ ts.version = "4.7.2";
/* @internal */
var Comparison;
(function (Comparison) {
@@ -1033,9 +1033,9 @@ var ts;
case true:
// relational comparison
// falls through
- case 0 /* EqualTo */:
+ case 0 /* Comparison.EqualTo */:
continue;
- case -1 /* LessThan */:
+ case -1 /* Comparison.LessThan */:
// If `array` is sorted, `next` should **never** be less than `last`.
return ts.Debug.fail("Array is unsorted.");
}
@@ -1071,7 +1071,7 @@ var ts;
var prevElement = array[0];
for (var _i = 0, _a = array.slice(1); _i < _a.length; _i++) {
var element = _a[_i];
- if (comparer(prevElement, element) === 1 /* GreaterThan */) {
+ if (comparer(prevElement, element) === 1 /* Comparison.GreaterThan */) {
return false;
}
prevElement = element;
@@ -1125,27 +1125,27 @@ var ts;
loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) {
if (offsetB > 0) {
// Ensure `arrayB` is properly sorted.
- ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */);
+ ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* Comparison.EqualTo */);
}
loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) {
if (offsetA > startA) {
// Ensure `arrayA` is properly sorted. We only need to perform this check if
// `offsetA` has changed since we entered the loop.
- ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */);
+ ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* Comparison.EqualTo */);
}
switch (comparer(arrayB[offsetB], arrayA[offsetA])) {
- case -1 /* LessThan */:
+ case -1 /* Comparison.LessThan */:
// If B is less than A, B does not exist in arrayA. Add B to the result and
// move to the next element in arrayB without changing the current position
// in arrayA.
result.push(arrayB[offsetB]);
continue loopB;
- case 0 /* EqualTo */:
+ case 0 /* Comparison.EqualTo */:
// If B is equal to A, B exists in arrayA. Move to the next element in
// arrayB without adding B to the result or changing the current position
// in arrayA.
continue loopB;
- case 1 /* GreaterThan */:
+ case 1 /* Comparison.GreaterThan */:
// If B is greater than A, we need to keep looking for B in arrayA. Move to
// the next element in arrayA and recheck.
continue loopA;
@@ -1385,12 +1385,12 @@ var ts;
var middle = low + ((high - low) >> 1);
var midKey = keySelector(array[middle], middle);
switch (keyComparer(midKey, key)) {
- case -1 /* LessThan */:
+ case -1 /* Comparison.LessThan */:
low = middle + 1;
break;
- case 0 /* EqualTo */:
+ case 0 /* Comparison.EqualTo */:
return middle;
- case 1 /* GreaterThan */:
+ case 1 /* Comparison.GreaterThan */:
high = middle - 1;
break;
}
@@ -1663,6 +1663,159 @@ var ts;
}
ts.createUnderscoreEscapedMultiMap = createUnderscoreEscapedMultiMap;
/**
+ * Creates a Set with custom equality and hash code functionality. This is useful when you
+ * want to use something looser than object identity - e.g. "has the same span".
+ *
+ * If `equals(a, b)`, it must be the case that `getHashCode(a) === getHashCode(b)`.
+ * The converse is not required.
+ *
+ * To facilitate a perf optimization (lazy allocation of bucket arrays), `TElement` is
+ * assumed not to be an array type.
+ */
+ function createSet(getHashCode, equals) {
+ var multiMap = new ts.Map();
+ var size = 0;
+ function getElementIterator() {
+ var valueIt = multiMap.values();
+ var arrayIt;
+ return {
+ next: function () {
+ while (true) {
+ if (arrayIt) {
+ var n = arrayIt.next();
+ if (!n.done) {
+ return { value: n.value };
+ }
+ arrayIt = undefined;
+ }
+ else {
+ var n = valueIt.next();
+ if (n.done) {
+ return { value: undefined, done: true };
+ }
+ if (!isArray(n.value)) {
+ return { value: n.value };
+ }
+ arrayIt = arrayIterator(n.value);
+ }
+ }
+ }
+ };
+ }
+ var set = {
+ has: function (element) {
+ var hash = getHashCode(element);
+ if (!multiMap.has(hash))
+ return false;
+ var candidates = multiMap.get(hash);
+ if (!isArray(candidates))
+ return equals(candidates, element);
+ for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
+ var candidate = candidates_1[_i];
+ if (equals(candidate, element)) {
+ return true;
+ }
+ }
+ return false;
+ },
+ add: function (element) {
+ var hash = getHashCode(element);
+ if (multiMap.has(hash)) {
+ var values = multiMap.get(hash);
+ if (isArray(values)) {
+ if (!contains(values, element, equals)) {
+ values.push(element);
+ size++;
+ }
+ }
+ else {
+ var value = values;
+ if (!equals(value, element)) {
+ multiMap.set(hash, [value, element]);
+ size++;
+ }
+ }
+ }
+ else {
+ multiMap.set(hash, element);
+ size++;
+ }
+ return this;
+ },
+ delete: function (element) {
+ var hash = getHashCode(element);
+ if (!multiMap.has(hash))
+ return false;
+ var candidates = multiMap.get(hash);
+ if (isArray(candidates)) {
+ for (var i = 0; i < candidates.length; i++) {
+ if (equals(candidates[i], element)) {
+ if (candidates.length === 1) {
+ multiMap.delete(hash);
+ }
+ else if (candidates.length === 2) {
+ multiMap.set(hash, candidates[1 - i]);
+ }
+ else {
+ unorderedRemoveItemAt(candidates, i);
+ }
+ size--;
+ return true;
+ }
+ }
+ }
+ else {
+ var candidate = candidates;
+ if (equals(candidate, element)) {
+ multiMap.delete(hash);
+ size--;
+ return true;
+ }
+ }
+ return false;
+ },
+ clear: function () {
+ multiMap.clear();
+ size = 0;
+ },
+ get size() {
+ return size;
+ },
+ forEach: function (action) {
+ for (var _i = 0, _a = arrayFrom(multiMap.values()); _i < _a.length; _i++) {
+ var elements = _a[_i];
+ if (isArray(elements)) {
+ for (var _b = 0, elements_1 = elements; _b < elements_1.length; _b++) {
+ var element = elements_1[_b];
+ action(element, element);
+ }
+ }
+ else {
+ var element = elements;
+ action(element, element);
+ }
+ }
+ },
+ keys: function () {
+ return getElementIterator();
+ },
+ values: function () {
+ return getElementIterator();
+ },
+ entries: function () {
+ var it = getElementIterator();
+ return {
+ next: function () {
+ var n = it.next();
+ return n.done ? n : { value: [n.value, n.value] };
+ }
+ };
+ },
+ };
+ return set;
+ }
+ ts.createSet = createSet;
+ /**
* Tests whether a value is an array.
*/
function isArray(value) {
@@ -1854,11 +2007,11 @@ var ts;
}
ts.equateStringsCaseSensitive = equateStringsCaseSensitive;
function compareComparableValues(a, b) {
- return a === b ? 0 /* EqualTo */ :
- a === undefined ? -1 /* LessThan */ :
- b === undefined ? 1 /* GreaterThan */ :
- a < b ? -1 /* LessThan */ :
- 1 /* GreaterThan */;
+ return a === b ? 0 /* Comparison.EqualTo */ :
+ a === undefined ? -1 /* Comparison.LessThan */ :
+ b === undefined ? 1 /* Comparison.GreaterThan */ :
+ a < b ? -1 /* Comparison.LessThan */ :
+ 1 /* Comparison.GreaterThan */;
}
/**
* Compare two numeric values for their order relative to each other.
@@ -1876,7 +2029,7 @@ var ts;
}
ts.compareTextSpans = compareTextSpans;
function min(a, b, compare) {
- return compare(a, b) === -1 /* LessThan */ ? a : b;
+ return compare(a, b) === -1 /* Comparison.LessThan */ ? a : b;
}
ts.min = min;
/**
@@ -1893,14 +2046,14 @@ var ts;
*/
function compareStringsCaseInsensitive(a, b) {
if (a === b)
- return 0 /* EqualTo */;
+ return 0 /* Comparison.EqualTo */;
if (a === undefined)
- return -1 /* LessThan */;
+ return -1 /* Comparison.LessThan */;
if (b === undefined)
- return 1 /* GreaterThan */;
+ return 1 /* Comparison.GreaterThan */;
a = a.toUpperCase();
b = b.toUpperCase();
- return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */;
+ return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */;
}
ts.compareStringsCaseInsensitive = compareStringsCaseInsensitive;
/**
@@ -1931,13 +2084,13 @@ var ts;
return createStringComparer;
function compareWithCallback(a, b, comparer) {
if (a === b)
- return 0 /* EqualTo */;
+ return 0 /* Comparison.EqualTo */;
if (a === undefined)
- return -1 /* LessThan */;
+ return -1 /* Comparison.LessThan */;
if (b === undefined)
- return 1 /* GreaterThan */;
+ return 1 /* Comparison.GreaterThan */;
var value = comparer(a, b);
- return value < 0 ? -1 /* LessThan */ : value > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */;
+ return value < 0 ? -1 /* Comparison.LessThan */ : value > 0 ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */;
}
function createIntlCollatorStringComparer(locale) {
// Intl.Collator.prototype.compare is bound to the collator. See NOTE in
@@ -1967,7 +2120,7 @@ var ts;
return compareStrings(a.toUpperCase(), b.toUpperCase()) || compareStrings(a, b);
}
function compareStrings(a, b) {
- return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */;
+ return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */;
}
}
function getStringComparerFactory() {
@@ -2028,9 +2181,9 @@ var ts;
}
ts.compareStringsCaseSensitiveUI = compareStringsCaseSensitiveUI;
function compareProperties(a, b, key, comparer) {
- return a === b ? 0 /* EqualTo */ :
- a === undefined ? -1 /* LessThan */ :
- b === undefined ? 1 /* GreaterThan */ :
+ return a === b ? 0 /* Comparison.EqualTo */ :
+ a === undefined ? -1 /* Comparison.LessThan */ :
+ b === undefined ? 1 /* Comparison.GreaterThan */ :
comparer(a[key], b[key]);
}
ts.compareProperties = compareProperties;
@@ -2055,8 +2208,8 @@ var ts;
var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34));
var bestDistance = Math.floor(name.length * 0.4) + 1; // If the best result is worse than this, don't bother.
var bestCandidate;
- for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
- var candidate = candidates_1[_i];
+ for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) {
+ var candidate = candidates_2[_i];
var candidateName = getName(candidate);
if (candidateName !== undefined && Math.abs(candidateName.length - name.length) <= maximumLengthDifference) {
if (candidateName === name) {
@@ -2149,24 +2302,24 @@ var ts;
var end = fileName.length;
for (var pos = end - 1; pos > 0; pos--) {
var ch = fileName.charCodeAt(pos);
- if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) {
+ if (ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) {
// Match a \d+ segment
do {
--pos;
ch = fileName.charCodeAt(pos);
- } while (pos > 0 && ch >= 48 /* _0 */ && ch <= 57 /* _9 */);
+ } while (pos > 0 && ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */);
}
- else if (pos > 4 && (ch === 110 /* n */ || ch === 78 /* N */)) {
+ else if (pos > 4 && (ch === 110 /* CharacterCodes.n */ || ch === 78 /* CharacterCodes.N */)) {
// Looking for "min" or "min"
// Already matched the 'n'
--pos;
ch = fileName.charCodeAt(pos);
- if (ch !== 105 /* i */ && ch !== 73 /* I */) {
+ if (ch !== 105 /* CharacterCodes.i */ && ch !== 73 /* CharacterCodes.I */) {
break;
}
--pos;
ch = fileName.charCodeAt(pos);
- if (ch !== 109 /* m */ && ch !== 77 /* M */) {
+ if (ch !== 109 /* CharacterCodes.m */ && ch !== 77 /* CharacterCodes.M */) {
break;
}
--pos;
@@ -2176,7 +2329,7 @@ var ts;
// This character is not part of either suffix pattern
break;
}
- if (ch !== 45 /* minus */ && ch !== 46 /* dot */) {
+ if (ch !== 45 /* CharacterCodes.minus */ && ch !== 46 /* CharacterCodes.dot */) {
break;
}
end = pos;
@@ -2293,13 +2446,15 @@ var ts;
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
+ var lastResult;
for (var _a = 0, fs_1 = fs; _a < fs_1.length; _a++) {
var f = fs_1[_a];
- if (f.apply(void 0, args)) {
- return true;
+ lastResult = f.apply(void 0, args);
+ if (lastResult) {
+ return lastResult;
}
}
- return false;
+ return lastResult;
};
}
ts.or = or;
@@ -2330,12 +2485,12 @@ var ts;
var newItem = newItems[newIndex];
var oldItem = oldItems[oldIndex];
var compareResult = comparer(newItem, oldItem);
- if (compareResult === -1 /* LessThan */) {
+ if (compareResult === -1 /* Comparison.LessThan */) {
inserted(newItem);
newIndex++;
hasChanges = true;
}
- else if (compareResult === 1 /* GreaterThan */) {
+ else if (compareResult === 1 /* Comparison.GreaterThan */) {
deleted(oldItem);
oldIndex++;
hasChanges = true;
@@ -2466,7 +2621,7 @@ var ts;
(function (Debug) {
var typeScriptVersion;
/* eslint-disable prefer-const */
- var currentAssertionLevel = 0 /* None */;
+ var currentAssertionLevel = 0 /* AssertionLevel.None */;
Debug.currentLogLevel = LogLevel.Warning;
Debug.isDebugging = false;
function getTypeScriptVersion() {
@@ -2617,42 +2772,42 @@ var ts;
Debug.checkEachDefined = checkEachDefined;
function assertNever(member, message, stackCrawlMark) {
if (message === void 0) { message = "Illegal value:"; }
- var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
+ var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
return fail("".concat(message, " ").concat(detail), stackCrawlMark || assertNever);
}
Debug.assertNever = assertNever;
function assertEachNode(nodes, test, message, stackCrawlMark) {
- if (shouldAssertFunction(1 /* Normal */, "assertEachNode")) {
+ if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertEachNode")) {
assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '".concat(getFunctionName(test), "'."); }, stackCrawlMark || assertEachNode);
}
}
Debug.assertEachNode = assertEachNode;
function assertNode(node, test, message, stackCrawlMark) {
- if (shouldAssertFunction(1 /* Normal */, "assertNode")) {
+ if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNode")) {
assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNode);
}
}
Debug.assertNode = assertNode;
function assertNotNode(node, test, message, stackCrawlMark) {
- if (shouldAssertFunction(1 /* Normal */, "assertNotNode")) {
+ if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNotNode")) {
assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " should not have passed test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNotNode);
}
}
Debug.assertNotNode = assertNotNode;
function assertOptionalNode(node, test, message, stackCrawlMark) {
- if (shouldAssertFunction(1 /* Normal */, "assertOptionalNode")) {
+ if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalNode")) {
assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertOptionalNode);
}
}
Debug.assertOptionalNode = assertOptionalNode;
function assertOptionalToken(node, kind, message, stackCrawlMark) {
- if (shouldAssertFunction(1 /* Normal */, "assertOptionalToken")) {
+ if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalToken")) {
assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " was not a '").concat(formatSyntaxKind(kind), "' token."); }, stackCrawlMark || assertOptionalToken);
}
}
Debug.assertOptionalToken = assertOptionalToken;
function assertMissingNode(node, message, stackCrawlMark) {
- if (shouldAssertFunction(1 /* Normal */, "assertMissingNode")) {
+ if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertMissingNode")) {
assert(node === undefined, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " was unexpected'."); }, stackCrawlMark || assertMissingNode);
}
}
@@ -2792,19 +2947,19 @@ var ts;
// for use with vscode-js-debug's new customDescriptionGenerator in launch.json
__tsDebuggerDisplay: {
value: function () {
- var flowHeader = this.flags & 2 /* Start */ ? "FlowStart" :
- this.flags & 4 /* BranchLabel */ ? "FlowBranchLabel" :
- this.flags & 8 /* LoopLabel */ ? "FlowLoopLabel" :
- this.flags & 16 /* Assignment */ ? "FlowAssignment" :
- this.flags & 32 /* TrueCondition */ ? "FlowTrueCondition" :
- this.flags & 64 /* FalseCondition */ ? "FlowFalseCondition" :
- this.flags & 128 /* SwitchClause */ ? "FlowSwitchClause" :
- this.flags & 256 /* ArrayMutation */ ? "FlowArrayMutation" :
- this.flags & 512 /* Call */ ? "FlowCall" :
- this.flags & 1024 /* ReduceLabel */ ? "FlowReduceLabel" :
- this.flags & 1 /* Unreachable */ ? "FlowUnreachable" :
+ var flowHeader = this.flags & 2 /* FlowFlags.Start */ ? "FlowStart" :
+ this.flags & 4 /* FlowFlags.BranchLabel */ ? "FlowBranchLabel" :
+ this.flags & 8 /* FlowFlags.LoopLabel */ ? "FlowLoopLabel" :
+ this.flags & 16 /* FlowFlags.Assignment */ ? "FlowAssignment" :
+ this.flags & 32 /* FlowFlags.TrueCondition */ ? "FlowTrueCondition" :
+ this.flags & 64 /* FlowFlags.FalseCondition */ ? "FlowFalseCondition" :
+ this.flags & 128 /* FlowFlags.SwitchClause */ ? "FlowSwitchClause" :
+ this.flags & 256 /* FlowFlags.ArrayMutation */ ? "FlowArrayMutation" :
+ this.flags & 512 /* FlowFlags.Call */ ? "FlowCall" :
+ this.flags & 1024 /* FlowFlags.ReduceLabel */ ? "FlowReduceLabel" :
+ this.flags & 1 /* FlowFlags.Unreachable */ ? "FlowUnreachable" :
"UnknownFlow";
- var remainingFlags = this.flags & ~(2048 /* Referenced */ - 1);
+ var remainingFlags = this.flags & ~(2048 /* FlowFlags.Referenced */ - 1);
return "".concat(flowHeader).concat(remainingFlags ? " (".concat(formatFlowFlags(remainingFlags), ")") : "");
}
},
@@ -2896,9 +3051,9 @@ var ts;
// for use with vscode-js-debug's new customDescriptionGenerator in launch.json
__tsDebuggerDisplay: {
value: function () {
- var symbolHeader = this.flags & 33554432 /* Transient */ ? "TransientSymbol" :
+ var symbolHeader = this.flags & 33554432 /* SymbolFlags.Transient */ ? "TransientSymbol" :
"Symbol";
- var remainingSymbolFlags = this.flags & ~33554432 /* Transient */;
+ var remainingSymbolFlags = this.flags & ~33554432 /* SymbolFlags.Transient */;
return "".concat(symbolHeader, " '").concat(ts.symbolName(this), "'").concat(remainingSymbolFlags ? " (".concat(formatSymbolFlags(remainingSymbolFlags), ")") : "");
}
},
@@ -2908,35 +3063,35 @@ var ts;
// for use with vscode-js-debug's new customDescriptionGenerator in launch.json
__tsDebuggerDisplay: {
value: function () {
- var typeHeader = this.flags & 98304 /* Nullable */ ? "NullableType" :
- this.flags & 384 /* StringOrNumberLiteral */ ? "LiteralType ".concat(JSON.stringify(this.value)) :
- this.flags & 2048 /* BigIntLiteral */ ? "LiteralType ".concat(this.value.negative ? "-" : "").concat(this.value.base10Value, "n") :
- this.flags & 8192 /* UniqueESSymbol */ ? "UniqueESSymbolType" :
- this.flags & 32 /* Enum */ ? "EnumType" :
- this.flags & 67359327 /* Intrinsic */ ? "IntrinsicType ".concat(this.intrinsicName) :
- this.flags & 1048576 /* Union */ ? "UnionType" :
- this.flags & 2097152 /* Intersection */ ? "IntersectionType" :
- this.flags & 4194304 /* Index */ ? "IndexType" :
- this.flags & 8388608 /* IndexedAccess */ ? "IndexedAccessType" :
- this.flags & 16777216 /* Conditional */ ? "ConditionalType" :
- this.flags & 33554432 /* Substitution */ ? "SubstitutionType" :
- this.flags & 262144 /* TypeParameter */ ? "TypeParameter" :
- this.flags & 524288 /* Object */ ?
- this.objectFlags & 3 /* ClassOrInterface */ ? "InterfaceType" :
- this.objectFlags & 4 /* Reference */ ? "TypeReference" :
- this.objectFlags & 8 /* Tuple */ ? "TupleType" :
- this.objectFlags & 16 /* Anonymous */ ? "AnonymousType" :
- this.objectFlags & 32 /* Mapped */ ? "MappedType" :
- this.objectFlags & 1024 /* ReverseMapped */ ? "ReverseMappedType" :
- this.objectFlags & 256 /* EvolvingArray */ ? "EvolvingArrayType" :
+ var typeHeader = this.flags & 98304 /* TypeFlags.Nullable */ ? "NullableType" :
+ this.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? "LiteralType ".concat(JSON.stringify(this.value)) :
+ this.flags & 2048 /* TypeFlags.BigIntLiteral */ ? "LiteralType ".concat(this.value.negative ? "-" : "").concat(this.value.base10Value, "n") :
+ this.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? "UniqueESSymbolType" :
+ this.flags & 32 /* TypeFlags.Enum */ ? "EnumType" :
+ this.flags & 67359327 /* TypeFlags.Intrinsic */ ? "IntrinsicType ".concat(this.intrinsicName) :
+ this.flags & 1048576 /* TypeFlags.Union */ ? "UnionType" :
+ this.flags & 2097152 /* TypeFlags.Intersection */ ? "IntersectionType" :
+ this.flags & 4194304 /* TypeFlags.Index */ ? "IndexType" :
+ this.flags & 8388608 /* TypeFlags.IndexedAccess */ ? "IndexedAccessType" :
+ this.flags & 16777216 /* TypeFlags.Conditional */ ? "ConditionalType" :
+ this.flags & 33554432 /* TypeFlags.Substitution */ ? "SubstitutionType" :
+ this.flags & 262144 /* TypeFlags.TypeParameter */ ? "TypeParameter" :
+ this.flags & 524288 /* TypeFlags.Object */ ?
+ this.objectFlags & 3 /* ObjectFlags.ClassOrInterface */ ? "InterfaceType" :
+ this.objectFlags & 4 /* ObjectFlags.Reference */ ? "TypeReference" :
+ this.objectFlags & 8 /* ObjectFlags.Tuple */ ? "TupleType" :
+ this.objectFlags & 16 /* ObjectFlags.Anonymous */ ? "AnonymousType" :
+ this.objectFlags & 32 /* ObjectFlags.Mapped */ ? "MappedType" :
+ this.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? "ReverseMappedType" :
+ this.objectFlags & 256 /* ObjectFlags.EvolvingArray */ ? "EvolvingArrayType" :
"ObjectType" :
"Type";
- var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~1343 /* ObjectTypeKindMask */ : 0;
+ var remainingObjectFlags = this.flags & 524288 /* TypeFlags.Object */ ? this.objectFlags & ~1343 /* ObjectFlags.ObjectTypeKindMask */ : 0;
return "".concat(typeHeader).concat(this.symbol ? " '".concat(ts.symbolName(this.symbol), "'") : "").concat(remainingObjectFlags ? " (".concat(formatObjectFlags(remainingObjectFlags), ")") : "");
}
},
__debugFlags: { get: function () { return formatTypeFlags(this.flags); } },
- __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? formatObjectFlags(this.objectFlags) : ""; } },
+ __debugObjectFlags: { get: function () { return this.flags & 524288 /* TypeFlags.Object */ ? formatObjectFlags(this.objectFlags) : ""; } },
__debugTypeToString: {
value: function () {
// avoid recomputing
@@ -3168,9 +3323,9 @@ var ts;
// https://semver.org/#spec-item-11
// > Build metadata does not figure into precedence
if (this === other)
- return 0 /* EqualTo */;
+ return 0 /* Comparison.EqualTo */;
if (other === undefined)
- return 1 /* GreaterThan */;
+ return 1 /* Comparison.GreaterThan */;
return ts.compareValues(this.major, other.major)
|| ts.compareValues(this.minor, other.minor)
|| ts.compareValues(this.patch, other.patch)
@@ -3218,11 +3373,11 @@ var ts;
// > When major, minor, and patch are equal, a pre-release version has lower precedence
// > than a normal version.
if (left === right)
- return 0 /* EqualTo */;
+ return 0 /* Comparison.EqualTo */;
if (left.length === 0)
- return right.length === 0 ? 0 /* EqualTo */ : 1 /* GreaterThan */;
+ return right.length === 0 ? 0 /* Comparison.EqualTo */ : 1 /* Comparison.GreaterThan */;
if (right.length === 0)
- return -1 /* LessThan */;
+ return -1 /* Comparison.LessThan */;
// https://semver.org/#spec-item-11
// > Precedence for two pre-release versions with the same major, minor, and patch version
// > MUST be determined by comparing each dot separated identifier from left to right until
@@ -3239,7 +3394,7 @@ var ts;
// https://semver.org/#spec-item-11
// > Numeric identifiers always have lower precedence than non-numeric identifiers.
if (leftIsNumeric !== rightIsNumeric)
- return leftIsNumeric ? -1 /* LessThan */ : 1 /* GreaterThan */;
+ return leftIsNumeric ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */;
// https://semver.org/#spec-item-11
// > identifiers consisting of only digits are compared numerically
var result = ts.compareValues(+leftIdentifier, +rightIdentifier);
@@ -3866,7 +4021,7 @@ var ts;
function writeEvent(eventType, phase, name, args, extras, time) {
if (time === void 0) { time = 1000 * ts.timestamp(); }
// In server mode, there's no easy way to dump type information, so we drop events that would require it.
- if (mode === "server" && phase === "checkTypes" /* CheckTypes */)
+ if (mode === "server" && phase === "checkTypes" /* Phase.CheckTypes */)
return;
ts.performance.mark("beginTracing");
fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"".concat(eventType, "\",\"cat\":\"").concat(phase, "\",\"ts\":").concat(time, ",\"name\":\"").concat(name, "\""));
@@ -3909,7 +4064,7 @@ var ts;
var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol;
// It's slow to compute the display text, so skip it unless it's really valuable (or cheap)
var display = void 0;
- if ((objectFlags & 16 /* Anonymous */) | (type.flags & 2944 /* Literal */)) {
+ if ((objectFlags & 16 /* ObjectFlags.Anonymous */) | (type.flags & 2944 /* TypeFlags.Literal */)) {
try {
display = (_b = type.checker) === null || _b === void 0 ? void 0 : _b.typeToString(type);
}
@@ -3918,7 +4073,7 @@ var ts;
}
}
var indexedAccessProperties = {};
- if (type.flags & 8388608 /* IndexedAccess */) {
+ if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) {
var indexedAccessType = type;
indexedAccessProperties = {
indexedAccessObjectType: (_c = indexedAccessType.objectType) === null || _c === void 0 ? void 0 : _c.id,
@@ -3926,7 +4081,7 @@ var ts;
};
}
var referenceProperties = {};
- if (objectFlags & 4 /* Reference */) {
+ if (objectFlags & 4 /* ObjectFlags.Reference */) {
var referenceType = type;
referenceProperties = {
instantiatedType: (_e = referenceType.target) === null || _e === void 0 ? void 0 : _e.id,
@@ -3935,7 +4090,7 @@ var ts;
};
}
var conditionalProperties = {};
- if (type.flags & 16777216 /* Conditional */) {
+ if (type.flags & 16777216 /* TypeFlags.Conditional */) {
var conditionalType = type;
conditionalProperties = {
conditionalCheckType: (_g = conditionalType.checkType) === null || _g === void 0 ? void 0 : _g.id,
@@ -3945,7 +4100,7 @@ var ts;
};
}
var substitutionProperties = {};
- if (type.flags & 33554432 /* Substitution */) {
+ if (type.flags & 33554432 /* TypeFlags.Substitution */) {
var substitutionType = type;
substitutionProperties = {
substitutionBaseType: (_o = substitutionType.baseType) === null || _o === void 0 ? void 0 : _o.id,
@@ -3953,7 +4108,7 @@ var ts;
};
}
var reverseMappedProperties = {};
- if (objectFlags & 1024 /* ReverseMapped */) {
+ if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) {
var reverseMappedType = type;
reverseMappedProperties = {
reverseMappedSourceType: (_q = reverseMappedType.source) === null || _q === void 0 ? void 0 : _q.id,
@@ -3962,7 +4117,7 @@ var ts;
};
}
var evolvingArrayProperties = {};
- if (objectFlags & 256 /* EvolvingArray */) {
+ if (objectFlags & 256 /* ObjectFlags.EvolvingArray */) {
var evolvingArrayType = type;
evolvingArrayProperties = {
evolvingArrayElementType: evolvingArrayType.elementType.id,
@@ -3980,7 +4135,7 @@ var ts;
recursionIdentityMap.set(recursionIdentity, recursionToken);
}
}
- var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display });
+ var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* ObjectFlags.Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* TypeFlags.Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* TypeFlags.Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* TypeFlags.Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display });
fs.writeSync(typesFd, JSON.stringify(descriptor));
if (i < numTypes - 1) {
fs.writeSync(typesFd, ",\n");
@@ -4166,236 +4321,239 @@ var ts;
SyntaxKind[SyntaxKind["ModuleKeyword"] = 141] = "ModuleKeyword";
SyntaxKind[SyntaxKind["NamespaceKeyword"] = 142] = "NamespaceKeyword";
SyntaxKind[SyntaxKind["NeverKeyword"] = 143] = "NeverKeyword";
- SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 144] = "ReadonlyKeyword";
- SyntaxKind[SyntaxKind["RequireKeyword"] = 145] = "RequireKeyword";
- SyntaxKind[SyntaxKind["NumberKeyword"] = 146] = "NumberKeyword";
- SyntaxKind[SyntaxKind["ObjectKeyword"] = 147] = "ObjectKeyword";
- SyntaxKind[SyntaxKind["SetKeyword"] = 148] = "SetKeyword";
- SyntaxKind[SyntaxKind["StringKeyword"] = 149] = "StringKeyword";
- SyntaxKind[SyntaxKind["SymbolKeyword"] = 150] = "SymbolKeyword";
- SyntaxKind[SyntaxKind["TypeKeyword"] = 151] = "TypeKeyword";
- SyntaxKind[SyntaxKind["UndefinedKeyword"] = 152] = "UndefinedKeyword";
- SyntaxKind[SyntaxKind["UniqueKeyword"] = 153] = "UniqueKeyword";
- SyntaxKind[SyntaxKind["UnknownKeyword"] = 154] = "UnknownKeyword";
- SyntaxKind[SyntaxKind["FromKeyword"] = 155] = "FromKeyword";
- SyntaxKind[SyntaxKind["GlobalKeyword"] = 156] = "GlobalKeyword";
- SyntaxKind[SyntaxKind["BigIntKeyword"] = 157] = "BigIntKeyword";
- SyntaxKind[SyntaxKind["OverrideKeyword"] = 158] = "OverrideKeyword";
- SyntaxKind[SyntaxKind["OfKeyword"] = 159] = "OfKeyword";
+ SyntaxKind[SyntaxKind["OutKeyword"] = 144] = "OutKeyword";
+ SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 145] = "ReadonlyKeyword";
+ SyntaxKind[SyntaxKind["RequireKeyword"] = 146] = "RequireKeyword";
+ SyntaxKind[SyntaxKind["NumberKeyword"] = 147] = "NumberKeyword";
+ SyntaxKind[SyntaxKind["ObjectKeyword"] = 148] = "ObjectKeyword";
+ SyntaxKind[SyntaxKind["SetKeyword"] = 149] = "SetKeyword";
+ SyntaxKind[SyntaxKind["StringKeyword"] = 150] = "StringKeyword";
+ SyntaxKind[SyntaxKind["SymbolKeyword"] = 151] = "SymbolKeyword";
+ SyntaxKind[SyntaxKind["TypeKeyword"] = 152] = "TypeKeyword";
+ SyntaxKind[SyntaxKind["UndefinedKeyword"] = 153] = "UndefinedKeyword";
+ SyntaxKind[SyntaxKind["UniqueKeyword"] = 154] = "UniqueKeyword";
+ SyntaxKind[SyntaxKind["UnknownKeyword"] = 155] = "UnknownKeyword";
+ SyntaxKind[SyntaxKind["FromKeyword"] = 156] = "FromKeyword";
+ SyntaxKind[SyntaxKind["GlobalKeyword"] = 157] = "GlobalKeyword";
+ SyntaxKind[SyntaxKind["BigIntKeyword"] = 158] = "BigIntKeyword";
+ SyntaxKind[SyntaxKind["OverrideKeyword"] = 159] = "OverrideKeyword";
+ SyntaxKind[SyntaxKind["OfKeyword"] = 160] = "OfKeyword";
// Parse tree nodes
// Names
- SyntaxKind[SyntaxKind["QualifiedName"] = 160] = "QualifiedName";
- SyntaxKind[SyntaxKind["ComputedPropertyName"] = 161] = "ComputedPropertyName";
+ SyntaxKind[SyntaxKind["QualifiedName"] = 161] = "QualifiedName";
+ SyntaxKind[SyntaxKind["ComputedPropertyName"] = 162] = "ComputedPropertyName";
// Signature elements
- SyntaxKind[SyntaxKind["TypeParameter"] = 162] = "TypeParameter";
- SyntaxKind[SyntaxKind["Parameter"] = 163] = "Parameter";
- SyntaxKind[SyntaxKind["Decorator"] = 164] = "Decorator";
+ SyntaxKind[SyntaxKind["TypeParameter"] = 163] = "TypeParameter";
+ SyntaxKind[SyntaxKind["Parameter"] = 164] = "Parameter";
+ SyntaxKind[SyntaxKind["Decorator"] = 165] = "Decorator";
// TypeMember
- SyntaxKind[SyntaxKind["PropertySignature"] = 165] = "PropertySignature";
- SyntaxKind[SyntaxKind["PropertyDeclaration"] = 166] = "PropertyDeclaration";
- SyntaxKind[SyntaxKind["MethodSignature"] = 167] = "MethodSignature";
- SyntaxKind[SyntaxKind["MethodDeclaration"] = 168] = "MethodDeclaration";
- SyntaxKind[SyntaxKind["ClassStaticBlockDeclaration"] = 169] = "ClassStaticBlockDeclaration";
- SyntaxKind[SyntaxKind["Constructor"] = 170] = "Constructor";
- SyntaxKind[SyntaxKind["GetAccessor"] = 171] = "GetAccessor";
- SyntaxKind[SyntaxKind["SetAccessor"] = 172] = "SetAccessor";
- SyntaxKind[SyntaxKind["CallSignature"] = 173] = "CallSignature";
- SyntaxKind[SyntaxKind["ConstructSignature"] = 174] = "ConstructSignature";
- SyntaxKind[SyntaxKind["IndexSignature"] = 175] = "IndexSignature";
+ SyntaxKind[SyntaxKind["PropertySignature"] = 166] = "PropertySignature";
+ SyntaxKind[SyntaxKind["PropertyDeclaration"] = 167] = "PropertyDeclaration";
+ SyntaxKind[SyntaxKind["MethodSignature"] = 168] = "MethodSignature";
+ SyntaxKind[SyntaxKind["MethodDeclaration"] = 169] = "MethodDeclaration";
+ SyntaxKind[SyntaxKind["ClassStaticBlockDeclaration"] = 170] = "ClassStaticBlockDeclaration";
+ SyntaxKind[SyntaxKind["Constructor"] = 171] = "Constructor";
+ SyntaxKind[SyntaxKind["GetAccessor"] = 172] = "GetAccessor";
+ SyntaxKind[SyntaxKind["SetAccessor"] = 173] = "SetAccessor";
+ SyntaxKind[SyntaxKind["CallSignature"] = 174] = "CallSignature";
+ SyntaxKind[SyntaxKind["ConstructSignature"] = 175] = "ConstructSignature";
+ SyntaxKind[SyntaxKind["IndexSignature"] = 176] = "IndexSignature";
// Type
- SyntaxKind[SyntaxKind["TypePredicate"] = 176] = "TypePredicate";
- SyntaxKind[SyntaxKind["TypeReference"] = 177] = "TypeReference";
- SyntaxKind[SyntaxKind["FunctionType"] = 178] = "FunctionType";
- SyntaxKind[SyntaxKind["ConstructorType"] = 179] = "ConstructorType";
- SyntaxKind[SyntaxKind["TypeQuery"] = 180] = "TypeQuery";
- SyntaxKind[SyntaxKind["TypeLiteral"] = 181] = "TypeLiteral";
- SyntaxKind[SyntaxKind["ArrayType"] = 182] = "ArrayType";
- SyntaxKind[SyntaxKind["TupleType"] = 183] = "TupleType";
- SyntaxKind[SyntaxKind["OptionalType"] = 184] = "OptionalType";
- SyntaxKind[SyntaxKind["RestType"] = 185] = "RestType";
- SyntaxKind[SyntaxKind["UnionType"] = 186] = "UnionType";
- SyntaxKind[SyntaxKind["IntersectionType"] = 187] = "IntersectionType";
- SyntaxKind[SyntaxKind["ConditionalType"] = 188] = "ConditionalType";
- SyntaxKind[SyntaxKind["InferType"] = 189] = "InferType";
- SyntaxKind[SyntaxKind["ParenthesizedType"] = 190] = "ParenthesizedType";
- SyntaxKind[SyntaxKind["ThisType"] = 191] = "ThisType";
- SyntaxKind[SyntaxKind["TypeOperator"] = 192] = "TypeOperator";
- SyntaxKind[SyntaxKind["IndexedAccessType"] = 193] = "IndexedAccessType";
- SyntaxKind[SyntaxKind["MappedType"] = 194] = "MappedType";
- SyntaxKind[SyntaxKind["LiteralType"] = 195] = "LiteralType";
- SyntaxKind[SyntaxKind["NamedTupleMember"] = 196] = "NamedTupleMember";
- SyntaxKind[SyntaxKind["TemplateLiteralType"] = 197] = "TemplateLiteralType";
- SyntaxKind[SyntaxKind["TemplateLiteralTypeSpan"] = 198] = "TemplateLiteralTypeSpan";
- SyntaxKind[SyntaxKind["ImportType"] = 199] = "ImportType";
+ SyntaxKind[SyntaxKind["TypePredicate"] = 177] = "TypePredicate";
+ SyntaxKind[SyntaxKind["TypeReference"] = 178] = "TypeReference";
+ SyntaxKind[SyntaxKind["FunctionType"] = 179] = "FunctionType";
+ SyntaxKind[SyntaxKind["ConstructorType"] = 180] = "ConstructorType";
+ SyntaxKind[SyntaxKind["TypeQuery"] = 181] = "TypeQuery";
+ SyntaxKind[SyntaxKind["TypeLiteral"] = 182] = "TypeLiteral";
+ SyntaxKind[SyntaxKind["ArrayType"] = 183] = "ArrayType";
+ SyntaxKind[SyntaxKind["TupleType"] = 184] = "TupleType";
+ SyntaxKind[SyntaxKind["OptionalType"] = 185] = "OptionalType";
+ SyntaxKind[SyntaxKind["RestType"] = 186] = "RestType";
+ SyntaxKind[SyntaxKind["UnionType"] = 187] = "UnionType";
+ SyntaxKind[SyntaxKind["IntersectionType"] = 188] = "IntersectionType";
+ SyntaxKind[SyntaxKind["ConditionalType"] = 189] = "ConditionalType";
+ SyntaxKind[SyntaxKind["InferType"] = 190] = "InferType";
+ SyntaxKind[SyntaxKind["ParenthesizedType"] = 191] = "ParenthesizedType";
+ SyntaxKind[SyntaxKind["ThisType"] = 192] = "ThisType";
+ SyntaxKind[SyntaxKind["TypeOperator"] = 193] = "TypeOperator";
+ SyntaxKind[SyntaxKind["IndexedAccessType"] = 194] = "IndexedAccessType";
+ SyntaxKind[SyntaxKind["MappedType"] = 195] = "MappedType";
+ SyntaxKind[SyntaxKind["LiteralType"] = 196] = "LiteralType";
+ SyntaxKind[SyntaxKind["NamedTupleMember"] = 197] = "NamedTupleMember";
+ SyntaxKind[SyntaxKind["TemplateLiteralType"] = 198] = "TemplateLiteralType";
+ SyntaxKind[SyntaxKind["TemplateLiteralTypeSpan"] = 199] = "TemplateLiteralTypeSpan";
+ SyntaxKind[SyntaxKind["ImportType"] = 200] = "ImportType";
// Binding patterns
- SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 200] = "ObjectBindingPattern";
- SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 201] = "ArrayBindingPattern";
- SyntaxKind[SyntaxKind["BindingElement"] = 202] = "BindingElement";
+ SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 201] = "ObjectBindingPattern";
+ SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 202] = "ArrayBindingPattern";
+ SyntaxKind[SyntaxKind["BindingElement"] = 203] = "BindingElement";
// Expression
- SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 203] = "ArrayLiteralExpression";
- SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 204] = "ObjectLiteralExpression";
- SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 205] = "PropertyAccessExpression";
- SyntaxKind[SyntaxKind["ElementAccessExpression"] = 206] = "ElementAccessExpression";
- SyntaxKind[SyntaxKind["CallExpression"] = 207] = "CallExpression";
- SyntaxKind[SyntaxKind["NewExpression"] = 208] = "NewExpression";
- SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 209] = "TaggedTemplateExpression";
- SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 210] = "TypeAssertionExpression";
- SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 211] = "ParenthesizedExpression";
- SyntaxKind[SyntaxKind["FunctionExpression"] = 212] = "FunctionExpression";
- SyntaxKind[SyntaxKind["ArrowFunction"] = 213] = "ArrowFunction";
- SyntaxKind[SyntaxKind["DeleteExpression"] = 214] = "DeleteExpression";
- SyntaxKind[SyntaxKind["TypeOfExpression"] = 215] = "TypeOfExpression";
- SyntaxKind[SyntaxKind["VoidExpression"] = 216] = "VoidExpression";
- SyntaxKind[SyntaxKind["AwaitExpression"] = 217] = "AwaitExpression";
- SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 218] = "PrefixUnaryExpression";
- SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 219] = "PostfixUnaryExpression";
- SyntaxKind[SyntaxKind["BinaryExpression"] = 220] = "BinaryExpression";
- SyntaxKind[SyntaxKind["ConditionalExpression"] = 221] = "ConditionalExpression";
- SyntaxKind[SyntaxKind["TemplateExpression"] = 222] = "TemplateExpression";
- SyntaxKind[SyntaxKind["YieldExpression"] = 223] = "YieldExpression";
- SyntaxKind[SyntaxKind["SpreadElement"] = 224] = "SpreadElement";
- SyntaxKind[SyntaxKind["ClassExpression"] = 225] = "ClassExpression";
- SyntaxKind[SyntaxKind["OmittedExpression"] = 226] = "OmittedExpression";
- SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 227] = "ExpressionWithTypeArguments";
- SyntaxKind[SyntaxKind["AsExpression"] = 228] = "AsExpression";
- SyntaxKind[SyntaxKind["NonNullExpression"] = 229] = "NonNullExpression";
- SyntaxKind[SyntaxKind["MetaProperty"] = 230] = "MetaProperty";
- SyntaxKind[SyntaxKind["SyntheticExpression"] = 231] = "SyntheticExpression";
+ SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 204] = "ArrayLiteralExpression";
+ SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 205] = "ObjectLiteralExpression";
+ SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 206] = "PropertyAccessExpression";
+ SyntaxKind[SyntaxKind["ElementAccessExpression"] = 207] = "ElementAccessExpression";
+ SyntaxKind[SyntaxKind["CallExpression"] = 208] = "CallExpression";
+ SyntaxKind[SyntaxKind["NewExpression"] = 209] = "NewExpression";
+ SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 210] = "TaggedTemplateExpression";
+ SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 211] = "TypeAssertionExpression";
+ SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 212] = "ParenthesizedExpression";
+ SyntaxKind[SyntaxKind["FunctionExpression"] = 213] = "FunctionExpression";
+ SyntaxKind[SyntaxKind["ArrowFunction"] = 214] = "ArrowFunction";
+ SyntaxKind[SyntaxKind["DeleteExpression"] = 215] = "DeleteExpression";
+ SyntaxKind[SyntaxKind["TypeOfExpression"] = 216] = "TypeOfExpression";
+ SyntaxKind[SyntaxKind["VoidExpression"] = 217] = "VoidExpression";
+ SyntaxKind[SyntaxKind["AwaitExpression"] = 218] = "AwaitExpression";
+ SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 219] = "PrefixUnaryExpression";
+ SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 220] = "PostfixUnaryExpression";
+ SyntaxKind[SyntaxKind["BinaryExpression"] = 221] = "BinaryExpression";
+ SyntaxKind[SyntaxKind["ConditionalExpression"] = 222] = "ConditionalExpression";
+ SyntaxKind[SyntaxKind["TemplateExpression"] = 223] = "TemplateExpression";
+ SyntaxKind[SyntaxKind["YieldExpression"] = 224] = "YieldExpression";
+ SyntaxKind[SyntaxKind["SpreadElement"] = 225] = "SpreadElement";
+ SyntaxKind[SyntaxKind["ClassExpression"] = 226] = "ClassExpression";
+ SyntaxKind[SyntaxKind["OmittedExpression"] = 227] = "OmittedExpression";
+ SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 228] = "ExpressionWithTypeArguments";
+ SyntaxKind[SyntaxKind["AsExpression"] = 229] = "AsExpression";
+ SyntaxKind[SyntaxKind["NonNullExpression"] = 230] = "NonNullExpression";
+ SyntaxKind[SyntaxKind["MetaProperty"] = 231] = "MetaProperty";
+ SyntaxKind[SyntaxKind["SyntheticExpression"] = 232] = "SyntheticExpression";
// Misc
- SyntaxKind[SyntaxKind["TemplateSpan"] = 232] = "TemplateSpan";
- SyntaxKind[SyntaxKind["SemicolonClassElement"] = 233] = "SemicolonClassElement";
+ SyntaxKind[SyntaxKind["TemplateSpan"] = 233] = "TemplateSpan";
+ SyntaxKind[SyntaxKind["SemicolonClassElement"] = 234] = "SemicolonClassElement";
// Element
- SyntaxKind[SyntaxKind["Block"] = 234] = "Block";
- SyntaxKind[SyntaxKind["EmptyStatement"] = 235] = "EmptyStatement";
- SyntaxKind[SyntaxKind["VariableStatement"] = 236] = "VariableStatement";
- SyntaxKind[SyntaxKind["ExpressionStatement"] = 237] = "ExpressionStatement";
- SyntaxKind[SyntaxKind["IfStatement"] = 238] = "IfStatement";
- SyntaxKind[SyntaxKind["DoStatement"] = 239] = "DoStatement";
- SyntaxKind[SyntaxKind["WhileStatement"] = 240] = "WhileStatement";
- SyntaxKind[SyntaxKind["ForStatement"] = 241] = "ForStatement";
- SyntaxKind[SyntaxKind["ForInStatement"] = 242] = "ForInStatement";
- SyntaxKind[SyntaxKind["ForOfStatement"] = 243] = "ForOfStatement";
- SyntaxKind[SyntaxKind["ContinueStatement"] = 244] = "ContinueStatement";
- SyntaxKind[SyntaxKind["BreakStatement"] = 245] = "BreakStatement";
- SyntaxKind[SyntaxKind["ReturnStatement"] = 246] = "ReturnStatement";
- SyntaxKind[SyntaxKind["WithStatement"] = 247] = "WithStatement";
- SyntaxKind[SyntaxKind["SwitchStatement"] = 248] = "SwitchStatement";
- SyntaxKind[SyntaxKind["LabeledStatement"] = 249] = "LabeledStatement";
- SyntaxKind[SyntaxKind["ThrowStatement"] = 250] = "ThrowStatement";
- SyntaxKind[SyntaxKind["TryStatement"] = 251] = "TryStatement";
- SyntaxKind[SyntaxKind["DebuggerStatement"] = 252] = "DebuggerStatement";
- SyntaxKind[SyntaxKind["VariableDeclaration"] = 253] = "VariableDeclaration";
- SyntaxKind[SyntaxKind["VariableDeclarationList"] = 254] = "VariableDeclarationList";
- SyntaxKind[SyntaxKind["FunctionDeclaration"] = 255] = "FunctionDeclaration";
- SyntaxKind[SyntaxKind["ClassDeclaration"] = 256] = "ClassDeclaration";
- SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 257] = "InterfaceDeclaration";
- SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 258] = "TypeAliasDeclaration";
- SyntaxKind[SyntaxKind["EnumDeclaration"] = 259] = "EnumDeclaration";
- SyntaxKind[SyntaxKind["ModuleDeclaration"] = 260] = "ModuleDeclaration";
- SyntaxKind[SyntaxKind["ModuleBlock"] = 261] = "ModuleBlock";
- SyntaxKind[SyntaxKind["CaseBlock"] = 262] = "CaseBlock";
- SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 263] = "NamespaceExportDeclaration";
- SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 264] = "ImportEqualsDeclaration";
- SyntaxKind[SyntaxKind["ImportDeclaration"] = 265] = "ImportDeclaration";
- SyntaxKind[SyntaxKind["ImportClause"] = 266] = "ImportClause";
- SyntaxKind[SyntaxKind["NamespaceImport"] = 267] = "NamespaceImport";
- SyntaxKind[SyntaxKind["NamedImports"] = 268] = "NamedImports";
- SyntaxKind[SyntaxKind["ImportSpecifier"] = 269] = "ImportSpecifier";
- SyntaxKind[SyntaxKind["ExportAssignment"] = 270] = "ExportAssignment";
- SyntaxKind[SyntaxKind["ExportDeclaration"] = 271] = "ExportDeclaration";
- SyntaxKind[SyntaxKind["NamedExports"] = 272] = "NamedExports";
- SyntaxKind[SyntaxKind["NamespaceExport"] = 273] = "NamespaceExport";
- SyntaxKind[SyntaxKind["ExportSpecifier"] = 274] = "ExportSpecifier";
- SyntaxKind[SyntaxKind["MissingDeclaration"] = 275] = "MissingDeclaration";
+ SyntaxKind[SyntaxKind["Block"] = 235] = "Block";
+ SyntaxKind[SyntaxKind["EmptyStatement"] = 236] = "EmptyStatement";
+ SyntaxKind[SyntaxKind["VariableStatement"] = 237] = "VariableStatement";
+ SyntaxKind[SyntaxKind["ExpressionStatement"] = 238] = "ExpressionStatement";
+ SyntaxKind[SyntaxKind["IfStatement"] = 239] = "IfStatement";
+ SyntaxKind[SyntaxKind["DoStatement"] = 240] = "DoStatement";
+ SyntaxKind[SyntaxKind["WhileStatement"] = 241] = "WhileStatement";
+ SyntaxKind[SyntaxKind["ForStatement"] = 242] = "ForStatement";
+ SyntaxKind[SyntaxKind["ForInStatement"] = 243] = "ForInStatement";
+ SyntaxKind[SyntaxKind["ForOfStatement"] = 244] = "ForOfStatement";
+ SyntaxKind[SyntaxKind["ContinueStatement"] = 245] = "ContinueStatement";
+ SyntaxKind[SyntaxKind["BreakStatement"] = 246] = "BreakStatement";
+ SyntaxKind[SyntaxKind["ReturnStatement"] = 247] = "ReturnStatement";
+ SyntaxKind[SyntaxKind["WithStatement"] = 248] = "WithStatement";
+ SyntaxKind[SyntaxKind["SwitchStatement"] = 249] = "SwitchStatement";
+ SyntaxKind[SyntaxKind["LabeledStatement"] = 250] = "LabeledStatement";
+ SyntaxKind[SyntaxKind["ThrowStatement"] = 251] = "ThrowStatement";
+ SyntaxKind[SyntaxKind["TryStatement"] = 252] = "TryStatement";
+ SyntaxKind[SyntaxKind["DebuggerStatement"] = 253] = "DebuggerStatement";
+ SyntaxKind[SyntaxKind["VariableDeclaration"] = 254] = "VariableDeclaration";
+ SyntaxKind[SyntaxKind["VariableDeclarationList"] = 255] = "VariableDeclarationList";
+ SyntaxKind[SyntaxKind["FunctionDeclaration"] = 256] = "FunctionDeclaration";
+ SyntaxKind[SyntaxKind["ClassDeclaration"] = 257] = "ClassDeclaration";
+ SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 258] = "InterfaceDeclaration";
+ SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 259] = "TypeAliasDeclaration";
+ SyntaxKind[SyntaxKind["EnumDeclaration"] = 260] = "EnumDeclaration";
+ SyntaxKind[SyntaxKind["ModuleDeclaration"] = 261] = "ModuleDeclaration";
+ SyntaxKind[SyntaxKind["ModuleBlock"] = 262] = "ModuleBlock";
+ SyntaxKind[SyntaxKind["CaseBlock"] = 263] = "CaseBlock";
+ SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 264] = "NamespaceExportDeclaration";
+ SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 265] = "ImportEqualsDeclaration";
+ SyntaxKind[SyntaxKind["ImportDeclaration"] = 266] = "ImportDeclaration";
+ SyntaxKind[SyntaxKind["ImportClause"] = 267] = "ImportClause";
+ SyntaxKind[SyntaxKind["NamespaceImport"] = 268] = "NamespaceImport";
+ SyntaxKind[SyntaxKind["NamedImports"] = 269] = "NamedImports";
+ SyntaxKind[SyntaxKind["ImportSpecifier"] = 270] = "ImportSpecifier";
+ SyntaxKind[SyntaxKind["ExportAssignment"] = 271] = "ExportAssignment";
+ SyntaxKind[SyntaxKind["ExportDeclaration"] = 272] = "ExportDeclaration";
+ SyntaxKind[SyntaxKind["NamedExports"] = 273] = "NamedExports";
+ SyntaxKind[SyntaxKind["NamespaceExport"] = 274] = "NamespaceExport";
+ SyntaxKind[SyntaxKind["ExportSpecifier"] = 275] = "ExportSpecifier";
+ SyntaxKind[SyntaxKind["MissingDeclaration"] = 276] = "MissingDeclaration";
// Module references
- SyntaxKind[SyntaxKind["ExternalModuleReference"] = 276] = "ExternalModuleReference";
+ SyntaxKind[SyntaxKind["ExternalModuleReference"] = 277] = "ExternalModuleReference";
// JSX
- SyntaxKind[SyntaxKind["JsxElement"] = 277] = "JsxElement";
- SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 278] = "JsxSelfClosingElement";
- SyntaxKind[SyntaxKind["JsxOpeningElement"] = 279] = "JsxOpeningElement";
- SyntaxKind[SyntaxKind["JsxClosingElement"] = 280] = "JsxClosingElement";
- SyntaxKind[SyntaxKind["JsxFragment"] = 281] = "JsxFragment";
- SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 282] = "JsxOpeningFragment";
- SyntaxKind[SyntaxKind["JsxClosingFragment"] = 283] = "JsxClosingFragment";
- SyntaxKind[SyntaxKind["JsxAttribute"] = 284] = "JsxAttribute";
- SyntaxKind[SyntaxKind["JsxAttributes"] = 285] = "JsxAttributes";
- SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 286] = "JsxSpreadAttribute";
- SyntaxKind[SyntaxKind["JsxExpression"] = 287] = "JsxExpression";
+ SyntaxKind[SyntaxKind["JsxElement"] = 278] = "JsxElement";
+ SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 279] = "JsxSelfClosingElement";
+ SyntaxKind[SyntaxKind["JsxOpeningElement"] = 280] = "JsxOpeningElement";
+ SyntaxKind[SyntaxKind["JsxClosingElement"] = 281] = "JsxClosingElement";
+ SyntaxKind[SyntaxKind["JsxFragment"] = 282] = "JsxFragment";
+ SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 283] = "JsxOpeningFragment";
+ SyntaxKind[SyntaxKind["JsxClosingFragment"] = 284] = "JsxClosingFragment";
+ SyntaxKind[SyntaxKind["JsxAttribute"] = 285] = "JsxAttribute";
+ SyntaxKind[SyntaxKind["JsxAttributes"] = 286] = "JsxAttributes";
+ SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 287] = "JsxSpreadAttribute";
+ SyntaxKind[SyntaxKind["JsxExpression"] = 288] = "JsxExpression";
// Clauses
- SyntaxKind[SyntaxKind["CaseClause"] = 288] = "CaseClause";
- SyntaxKind[SyntaxKind["DefaultClause"] = 289] = "DefaultClause";
- SyntaxKind[SyntaxKind["HeritageClause"] = 290] = "HeritageClause";
- SyntaxKind[SyntaxKind["CatchClause"] = 291] = "CatchClause";
- SyntaxKind[SyntaxKind["AssertClause"] = 292] = "AssertClause";
- SyntaxKind[SyntaxKind["AssertEntry"] = 293] = "AssertEntry";
+ SyntaxKind[SyntaxKind["CaseClause"] = 289] = "CaseClause";
+ SyntaxKind[SyntaxKind["DefaultClause"] = 290] = "DefaultClause";
+ SyntaxKind[SyntaxKind["HeritageClause"] = 291] = "HeritageClause";
+ SyntaxKind[SyntaxKind["CatchClause"] = 292] = "CatchClause";
+ SyntaxKind[SyntaxKind["AssertClause"] = 293] = "AssertClause";
+ SyntaxKind[SyntaxKind["AssertEntry"] = 294] = "AssertEntry";
+ SyntaxKind[SyntaxKind["ImportTypeAssertionContainer"] = 295] = "ImportTypeAssertionContainer";
// Property assignments
- SyntaxKind[SyntaxKind["PropertyAssignment"] = 294] = "PropertyAssignment";
- SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 295] = "ShorthandPropertyAssignment";
- SyntaxKind[SyntaxKind["SpreadAssignment"] = 296] = "SpreadAssignment";
+ SyntaxKind[SyntaxKind["PropertyAssignment"] = 296] = "PropertyAssignment";
+ SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 297] = "ShorthandPropertyAssignment";
+ SyntaxKind[SyntaxKind["SpreadAssignment"] = 298] = "SpreadAssignment";
// Enum
- SyntaxKind[SyntaxKind["EnumMember"] = 297] = "EnumMember";
+ SyntaxKind[SyntaxKind["EnumMember"] = 299] = "EnumMember";
// Unparsed
- SyntaxKind[SyntaxKind["UnparsedPrologue"] = 298] = "UnparsedPrologue";
- SyntaxKind[SyntaxKind["UnparsedPrepend"] = 299] = "UnparsedPrepend";
- SyntaxKind[SyntaxKind["UnparsedText"] = 300] = "UnparsedText";
- SyntaxKind[SyntaxKind["UnparsedInternalText"] = 301] = "UnparsedInternalText";
- SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 302] = "UnparsedSyntheticReference";
+ SyntaxKind[SyntaxKind["UnparsedPrologue"] = 300] = "UnparsedPrologue";
+ SyntaxKind[SyntaxKind["UnparsedPrepend"] = 301] = "UnparsedPrepend";
+ SyntaxKind[SyntaxKind["UnparsedText"] = 302] = "UnparsedText";
+ SyntaxKind[SyntaxKind["UnparsedInternalText"] = 303] = "UnparsedInternalText";
+ SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 304] = "UnparsedSyntheticReference";
// Top-level nodes
- SyntaxKind[SyntaxKind["SourceFile"] = 303] = "SourceFile";
- SyntaxKind[SyntaxKind["Bundle"] = 304] = "Bundle";
- SyntaxKind[SyntaxKind["UnparsedSource"] = 305] = "UnparsedSource";
- SyntaxKind[SyntaxKind["InputFiles"] = 306] = "InputFiles";
+ SyntaxKind[SyntaxKind["SourceFile"] = 305] = "SourceFile";
+ SyntaxKind[SyntaxKind["Bundle"] = 306] = "Bundle";
+ SyntaxKind[SyntaxKind["UnparsedSource"] = 307] = "UnparsedSource";
+ SyntaxKind[SyntaxKind["InputFiles"] = 308] = "InputFiles";
// JSDoc nodes
- SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 307] = "JSDocTypeExpression";
- SyntaxKind[SyntaxKind["JSDocNameReference"] = 308] = "JSDocNameReference";
- SyntaxKind[SyntaxKind["JSDocMemberName"] = 309] = "JSDocMemberName";
- SyntaxKind[SyntaxKind["JSDocAllType"] = 310] = "JSDocAllType";
- SyntaxKind[SyntaxKind["JSDocUnknownType"] = 311] = "JSDocUnknownType";
- SyntaxKind[SyntaxKind["JSDocNullableType"] = 312] = "JSDocNullableType";
- SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 313] = "JSDocNonNullableType";
- SyntaxKind[SyntaxKind["JSDocOptionalType"] = 314] = "JSDocOptionalType";
- SyntaxKind[SyntaxKind["JSDocFunctionType"] = 315] = "JSDocFunctionType";
- SyntaxKind[SyntaxKind["JSDocVariadicType"] = 316] = "JSDocVariadicType";
- SyntaxKind[SyntaxKind["JSDocNamepathType"] = 317] = "JSDocNamepathType";
- SyntaxKind[SyntaxKind["JSDocComment"] = 318] = "JSDocComment";
- SyntaxKind[SyntaxKind["JSDocText"] = 319] = "JSDocText";
- SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 320] = "JSDocTypeLiteral";
- SyntaxKind[SyntaxKind["JSDocSignature"] = 321] = "JSDocSignature";
- SyntaxKind[SyntaxKind["JSDocLink"] = 322] = "JSDocLink";
- SyntaxKind[SyntaxKind["JSDocLinkCode"] = 323] = "JSDocLinkCode";
- SyntaxKind[SyntaxKind["JSDocLinkPlain"] = 324] = "JSDocLinkPlain";
- SyntaxKind[SyntaxKind["JSDocTag"] = 325] = "JSDocTag";
- SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 326] = "JSDocAugmentsTag";
- SyntaxKind[SyntaxKind["JSDocImplementsTag"] = 327] = "JSDocImplementsTag";
- SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 328] = "JSDocAuthorTag";
- SyntaxKind[SyntaxKind["JSDocDeprecatedTag"] = 329] = "JSDocDeprecatedTag";
- SyntaxKind[SyntaxKind["JSDocClassTag"] = 330] = "JSDocClassTag";
- SyntaxKind[SyntaxKind["JSDocPublicTag"] = 331] = "JSDocPublicTag";
- SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 332] = "JSDocPrivateTag";
- SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 333] = "JSDocProtectedTag";
- SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 334] = "JSDocReadonlyTag";
- SyntaxKind[SyntaxKind["JSDocOverrideTag"] = 335] = "JSDocOverrideTag";
- SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 336] = "JSDocCallbackTag";
- SyntaxKind[SyntaxKind["JSDocEnumTag"] = 337] = "JSDocEnumTag";
- SyntaxKind[SyntaxKind["JSDocParameterTag"] = 338] = "JSDocParameterTag";
- SyntaxKind[SyntaxKind["JSDocReturnTag"] = 339] = "JSDocReturnTag";
- SyntaxKind[SyntaxKind["JSDocThisTag"] = 340] = "JSDocThisTag";
- SyntaxKind[SyntaxKind["JSDocTypeTag"] = 341] = "JSDocTypeTag";
- SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 342] = "JSDocTemplateTag";
- SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 343] = "JSDocTypedefTag";
- SyntaxKind[SyntaxKind["JSDocSeeTag"] = 344] = "JSDocSeeTag";
- SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 345] = "JSDocPropertyTag";
+ SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 309] = "JSDocTypeExpression";
+ SyntaxKind[SyntaxKind["JSDocNameReference"] = 310] = "JSDocNameReference";
+ SyntaxKind[SyntaxKind["JSDocMemberName"] = 311] = "JSDocMemberName";
+ SyntaxKind[SyntaxKind["JSDocAllType"] = 312] = "JSDocAllType";
+ SyntaxKind[SyntaxKind["JSDocUnknownType"] = 313] = "JSDocUnknownType";
+ SyntaxKind[SyntaxKind["JSDocNullableType"] = 314] = "JSDocNullableType";
+ SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 315] = "JSDocNonNullableType";
+ SyntaxKind[SyntaxKind["JSDocOptionalType"] = 316] = "JSDocOptionalType";
+ SyntaxKind[SyntaxKind["JSDocFunctionType"] = 317] = "JSDocFunctionType";
+ SyntaxKind[SyntaxKind["JSDocVariadicType"] = 318] = "JSDocVariadicType";
+ SyntaxKind[SyntaxKind["JSDocNamepathType"] = 319] = "JSDocNamepathType";
+ /** @deprecated Use SyntaxKind.JSDoc */
+ SyntaxKind[SyntaxKind["JSDocComment"] = 320] = "JSDocComment";
+ SyntaxKind[SyntaxKind["JSDocText"] = 321] = "JSDocText";
+ SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 322] = "JSDocTypeLiteral";
+ SyntaxKind[SyntaxKind["JSDocSignature"] = 323] = "JSDocSignature";
+ SyntaxKind[SyntaxKind["JSDocLink"] = 324] = "JSDocLink";
+ SyntaxKind[SyntaxKind["JSDocLinkCode"] = 325] = "JSDocLinkCode";
+ SyntaxKind[SyntaxKind["JSDocLinkPlain"] = 326] = "JSDocLinkPlain";
+ SyntaxKind[SyntaxKind["JSDocTag"] = 327] = "JSDocTag";
+ SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 328] = "JSDocAugmentsTag";
+ SyntaxKind[SyntaxKind["JSDocImplementsTag"] = 329] = "JSDocImplementsTag";
+ SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 330] = "JSDocAuthorTag";
+ SyntaxKind[SyntaxKind["JSDocDeprecatedTag"] = 331] = "JSDocDeprecatedTag";
+ SyntaxKind[SyntaxKind["JSDocClassTag"] = 332] = "JSDocClassTag";
+ SyntaxKind[SyntaxKind["JSDocPublicTag"] = 333] = "JSDocPublicTag";
+ SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 334] = "JSDocPrivateTag";
+ SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 335] = "JSDocProtectedTag";
+ SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 336] = "JSDocReadonlyTag";
+ SyntaxKind[SyntaxKind["JSDocOverrideTag"] = 337] = "JSDocOverrideTag";
+ SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 338] = "JSDocCallbackTag";
+ SyntaxKind[SyntaxKind["JSDocEnumTag"] = 339] = "JSDocEnumTag";
+ SyntaxKind[SyntaxKind["JSDocParameterTag"] = 340] = "JSDocParameterTag";
+ SyntaxKind[SyntaxKind["JSDocReturnTag"] = 341] = "JSDocReturnTag";
+ SyntaxKind[SyntaxKind["JSDocThisTag"] = 342] = "JSDocThisTag";
+ SyntaxKind[SyntaxKind["JSDocTypeTag"] = 343] = "JSDocTypeTag";
+ SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 344] = "JSDocTemplateTag";
+ SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 345] = "JSDocTypedefTag";
+ SyntaxKind[SyntaxKind["JSDocSeeTag"] = 346] = "JSDocSeeTag";
+ SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 347] = "JSDocPropertyTag";
// Synthesized list
- SyntaxKind[SyntaxKind["SyntaxList"] = 346] = "SyntaxList";
+ SyntaxKind[SyntaxKind["SyntaxList"] = 348] = "SyntaxList";
// Transformation nodes
- SyntaxKind[SyntaxKind["NotEmittedStatement"] = 347] = "NotEmittedStatement";
- SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 348] = "PartiallyEmittedExpression";
- SyntaxKind[SyntaxKind["CommaListExpression"] = 349] = "CommaListExpression";
- SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 350] = "MergeDeclarationMarker";
- SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 351] = "EndOfDeclarationMarker";
- SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 352] = "SyntheticReferenceExpression";
+ SyntaxKind[SyntaxKind["NotEmittedStatement"] = 349] = "NotEmittedStatement";
+ SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 350] = "PartiallyEmittedExpression";
+ SyntaxKind[SyntaxKind["CommaListExpression"] = 351] = "CommaListExpression";
+ SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 352] = "MergeDeclarationMarker";
+ SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 353] = "EndOfDeclarationMarker";
+ SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 354] = "SyntheticReferenceExpression";
// Enum value count
- SyntaxKind[SyntaxKind["Count"] = 353] = "Count";
+ SyntaxKind[SyntaxKind["Count"] = 355] = "Count";
// Markers
SyntaxKind[SyntaxKind["FirstAssignment"] = 63] = "FirstAssignment";
SyntaxKind[SyntaxKind["LastAssignment"] = 78] = "LastAssignment";
@@ -4404,15 +4562,15 @@ var ts;
SyntaxKind[SyntaxKind["FirstReservedWord"] = 81] = "FirstReservedWord";
SyntaxKind[SyntaxKind["LastReservedWord"] = 116] = "LastReservedWord";
SyntaxKind[SyntaxKind["FirstKeyword"] = 81] = "FirstKeyword";
- SyntaxKind[SyntaxKind["LastKeyword"] = 159] = "LastKeyword";
+ SyntaxKind[SyntaxKind["LastKeyword"] = 160] = "LastKeyword";
SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 117] = "FirstFutureReservedWord";
SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 125] = "LastFutureReservedWord";
- SyntaxKind[SyntaxKind["FirstTypeNode"] = 176] = "FirstTypeNode";
- SyntaxKind[SyntaxKind["LastTypeNode"] = 199] = "LastTypeNode";
+ SyntaxKind[SyntaxKind["FirstTypeNode"] = 177] = "FirstTypeNode";
+ SyntaxKind[SyntaxKind["LastTypeNode"] = 200] = "LastTypeNode";
SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation";
SyntaxKind[SyntaxKind["LastPunctuation"] = 78] = "LastPunctuation";
SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken";
- SyntaxKind[SyntaxKind["LastToken"] = 159] = "LastToken";
+ SyntaxKind[SyntaxKind["LastToken"] = 160] = "LastToken";
SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken";
SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken";
SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken";
@@ -4421,15 +4579,16 @@ var ts;
SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken";
SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 29] = "FirstBinaryOperator";
SyntaxKind[SyntaxKind["LastBinaryOperator"] = 78] = "LastBinaryOperator";
- SyntaxKind[SyntaxKind["FirstStatement"] = 236] = "FirstStatement";
- SyntaxKind[SyntaxKind["LastStatement"] = 252] = "LastStatement";
- SyntaxKind[SyntaxKind["FirstNode"] = 160] = "FirstNode";
- SyntaxKind[SyntaxKind["FirstJSDocNode"] = 307] = "FirstJSDocNode";
- SyntaxKind[SyntaxKind["LastJSDocNode"] = 345] = "LastJSDocNode";
- SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 325] = "FirstJSDocTagNode";
- SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 345] = "LastJSDocTagNode";
+ SyntaxKind[SyntaxKind["FirstStatement"] = 237] = "FirstStatement";
+ SyntaxKind[SyntaxKind["LastStatement"] = 253] = "LastStatement";
+ SyntaxKind[SyntaxKind["FirstNode"] = 161] = "FirstNode";
+ SyntaxKind[SyntaxKind["FirstJSDocNode"] = 309] = "FirstJSDocNode";
+ SyntaxKind[SyntaxKind["LastJSDocNode"] = 347] = "LastJSDocNode";
+ SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 327] = "FirstJSDocTagNode";
+ SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 347] = "LastJSDocTagNode";
/* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 126] = "FirstContextualKeyword";
- /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 159] = "LastContextualKeyword";
+ /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 160] = "LastContextualKeyword";
+ SyntaxKind[SyntaxKind["JSDoc"] = 320] = "JSDoc";
})(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {}));
var NodeFlags;
(function (NodeFlags) {
@@ -4450,10 +4609,11 @@ var ts;
NodeFlags[NodeFlags["YieldContext"] = 8192] = "YieldContext";
NodeFlags[NodeFlags["DecoratorContext"] = 16384] = "DecoratorContext";
NodeFlags[NodeFlags["AwaitContext"] = 32768] = "AwaitContext";
- NodeFlags[NodeFlags["ThisNodeHasError"] = 65536] = "ThisNodeHasError";
- NodeFlags[NodeFlags["JavaScriptFile"] = 131072] = "JavaScriptFile";
- NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 262144] = "ThisNodeOrAnySubNodesHasError";
- NodeFlags[NodeFlags["HasAggregatedChildData"] = 524288] = "HasAggregatedChildData";
+ NodeFlags[NodeFlags["DisallowConditionalTypesContext"] = 65536] = "DisallowConditionalTypesContext";
+ NodeFlags[NodeFlags["ThisNodeHasError"] = 131072] = "ThisNodeHasError";
+ NodeFlags[NodeFlags["JavaScriptFile"] = 262144] = "JavaScriptFile";
+ NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 524288] = "ThisNodeOrAnySubNodesHasError";
+ NodeFlags[NodeFlags["HasAggregatedChildData"] = 1048576] = "HasAggregatedChildData";
// These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid
// walking the tree if the flags are not set. However, these flags are just a approximation
// (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared.
@@ -4463,25 +4623,25 @@ var ts;
// removal, it is likely that users will add the import anyway.
// The advantage of this approach is its simplicity. For the case of batch compilation,
// we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used.
- /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 1048576] = "PossiblyContainsDynamicImport";
- /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 2097152] = "PossiblyContainsImportMeta";
- NodeFlags[NodeFlags["JSDoc"] = 4194304] = "JSDoc";
- /* @internal */ NodeFlags[NodeFlags["Ambient"] = 8388608] = "Ambient";
- /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 16777216] = "InWithStatement";
- NodeFlags[NodeFlags["JsonFile"] = 33554432] = "JsonFile";
- /* @internal */ NodeFlags[NodeFlags["TypeCached"] = 67108864] = "TypeCached";
- /* @internal */ NodeFlags[NodeFlags["Deprecated"] = 134217728] = "Deprecated";
+ /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 2097152] = "PossiblyContainsDynamicImport";
+ /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 4194304] = "PossiblyContainsImportMeta";
+ NodeFlags[NodeFlags["JSDoc"] = 8388608] = "JSDoc";
+ /* @internal */ NodeFlags[NodeFlags["Ambient"] = 16777216] = "Ambient";
+ /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 33554432] = "InWithStatement";
+ NodeFlags[NodeFlags["JsonFile"] = 67108864] = "JsonFile";
+ /* @internal */ NodeFlags[NodeFlags["TypeCached"] = 134217728] = "TypeCached";
+ /* @internal */ NodeFlags[NodeFlags["Deprecated"] = 268435456] = "Deprecated";
NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped";
NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags";
NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags";
// Parsing context flags
- NodeFlags[NodeFlags["ContextFlags"] = 25358336] = "ContextFlags";
+ NodeFlags[NodeFlags["ContextFlags"] = 50720768] = "ContextFlags";
// Exclude these flags when parsing a Type
NodeFlags[NodeFlags["TypeExcludesFlags"] = 40960] = "TypeExcludesFlags";
// Represents all flags that are potentially set once and
// never cleared on SourceFiles which get re-used in between incremental parses.
// See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`.
- /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 3145728] = "PermanentlySetIncrementalFlags";
+ /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 6291456] = "PermanentlySetIncrementalFlags";
})(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {}));
var ModifierFlags;
(function (ModifierFlags) {
@@ -4500,14 +4660,16 @@ var ts;
ModifierFlags[ModifierFlags["HasComputedJSDocModifiers"] = 4096] = "HasComputedJSDocModifiers";
ModifierFlags[ModifierFlags["Deprecated"] = 8192] = "Deprecated";
ModifierFlags[ModifierFlags["Override"] = 16384] = "Override";
+ ModifierFlags[ModifierFlags["In"] = 32768] = "In";
+ ModifierFlags[ModifierFlags["Out"] = 65536] = "Out";
ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags";
ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier";
// Accessibility modifiers and 'readonly' can be attached to a parameter in a constructor to make it a property.
ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 16476] = "ParameterPropertyModifier";
ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier";
- ModifierFlags[ModifierFlags["TypeScriptModifier"] = 18654] = "TypeScriptModifier";
+ ModifierFlags[ModifierFlags["TypeScriptModifier"] = 116958] = "TypeScriptModifier";
ModifierFlags[ModifierFlags["ExportDefault"] = 513] = "ExportDefault";
- ModifierFlags[ModifierFlags["All"] = 27647] = "All";
+ ModifierFlags[ModifierFlags["All"] = 125951] = "All";
})(ModifierFlags = ts.ModifierFlags || (ts.ModifierFlags = {}));
var JsxFlags;
(function (JsxFlags) {
@@ -4692,7 +4854,6 @@ var ts;
NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
- NodeBuilderFlags[NodeBuilderFlags["NoUndefinedOptionalParameterType"] = 1073741824] = "NoUndefinedOptionalParameterType";
// Error handling
NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral";
NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier";
@@ -5087,33 +5248,33 @@ var ts;
ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties";
ObjectFlags[ObjectFlags["ReverseMapped"] = 1024] = "ReverseMapped";
ObjectFlags[ObjectFlags["JsxAttributes"] = 2048] = "JsxAttributes";
- ObjectFlags[ObjectFlags["MarkerType"] = 4096] = "MarkerType";
- ObjectFlags[ObjectFlags["JSLiteral"] = 8192] = "JSLiteral";
- ObjectFlags[ObjectFlags["FreshLiteral"] = 16384] = "FreshLiteral";
- ObjectFlags[ObjectFlags["ArrayLiteral"] = 32768] = "ArrayLiteral";
+ ObjectFlags[ObjectFlags["JSLiteral"] = 4096] = "JSLiteral";
+ ObjectFlags[ObjectFlags["FreshLiteral"] = 8192] = "FreshLiteral";
+ ObjectFlags[ObjectFlags["ArrayLiteral"] = 16384] = "ArrayLiteral";
/* @internal */
- ObjectFlags[ObjectFlags["PrimitiveUnion"] = 65536] = "PrimitiveUnion";
+ ObjectFlags[ObjectFlags["PrimitiveUnion"] = 32768] = "PrimitiveUnion";
/* @internal */
- ObjectFlags[ObjectFlags["ContainsWideningType"] = 131072] = "ContainsWideningType";
+ ObjectFlags[ObjectFlags["ContainsWideningType"] = 65536] = "ContainsWideningType";
/* @internal */
- ObjectFlags[ObjectFlags["ContainsObjectOrArrayLiteral"] = 262144] = "ContainsObjectOrArrayLiteral";
+ ObjectFlags[ObjectFlags["ContainsObjectOrArrayLiteral"] = 131072] = "ContainsObjectOrArrayLiteral";
/* @internal */
- ObjectFlags[ObjectFlags["NonInferrableType"] = 524288] = "NonInferrableType";
+ ObjectFlags[ObjectFlags["NonInferrableType"] = 262144] = "NonInferrableType";
/* @internal */
- ObjectFlags[ObjectFlags["CouldContainTypeVariablesComputed"] = 1048576] = "CouldContainTypeVariablesComputed";
+ ObjectFlags[ObjectFlags["CouldContainTypeVariablesComputed"] = 524288] = "CouldContainTypeVariablesComputed";
/* @internal */
- ObjectFlags[ObjectFlags["CouldContainTypeVariables"] = 2097152] = "CouldContainTypeVariables";
+ ObjectFlags[ObjectFlags["CouldContainTypeVariables"] = 1048576] = "CouldContainTypeVariables";
ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface";
/* @internal */
- ObjectFlags[ObjectFlags["RequiresWidening"] = 393216] = "RequiresWidening";
+ ObjectFlags[ObjectFlags["RequiresWidening"] = 196608] = "RequiresWidening";
/* @internal */
- ObjectFlags[ObjectFlags["PropagatingFlags"] = 917504] = "PropagatingFlags";
+ ObjectFlags[ObjectFlags["PropagatingFlags"] = 458752] = "PropagatingFlags";
// Object flags that uniquely identify the kind of ObjectType
/* @internal */
ObjectFlags[ObjectFlags["ObjectTypeKindMask"] = 1343] = "ObjectTypeKindMask";
// Flags that require TypeFlags.Object
- ObjectFlags[ObjectFlags["ContainsSpread"] = 4194304] = "ContainsSpread";
- ObjectFlags[ObjectFlags["ObjectRestType"] = 8388608] = "ObjectRestType";
+ ObjectFlags[ObjectFlags["ContainsSpread"] = 2097152] = "ContainsSpread";
+ ObjectFlags[ObjectFlags["ObjectRestType"] = 4194304] = "ObjectRestType";
+ ObjectFlags[ObjectFlags["InstantiationExpressionType"] = 8388608] = "InstantiationExpressionType";
/* @internal */
ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 16777216] = "IsClassInstanceClone";
// Flags that require TypeFlags.Object and ObjectFlags.Reference
@@ -5123,21 +5284,21 @@ var ts;
ObjectFlags[ObjectFlags["IdenticalBaseTypeExists"] = 67108864] = "IdenticalBaseTypeExists";
// Flags that require TypeFlags.UnionOrIntersection or TypeFlags.Substitution
/* @internal */
- ObjectFlags[ObjectFlags["IsGenericTypeComputed"] = 4194304] = "IsGenericTypeComputed";
+ ObjectFlags[ObjectFlags["IsGenericTypeComputed"] = 2097152] = "IsGenericTypeComputed";
/* @internal */
- ObjectFlags[ObjectFlags["IsGenericObjectType"] = 8388608] = "IsGenericObjectType";
+ ObjectFlags[ObjectFlags["IsGenericObjectType"] = 4194304] = "IsGenericObjectType";
/* @internal */
- ObjectFlags[ObjectFlags["IsGenericIndexType"] = 16777216] = "IsGenericIndexType";
+ ObjectFlags[ObjectFlags["IsGenericIndexType"] = 8388608] = "IsGenericIndexType";
/* @internal */
- ObjectFlags[ObjectFlags["IsGenericType"] = 25165824] = "IsGenericType";
+ ObjectFlags[ObjectFlags["IsGenericType"] = 12582912] = "IsGenericType";
// Flags that require TypeFlags.Union
/* @internal */
- ObjectFlags[ObjectFlags["ContainsIntersections"] = 33554432] = "ContainsIntersections";
+ ObjectFlags[ObjectFlags["ContainsIntersections"] = 16777216] = "ContainsIntersections";
// Flags that require TypeFlags.Intersection
/* @internal */
- ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 33554432] = "IsNeverIntersectionComputed";
+ ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 16777216] = "IsNeverIntersectionComputed";
/* @internal */
- ObjectFlags[ObjectFlags["IsNeverIntersection"] = 67108864] = "IsNeverIntersection";
+ ObjectFlags[ObjectFlags["IsNeverIntersection"] = 33554432] = "IsNeverIntersection";
})(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {}));
/* @internal */
var VarianceFlags;
@@ -5309,12 +5470,28 @@ var ts;
ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic";
ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs";
// Starting with node12, node's module resolver has significant departures from traditional cjs resolution
- // to better support ecmascript modules and their use within node - more features are still being added, so
- // we can expect it to change over time, and as such, offer both a `NodeNext` moving resolution target, and a `Node12`
- // version-anchored resolution target
- ModuleResolutionKind[ModuleResolutionKind["Node12"] = 3] = "Node12";
+ // to better support ecmascript modules and their use within node - however more features are still being added.
+ // TypeScript's Node ESM support was introduced after Node 12 went end-of-life, and Node 14 is the earliest stable
+ // version that supports both pattern trailers - *but*, Node 16 is the first version that also supports ECMASCript 2022.
+ // In turn, we offer both a `NodeNext` moving resolution target, and a `Node16` version-anchored resolution target
+ ModuleResolutionKind[ModuleResolutionKind["Node16"] = 3] = "Node16";
ModuleResolutionKind[ModuleResolutionKind["NodeNext"] = 99] = "NodeNext";
})(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {}));
+ var ModuleDetectionKind;
+ (function (ModuleDetectionKind) {
+ /**
+ * Files with imports, exports and/or import.meta are considered modules
+ */
+ ModuleDetectionKind[ModuleDetectionKind["Legacy"] = 1] = "Legacy";
+ /**
+ * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node16+
+ */
+ ModuleDetectionKind[ModuleDetectionKind["Auto"] = 2] = "Auto";
+ /**
+ * Consider all non-declaration files modules, regardless of present syntax
+ */
+ ModuleDetectionKind[ModuleDetectionKind["Force"] = 3] = "Force";
+ })(ModuleDetectionKind = ts.ModuleDetectionKind || (ts.ModuleDetectionKind = {}));
var WatchFileKind;
(function (WatchFileKind) {
WatchFileKind[WatchFileKind["FixedPollingInterval"] = 0] = "FixedPollingInterval";
@@ -5352,8 +5529,8 @@ var ts;
ModuleKind[ModuleKind["ES2020"] = 6] = "ES2020";
ModuleKind[ModuleKind["ES2022"] = 7] = "ES2022";
ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext";
- // Node12+ is an amalgam of commonjs (albeit updated) and es2020+, and represents a distinct module system from es2020/esnext
- ModuleKind[ModuleKind["Node12"] = 100] = "Node12";
+ // Node16+ is an amalgam of commonjs (albeit updated) and es2022+, and represents a distinct module system from es2020/esnext
+ ModuleKind[ModuleKind["Node16"] = 100] = "Node16";
ModuleKind[ModuleKind["NodeNext"] = 199] = "NodeNext";
})(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {}));
var JsxEmit;
@@ -5768,6 +5945,8 @@ var ts;
BundleFileSectionKind["NoDefaultLib"] = "no-default-lib";
BundleFileSectionKind["Reference"] = "reference";
BundleFileSectionKind["Type"] = "type";
+ BundleFileSectionKind["TypeResolutionModeRequire"] = "type-require";
+ BundleFileSectionKind["TypeResolutionModeImport"] = "type-import";
BundleFileSectionKind["Lib"] = "lib";
BundleFileSectionKind["Prepend"] = "prepend";
BundleFileSectionKind["Text"] = "text";
@@ -5884,39 +6063,40 @@ var ts;
{ name: "types", optional: true, captureSpan: true },
{ name: "lib", optional: true, captureSpan: true },
{ name: "path", optional: true, captureSpan: true },
- { name: "no-default-lib", optional: true }
+ { name: "no-default-lib", optional: true },
+ { name: "resolution-mode", optional: true }
],
- kind: 1 /* TripleSlashXML */
+ kind: 1 /* PragmaKindFlags.TripleSlashXML */
},
"amd-dependency": {
args: [{ name: "path" }, { name: "name", optional: true }],
- kind: 1 /* TripleSlashXML */
+ kind: 1 /* PragmaKindFlags.TripleSlashXML */
},
"amd-module": {
args: [{ name: "name" }],
- kind: 1 /* TripleSlashXML */
+ kind: 1 /* PragmaKindFlags.TripleSlashXML */
},
"ts-check": {
- kind: 2 /* SingleLine */
+ kind: 2 /* PragmaKindFlags.SingleLine */
},
"ts-nocheck": {
- kind: 2 /* SingleLine */
+ kind: 2 /* PragmaKindFlags.SingleLine */
},
"jsx": {
args: [{ name: "factory" }],
- kind: 4 /* MultiLine */
+ kind: 4 /* PragmaKindFlags.MultiLine */
},
"jsxfrag": {
args: [{ name: "factory" }],
- kind: 4 /* MultiLine */
+ kind: 4 /* PragmaKindFlags.MultiLine */
},
"jsximportsource": {
args: [{ name: "factory" }],
- kind: 4 /* MultiLine */
+ kind: 4 /* PragmaKindFlags.MultiLine */
},
"jsxruntime": {
args: [{ name: "factory" }],
- kind: 4 /* MultiLine */
+ kind: 4 /* PragmaKindFlags.MultiLine */
},
};
})(ts || (ts = {}));
@@ -6205,7 +6385,7 @@ var ts;
};
}
function createDirectoryWatcher(dirName, dirPath, fallbackOptions) {
- var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName) {
+ var watcher = fsWatch(dirName, 1 /* FileSystemEntryKind.Directory */, function (_eventName, relativeFileName) {
// When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined"
if (!ts.isString(relativeFileName))
return;
@@ -6509,7 +6689,7 @@ var ts;
var childFullName = ts.getNormalizedAbsolutePath(child, parentDir);
// Filter our the symbolic link directories since those arent included in recursive watch
// which is same behaviour when recursive: true is passed to fs.watch
- return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* EqualTo */ ? childFullName : undefined;
+ return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* Comparison.EqualTo */ ? childFullName : undefined;
}) : ts.emptyArray, parentWatcher.childWatches, function (child, childWatcher) { return filePathComparer(child, childWatcher.dirName); }, createAndAddChildDirectoryWatcher, ts.closeFileWatcher, addChildDirectoryWatcher);
parentWatcher.childWatches = newChildWatches || ts.emptyArray;
return hasChanges;
@@ -6604,7 +6784,7 @@ var ts;
case ts.WatchFileKind.FixedChunkSizePolling:
return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined);
case ts.WatchFileKind.UseFsEvents:
- return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists),
+ return fsWatch(fileName, 0 /* FileSystemEntryKind.File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists),
/*recursive*/ false, pollingInterval, ts.getFallbackOptions(options));
case ts.WatchFileKind.UseFsEventsOnParentDirectory:
if (!nonPollingWatchFile) {
@@ -6659,7 +6839,7 @@ var ts;
}
function watchDirectory(directoryName, callback, recursive, options) {
if (fsSupportsRecursiveFsWatch) {
- return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options));
+ return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options));
}
if (!hostRecursiveDirectoryWatcher) {
hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({
@@ -6691,7 +6871,7 @@ var ts;
/* pollingInterval */ undefined,
/*options*/ undefined);
case ts.WatchDirectoryKind.UseFsEvents:
- return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions));
+ return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions));
default:
ts.Debug.assertNever(watchDirectoryKind);
}
@@ -7265,8 +7445,8 @@ var ts;
return false;
}
switch (entryKind) {
- case 0 /* File */: return stat.isFile();
- case 1 /* Directory */: return stat.isDirectory();
+ case 0 /* FileSystemEntryKind.File */: return stat.isFile();
+ case 1 /* FileSystemEntryKind.Directory */: return stat.isDirectory();
default: return false;
}
}
@@ -7278,10 +7458,10 @@ var ts;
}
}
function fileExists(path) {
- return fileSystemEntryExists(path, 0 /* File */);
+ return fileSystemEntryExists(path, 0 /* FileSystemEntryKind.File */);
}
function directoryExists(path) {
- return fileSystemEntryExists(path, 1 /* Directory */);
+ return fileSystemEntryExists(path, 1 /* FileSystemEntryKind.Directory */);
}
function getDirectories(path) {
return getAccessibleFileSystemEntries(path).directories.slice();
@@ -7345,8 +7525,8 @@ var ts;
if (ts.sys && ts.sys.getEnvironmentVariable) {
setCustomPollingValues(ts.sys);
ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))
- ? 1 /* Normal */
- : 0 /* None */);
+ ? 1 /* AssertionLevel.Normal */
+ : 0 /* AssertionLevel.None */);
}
if (ts.sys && ts.sys.debugMode) {
ts.Debug.isDebugging = true;
@@ -7369,7 +7549,7 @@ var ts;
* Determines whether a charCode corresponds to `/` or `\`.
*/
function isAnyDirectorySeparator(charCode) {
- return charCode === 47 /* slash */ || charCode === 92 /* backslash */;
+ return charCode === 47 /* CharacterCodes.slash */ || charCode === 92 /* CharacterCodes.backslash */;
}
ts.isAnyDirectorySeparator = isAnyDirectorySeparator;
/**
@@ -7456,16 +7636,16 @@ var ts;
ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator;
//// Path Parsing
function isVolumeCharacter(charCode) {
- return (charCode >= 97 /* a */ && charCode <= 122 /* z */) ||
- (charCode >= 65 /* A */ && charCode <= 90 /* Z */);
+ return (charCode >= 97 /* CharacterCodes.a */ && charCode <= 122 /* CharacterCodes.z */) ||
+ (charCode >= 65 /* CharacterCodes.A */ && charCode <= 90 /* CharacterCodes.Z */);
}
function getFileUrlVolumeSeparatorEnd(url, start) {
var ch0 = url.charCodeAt(start);
- if (ch0 === 58 /* colon */)
+ if (ch0 === 58 /* CharacterCodes.colon */)
return start + 1;
- if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) {
+ if (ch0 === 37 /* CharacterCodes.percent */ && url.charCodeAt(start + 1) === 51 /* CharacterCodes._3 */) {
var ch2 = url.charCodeAt(start + 2);
- if (ch2 === 97 /* a */ || ch2 === 65 /* A */)
+ if (ch2 === 97 /* CharacterCodes.a */ || ch2 === 65 /* CharacterCodes.A */)
return start + 3;
}
return -1;
@@ -7479,18 +7659,18 @@ var ts;
return 0;
var ch0 = path.charCodeAt(0);
// POSIX or UNC
- if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) {
+ if (ch0 === 47 /* CharacterCodes.slash */ || ch0 === 92 /* CharacterCodes.backslash */) {
if (path.charCodeAt(1) !== ch0)
return 1; // POSIX: "/" (or non-normalized "\")
- var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2);
+ var p1 = path.indexOf(ch0 === 47 /* CharacterCodes.slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2);
if (p1 < 0)
return path.length; // UNC: "//server" or "\\server"
return p1 + 1; // UNC: "//server/" or "\\server\"
}
// DOS
- if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) {
+ if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* CharacterCodes.colon */) {
var ch2 = path.charCodeAt(2);
- if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */)
+ if (ch2 === 47 /* CharacterCodes.slash */ || ch2 === 92 /* CharacterCodes.backslash */)
return 3; // DOS: "c:/" or "c:\"
if (path.length === 2)
return 2; // DOS: "c:" (but not "c:d")
@@ -7510,7 +7690,7 @@ var ts;
isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
if (volumeSeparatorEnd !== -1) {
- if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) {
+ if (path.charCodeAt(volumeSeparatorEnd) === 47 /* CharacterCodes.slash */) {
// URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/"
return ~(volumeSeparatorEnd + 1);
}
@@ -7587,7 +7767,7 @@ var ts;
function tryGetExtensionFromPath(path, extension, stringEqualityComparer) {
if (!ts.startsWith(extension, "."))
extension = "." + extension;
- if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) {
+ if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* CharacterCodes.dot */) {
var pathExtension = path.slice(path.length - extension.length);
if (stringEqualityComparer(pathExtension, extension)) {
return pathExtension;
@@ -7832,18 +8012,6 @@ var ts;
return getCanonicalFileName(nonCanonicalizedPath);
}
ts.toPath = toPath;
- function normalizePathAndParts(path) {
- path = normalizeSlashes(path);
- var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
- if (parts.length) {
- var joinedParts = root + parts.join(ts.directorySeparator);
- return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
- }
- else {
- return { path: root, parts: parts };
- }
- }
- ts.normalizePathAndParts = normalizePathAndParts;
function removeTrailingDirectorySeparator(path) {
if (hasTrailingDirectorySeparator(path)) {
return path.substr(0, path.length - 1);
@@ -7883,17 +8051,17 @@ var ts;
var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/;
function comparePathsWorker(a, b, componentComparer) {
if (a === b)
- return 0 /* EqualTo */;
+ return 0 /* Comparison.EqualTo */;
if (a === undefined)
- return -1 /* LessThan */;
+ return -1 /* Comparison.LessThan */;
if (b === undefined)
- return 1 /* GreaterThan */;
+ return 1 /* Comparison.GreaterThan */;
// NOTE: Performance optimization - shortcut if the root segments differ as there would be no
// need to perform path reduction.
var aRoot = a.substring(0, getRootLength(a));
var bRoot = b.substring(0, getRootLength(b));
var result = ts.compareStringsCaseInsensitive(aRoot, bRoot);
- if (result !== 0 /* EqualTo */) {
+ if (result !== 0 /* Comparison.EqualTo */) {
return result;
}
// NOTE: Performance optimization - shortcut if there are no relative path segments in
@@ -7910,7 +8078,7 @@ var ts;
var sharedLength = Math.min(aComponents.length, bComponents.length);
for (var i = 1; i < sharedLength; i++) {
var result_2 = componentComparer(aComponents[i], bComponents[i]);
- if (result_2 !== 0 /* EqualTo */) {
+ if (result_2 !== 0 /* Comparison.EqualTo */) {
return result_2;
}
}
@@ -8063,7 +8231,7 @@ var ts;
Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."),
_0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."),
A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."),
- The_parser_expected_to_find_a_to_match_the_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_to_match_the_token_here_1007", "The parser expected to find a '}' to match the '{' token here."),
+ The_parser_expected_to_find_a_1_to_match_the_0_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_1_to_match_the_0_token_here_1007", "The parser expected to find a '{1}' to match the '{0}' token here."),
Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."),
Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."),
An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."),
@@ -8279,8 +8447,12 @@ var ts;
Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided: diag(1269, ts.DiagnosticCategory.Error, "Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided_1269", "Cannot use 'export import' on a type or type-only namespace when the '--isolatedModules' flag is provided."),
Decorator_function_return_type_0_is_not_assignable_to_type_1: diag(1270, ts.DiagnosticCategory.Error, "Decorator_function_return_type_0_is_not_assignable_to_type_1_1270", "Decorator function return type '{0}' is not assignable to type '{1}'."),
Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any: diag(1271, ts.DiagnosticCategory.Error, "Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any_1271", "Decorator function return type is '{0}' but is expected to be 'void' or 'any'."),
+ A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled: diag(1272, ts.DiagnosticCategory.Error, "A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_w_1272", "A type referenced in a decorated signature must be imported with 'import type' or a namespace import when 'isolatedModules' and 'emitDecoratorMetadata' are enabled."),
+ _0_modifier_cannot_appear_on_a_type_parameter: diag(1273, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_parameter_1273", "'{0}' modifier cannot appear on a type parameter"),
+ _0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias: diag(1274, ts.DiagnosticCategory.Error, "_0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias_1274", "'{0}' modifier can only appear on a type parameter of a class, interface or type alias"),
with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
+ The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level: diag(1309, ts.DiagnosticCategory.Error, "The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level_1309", "The current file is a CommonJS module and cannot use 'await' at the top level."),
Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."),
The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."),
Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."),
@@ -8292,10 +8464,10 @@ var ts;
Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."),
Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."),
Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."),
- Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'."),
- Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'."),
+ Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'."),
+ Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nodenext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nod_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'."),
Argument_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Argument_of_dynamic_import_cannot_be_spread_element_1325", "Argument of dynamic import cannot be spread element."),
- Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."),
+ This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326", "This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments."),
String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."),
Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."),
_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"),
@@ -8310,7 +8482,7 @@ var ts;
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}')'?"),
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_node12_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', 'node12', or 'nodenext'."),
+ 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."),
An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness."),
This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."),
@@ -8341,13 +8513,12 @@ var ts;
await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1375, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_fi_1375", "'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."),
_0_was_imported_here: diag(1376, ts.DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."),
_0_was_exported_here: diag(1377, ts.DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."),
- Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."),
+ Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_n_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher."),
An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379", "An import alias cannot reference a declaration that was exported using 'export type'."),
An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."),
Unexpected_token_Did_you_mean_or_rbrace: diag(1381, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_rbrace_1381", "Unexpected token. Did you mean `{'}'}` or `&rbrace;`?"),
Unexpected_token_Did_you_mean_or_gt: diag(1382, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_gt_1382", "Unexpected token. Did you mean `{'>'}` or `&gt;`?"),
Only_named_exports_may_use_export_type: diag(1383, ts.DiagnosticCategory.Error, "Only_named_exports_may_use_export_type_1383", "Only named exports may use 'export type'."),
- A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list: diag(1384, ts.DiagnosticCategory.Error, "A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list_1384", "A 'new' expression with type arguments must always be followed by a parenthesized argument list."),
Function_type_notation_must_be_parenthesized_when_used_in_a_union_type: diag(1385, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_a_union_type_1385", "Function type notation must be parenthesized when used in a union type."),
Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type: diag(1386, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type_1386", "Constructor type notation must be parenthesized when used in a union type."),
Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1387, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1387", "Function type notation must be parenthesized when used in an intersection type."),
@@ -8394,7 +8565,7 @@ var ts;
File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"),
The_file_is_in_the_program_because_Colon: diag(1430, ts.DiagnosticCategory.Message, "The_file_is_in_the_program_because_Colon_1430", "The file is in the program because:"),
for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1431, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_1431", "'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."),
- Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."),
+ Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_nod_1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher."),
Decorators_may_not_be_applied_to_this_parameters: diag(1433, ts.DiagnosticCategory.Error, "Decorators_may_not_be_applied_to_this_parameters_1433", "Decorators may not be applied to 'this' parameters."),
Unexpected_keyword_or_identifier: diag(1434, ts.DiagnosticCategory.Error, "Unexpected_keyword_or_identifier_1434", "Unexpected keyword or identifier."),
Unknown_keyword_or_identifier_Did_you_mean_0: diag(1435, ts.DiagnosticCategory.Error, "Unknown_keyword_or_identifier_Did_you_mean_0_1435", "Unknown keyword or identifier. Did you mean '{0}'?"),
@@ -8412,11 +8583,18 @@ var ts;
Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed: diag(1449, ts.DiagnosticCategory.Message, "Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed_1449", "Preserve unused imported values in the JavaScript output that would otherwise be removed."),
Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments: diag(1450, ts.DiagnosticCategory.Message, "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450", "Dynamic imports can only accept a module specifier and an optional assertion as arguments"),
Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"),
+ Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext_1452", "Resolution modes are only supported when `moduleResolution` is `node16` or `nodenext`."),
+ resolution_mode_should_be_either_require_or_import: diag(1453, ts.DiagnosticCategory.Error, "resolution_mode_should_be_either_require_or_import_1453", "`resolution-mode` should be either `require` or `import`."),
+ 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`."),
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."),
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."),
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.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
@@ -8425,6 +8603,8 @@ 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}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ 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."),
+ 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."),
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."),
@@ -8675,7 +8855,6 @@ var ts;
A_rest_element_cannot_have_a_property_name: diag(2566, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_a_property_name_2566", "A rest element cannot have a property name."),
Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations: diag(2567, ts.DiagnosticCategory.Error, "Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations_2567", "Enum declarations can only merge with namespace or other enum declarations."),
Property_0_may_not_exist_on_type_1_Did_you_mean_2: diag(2568, ts.DiagnosticCategory.Error, "Property_0_may_not_exist_on_type_1_Did_you_mean_2_2568", "Property '{0}' may not exist on type '{1}'. Did you mean '{2}'?"),
- Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2569, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569", "Type '{0}' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators."),
Could_not_find_name_0_Did_you_mean_1: diag(2570, ts.DiagnosticCategory.Error, "Could_not_find_name_0_Did_you_mean_1_2570", "Could not find name '{0}'. Did you mean '{1}'?"),
Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."),
A_rest_element_type_must_be_an_array_type: diag(2574, ts.DiagnosticCategory.Error, "A_rest_element_type_must_be_an_array_type_2574", "A rest element type must be an array type."),
@@ -8731,6 +8910,9 @@ var ts;
Cannot_assign_to_0_because_it_is_an_import: diag(2632, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_import_2632", "Cannot assign to '{0}' because it is an import."),
JSX_property_access_expressions_cannot_include_JSX_namespace_names: diag(2633, ts.DiagnosticCategory.Error, "JSX_property_access_expressions_cannot_include_JSX_namespace_names_2633", "JSX property access expressions cannot include JSX namespace names"),
_0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."),
+ Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable: diag(2635, ts.DiagnosticCategory.Error, "Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable_2635", "Type '{0}' has no signatures for which the type argument list is applicable."),
+ Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation: diag(2636, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation_2636", "Type '{0}' is not assignable to type '{1}' as implied by variance annotation."),
+ Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types: diag(2637, ts.DiagnosticCategory.Error, "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637", "Variance annotations are only supported in type aliases for object, function, constructor, and mapped types."),
Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."),
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."),
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."),
@@ -8886,6 +9068,7 @@ var ts;
This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."),
A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"),
Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."),
+ Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments: diag(2810, ts.DiagnosticCategory.Error, "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810", "Expected 1 argument, but got 0. 'new Promise()' needs a JSDoc hint to produce a 'resolve' that can be called without arguments."),
Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"),
Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."),
Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."),
@@ -8899,10 +9082,11 @@ var ts;
Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext: diag(2821, ts.DiagnosticCategory.Error, "Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext_2821", "Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'."),
Import_assertions_cannot_be_used_with_type_only_imports_or_exports: diag(2822, ts.DiagnosticCategory.Error, "Import_assertions_cannot_be_used_with_type_only_imports_or_exports_2822", "Import assertions cannot be used with type-only imports or exports."),
Cannot_find_namespace_0_Did_you_mean_1: diag(2833, ts.DiagnosticCategory.Error, "Cannot_find_namespace_0_Did_you_mean_1_2833", "Cannot find namespace '{0}'. Did you mean '{1}'?"),
- Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path."),
- Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{0}'?"),
+ Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path."),
+ Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '{0}'?"),
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."),
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}'."),
@@ -9010,6 +9194,7 @@ var ts;
This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0: diag(4122, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4122", "This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class '{0}'."),
This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4123, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4123", "This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class '{0}'. Did you mean '{1}'?"),
Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4124, ts.DiagnosticCategory.Error, "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124", "Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
+ Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4125, ts.DiagnosticCategory.Error, "Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_wi_4125", "Resolution mode assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."),
Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."),
File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."),
@@ -9220,7 +9405,6 @@ var ts;
Command_line_Options: diag(6171, ts.DiagnosticCategory.Message, "Command_line_Options_6171", "Command-line Options"),
Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3: diag(6179, ts.DiagnosticCategory.Message, "Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3_6179", "Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'."),
Enable_all_strict_type_checking_options: diag(6180, ts.DiagnosticCategory.Message, "Enable_all_strict_type_checking_options_6180", "Enable all strict type-checking options."),
- List_of_language_service_plugins: diag(6181, ts.DiagnosticCategory.Message, "List_of_language_service_plugins_6181", "List of language service plugins."),
Scoped_package_detected_looking_in_0: diag(6182, ts.DiagnosticCategory.Message, "Scoped_package_detected_looking_in_0_6182", "Scoped package detected, looking in '{0}'"),
Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2: diag(6183, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_6183", "Reusing resolution of module '{0}' from '{1}' of old program, it was successfully resolved to '{2}'."),
Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3: diag(6184, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package__6184", "Reusing resolution of module '{0}' from '{1}' of old program, it was successfully resolved to '{2}' with Package ID '{3}'."),
@@ -9327,7 +9511,7 @@ var ts;
Skipping_build_of_project_0_because_its_dependency_1_has_errors: diag(6362, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_has_errors_6362", "Skipping build of project '{0}' because its dependency '{1}' has errors"),
Project_0_can_t_be_built_because_its_dependency_1_has_errors: diag(6363, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_has_errors_6363", "Project '{0}' can't be built because its dependency '{1}' has errors"),
Build_one_or_more_projects_and_their_dependencies_if_out_of_date: diag(6364, ts.DiagnosticCategory.Message, "Build_one_or_more_projects_and_their_dependencies_if_out_of_date_6364", "Build one or more projects and their dependencies, if out of date"),
- Delete_the_outputs_of_all_projects: diag(6365, ts.DiagnosticCategory.Message, "Delete_the_outputs_of_all_projects_6365", "Delete the outputs of all projects"),
+ Delete_the_outputs_of_all_projects: diag(6365, ts.DiagnosticCategory.Message, "Delete_the_outputs_of_all_projects_6365", "Delete the outputs of all projects."),
Show_what_would_be_built_or_deleted_if_specified_with_clean: diag(6367, ts.DiagnosticCategory.Message, "Show_what_would_be_built_or_deleted_if_specified_with_clean_6367", "Show what would be built (or deleted, if specified with '--clean')"),
Option_build_must_be_the_first_command_line_argument: diag(6369, ts.DiagnosticCategory.Error, "Option_build_must_be_the_first_command_line_argument_6369", "Option '--build' must be the first command line argument."),
Options_0_and_1_cannot_be_combined: diag(6370, ts.DiagnosticCategory.Error, "Options_0_and_1_cannot_be_combined_6370", "Options '{0}' and '{1}' cannot be combined."),
@@ -9338,7 +9522,6 @@ var ts;
A_non_dry_build_would_update_output_of_project_0: diag(6375, ts.DiagnosticCategory.Message, "A_non_dry_build_would_update_output_of_project_0_6375", "A non-dry build would update output of project '{0}'"),
Cannot_update_output_of_project_0_because_there_was_error_reading_file_1: diag(6376, ts.DiagnosticCategory.Message, "Cannot_update_output_of_project_0_because_there_was_error_reading_file_1_6376", "Cannot update output of project '{0}' because there was error reading file '{1}'"),
Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1: diag(6377, ts.DiagnosticCategory.Error, "Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1_6377", "Cannot write file '{0}' because it will overwrite '.tsbuildinfo' file generated by referenced project '{1}'"),
- Enable_incremental_compilation: diag(6378, ts.DiagnosticCategory.Message, "Enable_incremental_compilation_6378", "Enable incremental compilation"),
Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."),
Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"),
Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2: diag(6381, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381", "Project '{0}' is out of date because output for it was generated with version '{1}' that differs with current version '{2}'"),
@@ -9366,13 +9549,13 @@ var ts;
File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option: diag(6504, ts.DiagnosticCategory.Error, "File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option_6504", "File '{0}' is a JavaScript file. Did you mean to enable the 'allowJs' option?"),
Print_names_of_files_and_the_reason_they_are_part_of_the_compilation: diag(6505, ts.DiagnosticCategory.Message, "Print_names_of_files_and_the_reason_they_are_part_of_the_compilation_6505", "Print names of files and the reason they are part of the compilation."),
Consider_adding_a_declare_modifier_to_this_class: diag(6506, ts.DiagnosticCategory.Message, "Consider_adding_a_declare_modifier_to_this_class_6506", "Consider adding a 'declare' modifier to this class."),
- Allow_JavaScript_files_to_be_a_part_of_your_program_Use_the_checkJS_option_to_get_errors_from_these_files: diag(6600, ts.DiagnosticCategory.Message, "Allow_JavaScript_files_to_be_a_part_of_your_program_Use_the_checkJS_option_to_get_errors_from_these__6600", "Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files."),
+ Allow_JavaScript_files_to_be_a_part_of_your_program_Use_the_checkJS_option_to_get_errors_from_these_files: diag(6600, ts.DiagnosticCategory.Message, "Allow_JavaScript_files_to_be_a_part_of_your_program_Use_the_checkJS_option_to_get_errors_from_these__6600", "Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files."),
Allow_import_x_from_y_when_a_module_doesn_t_have_a_default_export: diag(6601, ts.DiagnosticCategory.Message, "Allow_import_x_from_y_when_a_module_doesn_t_have_a_default_export_6601", "Allow 'import x from y' when a module doesn't have a default export."),
Allow_accessing_UMD_globals_from_modules: diag(6602, ts.DiagnosticCategory.Message, "Allow_accessing_UMD_globals_from_modules_6602", "Allow accessing UMD globals from modules."),
Disable_error_reporting_for_unreachable_code: diag(6603, ts.DiagnosticCategory.Message, "Disable_error_reporting_for_unreachable_code_6603", "Disable error reporting for unreachable code."),
Disable_error_reporting_for_unused_labels: diag(6604, ts.DiagnosticCategory.Message, "Disable_error_reporting_for_unused_labels_6604", "Disable error reporting for unused labels."),
Ensure_use_strict_is_always_emitted: diag(6605, ts.DiagnosticCategory.Message, "Ensure_use_strict_is_always_emitted_6605", "Ensure 'use strict' is always emitted."),
- Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it: diag(6606, ts.DiagnosticCategory.Message, "Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_wi_6606", "Have recompiles in projects that use `incremental` and `watch` mode assume that changes within a file will only affect files directly depending on it."),
+ Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it: diag(6606, ts.DiagnosticCategory.Message, "Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_wi_6606", "Have recompiles in projects that use 'incremental' and 'watch' mode assume that changes within a file will only affect files directly depending on it."),
Specify_the_base_directory_to_resolve_non_relative_module_names: diag(6607, ts.DiagnosticCategory.Message, "Specify_the_base_directory_to_resolve_non_relative_module_names_6607", "Specify the base directory to resolve non-relative module names."),
No_longer_supported_In_early_versions_manually_set_the_text_encoding_for_reading_files: diag(6608, ts.DiagnosticCategory.Message, "No_longer_supported_In_early_versions_manually_set_the_text_encoding_for_reading_files_6608", "No longer supported. In early versions, manually set the text encoding for reading files."),
Enable_error_reporting_in_type_checked_JavaScript_files: diag(6609, ts.DiagnosticCategory.Message, "Enable_error_reporting_in_type_checked_JavaScript_files_6609", "Enable error reporting in type-checked JavaScript files."),
@@ -9385,13 +9568,13 @@ var ts;
Reduce_the_number_of_projects_loaded_automatically_by_TypeScript: diag(6617, ts.DiagnosticCategory.Message, "Reduce_the_number_of_projects_loaded_automatically_by_TypeScript_6617", "Reduce the number of projects loaded automatically by TypeScript."),
Remove_the_20mb_cap_on_total_source_code_size_for_JavaScript_files_in_the_TypeScript_language_server: diag(6618, ts.DiagnosticCategory.Message, "Remove_the_20mb_cap_on_total_source_code_size_for_JavaScript_files_in_the_TypeScript_language_server_6618", "Remove the 20mb cap on total source code size for JavaScript files in the TypeScript language server."),
Opt_a_project_out_of_multi_project_reference_checking_when_editing: diag(6619, ts.DiagnosticCategory.Message, "Opt_a_project_out_of_multi_project_reference_checking_when_editing_6619", "Opt a project out of multi-project reference checking when editing."),
- Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects: diag(6620, ts.DiagnosticCategory.Message, "Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects_6620", "Disable preferring source files instead of declaration files when referencing composite projects"),
+ Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects: diag(6620, ts.DiagnosticCategory.Message, "Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects_6620", "Disable preferring source files instead of declaration files when referencing composite projects."),
Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration: diag(6621, ts.DiagnosticCategory.Message, "Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration_6621", "Emit more compliant, but verbose and less performant JavaScript for iteration."),
Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files: diag(6622, ts.DiagnosticCategory.Message, "Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files_6622", "Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files."),
Only_output_d_ts_files_and_not_JavaScript_files: diag(6623, ts.DiagnosticCategory.Message, "Only_output_d_ts_files_and_not_JavaScript_files_6623", "Only output d.ts files and not JavaScript files."),
Emit_design_type_metadata_for_decorated_declarations_in_source_files: diag(6624, ts.DiagnosticCategory.Message, "Emit_design_type_metadata_for_decorated_declarations_in_source_files_6624", "Emit design-type metadata for decorated declarations in source files."),
Disable_the_type_acquisition_for_JavaScript_projects: diag(6625, ts.DiagnosticCategory.Message, "Disable_the_type_acquisition_for_JavaScript_projects_6625", "Disable the type acquisition for JavaScript projects"),
- Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheticDefaultImports_for_type_compatibility: diag(6626, ts.DiagnosticCategory.Message, "Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheti_6626", "Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility."),
+ Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheticDefaultImports_for_type_compatibility: diag(6626, ts.DiagnosticCategory.Message, "Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheti_6626", "Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility."),
Filters_results_from_the_include_option: diag(6627, ts.DiagnosticCategory.Message, "Filters_results_from_the_include_option_6627", "Filters results from the `include` option."),
Remove_a_list_of_directories_from_the_watch_process: diag(6628, ts.DiagnosticCategory.Message, "Remove_a_list_of_directories_from_the_watch_process_6628", "Remove a list of directories from the watch process."),
Remove_a_list_of_files_from_the_watch_mode_s_processing: diag(6629, ts.DiagnosticCategory.Message, "Remove_a_list_of_files_from_the_watch_mode_s_processing_6629", "Remove a list of files from the watch mode's processing."),
@@ -9401,7 +9584,7 @@ var ts;
Specify_one_or_more_path_or_node_module_references_to_base_configuration_files_from_which_settings_are_inherited: diag(6633, ts.DiagnosticCategory.Message, "Specify_one_or_more_path_or_node_module_references_to_base_configuration_files_from_which_settings_a_6633", "Specify one or more path or node module references to base configuration files from which settings are inherited."),
Specify_what_approach_the_watcher_should_use_if_the_system_runs_out_of_native_file_watchers: diag(6634, ts.DiagnosticCategory.Message, "Specify_what_approach_the_watcher_should_use_if_the_system_runs_out_of_native_file_watchers_6634", "Specify what approach the watcher should use if the system runs out of native file watchers."),
Include_a_list_of_files_This_does_not_support_glob_patterns_as_opposed_to_include: diag(6635, ts.DiagnosticCategory.Message, "Include_a_list_of_files_This_does_not_support_glob_patterns_as_opposed_to_include_6635", "Include a list of files. This does not support glob patterns, as opposed to `include`."),
- Build_all_projects_including_those_that_appear_to_be_up_to_date: diag(6636, ts.DiagnosticCategory.Message, "Build_all_projects_including_those_that_appear_to_be_up_to_date_6636", "Build all projects, including those that appear to be up to date"),
+ Build_all_projects_including_those_that_appear_to_be_up_to_date: diag(6636, ts.DiagnosticCategory.Message, "Build_all_projects_including_those_that_appear_to_be_up_to_date_6636", "Build all projects, including those that appear to be up to date."),
Ensure_that_casing_is_correct_in_imports: diag(6637, ts.DiagnosticCategory.Message, "Ensure_that_casing_is_correct_in_imports_6637", "Ensure that casing is correct in imports."),
Emit_a_v8_CPU_profile_of_the_compiler_run_for_debugging: diag(6638, ts.DiagnosticCategory.Message, "Emit_a_v8_CPU_profile_of_the_compiler_run_for_debugging_6638", "Emit a v8 CPU profile of the compiler run for debugging."),
Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file: diag(6639, ts.DiagnosticCategory.Message, "Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file_6639", "Allow importing helper functions from tslib once per project, instead of including them per-file."),
@@ -9411,77 +9594,76 @@ var ts;
Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript: diag(6644, ts.DiagnosticCategory.Message, "Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript_6644", "Include source code in the sourcemaps inside the emitted JavaScript."),
Ensure_that_each_file_can_be_safely_transpiled_without_relying_on_other_imports: diag(6645, ts.DiagnosticCategory.Message, "Ensure_that_each_file_can_be_safely_transpiled_without_relying_on_other_imports_6645", "Ensure that each file can be safely transpiled without relying on other imports."),
Specify_what_JSX_code_is_generated: diag(6646, ts.DiagnosticCategory.Message, "Specify_what_JSX_code_is_generated_6646", "Specify what JSX code is generated."),
- Specify_the_JSX_factory_function_used_when_targeting_React_JSX_emit_e_g_React_createElement_or_h: diag(6647, ts.DiagnosticCategory.Message, "Specify_the_JSX_factory_function_used_when_targeting_React_JSX_emit_e_g_React_createElement_or_h_6647", "Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'"),
+ Specify_the_JSX_factory_function_used_when_targeting_React_JSX_emit_e_g_React_createElement_or_h: diag(6647, ts.DiagnosticCategory.Message, "Specify_the_JSX_factory_function_used_when_targeting_React_JSX_emit_e_g_React_createElement_or_h_6647", "Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'."),
Specify_the_JSX_Fragment_reference_used_for_fragments_when_targeting_React_JSX_emit_e_g_React_Fragment_or_Fragment: diag(6648, ts.DiagnosticCategory.Message, "Specify_the_JSX_Fragment_reference_used_for_fragments_when_targeting_React_JSX_emit_e_g_React_Fragme_6648", "Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'."),
- Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk: diag(6649, ts.DiagnosticCategory.Message, "Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Ast_6649", "Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.`"),
+ Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk: diag(6649, ts.DiagnosticCategory.Message, "Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Ast_6649", "Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'."),
Make_keyof_only_return_strings_instead_of_string_numbers_or_symbols_Legacy_option: diag(6650, ts.DiagnosticCategory.Message, "Make_keyof_only_return_strings_instead_of_string_numbers_or_symbols_Legacy_option_6650", "Make keyof only return strings instead of string, numbers or symbols. Legacy option."),
Specify_a_set_of_bundled_library_declaration_files_that_describe_the_target_runtime_environment: diag(6651, ts.DiagnosticCategory.Message, "Specify_a_set_of_bundled_library_declaration_files_that_describe_the_target_runtime_environment_6651", "Specify a set of bundled library declaration files that describe the target runtime environment."),
Print_the_names_of_emitted_files_after_a_compilation: diag(6652, ts.DiagnosticCategory.Message, "Print_the_names_of_emitted_files_after_a_compilation_6652", "Print the names of emitted files after a compilation."),
Print_all_of_the_files_read_during_the_compilation: diag(6653, ts.DiagnosticCategory.Message, "Print_all_of_the_files_read_during_the_compilation_6653", "Print all of the files read during the compilation."),
Set_the_language_of_the_messaging_from_TypeScript_This_does_not_affect_emit: diag(6654, ts.DiagnosticCategory.Message, "Set_the_language_of_the_messaging_from_TypeScript_This_does_not_affect_emit_6654", "Set the language of the messaging from TypeScript. This does not affect emit."),
Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: diag(6655, ts.DiagnosticCategory.Message, "Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations_6655", "Specify the location where debugger should locate map files instead of generated locations."),
- Specify_the_maximum_folder_depth_used_for_checking_JavaScript_files_from_node_modules_Only_applicable_with_allowJs: diag(6656, ts.DiagnosticCategory.Message, "Specify_the_maximum_folder_depth_used_for_checking_JavaScript_files_from_node_modules_Only_applicabl_6656", "Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`."),
+ Specify_the_maximum_folder_depth_used_for_checking_JavaScript_files_from_node_modules_Only_applicable_with_allowJs: diag(6656, ts.DiagnosticCategory.Message, "Specify_the_maximum_folder_depth_used_for_checking_JavaScript_files_from_node_modules_Only_applicabl_6656", "Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'."),
Specify_what_module_code_is_generated: diag(6657, ts.DiagnosticCategory.Message, "Specify_what_module_code_is_generated_6657", "Specify what module code is generated."),
Specify_how_TypeScript_looks_up_a_file_from_a_given_module_specifier: diag(6658, ts.DiagnosticCategory.Message, "Specify_how_TypeScript_looks_up_a_file_from_a_given_module_specifier_6658", "Specify how TypeScript looks up a file from a given module specifier."),
Set_the_newline_character_for_emitting_files: diag(6659, ts.DiagnosticCategory.Message, "Set_the_newline_character_for_emitting_files_6659", "Set the newline character for emitting files."),
Disable_emitting_files_from_a_compilation: diag(6660, ts.DiagnosticCategory.Message, "Disable_emitting_files_from_a_compilation_6660", "Disable emitting files from a compilation."),
- Disable_generating_custom_helper_functions_like_extends_in_compiled_output: diag(6661, ts.DiagnosticCategory.Message, "Disable_generating_custom_helper_functions_like_extends_in_compiled_output_6661", "Disable generating custom helper functions like `__extends` in compiled output."),
+ Disable_generating_custom_helper_functions_like_extends_in_compiled_output: diag(6661, ts.DiagnosticCategory.Message, "Disable_generating_custom_helper_functions_like_extends_in_compiled_output_6661", "Disable generating custom helper functions like '__extends' in compiled output."),
Disable_emitting_files_if_any_type_checking_errors_are_reported: diag(6662, ts.DiagnosticCategory.Message, "Disable_emitting_files_if_any_type_checking_errors_are_reported_6662", "Disable emitting files if any type checking errors are reported."),
Disable_truncating_types_in_error_messages: diag(6663, ts.DiagnosticCategory.Message, "Disable_truncating_types_in_error_messages_6663", "Disable truncating types in error messages."),
Enable_error_reporting_for_fallthrough_cases_in_switch_statements: diag(6664, ts.DiagnosticCategory.Message, "Enable_error_reporting_for_fallthrough_cases_in_switch_statements_6664", "Enable error reporting for fallthrough cases in switch statements."),
- Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type: diag(6665, ts.DiagnosticCategory.Message, "Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type_6665", "Enable error reporting for expressions and declarations with an implied `any` type.."),
+ Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type: diag(6665, ts.DiagnosticCategory.Message, "Enable_error_reporting_for_expressions_and_declarations_with_an_implied_any_type_6665", "Enable error reporting for expressions and declarations with an implied 'any' type."),
Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier: diag(6666, ts.DiagnosticCategory.Message, "Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier_6666", "Ensure overriding members in derived classes are marked with an override modifier."),
Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function: diag(6667, ts.DiagnosticCategory.Message, "Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function_6667", "Enable error reporting for codepaths that do not explicitly return in a function."),
- Enable_error_reporting_when_this_is_given_the_type_any: diag(6668, ts.DiagnosticCategory.Message, "Enable_error_reporting_when_this_is_given_the_type_any_6668", "Enable error reporting when `this` is given the type `any`."),
+ Enable_error_reporting_when_this_is_given_the_type_any: diag(6668, ts.DiagnosticCategory.Message, "Enable_error_reporting_when_this_is_given_the_type_any_6668", "Enable error reporting when 'this' is given the type 'any'."),
Disable_adding_use_strict_directives_in_emitted_JavaScript_files: diag(6669, ts.DiagnosticCategory.Message, "Disable_adding_use_strict_directives_in_emitted_JavaScript_files_6669", "Disable adding 'use strict' directives in emitted JavaScript files."),
Disable_including_any_library_files_including_the_default_lib_d_ts: diag(6670, ts.DiagnosticCategory.Message, "Disable_including_any_library_files_including_the_default_lib_d_ts_6670", "Disable including any library files, including the default lib.d.ts."),
- Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type: diag(6671, ts.DiagnosticCategory.Message, "Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type_6671", "Enforces using indexed accessors for keys declared using an indexed type"),
- Disallow_import_s_require_s_or_reference_s_from_expanding_the_number_of_files_TypeScript_should_add_to_a_project: diag(6672, ts.DiagnosticCategory.Message, "Disallow_import_s_require_s_or_reference_s_from_expanding_the_number_of_files_TypeScript_should_add__6672", "Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project."),
+ Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type: diag(6671, ts.DiagnosticCategory.Message, "Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type_6671", "Enforces using indexed accessors for keys declared using an indexed type."),
+ Disallow_import_s_require_s_or_reference_s_from_expanding_the_number_of_files_TypeScript_should_add_to_a_project: diag(6672, ts.DiagnosticCategory.Message, "Disallow_import_s_require_s_or_reference_s_from_expanding_the_number_of_files_TypeScript_should_add__6672", "Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project."),
Disable_strict_checking_of_generic_signatures_in_function_types: diag(6673, ts.DiagnosticCategory.Message, "Disable_strict_checking_of_generic_signatures_in_function_types_6673", "Disable strict checking of generic signatures in function types."),
- Add_undefined_to_a_type_when_accessed_using_an_index: diag(6674, ts.DiagnosticCategory.Message, "Add_undefined_to_a_type_when_accessed_using_an_index_6674", "Add `undefined` to a type when accessed using an index."),
- Enable_error_reporting_when_a_local_variables_aren_t_read: diag(6675, ts.DiagnosticCategory.Message, "Enable_error_reporting_when_a_local_variables_aren_t_read_6675", "Enable error reporting when a local variables aren't read."),
- Raise_an_error_when_a_function_parameter_isn_t_read: diag(6676, ts.DiagnosticCategory.Message, "Raise_an_error_when_a_function_parameter_isn_t_read_6676", "Raise an error when a function parameter isn't read"),
- Deprecated_setting_Use_outFile_instead: diag(6677, ts.DiagnosticCategory.Message, "Deprecated_setting_Use_outFile_instead_6677", "Deprecated setting. Use `outFile` instead."),
+ Add_undefined_to_a_type_when_accessed_using_an_index: diag(6674, ts.DiagnosticCategory.Message, "Add_undefined_to_a_type_when_accessed_using_an_index_6674", "Add 'undefined' to a type when accessed using an index."),
+ Enable_error_reporting_when_local_variables_aren_t_read: diag(6675, ts.DiagnosticCategory.Message, "Enable_error_reporting_when_local_variables_aren_t_read_6675", "Enable error reporting when local variables aren't read."),
+ Raise_an_error_when_a_function_parameter_isn_t_read: diag(6676, ts.DiagnosticCategory.Message, "Raise_an_error_when_a_function_parameter_isn_t_read_6676", "Raise an error when a function parameter isn't read."),
+ Deprecated_setting_Use_outFile_instead: diag(6677, ts.DiagnosticCategory.Message, "Deprecated_setting_Use_outFile_instead_6677", "Deprecated setting. Use 'outFile' instead."),
Specify_an_output_folder_for_all_emitted_files: diag(6678, ts.DiagnosticCategory.Message, "Specify_an_output_folder_for_all_emitted_files_6678", "Specify an output folder for all emitted files."),
- Specify_a_file_that_bundles_all_outputs_into_one_JavaScript_file_If_declaration_is_true_also_designates_a_file_that_bundles_all_d_ts_output: diag(6679, ts.DiagnosticCategory.Message, "Specify_a_file_that_bundles_all_outputs_into_one_JavaScript_file_If_declaration_is_true_also_designa_6679", "Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output."),
+ Specify_a_file_that_bundles_all_outputs_into_one_JavaScript_file_If_declaration_is_true_also_designates_a_file_that_bundles_all_d_ts_output: diag(6679, ts.DiagnosticCategory.Message, "Specify_a_file_that_bundles_all_outputs_into_one_JavaScript_file_If_declaration_is_true_also_designa_6679", "Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output."),
Specify_a_set_of_entries_that_re_map_imports_to_additional_lookup_locations: diag(6680, ts.DiagnosticCategory.Message, "Specify_a_set_of_entries_that_re_map_imports_to_additional_lookup_locations_6680", "Specify a set of entries that re-map imports to additional lookup locations."),
Specify_a_list_of_language_service_plugins_to_include: diag(6681, ts.DiagnosticCategory.Message, "Specify_a_list_of_language_service_plugins_to_include_6681", "Specify a list of language service plugins to include."),
- Disable_erasing_const_enum_declarations_in_generated_code: diag(6682, ts.DiagnosticCategory.Message, "Disable_erasing_const_enum_declarations_in_generated_code_6682", "Disable erasing `const enum` declarations in generated code."),
+ Disable_erasing_const_enum_declarations_in_generated_code: diag(6682, ts.DiagnosticCategory.Message, "Disable_erasing_const_enum_declarations_in_generated_code_6682", "Disable erasing 'const enum' declarations in generated code."),
Disable_resolving_symlinks_to_their_realpath_This_correlates_to_the_same_flag_in_node: diag(6683, ts.DiagnosticCategory.Message, "Disable_resolving_symlinks_to_their_realpath_This_correlates_to_the_same_flag_in_node_6683", "Disable resolving symlinks to their realpath. This correlates to the same flag in node."),
- Disable_wiping_the_console_in_watch_mode: diag(6684, ts.DiagnosticCategory.Message, "Disable_wiping_the_console_in_watch_mode_6684", "Disable wiping the console in watch mode"),
- Enable_color_and_formatting_in_TypeScript_s_output_to_make_compiler_errors_easier_to_read: diag(6685, ts.DiagnosticCategory.Message, "Enable_color_and_formatting_in_TypeScript_s_output_to_make_compiler_errors_easier_to_read_6685", "Enable color and formatting in TypeScript's output to make compiler errors easier to read"),
- Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit: diag(6686, ts.DiagnosticCategory.Message, "Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit_6686", "Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit."),
+ Disable_wiping_the_console_in_watch_mode: diag(6684, ts.DiagnosticCategory.Message, "Disable_wiping_the_console_in_watch_mode_6684", "Disable wiping the console in watch mode."),
+ Enable_color_and_formatting_in_TypeScript_s_output_to_make_compiler_errors_easier_to_read: diag(6685, ts.DiagnosticCategory.Message, "Enable_color_and_formatting_in_TypeScript_s_output_to_make_compiler_errors_easier_to_read_6685", "Enable color and formatting in TypeScript's output to make compiler errors easier to read."),
+ Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit: diag(6686, ts.DiagnosticCategory.Message, "Specify_the_object_invoked_for_createElement_This_only_applies_when_targeting_react_JSX_emit_6686", "Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit."),
Specify_an_array_of_objects_that_specify_paths_for_projects_Used_in_project_references: diag(6687, ts.DiagnosticCategory.Message, "Specify_an_array_of_objects_that_specify_paths_for_projects_Used_in_project_references_6687", "Specify an array of objects that specify paths for projects. Used in project references."),
Disable_emitting_comments: diag(6688, ts.DiagnosticCategory.Message, "Disable_emitting_comments_6688", "Disable emitting comments."),
- Enable_importing_json_files: diag(6689, ts.DiagnosticCategory.Message, "Enable_importing_json_files_6689", "Enable importing .json files"),
+ Enable_importing_json_files: diag(6689, ts.DiagnosticCategory.Message, "Enable_importing_json_files_6689", "Enable importing .json files."),
Specify_the_root_folder_within_your_source_files: diag(6690, ts.DiagnosticCategory.Message, "Specify_the_root_folder_within_your_source_files_6690", "Specify the root folder within your source files."),
Allow_multiple_folders_to_be_treated_as_one_when_resolving_modules: diag(6691, ts.DiagnosticCategory.Message, "Allow_multiple_folders_to_be_treated_as_one_when_resolving_modules_6691", "Allow multiple folders to be treated as one when resolving modules."),
Skip_type_checking_d_ts_files_that_are_included_with_TypeScript: diag(6692, ts.DiagnosticCategory.Message, "Skip_type_checking_d_ts_files_that_are_included_with_TypeScript_6692", "Skip type checking .d.ts files that are included with TypeScript."),
Skip_type_checking_all_d_ts_files: diag(6693, ts.DiagnosticCategory.Message, "Skip_type_checking_all_d_ts_files_6693", "Skip type checking all .d.ts files."),
Create_source_map_files_for_emitted_JavaScript_files: diag(6694, ts.DiagnosticCategory.Message, "Create_source_map_files_for_emitted_JavaScript_files_6694", "Create source map files for emitted JavaScript files."),
Specify_the_root_path_for_debuggers_to_find_the_reference_source_code: diag(6695, ts.DiagnosticCategory.Message, "Specify_the_root_path_for_debuggers_to_find_the_reference_source_code_6695", "Specify the root path for debuggers to find the reference source code."),
- Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function: diag(6697, ts.DiagnosticCategory.Message, "Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function_6697", "Check that the arguments for `bind`, `call`, and `apply` methods match the original function."),
+ Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function: diag(6697, ts.DiagnosticCategory.Message, "Check_that_the_arguments_for_bind_call_and_apply_methods_match_the_original_function_6697", "Check that the arguments for 'bind', 'call', and 'apply' methods match the original function."),
When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible: diag(6698, ts.DiagnosticCategory.Message, "When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible_6698", "When assigning functions, check to ensure parameters and the return values are subtype-compatible."),
- When_type_checking_take_into_account_null_and_undefined: diag(6699, ts.DiagnosticCategory.Message, "When_type_checking_take_into_account_null_and_undefined_6699", "When type checking, take into account `null` and `undefined`."),
+ When_type_checking_take_into_account_null_and_undefined: diag(6699, ts.DiagnosticCategory.Message, "When_type_checking_take_into_account_null_and_undefined_6699", "When type checking, take into account 'null' and 'undefined'."),
Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor: diag(6700, ts.DiagnosticCategory.Message, "Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor_6700", "Check for class properties that are declared but not set in the constructor."),
- Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments: diag(6701, ts.DiagnosticCategory.Message, "Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments_6701", "Disable emitting declarations that have `@internal` in their JSDoc comments."),
+ Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments: diag(6701, ts.DiagnosticCategory.Message, "Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments_6701", "Disable emitting declarations that have '@internal' in their JSDoc comments."),
Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals: diag(6702, ts.DiagnosticCategory.Message, "Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals_6702", "Disable reporting of excess property errors during the creation of object literals."),
- Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures: diag(6703, ts.DiagnosticCategory.Message, "Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures_6703", "Suppress `noImplicitAny` errors when indexing objects that lack index signatures."),
+ Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures: diag(6703, ts.DiagnosticCategory.Message, "Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures_6703", "Suppress 'noImplicitAny' errors when indexing objects that lack index signatures."),
Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively: diag(6704, ts.DiagnosticCategory.Message, "Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6704", "Synchronously call callbacks and update the state of directory watchers on platforms that don`t support recursive watching natively."),
Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations: diag(6705, ts.DiagnosticCategory.Message, "Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declaratio_6705", "Set the JavaScript language version for emitted JavaScript and include compatible library declarations."),
- Log_paths_used_during_the_moduleResolution_process: diag(6706, ts.DiagnosticCategory.Message, "Log_paths_used_during_the_moduleResolution_process_6706", "Log paths used during the `moduleResolution` process."),
- Specify_the_folder_for_tsbuildinfo_incremental_compilation_files: diag(6707, ts.DiagnosticCategory.Message, "Specify_the_folder_for_tsbuildinfo_incremental_compilation_files_6707", "Specify the folder for .tsbuildinfo incremental compilation files."),
+ Log_paths_used_during_the_moduleResolution_process: diag(6706, ts.DiagnosticCategory.Message, "Log_paths_used_during_the_moduleResolution_process_6706", "Log paths used during the 'moduleResolution' process."),
+ Specify_the_path_to_tsbuildinfo_incremental_compilation_file: diag(6707, ts.DiagnosticCategory.Message, "Specify_the_path_to_tsbuildinfo_incremental_compilation_file_6707", "Specify the path to .tsbuildinfo incremental compilation file."),
Specify_options_for_automatic_acquisition_of_declaration_files: diag(6709, ts.DiagnosticCategory.Message, "Specify_options_for_automatic_acquisition_of_declaration_files_6709", "Specify options for automatic acquisition of declaration files."),
- Specify_multiple_folders_that_act_like_Slashnode_modules_Slash_types: diag(6710, ts.DiagnosticCategory.Message, "Specify_multiple_folders_that_act_like_Slashnode_modules_Slash_types_6710", "Specify multiple folders that act like `./node_modules/@types`."),
+ Specify_multiple_folders_that_act_like_Slashnode_modules_Slash_types: diag(6710, ts.DiagnosticCategory.Message, "Specify_multiple_folders_that_act_like_Slashnode_modules_Slash_types_6710", "Specify multiple folders that act like './node_modules/@types'."),
Specify_type_package_names_to_be_included_without_being_referenced_in_a_source_file: diag(6711, ts.DiagnosticCategory.Message, "Specify_type_package_names_to_be_included_without_being_referenced_in_a_source_file_6711", "Specify type package names to be included without being referenced in a source file."),
Emit_ECMAScript_standard_compliant_class_fields: diag(6712, ts.DiagnosticCategory.Message, "Emit_ECMAScript_standard_compliant_class_fields_6712", "Emit ECMAScript-standard-compliant class fields."),
- Enable_verbose_logging: diag(6713, ts.DiagnosticCategory.Message, "Enable_verbose_logging_6713", "Enable verbose logging"),
+ Enable_verbose_logging: diag(6713, ts.DiagnosticCategory.Message, "Enable_verbose_logging_6713", "Enable verbose logging."),
Specify_how_directories_are_watched_on_systems_that_lack_recursive_file_watching_functionality: diag(6714, ts.DiagnosticCategory.Message, "Specify_how_directories_are_watched_on_systems_that_lack_recursive_file_watching_functionality_6714", "Specify how directories are watched on systems that lack recursive file-watching functionality."),
Specify_how_the_TypeScript_watch_mode_works: diag(6715, ts.DiagnosticCategory.Message, "Specify_how_the_TypeScript_watch_mode_works_6715", "Specify how the TypeScript watch mode works."),
- Include_undefined_in_index_signature_results: diag(6716, ts.DiagnosticCategory.Message, "Include_undefined_in_index_signature_results_6716", "Include 'undefined' in index signature results"),
Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6717, ts.DiagnosticCategory.Message, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6717", "Require undeclared properties from index signatures to use element accesses."),
- Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types: diag(6718, ts.DiagnosticCategory.Message, "Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types_6718", "Specify emit/checking behavior for imports that are only used for types"),
- Type_catch_clause_variables_as_unknown_instead_of_any: diag(6803, ts.DiagnosticCategory.Message, "Type_catch_clause_variables_as_unknown_instead_of_any_6803", "Type catch clause variables as 'unknown' instead of 'any'."),
+ Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types: diag(6718, ts.DiagnosticCategory.Message, "Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types_6718", "Specify emit/checking behavior for imports that are only used for types."),
+ Default_catch_clause_variables_as_unknown_instead_of_any: diag(6803, ts.DiagnosticCategory.Message, "Default_catch_clause_variables_as_unknown_instead_of_any_6803", "Default catch clause variables as 'unknown' instead of 'any'."),
one_of_Colon: diag(6900, ts.DiagnosticCategory.Message, "one_of_Colon_6900", "one of:"),
one_or_more_Colon: diag(6901, ts.DiagnosticCategory.Message, "one_or_more_Colon_6901", "one or more:"),
type_Colon: diag(6902, ts.DiagnosticCategory.Message, "type_Colon_6902", "type:"),
@@ -9513,6 +9695,7 @@ var ts;
An_expanded_version_of_this_information_showing_all_possible_compiler_options: diag(6928, ts.DiagnosticCategory.Message, "An_expanded_version_of_this_information_showing_all_possible_compiler_options_6928", "An expanded version of this information, showing all possible compiler options"),
Compiles_the_current_project_with_additional_settings: diag(6929, ts.DiagnosticCategory.Message, "Compiles_the_current_project_with_additional_settings_6929", "Compiles the current project, with additional settings."),
true_for_ES2022_and_above_including_ESNext: diag(6930, ts.DiagnosticCategory.Message, "true_for_ES2022_and_above_including_ESNext_6930", "`true` for ES2022 and above, including ESNext."),
+ List_of_file_name_suffixes_to_search_when_resolving_a_module: diag(6931, ts.DiagnosticCategory.Error, "List_of_file_name_suffixes_to_search_when_resolving_a_module_6931", "List of file name suffixes to search when resolving a module."),
Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."),
Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."),
Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."),
@@ -9567,7 +9750,6 @@ var ts;
This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead: diag(7059, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead_7059", "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead."),
This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint: diag(7060, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_cons_7060", "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint."),
A_mapped_type_may_not_declare_properties_or_methods: diag(7061, ts.DiagnosticCategory.Error, "A_mapped_type_may_not_declare_properties_or_methods_7061", "A mapped type may not declare properties or methods."),
- JSON_imports_are_experimental_in_ES_module_mode_imports: diag(7062, ts.DiagnosticCategory.Error, "JSON_imports_are_experimental_in_ES_module_mode_imports_7062", "JSON imports are experimental in ES module mode imports."),
You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."),
import_can_only_be_used_in_TypeScript_files: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_TypeScript_files_8002", "'import ... =' can only be used in TypeScript files."),
@@ -9776,7 +9958,7 @@ var ts;
Fix_all_implicit_this_errors: diag(95107, ts.DiagnosticCategory.Message, "Fix_all_implicit_this_errors_95107", "Fix all implicit-'this' errors"),
Wrap_invalid_character_in_an_expression_container: diag(95108, ts.DiagnosticCategory.Message, "Wrap_invalid_character_in_an_expression_container_95108", "Wrap invalid character in an expression container"),
Wrap_all_invalid_characters_in_an_expression_container: diag(95109, ts.DiagnosticCategory.Message, "Wrap_all_invalid_characters_in_an_expression_container_95109", "Wrap all invalid characters in an expression container"),
- Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file: diag(95110, ts.DiagnosticCategory.Message, "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file_95110", "Visit https://aka.ms/tsconfig.json to read more about this file"),
+ Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file: diag(95110, ts.DiagnosticCategory.Message, "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file_95110", "Visit https://aka.ms/tsconfig to read more about this file"),
Add_a_return_statement: diag(95111, ts.DiagnosticCategory.Message, "Add_a_return_statement_95111", "Add a return statement"),
Remove_braces_from_arrow_function_body: diag(95112, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_body_95112", "Remove braces from arrow function body"),
Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal: diag(95113, ts.DiagnosticCategory.Message, "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113", "Wrap the following body with parentheses which should be an object literal"),
@@ -9877,99 +10059,100 @@ var ts;
var _a;
/* @internal */
function tokenIsIdentifierOrKeyword(token) {
- return token >= 79 /* Identifier */;
+ return token >= 79 /* SyntaxKind.Identifier */;
}
ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword;
/* @internal */
function tokenIsIdentifierOrKeywordOrGreaterThan(token) {
- return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token);
+ return token === 31 /* SyntaxKind.GreaterThanToken */ || tokenIsIdentifierOrKeyword(token);
}
ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan;
/** @internal */
ts.textToKeywordObj = (_a = {
- abstract: 126 /* AbstractKeyword */,
- any: 130 /* AnyKeyword */,
- as: 127 /* AsKeyword */,
- asserts: 128 /* AssertsKeyword */,
- assert: 129 /* AssertKeyword */,
- bigint: 157 /* BigIntKeyword */,
- boolean: 133 /* BooleanKeyword */,
- break: 81 /* BreakKeyword */,
- case: 82 /* CaseKeyword */,
- catch: 83 /* CatchKeyword */,
- class: 84 /* ClassKeyword */,
- continue: 86 /* ContinueKeyword */,
- const: 85 /* ConstKeyword */
+ abstract: 126 /* SyntaxKind.AbstractKeyword */,
+ any: 130 /* SyntaxKind.AnyKeyword */,
+ as: 127 /* SyntaxKind.AsKeyword */,
+ asserts: 128 /* SyntaxKind.AssertsKeyword */,
+ assert: 129 /* SyntaxKind.AssertKeyword */,
+ bigint: 158 /* SyntaxKind.BigIntKeyword */,
+ boolean: 133 /* SyntaxKind.BooleanKeyword */,
+ break: 81 /* SyntaxKind.BreakKeyword */,
+ case: 82 /* SyntaxKind.CaseKeyword */,
+ catch: 83 /* SyntaxKind.CatchKeyword */,
+ class: 84 /* SyntaxKind.ClassKeyword */,
+ continue: 86 /* SyntaxKind.ContinueKeyword */,
+ const: 85 /* SyntaxKind.ConstKeyword */
},
- _a["" + "constructor"] = 134 /* ConstructorKeyword */,
- _a.debugger = 87 /* DebuggerKeyword */,
- _a.declare = 135 /* DeclareKeyword */,
- _a.default = 88 /* DefaultKeyword */,
- _a.delete = 89 /* DeleteKeyword */,
- _a.do = 90 /* DoKeyword */,
- _a.else = 91 /* ElseKeyword */,
- _a.enum = 92 /* EnumKeyword */,
- _a.export = 93 /* ExportKeyword */,
- _a.extends = 94 /* ExtendsKeyword */,
- _a.false = 95 /* FalseKeyword */,
- _a.finally = 96 /* FinallyKeyword */,
- _a.for = 97 /* ForKeyword */,
- _a.from = 155 /* FromKeyword */,
- _a.function = 98 /* FunctionKeyword */,
- _a.get = 136 /* GetKeyword */,
- _a.if = 99 /* IfKeyword */,
- _a.implements = 117 /* ImplementsKeyword */,
- _a.import = 100 /* ImportKeyword */,
- _a.in = 101 /* InKeyword */,
- _a.infer = 137 /* InferKeyword */,
- _a.instanceof = 102 /* InstanceOfKeyword */,
- _a.interface = 118 /* InterfaceKeyword */,
- _a.intrinsic = 138 /* IntrinsicKeyword */,
- _a.is = 139 /* IsKeyword */,
- _a.keyof = 140 /* KeyOfKeyword */,
- _a.let = 119 /* LetKeyword */,
- _a.module = 141 /* ModuleKeyword */,
- _a.namespace = 142 /* NamespaceKeyword */,
- _a.never = 143 /* NeverKeyword */,
- _a.new = 103 /* NewKeyword */,
- _a.null = 104 /* NullKeyword */,
- _a.number = 146 /* NumberKeyword */,
- _a.object = 147 /* ObjectKeyword */,
- _a.package = 120 /* PackageKeyword */,
- _a.private = 121 /* PrivateKeyword */,
- _a.protected = 122 /* ProtectedKeyword */,
- _a.public = 123 /* PublicKeyword */,
- _a.override = 158 /* OverrideKeyword */,
- _a.readonly = 144 /* ReadonlyKeyword */,
- _a.require = 145 /* RequireKeyword */,
- _a.global = 156 /* GlobalKeyword */,
- _a.return = 105 /* ReturnKeyword */,
- _a.set = 148 /* SetKeyword */,
- _a.static = 124 /* StaticKeyword */,
- _a.string = 149 /* StringKeyword */,
- _a.super = 106 /* SuperKeyword */,
- _a.switch = 107 /* SwitchKeyword */,
- _a.symbol = 150 /* SymbolKeyword */,
- _a.this = 108 /* ThisKeyword */,
- _a.throw = 109 /* ThrowKeyword */,
- _a.true = 110 /* TrueKeyword */,
- _a.try = 111 /* TryKeyword */,
- _a.type = 151 /* TypeKeyword */,
- _a.typeof = 112 /* TypeOfKeyword */,
- _a.undefined = 152 /* UndefinedKeyword */,
- _a.unique = 153 /* UniqueKeyword */,
- _a.unknown = 154 /* UnknownKeyword */,
- _a.var = 113 /* VarKeyword */,
- _a.void = 114 /* VoidKeyword */,
- _a.while = 115 /* WhileKeyword */,
- _a.with = 116 /* WithKeyword */,
- _a.yield = 125 /* YieldKeyword */,
- _a.async = 131 /* AsyncKeyword */,
- _a.await = 132 /* AwaitKeyword */,
- _a.of = 159 /* OfKeyword */,
+ _a["" + "constructor"] = 134 /* SyntaxKind.ConstructorKeyword */,
+ _a.debugger = 87 /* SyntaxKind.DebuggerKeyword */,
+ _a.declare = 135 /* SyntaxKind.DeclareKeyword */,
+ _a.default = 88 /* SyntaxKind.DefaultKeyword */,
+ _a.delete = 89 /* SyntaxKind.DeleteKeyword */,
+ _a.do = 90 /* SyntaxKind.DoKeyword */,
+ _a.else = 91 /* SyntaxKind.ElseKeyword */,
+ _a.enum = 92 /* SyntaxKind.EnumKeyword */,
+ _a.export = 93 /* SyntaxKind.ExportKeyword */,
+ _a.extends = 94 /* SyntaxKind.ExtendsKeyword */,
+ _a.false = 95 /* SyntaxKind.FalseKeyword */,
+ _a.finally = 96 /* SyntaxKind.FinallyKeyword */,
+ _a.for = 97 /* SyntaxKind.ForKeyword */,
+ _a.from = 156 /* SyntaxKind.FromKeyword */,
+ _a.function = 98 /* SyntaxKind.FunctionKeyword */,
+ _a.get = 136 /* SyntaxKind.GetKeyword */,
+ _a.if = 99 /* SyntaxKind.IfKeyword */,
+ _a.implements = 117 /* SyntaxKind.ImplementsKeyword */,
+ _a.import = 100 /* SyntaxKind.ImportKeyword */,
+ _a.in = 101 /* SyntaxKind.InKeyword */,
+ _a.infer = 137 /* SyntaxKind.InferKeyword */,
+ _a.instanceof = 102 /* SyntaxKind.InstanceOfKeyword */,
+ _a.interface = 118 /* SyntaxKind.InterfaceKeyword */,
+ _a.intrinsic = 138 /* SyntaxKind.IntrinsicKeyword */,
+ _a.is = 139 /* SyntaxKind.IsKeyword */,
+ _a.keyof = 140 /* SyntaxKind.KeyOfKeyword */,
+ _a.let = 119 /* SyntaxKind.LetKeyword */,
+ _a.module = 141 /* SyntaxKind.ModuleKeyword */,
+ _a.namespace = 142 /* SyntaxKind.NamespaceKeyword */,
+ _a.never = 143 /* SyntaxKind.NeverKeyword */,
+ _a.new = 103 /* SyntaxKind.NewKeyword */,
+ _a.null = 104 /* SyntaxKind.NullKeyword */,
+ _a.number = 147 /* SyntaxKind.NumberKeyword */,
+ _a.object = 148 /* SyntaxKind.ObjectKeyword */,
+ _a.package = 120 /* SyntaxKind.PackageKeyword */,
+ _a.private = 121 /* SyntaxKind.PrivateKeyword */,
+ _a.protected = 122 /* SyntaxKind.ProtectedKeyword */,
+ _a.public = 123 /* SyntaxKind.PublicKeyword */,
+ _a.override = 159 /* SyntaxKind.OverrideKeyword */,
+ _a.out = 144 /* SyntaxKind.OutKeyword */,
+ _a.readonly = 145 /* SyntaxKind.ReadonlyKeyword */,
+ _a.require = 146 /* SyntaxKind.RequireKeyword */,
+ _a.global = 157 /* SyntaxKind.GlobalKeyword */,
+ _a.return = 105 /* SyntaxKind.ReturnKeyword */,
+ _a.set = 149 /* SyntaxKind.SetKeyword */,
+ _a.static = 124 /* SyntaxKind.StaticKeyword */,
+ _a.string = 150 /* SyntaxKind.StringKeyword */,
+ _a.super = 106 /* SyntaxKind.SuperKeyword */,
+ _a.switch = 107 /* SyntaxKind.SwitchKeyword */,
+ _a.symbol = 151 /* SyntaxKind.SymbolKeyword */,
+ _a.this = 108 /* SyntaxKind.ThisKeyword */,
+ _a.throw = 109 /* SyntaxKind.ThrowKeyword */,
+ _a.true = 110 /* SyntaxKind.TrueKeyword */,
+ _a.try = 111 /* SyntaxKind.TryKeyword */,
+ _a.type = 152 /* SyntaxKind.TypeKeyword */,
+ _a.typeof = 112 /* SyntaxKind.TypeOfKeyword */,
+ _a.undefined = 153 /* SyntaxKind.UndefinedKeyword */,
+ _a.unique = 154 /* SyntaxKind.UniqueKeyword */,
+ _a.unknown = 155 /* SyntaxKind.UnknownKeyword */,
+ _a.var = 113 /* SyntaxKind.VarKeyword */,
+ _a.void = 114 /* SyntaxKind.VoidKeyword */,
+ _a.while = 115 /* SyntaxKind.WhileKeyword */,
+ _a.with = 116 /* SyntaxKind.WithKeyword */,
+ _a.yield = 125 /* SyntaxKind.YieldKeyword */,
+ _a.async = 131 /* SyntaxKind.AsyncKeyword */,
+ _a.await = 132 /* SyntaxKind.AwaitKeyword */,
+ _a.of = 160 /* SyntaxKind.OfKeyword */,
_a);
var textToKeyword = new ts.Map(ts.getEntries(ts.textToKeywordObj));
- var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, "</": 30 /* LessThanSlashToken */, ">>": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 63 /* EqualsToken */, "+=": 64 /* PlusEqualsToken */, "-=": 65 /* MinusEqualsToken */, "*=": 66 /* AsteriskEqualsToken */, "**=": 67 /* AsteriskAsteriskEqualsToken */, "/=": 68 /* SlashEqualsToken */, "%=": 69 /* PercentEqualsToken */, "<<=": 70 /* LessThanLessThanEqualsToken */, ">>=": 71 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* AmpersandEqualsToken */, "|=": 74 /* BarEqualsToken */, "^=": 78 /* CaretEqualsToken */, "||=": 75 /* BarBarEqualsToken */, "&&=": 76 /* AmpersandAmpersandEqualsToken */, "??=": 77 /* QuestionQuestionEqualsToken */, "@": 59 /* AtToken */, "#": 62 /* HashToken */, "`": 61 /* BacktickToken */ })));
+ var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* SyntaxKind.OpenBraceToken */, "}": 19 /* SyntaxKind.CloseBraceToken */, "(": 20 /* SyntaxKind.OpenParenToken */, ")": 21 /* SyntaxKind.CloseParenToken */, "[": 22 /* SyntaxKind.OpenBracketToken */, "]": 23 /* SyntaxKind.CloseBracketToken */, ".": 24 /* SyntaxKind.DotToken */, "...": 25 /* SyntaxKind.DotDotDotToken */, ";": 26 /* SyntaxKind.SemicolonToken */, ",": 27 /* SyntaxKind.CommaToken */, "<": 29 /* SyntaxKind.LessThanToken */, ">": 31 /* SyntaxKind.GreaterThanToken */, "<=": 32 /* SyntaxKind.LessThanEqualsToken */, ">=": 33 /* SyntaxKind.GreaterThanEqualsToken */, "==": 34 /* SyntaxKind.EqualsEqualsToken */, "!=": 35 /* SyntaxKind.ExclamationEqualsToken */, "===": 36 /* SyntaxKind.EqualsEqualsEqualsToken */, "!==": 37 /* SyntaxKind.ExclamationEqualsEqualsToken */, "=>": 38 /* SyntaxKind.EqualsGreaterThanToken */, "+": 39 /* SyntaxKind.PlusToken */, "-": 40 /* SyntaxKind.MinusToken */, "**": 42 /* SyntaxKind.AsteriskAsteriskToken */, "*": 41 /* SyntaxKind.AsteriskToken */, "/": 43 /* SyntaxKind.SlashToken */, "%": 44 /* SyntaxKind.PercentToken */, "++": 45 /* SyntaxKind.PlusPlusToken */, "--": 46 /* SyntaxKind.MinusMinusToken */, "<<": 47 /* SyntaxKind.LessThanLessThanToken */, "</": 30 /* SyntaxKind.LessThanSlashToken */, ">>": 48 /* SyntaxKind.GreaterThanGreaterThanToken */, ">>>": 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* SyntaxKind.AmpersandToken */, "|": 51 /* SyntaxKind.BarToken */, "^": 52 /* SyntaxKind.CaretToken */, "!": 53 /* SyntaxKind.ExclamationToken */, "~": 54 /* SyntaxKind.TildeToken */, "&&": 55 /* SyntaxKind.AmpersandAmpersandToken */, "||": 56 /* SyntaxKind.BarBarToken */, "?": 57 /* SyntaxKind.QuestionToken */, "??": 60 /* SyntaxKind.QuestionQuestionToken */, "?.": 28 /* SyntaxKind.QuestionDotToken */, ":": 58 /* SyntaxKind.ColonToken */, "=": 63 /* SyntaxKind.EqualsToken */, "+=": 64 /* SyntaxKind.PlusEqualsToken */, "-=": 65 /* SyntaxKind.MinusEqualsToken */, "*=": 66 /* SyntaxKind.AsteriskEqualsToken */, "**=": 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */, "/=": 68 /* SyntaxKind.SlashEqualsToken */, "%=": 69 /* SyntaxKind.PercentEqualsToken */, "<<=": 70 /* SyntaxKind.LessThanLessThanEqualsToken */, ">>=": 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* SyntaxKind.AmpersandEqualsToken */, "|=": 74 /* SyntaxKind.BarEqualsToken */, "^=": 78 /* SyntaxKind.CaretEqualsToken */, "||=": 75 /* SyntaxKind.BarBarEqualsToken */, "&&=": 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */, "??=": 77 /* SyntaxKind.QuestionQuestionEqualsToken */, "@": 59 /* SyntaxKind.AtToken */, "#": 62 /* SyntaxKind.HashToken */, "`": 61 /* SyntaxKind.BacktickToken */ })));
/*
As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers
IdentifierStart ::
@@ -10058,16 +10241,16 @@ var ts;
return false;
}
/* @internal */ function isUnicodeIdentifierStart(code, languageVersion) {
- return languageVersion >= 2 /* ES2015 */ ?
+ return languageVersion >= 2 /* ScriptTarget.ES2015 */ ?
lookupInUnicodeMap(code, unicodeESNextIdentifierStart) :
- languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) :
+ languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) :
lookupInUnicodeMap(code, unicodeES3IdentifierStart);
}
ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart;
function isUnicodeIdentifierPart(code, languageVersion) {
- return languageVersion >= 2 /* ES2015 */ ?
+ return languageVersion >= 2 /* ScriptTarget.ES2015 */ ?
lookupInUnicodeMap(code, unicodeESNextIdentifierPart) :
- languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) :
+ languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) :
lookupInUnicodeMap(code, unicodeES3IdentifierPart);
}
function makeReverseMap(source) {
@@ -10096,17 +10279,17 @@ var ts;
var ch = text.charCodeAt(pos);
pos++;
switch (ch) {
- case 13 /* carriageReturn */:
- if (text.charCodeAt(pos) === 10 /* lineFeed */) {
+ case 13 /* CharacterCodes.carriageReturn */:
+ if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) {
pos++;
}
// falls through
- case 10 /* lineFeed */:
+ case 10 /* CharacterCodes.lineFeed */:
result.push(lineStart);
lineStart = pos;
break;
default:
- if (ch > 127 /* maxAsciiCharacter */ && isLineBreak(ch)) {
+ if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isLineBreak(ch)) {
result.push(lineStart);
lineStart = pos;
}
@@ -10209,18 +10392,18 @@ var ts;
function isWhiteSpaceSingleLine(ch) {
// Note: nextLine is in the Zs space, and should be considered to be a whitespace.
// It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript.
- return ch === 32 /* space */ ||
- ch === 9 /* tab */ ||
- ch === 11 /* verticalTab */ ||
- ch === 12 /* formFeed */ ||
- ch === 160 /* nonBreakingSpace */ ||
- ch === 133 /* nextLine */ ||
- ch === 5760 /* ogham */ ||
- ch >= 8192 /* enQuad */ && ch <= 8203 /* zeroWidthSpace */ ||
- ch === 8239 /* narrowNoBreakSpace */ ||
- ch === 8287 /* mathematicalSpace */ ||
- ch === 12288 /* ideographicSpace */ ||
- ch === 65279 /* byteOrderMark */;
+ return ch === 32 /* CharacterCodes.space */ ||
+ ch === 9 /* CharacterCodes.tab */ ||
+ ch === 11 /* CharacterCodes.verticalTab */ ||
+ ch === 12 /* CharacterCodes.formFeed */ ||
+ ch === 160 /* CharacterCodes.nonBreakingSpace */ ||
+ ch === 133 /* CharacterCodes.nextLine */ ||
+ ch === 5760 /* CharacterCodes.ogham */ ||
+ ch >= 8192 /* CharacterCodes.enQuad */ && ch <= 8203 /* CharacterCodes.zeroWidthSpace */ ||
+ ch === 8239 /* CharacterCodes.narrowNoBreakSpace */ ||
+ ch === 8287 /* CharacterCodes.mathematicalSpace */ ||
+ ch === 12288 /* CharacterCodes.ideographicSpace */ ||
+ ch === 65279 /* CharacterCodes.byteOrderMark */;
}
ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine;
function isLineBreak(ch) {
@@ -10234,50 +10417,50 @@ var ts;
// \u2029 Paragraph separator <PS>
// Only the characters in Table 3 are treated as line terminators. Other new line or line
// breaking characters are treated as white space but not as line terminators.
- return ch === 10 /* lineFeed */ ||
- ch === 13 /* carriageReturn */ ||
- ch === 8232 /* lineSeparator */ ||
- ch === 8233 /* paragraphSeparator */;
+ return ch === 10 /* CharacterCodes.lineFeed */ ||
+ ch === 13 /* CharacterCodes.carriageReturn */ ||
+ ch === 8232 /* CharacterCodes.lineSeparator */ ||
+ ch === 8233 /* CharacterCodes.paragraphSeparator */;
}
ts.isLineBreak = isLineBreak;
function isDigit(ch) {
- return ch >= 48 /* _0 */ && ch <= 57 /* _9 */;
+ return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */;
}
function isHexDigit(ch) {
- return isDigit(ch) || ch >= 65 /* A */ && ch <= 70 /* F */ || ch >= 97 /* a */ && ch <= 102 /* f */;
+ return isDigit(ch) || ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */ || ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */;
}
function isCodePoint(code) {
return code <= 0x10FFFF;
}
/* @internal */
function isOctalDigit(ch) {
- return ch >= 48 /* _0 */ && ch <= 55 /* _7 */;
+ return ch >= 48 /* CharacterCodes._0 */ && ch <= 55 /* CharacterCodes._7 */;
}
ts.isOctalDigit = isOctalDigit;
function couldStartTrivia(text, pos) {
// Keep in sync with skipTrivia
var ch = text.charCodeAt(pos);
switch (ch) {
- case 13 /* carriageReturn */:
- case 10 /* lineFeed */:
- case 9 /* tab */:
- case 11 /* verticalTab */:
- case 12 /* formFeed */:
- case 32 /* space */:
- case 47 /* slash */:
+ case 13 /* CharacterCodes.carriageReturn */:
+ case 10 /* CharacterCodes.lineFeed */:
+ case 9 /* CharacterCodes.tab */:
+ case 11 /* CharacterCodes.verticalTab */:
+ case 12 /* CharacterCodes.formFeed */:
+ case 32 /* CharacterCodes.space */:
+ case 47 /* CharacterCodes.slash */:
// starts of normal trivia
// falls through
- case 60 /* lessThan */:
- case 124 /* bar */:
- case 61 /* equals */:
- case 62 /* greaterThan */:
+ case 60 /* CharacterCodes.lessThan */:
+ case 124 /* CharacterCodes.bar */:
+ case 61 /* CharacterCodes.equals */:
+ case 62 /* CharacterCodes.greaterThan */:
// Starts of conflict marker trivia
return true;
- case 35 /* hash */:
+ case 35 /* CharacterCodes.hash */:
// Only if its the beginning can we have #! trivia
return pos === 0;
default:
- return ch > 127 /* maxAsciiCharacter */;
+ return ch > 127 /* CharacterCodes.maxAsciiCharacter */;
}
}
ts.couldStartTrivia = couldStartTrivia;
@@ -10291,29 +10474,29 @@ var ts;
while (true) {
var ch = text.charCodeAt(pos);
switch (ch) {
- case 13 /* carriageReturn */:
- if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) {
+ case 13 /* CharacterCodes.carriageReturn */:
+ if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) {
pos++;
}
// falls through
- case 10 /* lineFeed */:
+ case 10 /* CharacterCodes.lineFeed */:
pos++;
if (stopAfterLineBreak) {
return pos;
}
canConsumeStar = !!inJSDoc;
continue;
- case 9 /* tab */:
- case 11 /* verticalTab */:
- case 12 /* formFeed */:
- case 32 /* space */:
+ case 9 /* CharacterCodes.tab */:
+ case 11 /* CharacterCodes.verticalTab */:
+ case 12 /* CharacterCodes.formFeed */:
+ case 32 /* CharacterCodes.space */:
pos++;
continue;
- case 47 /* slash */:
+ case 47 /* CharacterCodes.slash */:
if (stopAtComments) {
break;
}
- if (text.charCodeAt(pos + 1) === 47 /* slash */) {
+ if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
pos += 2;
while (pos < text.length) {
if (isLineBreak(text.charCodeAt(pos))) {
@@ -10324,10 +10507,10 @@ var ts;
canConsumeStar = false;
continue;
}
- if (text.charCodeAt(pos + 1) === 42 /* asterisk */) {
+ if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) {
pos += 2;
while (pos < text.length) {
- if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) {
+ if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
pos += 2;
break;
}
@@ -10337,24 +10520,24 @@ var ts;
continue;
}
break;
- case 60 /* lessThan */:
- case 124 /* bar */:
- case 61 /* equals */:
- case 62 /* greaterThan */:
+ case 60 /* CharacterCodes.lessThan */:
+ case 124 /* CharacterCodes.bar */:
+ case 61 /* CharacterCodes.equals */:
+ case 62 /* CharacterCodes.greaterThan */:
if (isConflictMarkerTrivia(text, pos)) {
pos = scanConflictMarkerTrivia(text, pos);
canConsumeStar = false;
continue;
}
break;
- case 35 /* hash */:
+ case 35 /* CharacterCodes.hash */:
if (pos === 0 && isShebangTrivia(text, pos)) {
pos = scanShebangTrivia(text, pos);
canConsumeStar = false;
continue;
}
break;
- case 42 /* asterisk */:
+ case 42 /* CharacterCodes.asterisk */:
if (canConsumeStar) {
pos++;
canConsumeStar = false;
@@ -10362,7 +10545,7 @@ var ts;
}
break;
default:
- if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) {
+ if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) {
pos++;
continue;
}
@@ -10386,8 +10569,8 @@ var ts;
return false;
}
}
- return ch === 61 /* equals */ ||
- text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* space */;
+ return ch === 61 /* CharacterCodes.equals */ ||
+ text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* CharacterCodes.space */;
}
}
return false;
@@ -10398,18 +10581,18 @@ var ts;
}
var ch = text.charCodeAt(pos);
var len = text.length;
- if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) {
+ if (ch === 60 /* CharacterCodes.lessThan */ || ch === 62 /* CharacterCodes.greaterThan */) {
while (pos < len && !isLineBreak(text.charCodeAt(pos))) {
pos++;
}
}
else {
- ts.Debug.assert(ch === 124 /* bar */ || ch === 61 /* equals */);
+ ts.Debug.assert(ch === 124 /* CharacterCodes.bar */ || ch === 61 /* CharacterCodes.equals */);
// Consume everything from the start of a ||||||| or ======= marker to the start
// of the next ======= or >>>>>>> marker.
while (pos < len) {
var currentChar = text.charCodeAt(pos);
- if ((currentChar === 61 /* equals */ || currentChar === 62 /* greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) {
+ if ((currentChar === 61 /* CharacterCodes.equals */ || currentChar === 62 /* CharacterCodes.greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) {
break;
}
pos++;
@@ -10470,12 +10653,12 @@ var ts;
scan: while (pos >= 0 && pos < text.length) {
var ch = text.charCodeAt(pos);
switch (ch) {
- case 13 /* carriageReturn */:
- if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) {
+ case 13 /* CharacterCodes.carriageReturn */:
+ if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) {
pos++;
}
// falls through
- case 10 /* lineFeed */:
+ case 10 /* CharacterCodes.lineFeed */:
pos++;
if (trailing) {
break scan;
@@ -10485,20 +10668,20 @@ var ts;
pendingHasTrailingNewLine = true;
}
continue;
- case 9 /* tab */:
- case 11 /* verticalTab */:
- case 12 /* formFeed */:
- case 32 /* space */:
+ case 9 /* CharacterCodes.tab */:
+ case 11 /* CharacterCodes.verticalTab */:
+ case 12 /* CharacterCodes.formFeed */:
+ case 32 /* CharacterCodes.space */:
pos++;
continue;
- case 47 /* slash */:
+ case 47 /* CharacterCodes.slash */:
var nextChar = text.charCodeAt(pos + 1);
var hasTrailingNewLine = false;
- if (nextChar === 47 /* slash */ || nextChar === 42 /* asterisk */) {
- var kind = nextChar === 47 /* slash */ ? 2 /* SingleLineCommentTrivia */ : 3 /* MultiLineCommentTrivia */;
+ if (nextChar === 47 /* CharacterCodes.slash */ || nextChar === 42 /* CharacterCodes.asterisk */) {
+ var kind = nextChar === 47 /* CharacterCodes.slash */ ? 2 /* SyntaxKind.SingleLineCommentTrivia */ : 3 /* SyntaxKind.MultiLineCommentTrivia */;
var startPos = pos;
pos += 2;
- if (nextChar === 47 /* slash */) {
+ if (nextChar === 47 /* CharacterCodes.slash */) {
while (pos < text.length) {
if (isLineBreak(text.charCodeAt(pos))) {
hasTrailingNewLine = true;
@@ -10509,7 +10692,7 @@ var ts;
}
else {
while (pos < text.length) {
- if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) {
+ if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
pos += 2;
break;
}
@@ -10534,7 +10717,7 @@ var ts;
}
break scan;
default:
- if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) {
+ if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) {
if (hasPendingCommentRange && isLineBreak(ch)) {
pendingHasTrailingNewLine = true;
}
@@ -10589,17 +10772,17 @@ var ts;
}
ts.getShebang = getShebang;
function isIdentifierStart(ch, languageVersion) {
- return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ ||
- ch === 36 /* $ */ || ch === 95 /* _ */ ||
- ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion);
+ return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ ||
+ ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ ||
+ ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion);
}
ts.isIdentifierStart = isIdentifierStart;
function isIdentifierPart(ch, languageVersion, identifierVariant) {
- return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ ||
- ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ ||
+ return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ ||
+ ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ || ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ ||
// "-" and ":" are valid in JSX Identifiers
- (identifierVariant === 1 /* JSX */ ? (ch === 45 /* minus */ || ch === 58 /* colon */) : false) ||
- ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion);
+ (identifierVariant === 1 /* LanguageVariant.JSX */ ? (ch === 45 /* CharacterCodes.minus */ || ch === 58 /* CharacterCodes.colon */) : false) ||
+ ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion);
}
ts.isIdentifierPart = isIdentifierPart;
/* @internal */
@@ -10618,7 +10801,7 @@ var ts;
ts.isIdentifierText = isIdentifierText;
// Creates a scanner over a (possibly unspecified) range of a piece of text.
function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) {
- if (languageVariant === void 0) { languageVariant = 0 /* Standard */; }
+ if (languageVariant === void 0) { languageVariant = 0 /* LanguageVariant.Standard */; }
var text = textInitial;
// Current position (end position of text of current token)
var pos;
@@ -10641,15 +10824,15 @@ var ts;
getTokenPos: function () { return tokenPos; },
getTokenText: function () { return text.substring(tokenPos, pos); },
getTokenValue: function () { return tokenValue; },
- hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; },
- hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; },
- hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; },
- hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* PrecedingJSDocComment */) !== 0; },
- isIdentifier: function () { return token === 79 /* Identifier */ || token > 116 /* LastReservedWord */; },
- isReservedWord: function () { return token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */; },
- isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; },
+ hasUnicodeEscape: function () { return (tokenFlags & 1024 /* TokenFlags.UnicodeEscape */) !== 0; },
+ hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* TokenFlags.ExtendedUnicodeEscape */) !== 0; },
+ hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */) !== 0; },
+ hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* TokenFlags.PrecedingJSDocComment */) !== 0; },
+ isIdentifier: function () { return token === 79 /* SyntaxKind.Identifier */ || token > 116 /* SyntaxKind.LastReservedWord */; },
+ isReservedWord: function () { return token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */; },
+ isUnterminated: function () { return (tokenFlags & 4 /* TokenFlags.Unterminated */) !== 0; },
getCommentDirectives: function () { return commentDirectives; },
- getNumericLiteralFlags: function () { return tokenFlags & 1008 /* NumericLiteralFlags */; },
+ getNumericLiteralFlags: function () { return tokenFlags & 1008 /* TokenFlags.NumericLiteralFlags */; },
getTokenFlags: function () { return tokenFlags; },
reScanGreaterToken: reScanGreaterToken,
reScanAsteriskEqualsToken: reScanAsteriskEqualsToken,
@@ -10704,8 +10887,8 @@ var ts;
var result = "";
while (true) {
var ch = text.charCodeAt(pos);
- if (ch === 95 /* _ */) {
- tokenFlags |= 512 /* ContainsSeparator */;
+ if (ch === 95 /* CharacterCodes._ */) {
+ tokenFlags |= 512 /* TokenFlags.ContainsSeparator */;
if (allowSeparator) {
allowSeparator = false;
isPreviousTokenSeparator = true;
@@ -10729,7 +10912,7 @@ var ts;
}
break;
}
- if (text.charCodeAt(pos - 1) === 95 /* _ */) {
+ if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) {
error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
}
return result + text.substring(start, pos);
@@ -10739,15 +10922,15 @@ var ts;
var mainFragment = scanNumberFragment();
var decimalFragment;
var scientificFragment;
- if (text.charCodeAt(pos) === 46 /* dot */) {
+ if (text.charCodeAt(pos) === 46 /* CharacterCodes.dot */) {
pos++;
decimalFragment = scanNumberFragment();
}
var end = pos;
- if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) {
+ if (text.charCodeAt(pos) === 69 /* CharacterCodes.E */ || text.charCodeAt(pos) === 101 /* CharacterCodes.e */) {
pos++;
- tokenFlags |= 16 /* Scientific */;
- if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */)
+ tokenFlags |= 16 /* TokenFlags.Scientific */;
+ if (text.charCodeAt(pos) === 43 /* CharacterCodes.plus */ || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */)
pos++;
var preNumericPart = pos;
var finalFragment = scanNumberFragment();
@@ -10760,7 +10943,7 @@ var ts;
}
}
var result;
- if (tokenFlags & 512 /* ContainsSeparator */) {
+ if (tokenFlags & 512 /* TokenFlags.ContainsSeparator */) {
result = mainFragment;
if (decimalFragment) {
result += "." + decimalFragment;
@@ -10772,10 +10955,10 @@ var ts;
else {
result = text.substring(start, end); // No need to use all the fragments; no _ removal needed
}
- if (decimalFragment !== undefined || tokenFlags & 16 /* Scientific */) {
- checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* Scientific */));
+ if (decimalFragment !== undefined || tokenFlags & 16 /* TokenFlags.Scientific */) {
+ checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* TokenFlags.Scientific */));
return {
- type: 8 /* NumericLiteral */,
+ type: 8 /* SyntaxKind.NumericLiteral */,
value: "" + +result // if value is not an integer, it can be safely coerced to a number
};
}
@@ -10833,8 +11016,8 @@ var ts;
var isPreviousTokenSeparator = false;
while (valueChars.length < minCount || scanAsManyAsPossible) {
var ch = text.charCodeAt(pos);
- if (canHaveSeparators && ch === 95 /* _ */) {
- tokenFlags |= 512 /* ContainsSeparator */;
+ if (canHaveSeparators && ch === 95 /* CharacterCodes._ */) {
+ tokenFlags |= 512 /* TokenFlags.ContainsSeparator */;
if (allowSeparator) {
allowSeparator = false;
isPreviousTokenSeparator = true;
@@ -10849,11 +11032,11 @@ var ts;
continue;
}
allowSeparator = canHaveSeparators;
- if (ch >= 65 /* A */ && ch <= 70 /* F */) {
- ch += 97 /* a */ - 65 /* A */; // standardize hex literals to lowercase
+ if (ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */) {
+ ch += 97 /* CharacterCodes.a */ - 65 /* CharacterCodes.A */; // standardize hex literals to lowercase
}
- else if (!((ch >= 48 /* _0 */ && ch <= 57 /* _9 */) ||
- (ch >= 97 /* a */ && ch <= 102 /* f */))) {
+ else if (!((ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) ||
+ (ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */))) {
break;
}
valueChars.push(ch);
@@ -10863,7 +11046,7 @@ var ts;
if (valueChars.length < minCount) {
valueChars = [];
}
- if (text.charCodeAt(pos - 1) === 95 /* _ */) {
+ if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) {
error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
}
return String.fromCharCode.apply(String, valueChars);
@@ -10877,7 +11060,7 @@ var ts;
while (true) {
if (pos >= end) {
result += text.substring(start, pos);
- tokenFlags |= 4 /* Unterminated */;
+ tokenFlags |= 4 /* TokenFlags.Unterminated */;
error(ts.Diagnostics.Unterminated_string_literal);
break;
}
@@ -10887,7 +11070,7 @@ var ts;
pos++;
break;
}
- if (ch === 92 /* backslash */ && !jsxAttributeString) {
+ if (ch === 92 /* CharacterCodes.backslash */ && !jsxAttributeString) {
result += text.substring(start, pos);
result += scanEscapeSequence();
start = pos;
@@ -10895,7 +11078,7 @@ var ts;
}
if (isLineBreak(ch) && !jsxAttributeString) {
result += text.substring(start, pos);
- tokenFlags |= 4 /* Unterminated */;
+ tokenFlags |= 4 /* TokenFlags.Unterminated */;
error(ts.Diagnostics.Unterminated_string_literal);
break;
}
@@ -10908,7 +11091,7 @@ var ts;
* a literal component of a TemplateExpression.
*/
function scanTemplateAndSetTokenValue(isTaggedTemplate) {
- var startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */;
+ var startedWithBacktick = text.charCodeAt(pos) === 96 /* CharacterCodes.backtick */;
pos++;
var start = pos;
var contents = "";
@@ -10916,28 +11099,28 @@ var ts;
while (true) {
if (pos >= end) {
contents += text.substring(start, pos);
- tokenFlags |= 4 /* Unterminated */;
+ tokenFlags |= 4 /* TokenFlags.Unterminated */;
error(ts.Diagnostics.Unterminated_template_literal);
- resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */;
+ resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */;
break;
}
var currChar = text.charCodeAt(pos);
// '`'
- if (currChar === 96 /* backtick */) {
+ if (currChar === 96 /* CharacterCodes.backtick */) {
contents += text.substring(start, pos);
pos++;
- resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */;
+ resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */;
break;
}
// '${'
- if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) {
+ if (currChar === 36 /* CharacterCodes.$ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* CharacterCodes.openBrace */) {
contents += text.substring(start, pos);
pos += 2;
- resultingToken = startedWithBacktick ? 15 /* TemplateHead */ : 16 /* TemplateMiddle */;
+ resultingToken = startedWithBacktick ? 15 /* SyntaxKind.TemplateHead */ : 16 /* SyntaxKind.TemplateMiddle */;
break;
}
// Escape character
- if (currChar === 92 /* backslash */) {
+ if (currChar === 92 /* CharacterCodes.backslash */) {
contents += text.substring(start, pos);
contents += scanEscapeSequence(isTaggedTemplate);
start = pos;
@@ -10945,10 +11128,10 @@ var ts;
}
// Speculated ECMAScript 6 Spec 11.8.6.1:
// <CR><LF> and <CR> LineTerminatorSequences are normalized to <LF> for Template Values
- if (currChar === 13 /* carriageReturn */) {
+ if (currChar === 13 /* CharacterCodes.carriageReturn */) {
contents += text.substring(start, pos);
pos++;
- if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) {
+ if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) {
pos++;
}
contents += "\n";
@@ -10971,47 +11154,47 @@ var ts;
var ch = text.charCodeAt(pos);
pos++;
switch (ch) {
- case 48 /* _0 */:
+ case 48 /* CharacterCodes._0 */:
// '\01'
if (isTaggedTemplate && pos < end && isDigit(text.charCodeAt(pos))) {
pos++;
- tokenFlags |= 2048 /* ContainsInvalidEscape */;
+ tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */;
return text.substring(start, pos);
}
return "\0";
- case 98 /* b */:
+ case 98 /* CharacterCodes.b */:
return "\b";
- case 116 /* t */:
+ case 116 /* CharacterCodes.t */:
return "\t";
- case 110 /* n */:
+ case 110 /* CharacterCodes.n */:
return "\n";
- case 118 /* v */:
+ case 118 /* CharacterCodes.v */:
return "\v";
- case 102 /* f */:
+ case 102 /* CharacterCodes.f */:
return "\f";
- case 114 /* r */:
+ case 114 /* CharacterCodes.r */:
return "\r";
- case 39 /* singleQuote */:
+ case 39 /* CharacterCodes.singleQuote */:
return "\'";
- case 34 /* doubleQuote */:
+ case 34 /* CharacterCodes.doubleQuote */:
return "\"";
- case 117 /* u */:
+ case 117 /* CharacterCodes.u */:
if (isTaggedTemplate) {
// '\u' or '\u0' or '\u00' or '\u000'
for (var escapePos = pos; escapePos < pos + 4; escapePos++) {
- if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* openBrace */) {
+ if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* CharacterCodes.openBrace */) {
pos = escapePos;
- tokenFlags |= 2048 /* ContainsInvalidEscape */;
+ tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */;
return text.substring(start, pos);
}
}
}
// '\u{DDDDDDDD}'
- if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) {
+ if (pos < end && text.charCodeAt(pos) === 123 /* CharacterCodes.openBrace */) {
pos++;
// '\u{'
if (isTaggedTemplate && !isHexDigit(text.charCodeAt(pos))) {
- tokenFlags |= 2048 /* ContainsInvalidEscape */;
+ tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */;
return text.substring(start, pos);
}
if (isTaggedTemplate) {
@@ -11019,29 +11202,29 @@ var ts;
var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false);
var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
// '\u{Not Code Point' or '\u{CodePoint'
- if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* closeBrace */) {
- tokenFlags |= 2048 /* ContainsInvalidEscape */;
+ if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* CharacterCodes.closeBrace */) {
+ tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */;
return text.substring(start, pos);
}
else {
pos = savePos;
}
}
- tokenFlags |= 8 /* ExtendedUnicodeEscape */;
+ tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */;
return scanExtendedUnicodeEscape();
}
- tokenFlags |= 1024 /* UnicodeEscape */;
+ tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */;
// '\uDDDD'
return scanHexadecimalEscape(/*numDigits*/ 4);
- case 120 /* x */:
+ case 120 /* CharacterCodes.x */:
if (isTaggedTemplate) {
if (!isHexDigit(text.charCodeAt(pos))) {
- tokenFlags |= 2048 /* ContainsInvalidEscape */;
+ tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */;
return text.substring(start, pos);
}
else if (!isHexDigit(text.charCodeAt(pos + 1))) {
pos++;
- tokenFlags |= 2048 /* ContainsInvalidEscape */;
+ tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */;
return text.substring(start, pos);
}
}
@@ -11049,14 +11232,14 @@ var ts;
return scanHexadecimalEscape(/*numDigits*/ 2);
// when encountering a LineContinuation (i.e. a backslash and a line terminator sequence),
// the line terminator is interpreted to be "the empty code unit sequence".
- case 13 /* carriageReturn */:
- if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) {
+ case 13 /* CharacterCodes.carriageReturn */:
+ if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) {
pos++;
}
// falls through
- case 10 /* lineFeed */:
- case 8232 /* lineSeparator */:
- case 8233 /* paragraphSeparator */:
+ case 10 /* CharacterCodes.lineFeed */:
+ case 8232 /* CharacterCodes.lineSeparator */:
+ case 8233 /* CharacterCodes.paragraphSeparator */:
return "";
default:
return String.fromCharCode(ch);
@@ -11089,7 +11272,7 @@ var ts;
error(ts.Diagnostics.Unexpected_end_of_text);
isInvalidExtendedEscape = true;
}
- else if (text.charCodeAt(pos) === 125 /* closeBrace */) {
+ else if (text.charCodeAt(pos) === 125 /* CharacterCodes.closeBrace */) {
// Only swallow the following character up if it's a '}'.
pos++;
}
@@ -11105,7 +11288,7 @@ var ts;
// Current character is known to be a backslash. Check for Unicode escape of the form '\uXXXX'
// and return code point value if valid Unicode escape is found. Otherwise return -1.
function peekUnicodeEscape() {
- if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* u */) {
+ if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* CharacterCodes.u */) {
var start_1 = pos;
pos += 2;
var value = scanExactNumberOfHexDigits(4, /*canHaveSeparators*/ false);
@@ -11115,7 +11298,7 @@ var ts;
return -1;
}
function peekExtendedUnicodeEscape() {
- if (languageVersion >= 2 /* ES2015 */ && codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) {
+ if (languageVersion >= 2 /* ScriptTarget.ES2015 */ && codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) {
var start_2 = pos;
pos += 3;
var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false);
@@ -11133,11 +11316,11 @@ var ts;
if (isIdentifierPart(ch, languageVersion)) {
pos += charSize(ch);
}
- else if (ch === 92 /* backslash */) {
+ else if (ch === 92 /* CharacterCodes.backslash */) {
ch = peekExtendedUnicodeEscape();
if (ch >= 0 && isIdentifierPart(ch, languageVersion)) {
pos += 3;
- tokenFlags |= 8 /* ExtendedUnicodeEscape */;
+ tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */;
result += scanExtendedUnicodeEscape();
start = pos;
continue;
@@ -11146,7 +11329,7 @@ var ts;
if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) {
break;
}
- tokenFlags |= 1024 /* UnicodeEscape */;
+ tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */;
result += text.substring(start, pos);
result += utf16EncodeAsString(ch);
// Valid Unicode escape is always six characters
@@ -11165,14 +11348,14 @@ var ts;
var len = tokenValue.length;
if (len >= 2 && len <= 12) {
var ch = tokenValue.charCodeAt(0);
- if (ch >= 97 /* a */ && ch <= 122 /* z */) {
+ if (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) {
var keyword = textToKeyword.get(tokenValue);
if (keyword !== undefined) {
return token = keyword;
}
}
}
- return token = 79 /* Identifier */;
+ return token = 79 /* SyntaxKind.Identifier */;
}
function scanBinaryOrOctalDigits(base) {
var value = "";
@@ -11183,8 +11366,8 @@ var ts;
while (true) {
var ch = text.charCodeAt(pos);
// Numeric separators are allowed anywhere within a numeric literal, except not at the beginning, or following another separator
- if (ch === 95 /* _ */) {
- tokenFlags |= 512 /* ContainsSeparator */;
+ if (ch === 95 /* CharacterCodes._ */) {
+ tokenFlags |= 512 /* TokenFlags.ContainsSeparator */;
if (separatorAllowed) {
separatorAllowed = false;
isPreviousTokenSeparator = true;
@@ -11199,101 +11382,101 @@ var ts;
continue;
}
separatorAllowed = true;
- if (!isDigit(ch) || ch - 48 /* _0 */ >= base) {
+ if (!isDigit(ch) || ch - 48 /* CharacterCodes._0 */ >= base) {
break;
}
value += text[pos];
pos++;
isPreviousTokenSeparator = false;
}
- if (text.charCodeAt(pos - 1) === 95 /* _ */) {
+ if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) {
// Literal ends with underscore - not allowed
error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
}
return value;
}
function checkBigIntSuffix() {
- if (text.charCodeAt(pos) === 110 /* n */) {
+ if (text.charCodeAt(pos) === 110 /* CharacterCodes.n */) {
tokenValue += "n";
// Use base 10 instead of base 2 or base 8 for shorter literals
- if (tokenFlags & 384 /* BinaryOrOctalSpecifier */) {
+ if (tokenFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) {
tokenValue = ts.parsePseudoBigInt(tokenValue) + "n";
}
pos++;
- return 9 /* BigIntLiteral */;
+ return 9 /* SyntaxKind.BigIntLiteral */;
}
else { // not a bigint, so can convert to number in simplified form
// Number() may not support 0b or 0o, so use parseInt() instead
- var numericValue = tokenFlags & 128 /* BinarySpecifier */
+ var numericValue = tokenFlags & 128 /* TokenFlags.BinarySpecifier */
? parseInt(tokenValue.slice(2), 2) // skip "0b"
- : tokenFlags & 256 /* OctalSpecifier */
+ : tokenFlags & 256 /* TokenFlags.OctalSpecifier */
? parseInt(tokenValue.slice(2), 8) // skip "0o"
: +tokenValue;
tokenValue = "" + numericValue;
- return 8 /* NumericLiteral */;
+ return 8 /* SyntaxKind.NumericLiteral */;
}
}
function scan() {
var _a;
startPos = pos;
- tokenFlags = 0 /* None */;
+ tokenFlags = 0 /* TokenFlags.None */;
var asteriskSeen = false;
while (true) {
tokenPos = pos;
if (pos >= end) {
- return token = 1 /* EndOfFileToken */;
+ return token = 1 /* SyntaxKind.EndOfFileToken */;
}
var ch = codePointAt(text, pos);
// Special handling for shebang
- if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) {
+ if (ch === 35 /* CharacterCodes.hash */ && pos === 0 && isShebangTrivia(text, pos)) {
pos = scanShebangTrivia(text, pos);
if (skipTrivia) {
continue;
}
else {
- return token = 6 /* ShebangTrivia */;
+ return token = 6 /* SyntaxKind.ShebangTrivia */;
}
}
switch (ch) {
- case 10 /* lineFeed */:
- case 13 /* carriageReturn */:
- tokenFlags |= 1 /* PrecedingLineBreak */;
+ case 10 /* CharacterCodes.lineFeed */:
+ case 13 /* CharacterCodes.carriageReturn */:
+ tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */;
if (skipTrivia) {
pos++;
continue;
}
else {
- if (ch === 13 /* carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* lineFeed */) {
+ if (ch === 13 /* CharacterCodes.carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) {
// consume both CR and LF
pos += 2;
}
else {
pos++;
}
- return token = 4 /* NewLineTrivia */;
- }
- case 9 /* tab */:
- case 11 /* verticalTab */:
- case 12 /* formFeed */:
- case 32 /* space */:
- case 160 /* nonBreakingSpace */:
- case 5760 /* ogham */:
- case 8192 /* enQuad */:
- case 8193 /* emQuad */:
- case 8194 /* enSpace */:
- case 8195 /* emSpace */:
- case 8196 /* threePerEmSpace */:
- case 8197 /* fourPerEmSpace */:
- case 8198 /* sixPerEmSpace */:
- case 8199 /* figureSpace */:
- case 8200 /* punctuationSpace */:
- case 8201 /* thinSpace */:
- case 8202 /* hairSpace */:
- case 8203 /* zeroWidthSpace */:
- case 8239 /* narrowNoBreakSpace */:
- case 8287 /* mathematicalSpace */:
- case 12288 /* ideographicSpace */:
- case 65279 /* byteOrderMark */:
+ return token = 4 /* SyntaxKind.NewLineTrivia */;
+ }
+ case 9 /* CharacterCodes.tab */:
+ case 11 /* CharacterCodes.verticalTab */:
+ case 12 /* CharacterCodes.formFeed */:
+ case 32 /* CharacterCodes.space */:
+ case 160 /* CharacterCodes.nonBreakingSpace */:
+ case 5760 /* CharacterCodes.ogham */:
+ case 8192 /* CharacterCodes.enQuad */:
+ case 8193 /* CharacterCodes.emQuad */:
+ case 8194 /* CharacterCodes.enSpace */:
+ case 8195 /* CharacterCodes.emSpace */:
+ case 8196 /* CharacterCodes.threePerEmSpace */:
+ case 8197 /* CharacterCodes.fourPerEmSpace */:
+ case 8198 /* CharacterCodes.sixPerEmSpace */:
+ case 8199 /* CharacterCodes.figureSpace */:
+ case 8200 /* CharacterCodes.punctuationSpace */:
+ case 8201 /* CharacterCodes.thinSpace */:
+ case 8202 /* CharacterCodes.hairSpace */:
+ case 8203 /* CharacterCodes.zeroWidthSpace */:
+ case 8239 /* CharacterCodes.narrowNoBreakSpace */:
+ case 8287 /* CharacterCodes.mathematicalSpace */:
+ case 12288 /* CharacterCodes.ideographicSpace */:
+ case 65279 /* CharacterCodes.byteOrderMark */:
if (skipTrivia) {
pos++;
continue;
@@ -11302,98 +11485,98 @@ var ts;
while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) {
pos++;
}
- return token = 5 /* WhitespaceTrivia */;
+ return token = 5 /* SyntaxKind.WhitespaceTrivia */;
}
- case 33 /* exclamation */:
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
- return pos += 3, token = 37 /* ExclamationEqualsEqualsToken */;
+ case 33 /* CharacterCodes.exclamation */:
+ if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) {
+ if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) {
+ return pos += 3, token = 37 /* SyntaxKind.ExclamationEqualsEqualsToken */;
}
- return pos += 2, token = 35 /* ExclamationEqualsToken */;
+ return pos += 2, token = 35 /* SyntaxKind.ExclamationEqualsToken */;
}
pos++;
- return token = 53 /* ExclamationToken */;
- case 34 /* doubleQuote */:
- case 39 /* singleQuote */:
+ return token = 53 /* SyntaxKind.ExclamationToken */;
+ case 34 /* CharacterCodes.doubleQuote */:
+ case 39 /* CharacterCodes.singleQuote */:
tokenValue = scanString();
- return token = 10 /* StringLiteral */;
- case 96 /* backtick */:
+ return token = 10 /* SyntaxKind.StringLiteral */;
+ case 96 /* CharacterCodes.backtick */:
return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ false);
- case 37 /* percent */:
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
- return pos += 2, token = 69 /* PercentEqualsToken */;
+ case 37 /* CharacterCodes.percent */:
+ if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) {
+ return pos += 2, token = 69 /* SyntaxKind.PercentEqualsToken */;
}
pos++;
- return token = 44 /* PercentToken */;
- case 38 /* ampersand */:
- if (text.charCodeAt(pos + 1) === 38 /* ampersand */) {
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
- return pos += 3, token = 76 /* AmpersandAmpersandEqualsToken */;
+ return token = 44 /* SyntaxKind.PercentToken */;
+ case 38 /* CharacterCodes.ampersand */:
+ if (text.charCodeAt(pos + 1) === 38 /* CharacterCodes.ampersand */) {
+ if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) {
+ return pos += 3, token = 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */;
}
- return pos += 2, token = 55 /* AmpersandAmpersandToken */;
+ return pos += 2, token = 55 /* SyntaxKind.AmpersandAmpersandToken */;
}
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
- return pos += 2, token = 73 /* AmpersandEqualsToken */;
+ if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) {
+ return pos += 2, token = 73 /* SyntaxKind.AmpersandEqualsToken */;
}
pos++;
- return token = 50 /* AmpersandToken */;
- case 40 /* openParen */:
+ return token = 50 /* SyntaxKind.AmpersandToken */;
+ case 40 /* CharacterCodes.openParen */:
pos++;
- return token = 20 /* OpenParenToken */;
- case 41 /* closeParen */:
+ return token = 20 /* SyntaxKind.OpenParenToken */;
+ case 41 /* CharacterCodes.closeParen */:
pos++;
- return token = 21 /* CloseParenToken */;
- case 42 /* asterisk */:
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
- return pos += 2, token = 66 /* AsteriskEqualsToken */;
+ return token = 21 /* SyntaxKind.CloseParenToken */;
+ case 42 /* CharacterCodes.asterisk */:
+ if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) {
+ return pos += 2, token = 66 /* SyntaxKind.AsteriskEqualsToken */;
}
- if (text.charCodeAt(pos + 1) === 42 /* asterisk */) {
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
- return pos += 3, token = 67 /* AsteriskAsteriskEqualsToken */;
+ if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) {
+ if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) {
+ return pos += 3, token = 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */;
}
- return pos += 2, token = 42 /* AsteriskAsteriskToken */;
+ return pos += 2, token = 42 /* SyntaxKind.AsteriskAsteriskToken */;
}
pos++;
- if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) {
+ if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */)) {
// decoration at the start of a JSDoc comment line
asteriskSeen = true;
continue;
}
- return token = 41 /* AsteriskToken */;
- case 43 /* plus */:
- if (text.charCodeAt(pos + 1) === 43 /* plus */) {
- return pos += 2, token = 45 /* PlusPlusToken */;
+ return token = 41 /* SyntaxKind.AsteriskToken */;
+ case 43 /* CharacterCodes.plus */:
+ if (text.charCodeAt(pos + 1) === 43 /* CharacterCodes.plus */) {
+ return pos += 2, token = 45 /* SyntaxKind.PlusPlusToken */;
}
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
- return pos += 2, token = 64 /* PlusEqualsToken */;
+ if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) {
+ return pos += 2, token = 64 /* SyntaxKind.PlusEqualsToken */;
}
pos++;
- return token = 39 /* PlusToken */;
- case 44 /* comma */:
+ return token = 39 /* SyntaxKind.PlusToken */;
+ case 44 /* CharacterCodes.comma */:
pos++;
- return token = 27 /* CommaToken */;
- case 45 /* minus */:
- if (text.charCodeAt(pos + 1) === 45 /* minus */) {
- return pos += 2, token = 46 /* MinusMinusToken */;
+ return token = 27 /* SyntaxKind.CommaToken */;
+ case 45 /* CharacterCodes.minus */:
+ if (text.charCodeAt(pos + 1) === 45 /* CharacterCodes.minus */) {
+ return pos += 2, token = 46 /* SyntaxKind.MinusMinusToken */;
}
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
- return pos += 2, token = 65 /* MinusEqualsToken */;
+ if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) {
+ return pos += 2, token = 65 /* SyntaxKind.MinusEqualsToken */;
}
pos++;
- return token = 40 /* MinusToken */;
- case 46 /* dot */:
+ return token = 40 /* SyntaxKind.MinusToken */;
+ case 46 /* CharacterCodes.dot */:
if (isDigit(text.charCodeAt(pos + 1))) {
tokenValue = scanNumber().value;
- return token = 8 /* NumericLiteral */;
+ return token = 8 /* SyntaxKind.NumericLiteral */;
}
- if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) {
- return pos += 3, token = 25 /* DotDotDotToken */;
+ if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && text.charCodeAt(pos + 2) === 46 /* CharacterCodes.dot */) {
+ return pos += 3, token = 25 /* SyntaxKind.DotDotDotToken */;
}
pos++;
- return token = 24 /* DotToken */;
- case 47 /* slash */:
+ return token = 24 /* SyntaxKind.DotToken */;
+ case 47 /* CharacterCodes.slash */:
// Single-line comment
- if (text.charCodeAt(pos + 1) === 47 /* slash */) {
+ if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
pos += 2;
while (pos < end) {
if (isLineBreak(text.charCodeAt(pos))) {
@@ -11406,20 +11589,20 @@ var ts;
continue;
}
else {
- return token = 2 /* SingleLineCommentTrivia */;
+ return token = 2 /* SyntaxKind.SingleLineCommentTrivia */;
}
}
// Multi-line comment
- if (text.charCodeAt(pos + 1) === 42 /* asterisk */) {
+ if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) {
pos += 2;
- if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) !== 47 /* slash */) {
- tokenFlags |= 2 /* PrecedingJSDocComment */;
+ if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) !== 47 /* CharacterCodes.slash */) {
+ tokenFlags |= 2 /* TokenFlags.PrecedingJSDocComment */;
}
var commentClosed = false;
var lastLineStart = tokenPos;
while (pos < end) {
var ch_1 = text.charCodeAt(pos);
- if (ch_1 === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) {
+ if (ch_1 === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
pos += 2;
commentClosed = true;
break;
@@ -11427,7 +11610,7 @@ var ts;
pos++;
if (isLineBreak(ch_1)) {
lastLineStart = pos;
- tokenFlags |= 1 /* PrecedingLineBreak */;
+ tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */;
}
}
commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(lastLineStart, pos), commentDirectiveRegExMultiLine, lastLineStart);
@@ -11439,18 +11622,18 @@ var ts;
}
else {
if (!commentClosed) {
- tokenFlags |= 4 /* Unterminated */;
+ tokenFlags |= 4 /* TokenFlags.Unterminated */;
}
- return token = 3 /* MultiLineCommentTrivia */;
+ return token = 3 /* SyntaxKind.MultiLineCommentTrivia */;
}
}
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
- return pos += 2, token = 68 /* SlashEqualsToken */;
+ if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) {
+ return pos += 2, token = 68 /* SyntaxKind.SlashEqualsToken */;
}
pos++;
- return token = 43 /* SlashToken */;
- case 48 /* _0 */:
- if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) {
+ return token = 43 /* SyntaxKind.SlashToken */;
+ case 48 /* CharacterCodes._0 */:
+ if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* CharacterCodes.X */ || text.charCodeAt(pos + 1) === 120 /* CharacterCodes.x */)) {
pos += 2;
tokenValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true);
if (!tokenValue) {
@@ -11458,10 +11641,10 @@ var ts;
tokenValue = "0";
}
tokenValue = "0x" + tokenValue;
- tokenFlags |= 64 /* HexSpecifier */;
+ tokenFlags |= 64 /* TokenFlags.HexSpecifier */;
return token = checkBigIntSuffix();
}
- else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) {
+ else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* CharacterCodes.B */ || text.charCodeAt(pos + 1) === 98 /* CharacterCodes.b */)) {
pos += 2;
tokenValue = scanBinaryOrOctalDigits(/* base */ 2);
if (!tokenValue) {
@@ -11469,10 +11652,10 @@ var ts;
tokenValue = "0";
}
tokenValue = "0b" + tokenValue;
- tokenFlags |= 128 /* BinarySpecifier */;
+ tokenFlags |= 128 /* TokenFlags.BinarySpecifier */;
return token = checkBigIntSuffix();
}
- else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) {
+ else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* CharacterCodes.O */ || text.charCodeAt(pos + 1) === 111 /* CharacterCodes.o */)) {
pos += 2;
tokenValue = scanBinaryOrOctalDigits(/* base */ 8);
if (!tokenValue) {
@@ -11480,175 +11663,175 @@ var ts;
tokenValue = "0";
}
tokenValue = "0o" + tokenValue;
- tokenFlags |= 256 /* OctalSpecifier */;
+ tokenFlags |= 256 /* TokenFlags.OctalSpecifier */;
return token = checkBigIntSuffix();
}
// Try to parse as an octal
if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) {
tokenValue = "" + scanOctalDigits();
- tokenFlags |= 32 /* Octal */;
- return token = 8 /* NumericLiteral */;
+ tokenFlags |= 32 /* TokenFlags.Octal */;
+ return token = 8 /* SyntaxKind.NumericLiteral */;
}
// This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero
// can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being
// permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do).
// falls through
- case 49 /* _1 */:
- case 50 /* _2 */:
- case 51 /* _3 */:
- case 52 /* _4 */:
- case 53 /* _5 */:
- case 54 /* _6 */:
- case 55 /* _7 */:
- case 56 /* _8 */:
- case 57 /* _9 */:
+ case 49 /* CharacterCodes._1 */:
+ case 50 /* CharacterCodes._2 */:
+ case 51 /* CharacterCodes._3 */:
+ case 52 /* CharacterCodes._4 */:
+ case 53 /* CharacterCodes._5 */:
+ case 54 /* CharacterCodes._6 */:
+ case 55 /* CharacterCodes._7 */:
+ case 56 /* CharacterCodes._8 */:
+ case 57 /* CharacterCodes._9 */:
(_a = scanNumber(), token = _a.type, tokenValue = _a.value);
return token;
- case 58 /* colon */:
+ case 58 /* CharacterCodes.colon */:
pos++;
- return token = 58 /* ColonToken */;
- case 59 /* semicolon */:
+ return token = 58 /* SyntaxKind.ColonToken */;
+ case 59 /* CharacterCodes.semicolon */:
pos++;
- return token = 26 /* SemicolonToken */;
- case 60 /* lessThan */:
+ return token = 26 /* SyntaxKind.SemicolonToken */;
+ case 60 /* CharacterCodes.lessThan */:
if (isConflictMarkerTrivia(text, pos)) {
pos = scanConflictMarkerTrivia(text, pos, error);
if (skipTrivia) {
continue;
}
else {
- return token = 7 /* ConflictMarkerTrivia */;
+ return token = 7 /* SyntaxKind.ConflictMarkerTrivia */;
}
}
- if (text.charCodeAt(pos + 1) === 60 /* lessThan */) {
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
- return pos += 3, token = 70 /* LessThanLessThanEqualsToken */;
+ if (text.charCodeAt(pos + 1) === 60 /* CharacterCodes.lessThan */) {
+ if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) {
+ return pos += 3, token = 70 /* SyntaxKind.LessThanLessThanEqualsToken */;
}
- return pos += 2, token = 47 /* LessThanLessThanToken */;
+ return pos += 2, token = 47 /* SyntaxKind.LessThanLessThanToken */;
}
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
- return pos += 2, token = 32 /* LessThanEqualsToken */;
+ if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) {
+ return pos += 2, token = 32 /* SyntaxKind.LessThanEqualsToken */;
}
- if (languageVariant === 1 /* JSX */ &&
- text.charCodeAt(pos + 1) === 47 /* slash */ &&
- text.charCodeAt(pos + 2) !== 42 /* asterisk */) {
- return pos += 2, token = 30 /* LessThanSlashToken */;
+ if (languageVariant === 1 /* LanguageVariant.JSX */ &&
+ text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */ &&
+ text.charCodeAt(pos + 2) !== 42 /* CharacterCodes.asterisk */) {
+ return pos += 2, token = 30 /* SyntaxKind.LessThanSlashToken */;
}
pos++;
- return token = 29 /* LessThanToken */;
- case 61 /* equals */:
+ return token = 29 /* SyntaxKind.LessThanToken */;
+ case 61 /* CharacterCodes.equals */:
if (isConflictMarkerTrivia(text, pos)) {
pos = scanConflictMarkerTrivia(text, pos, error);
if (skipTrivia) {
continue;
}
else {
- return token = 7 /* ConflictMarkerTrivia */;
+ return token = 7 /* SyntaxKind.ConflictMarkerTrivia */;
}
}
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
- return pos += 3, token = 36 /* EqualsEqualsEqualsToken */;
+ if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) {
+ if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) {
+ return pos += 3, token = 36 /* SyntaxKind.EqualsEqualsEqualsToken */;
}
- return pos += 2, token = 34 /* EqualsEqualsToken */;
+ return pos += 2, token = 34 /* SyntaxKind.EqualsEqualsToken */;
}
- if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) {
- return pos += 2, token = 38 /* EqualsGreaterThanToken */;
+ if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) {
+ return pos += 2, token = 38 /* SyntaxKind.EqualsGreaterThanToken */;
}
pos++;
- return token = 63 /* EqualsToken */;
- case 62 /* greaterThan */:
+ return token = 63 /* SyntaxKind.EqualsToken */;
+ case 62 /* CharacterCodes.greaterThan */:
if (isConflictMarkerTrivia(text, pos)) {
pos = scanConflictMarkerTrivia(text, pos, error);
if (skipTrivia) {
continue;
}
else {
- return token = 7 /* ConflictMarkerTrivia */;
+ return token = 7 /* SyntaxKind.ConflictMarkerTrivia */;
}
}
pos++;
- return token = 31 /* GreaterThanToken */;
- case 63 /* question */:
- if (text.charCodeAt(pos + 1) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 2))) {
- return pos += 2, token = 28 /* QuestionDotToken */;
+ return token = 31 /* SyntaxKind.GreaterThanToken */;
+ case 63 /* CharacterCodes.question */:
+ if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && !isDigit(text.charCodeAt(pos + 2))) {
+ return pos += 2, token = 28 /* SyntaxKind.QuestionDotToken */;
}
- if (text.charCodeAt(pos + 1) === 63 /* question */) {
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
- return pos += 3, token = 77 /* QuestionQuestionEqualsToken */;
+ if (text.charCodeAt(pos + 1) === 63 /* CharacterCodes.question */) {
+ if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) {
+ return pos += 3, token = 77 /* SyntaxKind.QuestionQuestionEqualsToken */;
}
- return pos += 2, token = 60 /* QuestionQuestionToken */;
+ return pos += 2, token = 60 /* SyntaxKind.QuestionQuestionToken */;
}
pos++;
- return token = 57 /* QuestionToken */;
- case 91 /* openBracket */:
+ return token = 57 /* SyntaxKind.QuestionToken */;
+ case 91 /* CharacterCodes.openBracket */:
pos++;
- return token = 22 /* OpenBracketToken */;
- case 93 /* closeBracket */:
+ return token = 22 /* SyntaxKind.OpenBracketToken */;
+ case 93 /* CharacterCodes.closeBracket */:
pos++;
- return token = 23 /* CloseBracketToken */;
- case 94 /* caret */:
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
- return pos += 2, token = 78 /* CaretEqualsToken */;
+ return token = 23 /* SyntaxKind.CloseBracketToken */;
+ case 94 /* CharacterCodes.caret */:
+ if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) {
+ return pos += 2, token = 78 /* SyntaxKind.CaretEqualsToken */;
}
pos++;
- return token = 52 /* CaretToken */;
- case 123 /* openBrace */:
+ return token = 52 /* SyntaxKind.CaretToken */;
+ case 123 /* CharacterCodes.openBrace */:
pos++;
- return token = 18 /* OpenBraceToken */;
- case 124 /* bar */:
+ return token = 18 /* SyntaxKind.OpenBraceToken */;
+ case 124 /* CharacterCodes.bar */:
if (isConflictMarkerTrivia(text, pos)) {
pos = scanConflictMarkerTrivia(text, pos, error);
if (skipTrivia) {
continue;
}
else {
- return token = 7 /* ConflictMarkerTrivia */;
+ return token = 7 /* SyntaxKind.ConflictMarkerTrivia */;
}
}
- if (text.charCodeAt(pos + 1) === 124 /* bar */) {
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
- return pos += 3, token = 75 /* BarBarEqualsToken */;
+ if (text.charCodeAt(pos + 1) === 124 /* CharacterCodes.bar */) {
+ if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) {
+ return pos += 3, token = 75 /* SyntaxKind.BarBarEqualsToken */;
}
- return pos += 2, token = 56 /* BarBarToken */;
+ return pos += 2, token = 56 /* SyntaxKind.BarBarToken */;
}
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
- return pos += 2, token = 74 /* BarEqualsToken */;
+ if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) {
+ return pos += 2, token = 74 /* SyntaxKind.BarEqualsToken */;
}
pos++;
- return token = 51 /* BarToken */;
- case 125 /* closeBrace */:
+ return token = 51 /* SyntaxKind.BarToken */;
+ case 125 /* CharacterCodes.closeBrace */:
pos++;
- return token = 19 /* CloseBraceToken */;
- case 126 /* tilde */:
+ return token = 19 /* SyntaxKind.CloseBraceToken */;
+ case 126 /* CharacterCodes.tilde */:
pos++;
- return token = 54 /* TildeToken */;
- case 64 /* at */:
+ return token = 54 /* SyntaxKind.TildeToken */;
+ case 64 /* CharacterCodes.at */:
pos++;
- return token = 59 /* AtToken */;
- case 92 /* backslash */:
+ return token = 59 /* SyntaxKind.AtToken */;
+ case 92 /* CharacterCodes.backslash */:
var extendedCookedChar = peekExtendedUnicodeEscape();
if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) {
pos += 3;
- tokenFlags |= 8 /* ExtendedUnicodeEscape */;
+ tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */;
tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts();
return token = getIdentifierToken();
}
var cookedChar = peekUnicodeEscape();
if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) {
pos += 6;
- tokenFlags |= 1024 /* UnicodeEscape */;
+ tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */;
tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
return token = getIdentifierToken();
}
error(ts.Diagnostics.Invalid_character);
pos++;
- return token = 0 /* Unknown */;
- case 35 /* hash */:
+ return token = 0 /* SyntaxKind.Unknown */;
+ case 35 /* CharacterCodes.hash */:
if (pos !== 0 && text[pos + 1] === "!") {
error(ts.Diagnostics.can_only_be_used_at_the_start_of_a_file);
pos++;
- return token = 0 /* Unknown */;
+ return token = 0 /* SyntaxKind.Unknown */;
}
if (isIdentifierStart(codePointAt(text, pos + 1), languageVersion)) {
pos++;
@@ -11658,7 +11841,7 @@ var ts;
tokenValue = String.fromCharCode(codePointAt(text, pos));
error(ts.Diagnostics.Invalid_character, pos++, charSize(ch));
}
- return token = 80 /* PrivateIdentifier */;
+ return token = 80 /* SyntaxKind.PrivateIdentifier */;
default:
var identifierKind = scanIdentifier(ch, languageVersion);
if (identifierKind) {
@@ -11669,23 +11852,23 @@ var ts;
continue;
}
else if (isLineBreak(ch)) {
- tokenFlags |= 1 /* PrecedingLineBreak */;
+ tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */;
pos += charSize(ch);
continue;
}
var size = charSize(ch);
error(ts.Diagnostics.Invalid_character, pos, size);
pos += size;
- return token = 0 /* Unknown */;
+ return token = 0 /* SyntaxKind.Unknown */;
}
}
}
function reScanInvalidIdentifier() {
- ts.Debug.assert(token === 0 /* Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'.");
+ ts.Debug.assert(token === 0 /* SyntaxKind.Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'.");
pos = tokenPos = startPos;
tokenFlags = 0;
var ch = codePointAt(text, pos);
- var identifierKind = scanIdentifier(ch, 99 /* ESNext */);
+ var identifierKind = scanIdentifier(ch, 99 /* ScriptTarget.ESNext */);
if (identifierKind) {
return token = identifierKind;
}
@@ -11699,41 +11882,41 @@ var ts;
while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion))
pos += charSize(ch);
tokenValue = text.substring(tokenPos, pos);
- if (ch === 92 /* backslash */) {
+ if (ch === 92 /* CharacterCodes.backslash */) {
tokenValue += scanIdentifierParts();
}
return getIdentifierToken();
}
}
function reScanGreaterToken() {
- if (token === 31 /* GreaterThanToken */) {
- if (text.charCodeAt(pos) === 62 /* greaterThan */) {
- if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) {
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
- return pos += 3, token = 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */;
+ if (token === 31 /* SyntaxKind.GreaterThanToken */) {
+ if (text.charCodeAt(pos) === 62 /* CharacterCodes.greaterThan */) {
+ if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) {
+ if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) {
+ return pos += 3, token = 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */;
}
- return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */;
+ return pos += 2, token = 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */;
}
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
- return pos += 2, token = 71 /* GreaterThanGreaterThanEqualsToken */;
+ if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) {
+ return pos += 2, token = 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */;
}
pos++;
- return token = 48 /* GreaterThanGreaterThanToken */;
+ return token = 48 /* SyntaxKind.GreaterThanGreaterThanToken */;
}
- if (text.charCodeAt(pos) === 61 /* equals */) {
+ if (text.charCodeAt(pos) === 61 /* CharacterCodes.equals */) {
pos++;
- return token = 33 /* GreaterThanEqualsToken */;
+ return token = 33 /* SyntaxKind.GreaterThanEqualsToken */;
}
}
return token;
}
function reScanAsteriskEqualsToken() {
- ts.Debug.assert(token === 66 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='");
+ ts.Debug.assert(token === 66 /* SyntaxKind.AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='");
pos = tokenPos + 1;
- return token = 63 /* EqualsToken */;
+ return token = 63 /* SyntaxKind.EqualsToken */;
}
function reScanSlashToken() {
- if (token === 43 /* SlashToken */ || token === 68 /* SlashEqualsToken */) {
+ if (token === 43 /* SyntaxKind.SlashToken */ || token === 68 /* SyntaxKind.SlashEqualsToken */) {
var p = tokenPos + 1;
var inEscape = false;
var inCharacterClass = false;
@@ -11741,13 +11924,13 @@ var ts;
// If we reach the end of a file, or hit a newline, then this is an unterminated
// regex. Report error and return what we have so far.
if (p >= end) {
- tokenFlags |= 4 /* Unterminated */;
+ tokenFlags |= 4 /* TokenFlags.Unterminated */;
error(ts.Diagnostics.Unterminated_regular_expression_literal);
break;
}
var ch = text.charCodeAt(p);
if (isLineBreak(ch)) {
- tokenFlags |= 4 /* Unterminated */;
+ tokenFlags |= 4 /* TokenFlags.Unterminated */;
error(ts.Diagnostics.Unterminated_regular_expression_literal);
break;
}
@@ -11756,19 +11939,19 @@ var ts;
// reset the flag and just advance to the next char.
inEscape = false;
}
- else if (ch === 47 /* slash */ && !inCharacterClass) {
+ else if (ch === 47 /* CharacterCodes.slash */ && !inCharacterClass) {
// A slash within a character class is permissible,
// but in general it signals the end of the regexp literal.
p++;
break;
}
- else if (ch === 91 /* openBracket */) {
+ else if (ch === 91 /* CharacterCodes.openBracket */) {
inCharacterClass = true;
}
- else if (ch === 92 /* backslash */) {
+ else if (ch === 92 /* CharacterCodes.backslash */) {
inEscape = true;
}
- else if (ch === 93 /* closeBracket */) {
+ else if (ch === 93 /* CharacterCodes.closeBracket */) {
inCharacterClass = false;
}
p++;
@@ -11778,7 +11961,7 @@ var ts;
}
pos = p;
tokenValue = text.substring(tokenPos, pos);
- token = 13 /* RegularExpressionLiteral */;
+ token = 13 /* SyntaxKind.RegularExpressionLiteral */;
}
return token;
}
@@ -11799,9 +11982,9 @@ var ts;
}
switch (match[1]) {
case "ts-expect-error":
- return 0 /* ExpectError */;
+ return 0 /* CommentDirectiveType.ExpectError */;
case "ts-ignore":
- return 1 /* Ignore */;
+ return 1 /* CommentDirectiveType.Ignore */;
}
return undefined;
}
@@ -11809,7 +11992,7 @@ var ts;
* Unconditionally back up and scan a template expression portion.
*/
function reScanTemplateToken(isTaggedTemplate) {
- ts.Debug.assert(token === 19 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'");
+ ts.Debug.assert(token === 19 /* SyntaxKind.CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'");
pos = tokenPos;
return token = scanTemplateAndSetTokenValue(isTaggedTemplate);
}
@@ -11823,42 +12006,42 @@ var ts;
return token = scanJsxToken(allowMultilineJsxText);
}
function reScanLessThanToken() {
- if (token === 47 /* LessThanLessThanToken */) {
+ if (token === 47 /* SyntaxKind.LessThanLessThanToken */) {
pos = tokenPos + 1;
- return token = 29 /* LessThanToken */;
+ return token = 29 /* SyntaxKind.LessThanToken */;
}
return token;
}
function reScanHashToken() {
- if (token === 80 /* PrivateIdentifier */) {
+ if (token === 80 /* SyntaxKind.PrivateIdentifier */) {
pos = tokenPos + 1;
- return token = 62 /* HashToken */;
+ return token = 62 /* SyntaxKind.HashToken */;
}
return token;
}
function reScanQuestionToken() {
- ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'");
+ ts.Debug.assert(token === 60 /* SyntaxKind.QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'");
pos = tokenPos + 1;
- return token = 57 /* QuestionToken */;
+ return token = 57 /* SyntaxKind.QuestionToken */;
}
function scanJsxToken(allowMultilineJsxText) {
if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; }
startPos = tokenPos = pos;
if (pos >= end) {
- return token = 1 /* EndOfFileToken */;
+ return token = 1 /* SyntaxKind.EndOfFileToken */;
}
var char = text.charCodeAt(pos);
- if (char === 60 /* lessThan */) {
- if (text.charCodeAt(pos + 1) === 47 /* slash */) {
+ if (char === 60 /* CharacterCodes.lessThan */) {
+ if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
pos += 2;
- return token = 30 /* LessThanSlashToken */;
+ return token = 30 /* SyntaxKind.LessThanSlashToken */;
}
pos++;
- return token = 29 /* LessThanToken */;
+ return token = 29 /* SyntaxKind.LessThanToken */;
}
- if (char === 123 /* openBrace */) {
+ if (char === 123 /* CharacterCodes.openBrace */) {
pos++;
- return token = 18 /* OpenBraceToken */;
+ return token = 18 /* SyntaxKind.OpenBraceToken */;
}
// First non-whitespace character on this line.
var firstNonWhitespace = 0;
@@ -11866,20 +12049,20 @@ var ts;
// firstNonWhitespace = 0 to indicate that we want leading whitespace,
while (pos < end) {
char = text.charCodeAt(pos);
- if (char === 123 /* openBrace */) {
+ if (char === 123 /* CharacterCodes.openBrace */) {
break;
}
- if (char === 60 /* lessThan */) {
+ if (char === 60 /* CharacterCodes.lessThan */) {
if (isConflictMarkerTrivia(text, pos)) {
pos = scanConflictMarkerTrivia(text, pos, error);
- return token = 7 /* ConflictMarkerTrivia */;
+ return token = 7 /* SyntaxKind.ConflictMarkerTrivia */;
}
break;
}
- if (char === 62 /* greaterThan */) {
+ if (char === 62 /* CharacterCodes.greaterThan */) {
error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_gt, pos, 1);
}
- if (char === 125 /* closeBrace */) {
+ if (char === 125 /* CharacterCodes.closeBrace */) {
error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1);
}
// FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces.
@@ -11902,7 +12085,7 @@ var ts;
pos++;
}
tokenValue = text.substring(startPos, pos);
- return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */;
+ return firstNonWhitespace === -1 ? 12 /* SyntaxKind.JsxTextAllWhiteSpaces */ : 11 /* SyntaxKind.JsxText */;
}
// Scans a JSX identifier; these differ from normal identifiers in that
// they allow dashes
@@ -11915,16 +12098,16 @@ var ts;
var namespaceSeparator = false;
while (pos < end) {
var ch = text.charCodeAt(pos);
- if (ch === 45 /* minus */) {
+ if (ch === 45 /* CharacterCodes.minus */) {
tokenValue += "-";
pos++;
continue;
}
- else if (ch === 58 /* colon */ && !namespaceSeparator) {
+ else if (ch === 58 /* CharacterCodes.colon */ && !namespaceSeparator) {
tokenValue += ":";
pos++;
namespaceSeparator = true;
- token = 79 /* Identifier */; // swap from keyword kind to identifier kind
+ token = 79 /* SyntaxKind.Identifier */; // swap from keyword kind to identifier kind
continue;
}
var oldPos = pos;
@@ -11945,10 +12128,10 @@ var ts;
function scanJsxAttributeValue() {
startPos = pos;
switch (text.charCodeAt(pos)) {
- case 34 /* doubleQuote */:
- case 39 /* singleQuote */:
+ case 34 /* CharacterCodes.doubleQuote */:
+ case 39 /* CharacterCodes.singleQuote */:
tokenValue = scanString(/*jsxAttributeString*/ true);
- return token = 10 /* StringLiteral */;
+ return token = 10 /* SyntaxKind.StringLiteral */;
default:
// If this scans anything other than `{`, it's a parse error.
return scan();
@@ -11960,86 +12143,86 @@ var ts;
}
function scanJsDocToken() {
startPos = tokenPos = pos;
- tokenFlags = 0 /* None */;
+ tokenFlags = 0 /* TokenFlags.None */;
if (pos >= end) {
- return token = 1 /* EndOfFileToken */;
+ return token = 1 /* SyntaxKind.EndOfFileToken */;
}
var ch = codePointAt(text, pos);
pos += charSize(ch);
switch (ch) {
- case 9 /* tab */:
- case 11 /* verticalTab */:
- case 12 /* formFeed */:
- case 32 /* space */:
+ case 9 /* CharacterCodes.tab */:
+ case 11 /* CharacterCodes.verticalTab */:
+ case 12 /* CharacterCodes.formFeed */:
+ case 32 /* CharacterCodes.space */:
while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) {
pos++;
}
- return token = 5 /* WhitespaceTrivia */;
- case 64 /* at */:
- return token = 59 /* AtToken */;
- case 13 /* carriageReturn */:
- if (text.charCodeAt(pos) === 10 /* lineFeed */) {
+ return token = 5 /* SyntaxKind.WhitespaceTrivia */;
+ case 64 /* CharacterCodes.at */:
+ return token = 59 /* SyntaxKind.AtToken */;
+ case 13 /* CharacterCodes.carriageReturn */:
+ if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) {
pos++;
}
// falls through
- case 10 /* lineFeed */:
- tokenFlags |= 1 /* PrecedingLineBreak */;
- return token = 4 /* NewLineTrivia */;
- case 42 /* asterisk */:
- return token = 41 /* AsteriskToken */;
- case 123 /* openBrace */:
- return token = 18 /* OpenBraceToken */;
- case 125 /* closeBrace */:
- return token = 19 /* CloseBraceToken */;
- case 91 /* openBracket */:
- return token = 22 /* OpenBracketToken */;
- case 93 /* closeBracket */:
- return token = 23 /* CloseBracketToken */;
- case 60 /* lessThan */:
- return token = 29 /* LessThanToken */;
- case 62 /* greaterThan */:
- return token = 31 /* GreaterThanToken */;
- case 61 /* equals */:
- return token = 63 /* EqualsToken */;
- case 44 /* comma */:
- return token = 27 /* CommaToken */;
- case 46 /* dot */:
- return token = 24 /* DotToken */;
- case 96 /* backtick */:
- return token = 61 /* BacktickToken */;
- case 35 /* hash */:
- return token = 62 /* HashToken */;
- case 92 /* backslash */:
+ case 10 /* CharacterCodes.lineFeed */:
+ tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */;
+ return token = 4 /* SyntaxKind.NewLineTrivia */;
+ case 42 /* CharacterCodes.asterisk */:
+ return token = 41 /* SyntaxKind.AsteriskToken */;
+ case 123 /* CharacterCodes.openBrace */:
+ return token = 18 /* SyntaxKind.OpenBraceToken */;
+ case 125 /* CharacterCodes.closeBrace */:
+ return token = 19 /* SyntaxKind.CloseBraceToken */;
+ case 91 /* CharacterCodes.openBracket */:
+ return token = 22 /* SyntaxKind.OpenBracketToken */;
+ case 93 /* CharacterCodes.closeBracket */:
+ return token = 23 /* SyntaxKind.CloseBracketToken */;
+ case 60 /* CharacterCodes.lessThan */:
+ return token = 29 /* SyntaxKind.LessThanToken */;
+ case 62 /* CharacterCodes.greaterThan */:
+ return token = 31 /* SyntaxKind.GreaterThanToken */;
+ case 61 /* CharacterCodes.equals */:
+ return token = 63 /* SyntaxKind.EqualsToken */;
+ case 44 /* CharacterCodes.comma */:
+ return token = 27 /* SyntaxKind.CommaToken */;
+ case 46 /* CharacterCodes.dot */:
+ return token = 24 /* SyntaxKind.DotToken */;
+ case 96 /* CharacterCodes.backtick */:
+ return token = 61 /* SyntaxKind.BacktickToken */;
+ case 35 /* CharacterCodes.hash */:
+ return token = 62 /* SyntaxKind.HashToken */;
+ case 92 /* CharacterCodes.backslash */:
pos--;
var extendedCookedChar = peekExtendedUnicodeEscape();
if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) {
pos += 3;
- tokenFlags |= 8 /* ExtendedUnicodeEscape */;
+ tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */;
tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts();
return token = getIdentifierToken();
}
var cookedChar = peekUnicodeEscape();
if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) {
pos += 6;
- tokenFlags |= 1024 /* UnicodeEscape */;
+ tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */;
tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
return token = getIdentifierToken();
}
pos++;
- return token = 0 /* Unknown */;
+ return token = 0 /* SyntaxKind.Unknown */;
}
if (isIdentifierStart(ch, languageVersion)) {
var char = ch;
- while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */)
+ while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */)
pos += charSize(char);
tokenValue = text.substring(tokenPos, pos);
- if (char === 92 /* backslash */) {
+ if (char === 92 /* CharacterCodes.backslash */) {
tokenValue += scanIdentifierParts();
}
return token = getIdentifierToken();
}
else {
- return token = 0 /* Unknown */;
+ return token = 0 /* SyntaxKind.Unknown */;
}
}
function speculationHelper(callback, isLookahead) {
@@ -12114,9 +12297,9 @@ var ts;
pos = textPos;
startPos = textPos;
tokenPos = textPos;
- token = 0 /* Unknown */;
+ token = 0 /* SyntaxKind.Unknown */;
tokenValue = undefined;
- tokenFlags = 0 /* None */;
+ tokenFlags = 0 /* TokenFlags.None */;
}
function setInJSDocType(inType) {
inJSDocType += inType ? 1 : -1;
@@ -12182,23 +12365,23 @@ var ts;
ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics;
function getDefaultLibFileName(options) {
switch (ts.getEmitScriptTarget(options)) {
- case 99 /* ESNext */:
+ case 99 /* ScriptTarget.ESNext */:
return "lib.esnext.full.d.ts";
- case 9 /* ES2022 */:
+ case 9 /* ScriptTarget.ES2022 */:
return "lib.es2022.full.d.ts";
- case 8 /* ES2021 */:
+ case 8 /* ScriptTarget.ES2021 */:
return "lib.es2021.full.d.ts";
- case 7 /* ES2020 */:
+ case 7 /* ScriptTarget.ES2020 */:
return "lib.es2020.full.d.ts";
- case 6 /* ES2019 */:
+ case 6 /* ScriptTarget.ES2019 */:
return "lib.es2019.full.d.ts";
- case 5 /* ES2018 */:
+ case 5 /* ScriptTarget.ES2018 */:
return "lib.es2018.full.d.ts";
- case 4 /* ES2017 */:
+ case 4 /* ScriptTarget.ES2017 */:
return "lib.es2017.full.d.ts";
- case 3 /* ES2016 */:
+ case 3 /* ScriptTarget.ES2016 */:
return "lib.es2016.full.d.ts";
- case 2 /* ES2015 */:
+ case 2 /* ScriptTarget.ES2015 */:
return "lib.es6.d.ts"; // We don't use lib.es2015.full.d.ts due to breaking change.
default:
return "lib.d.ts";
@@ -12406,9 +12589,9 @@ var ts;
}
ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions;
function getTypeParameterOwner(d) {
- if (d && d.kind === 162 /* TypeParameter */) {
+ if (d && d.kind === 163 /* SyntaxKind.TypeParameter */) {
for (var current = d; current; current = current.parent) {
- if (isFunctionLike(current) || isClassLike(current) || current.kind === 257 /* InterfaceDeclaration */) {
+ if (isFunctionLike(current) || isClassLike(current) || current.kind === 258 /* SyntaxKind.InterfaceDeclaration */) {
return current;
}
}
@@ -12416,7 +12599,7 @@ var ts;
}
ts.getTypeParameterOwner = getTypeParameterOwner;
function isParameterPropertyDeclaration(node, parent) {
- return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 170 /* Constructor */;
+ return ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */) && parent.kind === 171 /* SyntaxKind.Constructor */;
}
ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration;
function isEmptyBindingPattern(node) {
@@ -12446,14 +12629,14 @@ var ts;
node = walkUpBindingElementsAndPatterns(node);
}
var flags = getFlags(node);
- if (node.kind === 253 /* VariableDeclaration */) {
+ if (node.kind === 254 /* SyntaxKind.VariableDeclaration */) {
node = node.parent;
}
- if (node && node.kind === 254 /* VariableDeclarationList */) {
+ if (node && node.kind === 255 /* SyntaxKind.VariableDeclarationList */) {
flags |= getFlags(node);
node = node.parent;
}
- if (node && node.kind === 236 /* VariableStatement */) {
+ if (node && node.kind === 237 /* SyntaxKind.VariableStatement */) {
flags |= getFlags(node);
}
return flags;
@@ -12567,7 +12750,7 @@ var ts;
* @param node The node to test.
*/
function isParseTreeNode(node) {
- return (node.flags & 8 /* Synthesized */) === 0;
+ return (node.flags & 8 /* NodeFlags.Synthesized */) === 0;
}
ts.isParseTreeNode = isParseTreeNode;
function getParseTreeNode(node, nodeTest) {
@@ -12585,7 +12768,7 @@ var ts;
ts.getParseTreeNode = getParseTreeNode;
/** Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' */
function escapeLeadingUnderscores(identifier) {
- return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier);
+ return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* CharacterCodes._ */ && identifier.charCodeAt(1) === 95 /* CharacterCodes._ */ ? "_" + identifier : identifier);
}
ts.escapeLeadingUnderscores = escapeLeadingUnderscores;
/**
@@ -12596,7 +12779,7 @@ var ts;
*/
function unescapeLeadingUnderscores(identifier) {
var id = identifier;
- return id.length >= 3 && id.charCodeAt(0) === 95 /* _ */ && id.charCodeAt(1) === 95 /* _ */ && id.charCodeAt(2) === 95 /* _ */ ? id.substr(1) : id;
+ return id.length >= 3 && id.charCodeAt(0) === 95 /* CharacterCodes._ */ && id.charCodeAt(1) === 95 /* CharacterCodes._ */ && id.charCodeAt(2) === 95 /* CharacterCodes._ */ ? id.substr(1) : id;
}
ts.unescapeLeadingUnderscores = unescapeLeadingUnderscores;
function idText(identifierOrPrivateName) {
@@ -12626,30 +12809,30 @@ var ts;
}
// Covers remaining cases (returning undefined if none match).
switch (hostNode.kind) {
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
if (hostNode.declarationList && hostNode.declarationList.declarations[0]) {
return getDeclarationIdentifier(hostNode.declarationList.declarations[0]);
}
break;
- case 237 /* ExpressionStatement */:
+ case 238 /* SyntaxKind.ExpressionStatement */:
var expr = hostNode.expression;
- if (expr.kind === 220 /* BinaryExpression */ && expr.operatorToken.kind === 63 /* EqualsToken */) {
+ if (expr.kind === 221 /* SyntaxKind.BinaryExpression */ && expr.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) {
expr = expr.left;
}
switch (expr.kind) {
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
return expr.name;
- case 206 /* ElementAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
var arg = expr.argumentExpression;
if (ts.isIdentifier(arg)) {
return arg;
}
}
break;
- case 211 /* ParenthesizedExpression */: {
+ case 212 /* SyntaxKind.ParenthesizedExpression */: {
return getDeclarationIdentifier(hostNode.expression);
}
- case 249 /* LabeledStatement */: {
+ case 250 /* SyntaxKind.LabeledStatement */: {
if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) {
return getDeclarationIdentifier(hostNode.statement);
}
@@ -12684,42 +12867,42 @@ var ts;
/** @internal */
function getNonAssignedNameOfDeclaration(declaration) {
switch (declaration.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return declaration;
- case 345 /* JSDocPropertyTag */:
- case 338 /* JSDocParameterTag */: {
+ case 347 /* SyntaxKind.JSDocPropertyTag */:
+ case 340 /* SyntaxKind.JSDocParameterTag */: {
var name = declaration.name;
- if (name.kind === 160 /* QualifiedName */) {
+ if (name.kind === 161 /* SyntaxKind.QualifiedName */) {
return name.right;
}
break;
}
- case 207 /* CallExpression */:
- case 220 /* BinaryExpression */: {
+ case 208 /* SyntaxKind.CallExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */: {
var expr_1 = declaration;
switch (ts.getAssignmentDeclarationKind(expr_1)) {
- case 1 /* ExportsProperty */:
- case 4 /* ThisProperty */:
- case 5 /* Property */:
- case 3 /* PrototypeProperty */:
+ case 1 /* AssignmentDeclarationKind.ExportsProperty */:
+ case 4 /* AssignmentDeclarationKind.ThisProperty */:
+ case 5 /* AssignmentDeclarationKind.Property */:
+ case 3 /* AssignmentDeclarationKind.PrototypeProperty */:
return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left);
- case 7 /* ObjectDefinePropertyValue */:
- case 8 /* ObjectDefinePropertyExports */:
- case 9 /* ObjectDefinePrototypeProperty */:
+ case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */:
+ case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */:
+ case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */:
return expr_1.arguments[1];
default:
return undefined;
}
}
- case 343 /* JSDocTypedefTag */:
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
return getNameOfJSDocTypedef(declaration);
- case 337 /* JSDocEnumTag */:
+ case 339 /* SyntaxKind.JSDocEnumTag */:
return nameForNamelessJSDocTypedef(declaration);
- case 270 /* ExportAssignment */: {
+ case 271 /* SyntaxKind.ExportAssignment */: {
var expression = declaration.expression;
return ts.isIdentifier(expression) ? expression : undefined;
}
- case 206 /* ElementAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
var expr = declaration;
if (ts.isBindableStaticElementAccessExpression(expr)) {
return expr.argumentExpression;
@@ -13012,12 +13195,12 @@ var ts;
/** Gets the text of a jsdoc comment, flattening links to their text. */
function getTextOfJSDocComment(comment) {
return typeof comment === "string" ? comment
- : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 319 /* JSDocText */ ? c.text : formatJSDocLink(c); }).join("");
+ : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 321 /* SyntaxKind.JSDocText */ ? c.text : formatJSDocLink(c); }).join("");
}
ts.getTextOfJSDocComment = getTextOfJSDocComment;
function formatJSDocLink(link) {
- var kind = link.kind === 322 /* JSDocLink */ ? "link"
- : link.kind === 323 /* JSDocLinkCode */ ? "linkcode"
+ var kind = link.kind === 324 /* SyntaxKind.JSDocLink */ ? "link"
+ : link.kind === 325 /* SyntaxKind.JSDocLinkCode */ ? "linkcode"
: "linkplain";
var name = link.name ? ts.entityNameToString(link.name) : "";
var space = link.name && link.text.startsWith("://") ? "" : " ";
@@ -13032,7 +13215,7 @@ var ts;
return ts.emptyArray;
}
if (ts.isJSDocTypeAlias(node)) {
- ts.Debug.assert(node.parent.kind === 318 /* JSDocComment */);
+ ts.Debug.assert(node.parent.kind === 320 /* SyntaxKind.JSDoc */);
return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; });
}
if (node.typeParameters) {
@@ -13059,33 +13242,33 @@ var ts;
ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter;
// #region
function isMemberName(node) {
- return node.kind === 79 /* Identifier */ || node.kind === 80 /* PrivateIdentifier */;
+ return node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 80 /* SyntaxKind.PrivateIdentifier */;
}
ts.isMemberName = isMemberName;
/* @internal */
function isGetOrSetAccessorDeclaration(node) {
- return node.kind === 172 /* SetAccessor */ || node.kind === 171 /* GetAccessor */;
+ return node.kind === 173 /* SyntaxKind.SetAccessor */ || node.kind === 172 /* SyntaxKind.GetAccessor */;
}
ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration;
function isPropertyAccessChain(node) {
- return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */);
+ return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */);
}
ts.isPropertyAccessChain = isPropertyAccessChain;
function isElementAccessChain(node) {
- return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */);
+ return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */);
}
ts.isElementAccessChain = isElementAccessChain;
function isCallChain(node) {
- return ts.isCallExpression(node) && !!(node.flags & 32 /* OptionalChain */);
+ return ts.isCallExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */);
}
ts.isCallChain = isCallChain;
function isOptionalChain(node) {
var kind = node.kind;
- return !!(node.flags & 32 /* OptionalChain */) &&
- (kind === 205 /* PropertyAccessExpression */
- || kind === 206 /* ElementAccessExpression */
- || kind === 207 /* CallExpression */
- || kind === 229 /* NonNullExpression */);
+ return !!(node.flags & 32 /* NodeFlags.OptionalChain */) &&
+ (kind === 206 /* SyntaxKind.PropertyAccessExpression */
+ || kind === 207 /* SyntaxKind.ElementAccessExpression */
+ || kind === 208 /* SyntaxKind.CallExpression */
+ || kind === 230 /* SyntaxKind.NonNullExpression */);
}
ts.isOptionalChain = isOptionalChain;
/* @internal */
@@ -13120,7 +13303,7 @@ var ts;
}
ts.isOutermostOptionalChain = isOutermostOptionalChain;
function isNullishCoalesce(node) {
- return node.kind === 220 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */;
+ return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */;
}
ts.isNullishCoalesce = isNullishCoalesce;
function isConstTypeReference(node) {
@@ -13129,25 +13312,25 @@ var ts;
}
ts.isConstTypeReference = isConstTypeReference;
function skipPartiallyEmittedExpressions(node) {
- return ts.skipOuterExpressions(node, 8 /* PartiallyEmittedExpressions */);
+ return ts.skipOuterExpressions(node, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */);
}
ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions;
function isNonNullChain(node) {
- return ts.isNonNullExpression(node) && !!(node.flags & 32 /* OptionalChain */);
+ return ts.isNonNullExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */);
}
ts.isNonNullChain = isNonNullChain;
function isBreakOrContinueStatement(node) {
- return node.kind === 245 /* BreakStatement */ || node.kind === 244 /* ContinueStatement */;
+ return node.kind === 246 /* SyntaxKind.BreakStatement */ || node.kind === 245 /* SyntaxKind.ContinueStatement */;
}
ts.isBreakOrContinueStatement = isBreakOrContinueStatement;
function isNamedExportBindings(node) {
- return node.kind === 273 /* NamespaceExport */ || node.kind === 272 /* NamedExports */;
+ return node.kind === 274 /* SyntaxKind.NamespaceExport */ || node.kind === 273 /* SyntaxKind.NamedExports */;
}
ts.isNamedExportBindings = isNamedExportBindings;
function isUnparsedTextLike(node) {
switch (node.kind) {
- case 300 /* UnparsedText */:
- case 301 /* UnparsedInternalText */:
+ case 302 /* SyntaxKind.UnparsedText */:
+ case 303 /* SyntaxKind.UnparsedInternalText */:
return true;
default:
return false;
@@ -13156,12 +13339,12 @@ var ts;
ts.isUnparsedTextLike = isUnparsedTextLike;
function isUnparsedNode(node) {
return isUnparsedTextLike(node) ||
- node.kind === 298 /* UnparsedPrologue */ ||
- node.kind === 302 /* UnparsedSyntheticReference */;
+ node.kind === 300 /* SyntaxKind.UnparsedPrologue */ ||
+ node.kind === 304 /* SyntaxKind.UnparsedSyntheticReference */;
}
ts.isUnparsedNode = isUnparsedNode;
function isJSDocPropertyLikeTag(node) {
- return node.kind === 345 /* JSDocPropertyTag */ || node.kind === 338 /* JSDocParameterTag */;
+ return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */ || node.kind === 340 /* SyntaxKind.JSDocParameterTag */;
}
ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag;
// #endregion
@@ -13177,7 +13360,7 @@ var ts;
ts.isNode = isNode;
/* @internal */
function isNodeKind(kind) {
- return kind >= 160 /* FirstNode */;
+ return kind >= 161 /* SyntaxKind.FirstNode */;
}
ts.isNodeKind = isNodeKind;
/**
@@ -13186,7 +13369,7 @@ var ts;
* Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail.
*/
function isTokenKind(kind) {
- return kind >= 0 /* FirstToken */ && kind <= 159 /* LastToken */;
+ return kind >= 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */;
}
ts.isTokenKind = isTokenKind;
/**
@@ -13207,7 +13390,7 @@ var ts;
// Literals
/* @internal */
function isLiteralKind(kind) {
- return 8 /* FirstLiteralToken */ <= kind && kind <= 14 /* LastLiteralToken */;
+ return 8 /* SyntaxKind.FirstLiteralToken */ <= kind && kind <= 14 /* SyntaxKind.LastLiteralToken */;
}
ts.isLiteralKind = isLiteralKind;
function isLiteralExpression(node) {
@@ -13217,7 +13400,7 @@ var ts;
// Pseudo-literals
/* @internal */
function isTemplateLiteralKind(kind) {
- return 14 /* FirstTemplateToken */ <= kind && kind <= 17 /* LastTemplateToken */;
+ return 14 /* SyntaxKind.FirstTemplateToken */ <= kind && kind <= 17 /* SyntaxKind.LastTemplateToken */;
}
ts.isTemplateLiteralKind = isTemplateLiteralKind;
function isTemplateLiteralToken(node) {
@@ -13226,8 +13409,8 @@ var ts;
ts.isTemplateLiteralToken = isTemplateLiteralToken;
function isTemplateMiddleOrTemplateTail(node) {
var kind = node.kind;
- return kind === 16 /* TemplateMiddle */
- || kind === 17 /* TemplateTail */;
+ return kind === 16 /* SyntaxKind.TemplateMiddle */
+ || kind === 17 /* SyntaxKind.TemplateTail */;
}
ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail;
function isImportOrExportSpecifier(node) {
@@ -13236,13 +13419,13 @@ var ts;
ts.isImportOrExportSpecifier = isImportOrExportSpecifier;
function isTypeOnlyImportOrExportDeclaration(node) {
switch (node.kind) {
- case 269 /* ImportSpecifier */:
- case 274 /* ExportSpecifier */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
+ case 275 /* SyntaxKind.ExportSpecifier */:
return node.isTypeOnly || node.parent.parent.isTypeOnly;
- case 267 /* NamespaceImport */:
+ case 268 /* SyntaxKind.NamespaceImport */:
return node.parent.isTypeOnly;
- case 266 /* ImportClause */:
- case 264 /* ImportEqualsDeclaration */:
+ case 267 /* SyntaxKind.ImportClause */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return node.isTypeOnly;
default:
return false;
@@ -13254,13 +13437,13 @@ var ts;
}
ts.isAssertionKey = isAssertionKey;
function isStringTextContainingNode(node) {
- return node.kind === 10 /* StringLiteral */ || isTemplateLiteralKind(node.kind);
+ return node.kind === 10 /* SyntaxKind.StringLiteral */ || isTemplateLiteralKind(node.kind);
}
ts.isStringTextContainingNode = isStringTextContainingNode;
// Identifiers
/* @internal */
function isGeneratedIdentifier(node) {
- return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* KindMask */) > 0 /* None */;
+ return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) > 0 /* GeneratedIdentifierFlags.None */;
}
ts.isGeneratedIdentifier = isGeneratedIdentifier;
// Private Identifiers
@@ -13278,18 +13461,20 @@ var ts;
/* @internal */
function isModifierKind(token) {
switch (token) {
- case 126 /* AbstractKeyword */:
- case 131 /* AsyncKeyword */:
- case 85 /* ConstKeyword */:
- case 135 /* DeclareKeyword */:
- case 88 /* DefaultKeyword */:
- case 93 /* ExportKeyword */:
- case 123 /* PublicKeyword */:
- case 121 /* PrivateKeyword */:
- case 122 /* ProtectedKeyword */:
- case 144 /* ReadonlyKeyword */:
- case 124 /* StaticKeyword */:
- case 158 /* OverrideKeyword */:
+ case 126 /* SyntaxKind.AbstractKeyword */:
+ case 131 /* SyntaxKind.AsyncKeyword */:
+ case 85 /* SyntaxKind.ConstKeyword */:
+ case 135 /* SyntaxKind.DeclareKeyword */:
+ case 88 /* SyntaxKind.DefaultKeyword */:
+ case 93 /* SyntaxKind.ExportKeyword */:
+ case 101 /* SyntaxKind.InKeyword */:
+ case 123 /* SyntaxKind.PublicKeyword */:
+ case 121 /* SyntaxKind.PrivateKeyword */:
+ case 122 /* SyntaxKind.ProtectedKeyword */:
+ case 145 /* SyntaxKind.ReadonlyKeyword */:
+ case 124 /* SyntaxKind.StaticKeyword */:
+ case 144 /* SyntaxKind.OutKeyword */:
+ case 159 /* SyntaxKind.OverrideKeyword */:
return true;
}
return false;
@@ -13297,12 +13482,12 @@ var ts;
ts.isModifierKind = isModifierKind;
/* @internal */
function isParameterPropertyModifier(kind) {
- return !!(ts.modifierToFlag(kind) & 16476 /* ParameterPropertyModifier */);
+ return !!(ts.modifierToFlag(kind) & 16476 /* ModifierFlags.ParameterPropertyModifier */);
}
ts.isParameterPropertyModifier = isParameterPropertyModifier;
/* @internal */
function isClassMemberModifier(idToken) {
- return isParameterPropertyModifier(idToken) || idToken === 124 /* StaticKeyword */ || idToken === 158 /* OverrideKeyword */;
+ return isParameterPropertyModifier(idToken) || idToken === 124 /* SyntaxKind.StaticKeyword */ || idToken === 159 /* SyntaxKind.OverrideKeyword */;
}
ts.isClassMemberModifier = isClassMemberModifier;
function isModifier(node) {
@@ -13311,24 +13496,24 @@ var ts;
ts.isModifier = isModifier;
function isEntityName(node) {
var kind = node.kind;
- return kind === 160 /* QualifiedName */
- || kind === 79 /* Identifier */;
+ return kind === 161 /* SyntaxKind.QualifiedName */
+ || kind === 79 /* SyntaxKind.Identifier */;
}
ts.isEntityName = isEntityName;
function isPropertyName(node) {
var kind = node.kind;
- return kind === 79 /* Identifier */
- || kind === 80 /* PrivateIdentifier */
- || kind === 10 /* StringLiteral */
- || kind === 8 /* NumericLiteral */
- || kind === 161 /* ComputedPropertyName */;
+ return kind === 79 /* SyntaxKind.Identifier */
+ || kind === 80 /* SyntaxKind.PrivateIdentifier */
+ || kind === 10 /* SyntaxKind.StringLiteral */
+ || kind === 8 /* SyntaxKind.NumericLiteral */
+ || kind === 162 /* SyntaxKind.ComputedPropertyName */;
}
ts.isPropertyName = isPropertyName;
function isBindingName(node) {
var kind = node.kind;
- return kind === 79 /* Identifier */
- || kind === 200 /* ObjectBindingPattern */
- || kind === 201 /* ArrayBindingPattern */;
+ return kind === 79 /* SyntaxKind.Identifier */
+ || kind === 201 /* SyntaxKind.ObjectBindingPattern */
+ || kind === 202 /* SyntaxKind.ArrayBindingPattern */;
}
ts.isBindingName = isBindingName;
// Functions
@@ -13348,18 +13533,18 @@ var ts;
ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration;
/* @internal */
function isBooleanLiteral(node) {
- return node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */;
+ return node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */;
}
ts.isBooleanLiteral = isBooleanLiteral;
function isFunctionLikeDeclarationKind(kind) {
switch (kind) {
- case 255 /* FunctionDeclaration */:
- case 168 /* MethodDeclaration */:
- case 170 /* Constructor */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
return true;
default:
return false;
@@ -13368,14 +13553,14 @@ var ts;
/* @internal */
function isFunctionLikeKind(kind) {
switch (kind) {
- case 167 /* MethodSignature */:
- case 173 /* CallSignature */:
- case 321 /* JSDocSignature */:
- case 174 /* ConstructSignature */:
- case 175 /* IndexSignature */:
- case 178 /* FunctionType */:
- case 315 /* JSDocFunctionType */:
- case 179 /* ConstructorType */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 323 /* SyntaxKind.JSDocSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 176 /* SyntaxKind.IndexSignature */:
+ case 179 /* SyntaxKind.FunctionType */:
+ case 317 /* SyntaxKind.JSDocFunctionType */:
+ case 180 /* SyntaxKind.ConstructorType */:
return true;
default:
return isFunctionLikeDeclarationKind(kind);
@@ -13390,30 +13575,30 @@ var ts;
// Classes
function isClassElement(node) {
var kind = node.kind;
- return kind === 170 /* Constructor */
- || kind === 166 /* PropertyDeclaration */
- || kind === 168 /* MethodDeclaration */
- || kind === 171 /* GetAccessor */
- || kind === 172 /* SetAccessor */
- || kind === 175 /* IndexSignature */
- || kind === 169 /* ClassStaticBlockDeclaration */
- || kind === 233 /* SemicolonClassElement */;
+ return kind === 171 /* SyntaxKind.Constructor */
+ || kind === 167 /* SyntaxKind.PropertyDeclaration */
+ || kind === 169 /* SyntaxKind.MethodDeclaration */
+ || kind === 172 /* SyntaxKind.GetAccessor */
+ || kind === 173 /* SyntaxKind.SetAccessor */
+ || kind === 176 /* SyntaxKind.IndexSignature */
+ || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */
+ || kind === 234 /* SyntaxKind.SemicolonClassElement */;
}
ts.isClassElement = isClassElement;
function isClassLike(node) {
- return node && (node.kind === 256 /* ClassDeclaration */ || node.kind === 225 /* ClassExpression */);
+ return node && (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */);
}
ts.isClassLike = isClassLike;
function isAccessor(node) {
- return node && (node.kind === 171 /* GetAccessor */ || node.kind === 172 /* SetAccessor */);
+ return node && (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */);
}
ts.isAccessor = isAccessor;
/* @internal */
function isMethodOrAccessor(node) {
switch (node.kind) {
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
return true;
default:
return false;
@@ -13423,11 +13608,13 @@ var ts;
// Type members
function isTypeElement(node) {
var kind = node.kind;
- return kind === 174 /* ConstructSignature */
- || kind === 173 /* CallSignature */
- || kind === 165 /* PropertySignature */
- || kind === 167 /* MethodSignature */
- || kind === 175 /* IndexSignature */;
+ return kind === 175 /* SyntaxKind.ConstructSignature */
+ || kind === 174 /* SyntaxKind.CallSignature */
+ || kind === 166 /* SyntaxKind.PropertySignature */
+ || kind === 168 /* SyntaxKind.MethodSignature */
+ || kind === 176 /* SyntaxKind.IndexSignature */
+ || kind === 172 /* SyntaxKind.GetAccessor */
+ || kind === 173 /* SyntaxKind.SetAccessor */;
}
ts.isTypeElement = isTypeElement;
function isClassOrTypeElement(node) {
@@ -13436,12 +13623,12 @@ var ts;
ts.isClassOrTypeElement = isClassOrTypeElement;
function isObjectLiteralElementLike(node) {
var kind = node.kind;
- return kind === 294 /* PropertyAssignment */
- || kind === 295 /* ShorthandPropertyAssignment */
- || kind === 296 /* SpreadAssignment */
- || kind === 168 /* MethodDeclaration */
- || kind === 171 /* GetAccessor */
- || kind === 172 /* SetAccessor */;
+ return kind === 296 /* SyntaxKind.PropertyAssignment */
+ || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */
+ || kind === 298 /* SyntaxKind.SpreadAssignment */
+ || kind === 169 /* SyntaxKind.MethodDeclaration */
+ || kind === 172 /* SyntaxKind.GetAccessor */
+ || kind === 173 /* SyntaxKind.SetAccessor */;
}
ts.isObjectLiteralElementLike = isObjectLiteralElementLike;
// Type
@@ -13456,8 +13643,8 @@ var ts;
ts.isTypeNode = isTypeNode;
function isFunctionOrConstructorTypeNode(node) {
switch (node.kind) {
- case 178 /* FunctionType */:
- case 179 /* ConstructorType */:
+ case 179 /* SyntaxKind.FunctionType */:
+ case 180 /* SyntaxKind.ConstructorType */:
return true;
}
return false;
@@ -13468,8 +13655,8 @@ var ts;
function isBindingPattern(node) {
if (node) {
var kind = node.kind;
- return kind === 201 /* ArrayBindingPattern */
- || kind === 200 /* ObjectBindingPattern */;
+ return kind === 202 /* SyntaxKind.ArrayBindingPattern */
+ || kind === 201 /* SyntaxKind.ObjectBindingPattern */;
}
return false;
}
@@ -13477,15 +13664,15 @@ var ts;
/* @internal */
function isAssignmentPattern(node) {
var kind = node.kind;
- return kind === 203 /* ArrayLiteralExpression */
- || kind === 204 /* ObjectLiteralExpression */;
+ return kind === 204 /* SyntaxKind.ArrayLiteralExpression */
+ || kind === 205 /* SyntaxKind.ObjectLiteralExpression */;
}
ts.isAssignmentPattern = isAssignmentPattern;
/* @internal */
function isArrayBindingElement(node) {
var kind = node.kind;
- return kind === 202 /* BindingElement */
- || kind === 226 /* OmittedExpression */;
+ return kind === 203 /* SyntaxKind.BindingElement */
+ || kind === 227 /* SyntaxKind.OmittedExpression */;
}
ts.isArrayBindingElement = isArrayBindingElement;
/**
@@ -13494,9 +13681,9 @@ var ts;
/* @internal */
function isDeclarationBindingElement(bindingElement) {
switch (bindingElement.kind) {
- case 253 /* VariableDeclaration */:
- case 163 /* Parameter */:
- case 202 /* BindingElement */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
+ case 164 /* SyntaxKind.Parameter */:
+ case 203 /* SyntaxKind.BindingElement */:
return true;
}
return false;
@@ -13517,8 +13704,8 @@ var ts;
/* @internal */
function isObjectBindingOrAssignmentPattern(node) {
switch (node.kind) {
- case 200 /* ObjectBindingPattern */:
- case 204 /* ObjectLiteralExpression */:
+ case 201 /* SyntaxKind.ObjectBindingPattern */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
return true;
}
return false;
@@ -13527,10 +13714,10 @@ var ts;
/* @internal */
function isObjectBindingOrAssignmentElement(node) {
switch (node.kind) {
- case 202 /* BindingElement */:
- case 294 /* PropertyAssignment */: // AssignmentProperty
- case 295 /* ShorthandPropertyAssignment */: // AssignmentProperty
- case 296 /* SpreadAssignment */: // AssignmentRestProperty
+ case 203 /* SyntaxKind.BindingElement */:
+ case 296 /* SyntaxKind.PropertyAssignment */: // AssignmentProperty
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // AssignmentProperty
+ case 298 /* SyntaxKind.SpreadAssignment */: // AssignmentRestProperty
return true;
}
return false;
@@ -13542,8 +13729,8 @@ var ts;
/* @internal */
function isArrayBindingOrAssignmentPattern(node) {
switch (node.kind) {
- case 201 /* ArrayBindingPattern */:
- case 203 /* ArrayLiteralExpression */:
+ case 202 /* SyntaxKind.ArrayBindingPattern */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
return true;
}
return false;
@@ -13552,26 +13739,26 @@ var ts;
/* @internal */
function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) {
var kind = node.kind;
- return kind === 205 /* PropertyAccessExpression */
- || kind === 160 /* QualifiedName */
- || kind === 199 /* ImportType */;
+ return kind === 206 /* SyntaxKind.PropertyAccessExpression */
+ || kind === 161 /* SyntaxKind.QualifiedName */
+ || kind === 200 /* SyntaxKind.ImportType */;
}
ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode;
// Expression
function isPropertyAccessOrQualifiedName(node) {
var kind = node.kind;
- return kind === 205 /* PropertyAccessExpression */
- || kind === 160 /* QualifiedName */;
+ return kind === 206 /* SyntaxKind.PropertyAccessExpression */
+ || kind === 161 /* SyntaxKind.QualifiedName */;
}
ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName;
function isCallLikeExpression(node) {
switch (node.kind) {
- case 279 /* JsxOpeningElement */:
- case 278 /* JsxSelfClosingElement */:
- case 207 /* CallExpression */:
- case 208 /* NewExpression */:
- case 209 /* TaggedTemplateExpression */:
- case 164 /* Decorator */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
+ case 208 /* SyntaxKind.CallExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
+ case 165 /* SyntaxKind.Decorator */:
return true;
default:
return false;
@@ -13579,13 +13766,13 @@ var ts;
}
ts.isCallLikeExpression = isCallLikeExpression;
function isCallOrNewExpression(node) {
- return node.kind === 207 /* CallExpression */ || node.kind === 208 /* NewExpression */;
+ return node.kind === 208 /* SyntaxKind.CallExpression */ || node.kind === 209 /* SyntaxKind.NewExpression */;
}
ts.isCallOrNewExpression = isCallOrNewExpression;
function isTemplateLiteral(node) {
var kind = node.kind;
- return kind === 222 /* TemplateExpression */
- || kind === 14 /* NoSubstitutionTemplateLiteral */;
+ return kind === 223 /* SyntaxKind.TemplateExpression */
+ || kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */;
}
ts.isTemplateLiteral = isTemplateLiteral;
/* @internal */
@@ -13595,35 +13782,36 @@ var ts;
ts.isLeftHandSideExpression = isLeftHandSideExpression;
function isLeftHandSideExpressionKind(kind) {
switch (kind) {
- case 205 /* PropertyAccessExpression */:
- case 206 /* ElementAccessExpression */:
- case 208 /* NewExpression */:
- case 207 /* CallExpression */:
- case 277 /* JsxElement */:
- case 278 /* JsxSelfClosingElement */:
- case 281 /* JsxFragment */:
- case 209 /* TaggedTemplateExpression */:
- case 203 /* ArrayLiteralExpression */:
- case 211 /* ParenthesizedExpression */:
- case 204 /* ObjectLiteralExpression */:
- case 225 /* ClassExpression */:
- case 212 /* FunctionExpression */:
- case 79 /* Identifier */:
- case 80 /* PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression
- case 13 /* RegularExpressionLiteral */:
- case 8 /* NumericLiteral */:
- case 9 /* BigIntLiteral */:
- case 10 /* StringLiteral */:
- case 14 /* NoSubstitutionTemplateLiteral */:
- case 222 /* TemplateExpression */:
- case 95 /* FalseKeyword */:
- case 104 /* NullKeyword */:
- case 108 /* ThisKeyword */:
- case 110 /* TrueKeyword */:
- case 106 /* SuperKeyword */:
- case 229 /* NonNullExpression */:
- case 230 /* MetaProperty */:
- case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
+ case 278 /* SyntaxKind.JsxElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
+ case 282 /* SyntaxKind.JsxFragment */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 79 /* SyntaxKind.Identifier */:
+ case 80 /* SyntaxKind.PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression
+ case 13 /* SyntaxKind.RegularExpressionLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
+ case 9 /* SyntaxKind.BigIntLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
+ case 223 /* SyntaxKind.TemplateExpression */:
+ case 95 /* SyntaxKind.FalseKeyword */:
+ case 104 /* SyntaxKind.NullKeyword */:
+ case 108 /* SyntaxKind.ThisKeyword */:
+ case 110 /* SyntaxKind.TrueKeyword */:
+ case 106 /* SyntaxKind.SuperKeyword */:
+ case 230 /* SyntaxKind.NonNullExpression */:
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
+ case 231 /* SyntaxKind.MetaProperty */:
+ case 100 /* SyntaxKind.ImportKeyword */: // technically this is only an Expression if it's in a CallExpression
return true;
default:
return false;
@@ -13636,13 +13824,13 @@ var ts;
ts.isUnaryExpression = isUnaryExpression;
function isUnaryExpressionKind(kind) {
switch (kind) {
- case 218 /* PrefixUnaryExpression */:
- case 219 /* PostfixUnaryExpression */:
- case 214 /* DeleteExpression */:
- case 215 /* TypeOfExpression */:
- case 216 /* VoidExpression */:
- case 217 /* AwaitExpression */:
- case 210 /* TypeAssertionExpression */:
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
+ case 220 /* SyntaxKind.PostfixUnaryExpression */:
+ case 215 /* SyntaxKind.DeleteExpression */:
+ case 216 /* SyntaxKind.TypeOfExpression */:
+ case 217 /* SyntaxKind.VoidExpression */:
+ case 218 /* SyntaxKind.AwaitExpression */:
+ case 211 /* SyntaxKind.TypeAssertionExpression */:
return true;
default:
return isLeftHandSideExpressionKind(kind);
@@ -13651,11 +13839,11 @@ var ts;
/* @internal */
function isUnaryExpressionWithWrite(expr) {
switch (expr.kind) {
- case 219 /* PostfixUnaryExpression */:
+ case 220 /* SyntaxKind.PostfixUnaryExpression */:
return true;
- case 218 /* PrefixUnaryExpression */:
- return expr.operator === 45 /* PlusPlusToken */ ||
- expr.operator === 46 /* MinusMinusToken */;
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
+ return expr.operator === 45 /* SyntaxKind.PlusPlusToken */ ||
+ expr.operator === 46 /* SyntaxKind.MinusMinusToken */;
default:
return false;
}
@@ -13672,15 +13860,15 @@ var ts;
ts.isExpression = isExpression;
function isExpressionKind(kind) {
switch (kind) {
- case 221 /* ConditionalExpression */:
- case 223 /* YieldExpression */:
- case 213 /* ArrowFunction */:
- case 220 /* BinaryExpression */:
- case 224 /* SpreadElement */:
- case 228 /* AsExpression */:
- case 226 /* OmittedExpression */:
- case 349 /* CommaListExpression */:
- case 348 /* PartiallyEmittedExpression */:
+ case 222 /* SyntaxKind.ConditionalExpression */:
+ case 224 /* SyntaxKind.YieldExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 221 /* SyntaxKind.BinaryExpression */:
+ case 225 /* SyntaxKind.SpreadElement */:
+ case 229 /* SyntaxKind.AsExpression */:
+ case 227 /* SyntaxKind.OmittedExpression */:
+ case 351 /* SyntaxKind.CommaListExpression */:
+ case 350 /* SyntaxKind.PartiallyEmittedExpression */:
return true;
default:
return isUnaryExpressionKind(kind);
@@ -13688,8 +13876,8 @@ var ts;
}
function isAssertionExpression(node) {
var kind = node.kind;
- return kind === 210 /* TypeAssertionExpression */
- || kind === 228 /* AsExpression */;
+ return kind === 211 /* SyntaxKind.TypeAssertionExpression */
+ || kind === 229 /* SyntaxKind.AsExpression */;
}
ts.isAssertionExpression = isAssertionExpression;
/* @internal */
@@ -13700,13 +13888,13 @@ var ts;
ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode;
function isIterationStatement(node, lookInLabeledStatements) {
switch (node.kind) {
- case 241 /* ForStatement */:
- case 242 /* ForInStatement */:
- case 243 /* ForOfStatement */:
- case 239 /* DoStatement */:
- case 240 /* WhileStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
return true;
- case 249 /* LabeledStatement */:
+ case 250 /* SyntaxKind.LabeledStatement */:
return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements);
}
return false;
@@ -13724,18 +13912,18 @@ var ts;
ts.hasScopeMarker = hasScopeMarker;
/* @internal */
function needsScopeMarker(result) {
- return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* Export */) && !ts.isAmbientModule(result);
+ return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */) && !ts.isAmbientModule(result);
}
ts.needsScopeMarker = needsScopeMarker;
/* @internal */
function isExternalModuleIndicator(result) {
// Exported top-level member indicates moduleness
- return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* Export */);
+ return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */);
}
ts.isExternalModuleIndicator = isExternalModuleIndicator;
/* @internal */
function isForInOrOfStatement(node) {
- return node.kind === 242 /* ForInStatement */ || node.kind === 243 /* ForOfStatement */;
+ return node.kind === 243 /* SyntaxKind.ForInStatement */ || node.kind === 244 /* SyntaxKind.ForOfStatement */;
}
ts.isForInOrOfStatement = isForInOrOfStatement;
// Element
@@ -13759,115 +13947,115 @@ var ts;
/* @internal */
function isModuleBody(node) {
var kind = node.kind;
- return kind === 261 /* ModuleBlock */
- || kind === 260 /* ModuleDeclaration */
- || kind === 79 /* Identifier */;
+ return kind === 262 /* SyntaxKind.ModuleBlock */
+ || kind === 261 /* SyntaxKind.ModuleDeclaration */
+ || kind === 79 /* SyntaxKind.Identifier */;
}
ts.isModuleBody = isModuleBody;
/* @internal */
function isNamespaceBody(node) {
var kind = node.kind;
- return kind === 261 /* ModuleBlock */
- || kind === 260 /* ModuleDeclaration */;
+ return kind === 262 /* SyntaxKind.ModuleBlock */
+ || kind === 261 /* SyntaxKind.ModuleDeclaration */;
}
ts.isNamespaceBody = isNamespaceBody;
/* @internal */
function isJSDocNamespaceBody(node) {
var kind = node.kind;
- return kind === 79 /* Identifier */
- || kind === 260 /* ModuleDeclaration */;
+ return kind === 79 /* SyntaxKind.Identifier */
+ || kind === 261 /* SyntaxKind.ModuleDeclaration */;
}
ts.isJSDocNamespaceBody = isJSDocNamespaceBody;
/* @internal */
function isNamedImportBindings(node) {
var kind = node.kind;
- return kind === 268 /* NamedImports */
- || kind === 267 /* NamespaceImport */;
+ return kind === 269 /* SyntaxKind.NamedImports */
+ || kind === 268 /* SyntaxKind.NamespaceImport */;
}
ts.isNamedImportBindings = isNamedImportBindings;
/* @internal */
function isModuleOrEnumDeclaration(node) {
- return node.kind === 260 /* ModuleDeclaration */ || node.kind === 259 /* EnumDeclaration */;
+ return node.kind === 261 /* SyntaxKind.ModuleDeclaration */ || node.kind === 260 /* SyntaxKind.EnumDeclaration */;
}
ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration;
function isDeclarationKind(kind) {
- return kind === 213 /* ArrowFunction */
- || kind === 202 /* BindingElement */
- || kind === 256 /* ClassDeclaration */
- || kind === 225 /* ClassExpression */
- || kind === 169 /* ClassStaticBlockDeclaration */
- || kind === 170 /* Constructor */
- || kind === 259 /* EnumDeclaration */
- || kind === 297 /* EnumMember */
- || kind === 274 /* ExportSpecifier */
- || kind === 255 /* FunctionDeclaration */
- || kind === 212 /* FunctionExpression */
- || kind === 171 /* GetAccessor */
- || kind === 266 /* ImportClause */
- || kind === 264 /* ImportEqualsDeclaration */
- || kind === 269 /* ImportSpecifier */
- || kind === 257 /* InterfaceDeclaration */
- || kind === 284 /* JsxAttribute */
- || kind === 168 /* MethodDeclaration */
- || kind === 167 /* MethodSignature */
- || kind === 260 /* ModuleDeclaration */
- || kind === 263 /* NamespaceExportDeclaration */
- || kind === 267 /* NamespaceImport */
- || kind === 273 /* NamespaceExport */
- || kind === 163 /* Parameter */
- || kind === 294 /* PropertyAssignment */
- || kind === 166 /* PropertyDeclaration */
- || kind === 165 /* PropertySignature */
- || kind === 172 /* SetAccessor */
- || kind === 295 /* ShorthandPropertyAssignment */
- || kind === 258 /* TypeAliasDeclaration */
- || kind === 162 /* TypeParameter */
- || kind === 253 /* VariableDeclaration */
- || kind === 343 /* JSDocTypedefTag */
- || kind === 336 /* JSDocCallbackTag */
- || kind === 345 /* JSDocPropertyTag */;
+ return kind === 214 /* SyntaxKind.ArrowFunction */
+ || kind === 203 /* SyntaxKind.BindingElement */
+ || kind === 257 /* SyntaxKind.ClassDeclaration */
+ || kind === 226 /* SyntaxKind.ClassExpression */
+ || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */
+ || kind === 171 /* SyntaxKind.Constructor */
+ || kind === 260 /* SyntaxKind.EnumDeclaration */
+ || kind === 299 /* SyntaxKind.EnumMember */
+ || kind === 275 /* SyntaxKind.ExportSpecifier */
+ || kind === 256 /* SyntaxKind.FunctionDeclaration */
+ || kind === 213 /* SyntaxKind.FunctionExpression */
+ || kind === 172 /* SyntaxKind.GetAccessor */
+ || kind === 267 /* SyntaxKind.ImportClause */
+ || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */
+ || kind === 270 /* SyntaxKind.ImportSpecifier */
+ || kind === 258 /* SyntaxKind.InterfaceDeclaration */
+ || kind === 285 /* SyntaxKind.JsxAttribute */
+ || kind === 169 /* SyntaxKind.MethodDeclaration */
+ || kind === 168 /* SyntaxKind.MethodSignature */
+ || kind === 261 /* SyntaxKind.ModuleDeclaration */
+ || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */
+ || kind === 268 /* SyntaxKind.NamespaceImport */
+ || kind === 274 /* SyntaxKind.NamespaceExport */
+ || kind === 164 /* SyntaxKind.Parameter */
+ || kind === 296 /* SyntaxKind.PropertyAssignment */
+ || kind === 167 /* SyntaxKind.PropertyDeclaration */
+ || kind === 166 /* SyntaxKind.PropertySignature */
+ || kind === 173 /* SyntaxKind.SetAccessor */
+ || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */
+ || kind === 259 /* SyntaxKind.TypeAliasDeclaration */
+ || kind === 163 /* SyntaxKind.TypeParameter */
+ || kind === 254 /* SyntaxKind.VariableDeclaration */
+ || kind === 345 /* SyntaxKind.JSDocTypedefTag */
+ || kind === 338 /* SyntaxKind.JSDocCallbackTag */
+ || kind === 347 /* SyntaxKind.JSDocPropertyTag */;
}
function isDeclarationStatementKind(kind) {
- return kind === 255 /* FunctionDeclaration */
- || kind === 275 /* MissingDeclaration */
- || kind === 256 /* ClassDeclaration */
- || kind === 257 /* InterfaceDeclaration */
- || kind === 258 /* TypeAliasDeclaration */
- || kind === 259 /* EnumDeclaration */
- || kind === 260 /* ModuleDeclaration */
- || kind === 265 /* ImportDeclaration */
- || kind === 264 /* ImportEqualsDeclaration */
- || kind === 271 /* ExportDeclaration */
- || kind === 270 /* ExportAssignment */
- || kind === 263 /* NamespaceExportDeclaration */;
+ return kind === 256 /* SyntaxKind.FunctionDeclaration */
+ || kind === 276 /* SyntaxKind.MissingDeclaration */
+ || kind === 257 /* SyntaxKind.ClassDeclaration */
+ || kind === 258 /* SyntaxKind.InterfaceDeclaration */
+ || kind === 259 /* SyntaxKind.TypeAliasDeclaration */
+ || kind === 260 /* SyntaxKind.EnumDeclaration */
+ || kind === 261 /* SyntaxKind.ModuleDeclaration */
+ || kind === 266 /* SyntaxKind.ImportDeclaration */
+ || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */
+ || kind === 272 /* SyntaxKind.ExportDeclaration */
+ || kind === 271 /* SyntaxKind.ExportAssignment */
+ || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */;
}
function isStatementKindButNotDeclarationKind(kind) {
- return kind === 245 /* BreakStatement */
- || kind === 244 /* ContinueStatement */
- || kind === 252 /* DebuggerStatement */
- || kind === 239 /* DoStatement */
- || kind === 237 /* ExpressionStatement */
- || kind === 235 /* EmptyStatement */
- || kind === 242 /* ForInStatement */
- || kind === 243 /* ForOfStatement */
- || kind === 241 /* ForStatement */
- || kind === 238 /* IfStatement */
- || kind === 249 /* LabeledStatement */
- || kind === 246 /* ReturnStatement */
- || kind === 248 /* SwitchStatement */
- || kind === 250 /* ThrowStatement */
- || kind === 251 /* TryStatement */
- || kind === 236 /* VariableStatement */
- || kind === 240 /* WhileStatement */
- || kind === 247 /* WithStatement */
- || kind === 347 /* NotEmittedStatement */
- || kind === 351 /* EndOfDeclarationMarker */
- || kind === 350 /* MergeDeclarationMarker */;
+ return kind === 246 /* SyntaxKind.BreakStatement */
+ || kind === 245 /* SyntaxKind.ContinueStatement */
+ || kind === 253 /* SyntaxKind.DebuggerStatement */
+ || kind === 240 /* SyntaxKind.DoStatement */
+ || kind === 238 /* SyntaxKind.ExpressionStatement */
+ || kind === 236 /* SyntaxKind.EmptyStatement */
+ || kind === 243 /* SyntaxKind.ForInStatement */
+ || kind === 244 /* SyntaxKind.ForOfStatement */
+ || kind === 242 /* SyntaxKind.ForStatement */
+ || kind === 239 /* SyntaxKind.IfStatement */
+ || kind === 250 /* SyntaxKind.LabeledStatement */
+ || kind === 247 /* SyntaxKind.ReturnStatement */
+ || kind === 249 /* SyntaxKind.SwitchStatement */
+ || kind === 251 /* SyntaxKind.ThrowStatement */
+ || kind === 252 /* SyntaxKind.TryStatement */
+ || kind === 237 /* SyntaxKind.VariableStatement */
+ || kind === 241 /* SyntaxKind.WhileStatement */
+ || kind === 248 /* SyntaxKind.WithStatement */
+ || kind === 349 /* SyntaxKind.NotEmittedStatement */
+ || kind === 353 /* SyntaxKind.EndOfDeclarationMarker */
+ || kind === 352 /* SyntaxKind.MergeDeclarationMarker */;
}
/* @internal */
function isDeclaration(node) {
- if (node.kind === 162 /* TypeParameter */) {
- return (node.parent && node.parent.kind !== 342 /* JSDocTemplateTag */) || ts.isInJSFile(node);
+ if (node.kind === 163 /* SyntaxKind.TypeParameter */) {
+ return (node.parent && node.parent.kind !== 344 /* SyntaxKind.JSDocTemplateTag */) || ts.isInJSFile(node);
}
return isDeclarationKind(node.kind);
}
@@ -13894,10 +14082,10 @@ var ts;
}
ts.isStatement = isStatement;
function isBlockStatement(node) {
- if (node.kind !== 234 /* Block */)
+ if (node.kind !== 235 /* SyntaxKind.Block */)
return false;
if (node.parent !== undefined) {
- if (node.parent.kind === 251 /* TryStatement */ || node.parent.kind === 291 /* CatchClause */) {
+ if (node.parent.kind === 252 /* SyntaxKind.TryStatement */ || node.parent.kind === 292 /* SyntaxKind.CatchClause */) {
return false;
}
}
@@ -13911,76 +14099,76 @@ var ts;
var kind = node.kind;
return isStatementKindButNotDeclarationKind(kind)
|| isDeclarationStatementKind(kind)
- || kind === 234 /* Block */;
+ || kind === 235 /* SyntaxKind.Block */;
}
ts.isStatementOrBlock = isStatementOrBlock;
// Module references
/* @internal */
function isModuleReference(node) {
var kind = node.kind;
- return kind === 276 /* ExternalModuleReference */
- || kind === 160 /* QualifiedName */
- || kind === 79 /* Identifier */;
+ return kind === 277 /* SyntaxKind.ExternalModuleReference */
+ || kind === 161 /* SyntaxKind.QualifiedName */
+ || kind === 79 /* SyntaxKind.Identifier */;
}
ts.isModuleReference = isModuleReference;
// JSX
/* @internal */
function isJsxTagNameExpression(node) {
var kind = node.kind;
- return kind === 108 /* ThisKeyword */
- || kind === 79 /* Identifier */
- || kind === 205 /* PropertyAccessExpression */;
+ return kind === 108 /* SyntaxKind.ThisKeyword */
+ || kind === 79 /* SyntaxKind.Identifier */
+ || kind === 206 /* SyntaxKind.PropertyAccessExpression */;
}
ts.isJsxTagNameExpression = isJsxTagNameExpression;
/* @internal */
function isJsxChild(node) {
var kind = node.kind;
- return kind === 277 /* JsxElement */
- || kind === 287 /* JsxExpression */
- || kind === 278 /* JsxSelfClosingElement */
- || kind === 11 /* JsxText */
- || kind === 281 /* JsxFragment */;
+ return kind === 278 /* SyntaxKind.JsxElement */
+ || kind === 288 /* SyntaxKind.JsxExpression */
+ || kind === 279 /* SyntaxKind.JsxSelfClosingElement */
+ || kind === 11 /* SyntaxKind.JsxText */
+ || kind === 282 /* SyntaxKind.JsxFragment */;
}
ts.isJsxChild = isJsxChild;
/* @internal */
function isJsxAttributeLike(node) {
var kind = node.kind;
- return kind === 284 /* JsxAttribute */
- || kind === 286 /* JsxSpreadAttribute */;
+ return kind === 285 /* SyntaxKind.JsxAttribute */
+ || kind === 287 /* SyntaxKind.JsxSpreadAttribute */;
}
ts.isJsxAttributeLike = isJsxAttributeLike;
/* @internal */
function isStringLiteralOrJsxExpression(node) {
var kind = node.kind;
- return kind === 10 /* StringLiteral */
- || kind === 287 /* JsxExpression */;
+ return kind === 10 /* SyntaxKind.StringLiteral */
+ || kind === 288 /* SyntaxKind.JsxExpression */;
}
ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression;
function isJsxOpeningLikeElement(node) {
var kind = node.kind;
- return kind === 279 /* JsxOpeningElement */
- || kind === 278 /* JsxSelfClosingElement */;
+ return kind === 280 /* SyntaxKind.JsxOpeningElement */
+ || kind === 279 /* SyntaxKind.JsxSelfClosingElement */;
}
ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement;
// Clauses
function isCaseOrDefaultClause(node) {
var kind = node.kind;
- return kind === 288 /* CaseClause */
- || kind === 289 /* DefaultClause */;
+ return kind === 289 /* SyntaxKind.CaseClause */
+ || kind === 290 /* SyntaxKind.DefaultClause */;
}
ts.isCaseOrDefaultClause = isCaseOrDefaultClause;
// JSDoc
/** True if node is of some JSDoc syntax kind. */
/* @internal */
function isJSDocNode(node) {
- return node.kind >= 307 /* FirstJSDocNode */ && node.kind <= 345 /* LastJSDocNode */;
+ return node.kind >= 309 /* SyntaxKind.FirstJSDocNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocNode */;
}
ts.isJSDocNode = isJSDocNode;
/** True if node is of a kind that may contain comment text. */
function isJSDocCommentContainingNode(node) {
- return node.kind === 318 /* JSDocComment */
- || node.kind === 317 /* JSDocNamepathType */
- || node.kind === 319 /* JSDocText */
+ return node.kind === 320 /* SyntaxKind.JSDoc */
+ || node.kind === 319 /* SyntaxKind.JSDocNamepathType */
+ || node.kind === 321 /* SyntaxKind.JSDocText */
|| isJSDocLinkLike(node)
|| isJSDocTag(node)
|| ts.isJSDocTypeLiteral(node)
@@ -13990,15 +14178,15 @@ var ts;
// TODO: determine what this does before making it public.
/* @internal */
function isJSDocTag(node) {
- return node.kind >= 325 /* FirstJSDocTagNode */ && node.kind <= 345 /* LastJSDocTagNode */;
+ return node.kind >= 327 /* SyntaxKind.FirstJSDocTagNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocTagNode */;
}
ts.isJSDocTag = isJSDocTag;
function isSetAccessor(node) {
- return node.kind === 172 /* SetAccessor */;
+ return node.kind === 173 /* SyntaxKind.SetAccessor */;
}
ts.isSetAccessor = isSetAccessor;
function isGetAccessor(node) {
- return node.kind === 171 /* GetAccessor */;
+ return node.kind === 172 /* SyntaxKind.GetAccessor */;
}
ts.isGetAccessor = isGetAccessor;
/** True if has jsdoc nodes attached to it. */
@@ -14024,13 +14212,13 @@ var ts;
/** True if has initializer node attached to it. */
function hasOnlyExpressionInitializer(node) {
switch (node.kind) {
- case 253 /* VariableDeclaration */:
- case 163 /* Parameter */:
- case 202 /* BindingElement */:
- case 165 /* PropertySignature */:
- case 166 /* PropertyDeclaration */:
- case 294 /* PropertyAssignment */:
- case 297 /* EnumMember */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
+ case 164 /* SyntaxKind.Parameter */:
+ case 203 /* SyntaxKind.BindingElement */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
+ case 299 /* SyntaxKind.EnumMember */:
return true;
default:
return false;
@@ -14038,12 +14226,12 @@ var ts;
}
ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer;
function isObjectLiteralElement(node) {
- return node.kind === 284 /* JsxAttribute */ || node.kind === 286 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node);
+ return node.kind === 285 /* SyntaxKind.JsxAttribute */ || node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */ || isObjectLiteralElementLike(node);
}
ts.isObjectLiteralElement = isObjectLiteralElement;
/* @internal */
function isTypeReferenceType(node) {
- return node.kind === 177 /* TypeReference */ || node.kind === 227 /* ExpressionWithTypeArguments */;
+ return node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */;
}
ts.isTypeReferenceType = isTypeReferenceType;
var MAX_SMI_X86 = 1073741823;
@@ -14072,11 +14260,11 @@ var ts;
}
ts.guessIndentation = guessIndentation;
function isStringLiteralLike(node) {
- return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */;
+ return node.kind === 10 /* SyntaxKind.StringLiteral */ || node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */;
}
ts.isStringLiteralLike = isStringLiteralLike;
function isJSDocLinkLike(node) {
- return node.kind === 322 /* JSDocLink */ || node.kind === 323 /* JSDocLinkCode */ || node.kind === 324 /* JSDocLinkPlain */;
+ return node.kind === 324 /* SyntaxKind.JSDocLink */ || node.kind === 325 /* SyntaxKind.JSDocLinkCode */ || node.kind === 326 /* SyntaxKind.JSDocLinkPlain */;
}
ts.isJSDocLinkLike = isJSDocLinkLike;
// #endregion
@@ -14117,7 +14305,7 @@ var ts;
}
ts.createSymbolTable = createSymbolTable;
function isTransientSymbol(symbol) {
- return (symbol.flags & 33554432 /* Transient */) !== 0;
+ return (symbol.flags & 33554432 /* SymbolFlags.Transient */) !== 0;
}
ts.isTransientSymbol = isTransientSymbol;
var stringWriter = createSingleLineStringWriter();
@@ -14295,7 +14483,11 @@ var ts;
ts.Debug.assert(names.length === newResolutions.length);
for (var i = 0; i < names.length; i++) {
var newResolution = newResolutions[i];
- var oldResolution = oldResolutions && oldResolutions.get(names[i], oldSourceFile && ts.getModeForResolutionAtIndex(oldSourceFile, i));
+ var entry = names[i];
+ // We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
+ var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
+ var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.impliedNodeFormat) : oldSourceFile && ts.getModeForResolutionAtIndex(oldSourceFile, i);
+ var oldResolution = oldResolutions && oldResolutions.get(name, mode);
var changed = oldResolution
? !newResolution || !comparer(oldResolution, newResolution)
: newResolution;
@@ -14309,28 +14501,28 @@ var ts;
// Returns true if this node contains a parse error anywhere underneath it.
function containsParseError(node) {
aggregateChildData(node);
- return (node.flags & 262144 /* ThisNodeOrAnySubNodesHasError */) !== 0;
+ return (node.flags & 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */) !== 0;
}
ts.containsParseError = containsParseError;
function aggregateChildData(node) {
- if (!(node.flags & 524288 /* HasAggregatedChildData */)) {
+ if (!(node.flags & 1048576 /* NodeFlags.HasAggregatedChildData */)) {
// A node is considered to contain a parse error if:
// a) the parser explicitly marked that it had an error
// b) any of it's children reported that it had an error.
- var thisNodeOrAnySubNodesHasError = ((node.flags & 65536 /* ThisNodeHasError */) !== 0) ||
+ var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* NodeFlags.ThisNodeHasError */) !== 0) ||
ts.forEachChild(node, containsParseError);
// If so, mark ourselves accordingly.
if (thisNodeOrAnySubNodesHasError) {
- node.flags |= 262144 /* ThisNodeOrAnySubNodesHasError */;
+ node.flags |= 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */;
}
// Also mark that we've propagated the child information to this node. This way we can
// always consult the bit directly on this node without needing to check its children
// again.
- node.flags |= 524288 /* HasAggregatedChildData */;
+ node.flags |= 1048576 /* NodeFlags.HasAggregatedChildData */;
}
}
function getSourceFileOfNode(node) {
- while (node && node.kind !== 303 /* SourceFile */) {
+ while (node && node.kind !== 305 /* SyntaxKind.SourceFile */) {
node = node.parent;
}
return node;
@@ -14341,16 +14533,16 @@ var ts;
}
ts.getSourceFileOfModule = getSourceFileOfModule;
function isPlainJsFile(file, checkJs) {
- return !!file && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */) && !file.checkJsDirective && checkJs === undefined;
+ return !!file && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */) && !file.checkJsDirective && checkJs === undefined;
}
ts.isPlainJsFile = isPlainJsFile;
function isStatementWithLocals(node) {
switch (node.kind) {
- case 234 /* Block */:
- case 262 /* CaseBlock */:
- case 241 /* ForStatement */:
- case 242 /* ForInStatement */:
- case 243 /* ForOfStatement */:
+ case 235 /* SyntaxKind.Block */:
+ case 263 /* SyntaxKind.CaseBlock */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
return true;
}
return false;
@@ -14418,7 +14610,7 @@ var ts;
if (node === undefined) {
return true;
}
- return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* EndOfFileToken */;
+ return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* SyntaxKind.EndOfFileToken */;
}
ts.nodeIsMissing = nodeIsMissing;
function nodeIsPresent(node) {
@@ -14452,7 +14644,7 @@ var ts;
return to;
}
function isAnyPrologueDirective(node) {
- return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* CustomPrologue */);
+ return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */);
}
/**
* Prepends statements to an array while taking care of prologue directives.
@@ -14484,9 +14676,9 @@ var ts;
function isRecognizedTripleSlashComment(text, commentPos, commentEnd) {
// Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text
// so that we don't end up computing comment string and doing match for all // comments
- if (text.charCodeAt(commentPos + 1) === 47 /* slash */ &&
+ if (text.charCodeAt(commentPos + 1) === 47 /* CharacterCodes.slash */ &&
commentPos + 2 < commentEnd &&
- text.charCodeAt(commentPos + 2) === 47 /* slash */) {
+ text.charCodeAt(commentPos + 2) === 47 /* CharacterCodes.slash */) {
var textSubStr = text.substring(commentPos, commentEnd);
return ts.fullTripleSlashReferencePathRegEx.test(textSubStr) ||
ts.fullTripleSlashAMDReferencePathRegEx.test(textSubStr) ||
@@ -14498,8 +14690,8 @@ var ts;
}
ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment;
function isPinnedComment(text, start) {
- return text.charCodeAt(start + 1) === 42 /* asterisk */ &&
- text.charCodeAt(start + 2) === 33 /* exclamation */;
+ return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ &&
+ text.charCodeAt(start + 2) === 33 /* CharacterCodes.exclamation */;
}
ts.isPinnedComment = isPinnedComment;
function createCommentDirectivesMap(sourceFile, commentDirectives) {
@@ -14513,7 +14705,7 @@ var ts;
return ts.arrayFrom(directivesByLine.entries())
.filter(function (_a) {
var line = _a[0], directive = _a[1];
- return directive.type === 0 /* ExpectError */ && !usedLines.get(line);
+ return directive.type === 0 /* CommentDirectiveType.ExpectError */ && !usedLines.get(line);
})
.map(function (_a) {
var _ = _a[0], directive = _a[1];
@@ -14535,7 +14727,7 @@ var ts;
if (nodeIsMissing(node)) {
return node.pos;
}
- if (ts.isJSDocNode(node) || node.kind === 11 /* JsxText */) {
+ if (ts.isJSDocNode(node) || node.kind === 11 /* SyntaxKind.JsxText */) {
// JsxText cannot actually contain comments, even though the scanner will think it sees comments
return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
}
@@ -14546,7 +14738,7 @@ var ts;
// the syntax list itself considers them as normal trivia. Therefore if we simply skip
// trivia for the list, we may have skipped the JSDocComment as well. So we should process its
// first child to determine the actual position of its first token.
- if (node.kind === 346 /* SyntaxList */ && node._children.length > 0) {
+ if (node.kind === 348 /* SyntaxKind.SyntaxList */ && node._children.length > 0) {
return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc);
}
return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos,
@@ -14707,50 +14899,50 @@ var ts;
var _a;
// If we don't need to downlevel and we can reach the original source text using
// the node's parent reference, then simply get the text as it was originally written.
- if (canUseOriginalText(node, flags)) {
+ if (sourceFile && canUseOriginalText(node, flags)) {
return getSourceTextOfNodeFromSourceFile(sourceFile, node);
}
// If we can't reach the original source text, use the canonical form if it's a number,
// or a (possibly escaped) quoted form of the original text if it's string-like.
switch (node.kind) {
- case 10 /* StringLiteral */: {
- var escapeText = flags & 2 /* JsxAttributeEscape */ ? escapeJsxAttributeString :
- flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString :
+ case 10 /* SyntaxKind.StringLiteral */: {
+ var escapeText = flags & 2 /* GetLiteralTextFlags.JsxAttributeEscape */ ? escapeJsxAttributeString :
+ flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString :
escapeNonAsciiString;
if (node.singleQuote) {
- return "'" + escapeText(node.text, 39 /* singleQuote */) + "'";
+ return "'" + escapeText(node.text, 39 /* CharacterCodes.singleQuote */) + "'";
}
else {
- return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"';
+ return '"' + escapeText(node.text, 34 /* CharacterCodes.doubleQuote */) + '"';
}
}
- case 14 /* NoSubstitutionTemplateLiteral */:
- case 15 /* TemplateHead */:
- case 16 /* TemplateMiddle */:
- case 17 /* TemplateTail */: {
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
+ case 15 /* SyntaxKind.TemplateHead */:
+ case 16 /* SyntaxKind.TemplateMiddle */:
+ case 17 /* SyntaxKind.TemplateTail */: {
// If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text
// had to include a backslash: `not \${a} substitution`.
- var escapeText = flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString :
+ var escapeText = flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString :
escapeNonAsciiString;
- var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */));
+ var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* CharacterCodes.backtick */));
switch (node.kind) {
- case 14 /* NoSubstitutionTemplateLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
return "`" + rawText + "`";
- case 15 /* TemplateHead */:
+ case 15 /* SyntaxKind.TemplateHead */:
return "`" + rawText + "${";
- case 16 /* TemplateMiddle */:
+ case 16 /* SyntaxKind.TemplateMiddle */:
return "}" + rawText + "${";
- case 17 /* TemplateTail */:
+ case 17 /* SyntaxKind.TemplateTail */:
return "}" + rawText + "`";
}
break;
}
- case 8 /* NumericLiteral */:
- case 9 /* BigIntLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
+ case 9 /* SyntaxKind.BigIntLiteral */:
return node.text;
- case 13 /* RegularExpressionLiteral */:
- if (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated) {
- return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* backslash */ ? " /" : "/");
+ case 13 /* SyntaxKind.RegularExpressionLiteral */:
+ if (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated) {
+ return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* CharacterCodes.backslash */ ? " /" : "/");
}
return node.text;
}
@@ -14758,11 +14950,11 @@ var ts;
}
ts.getLiteralText = getLiteralText;
function canUseOriginalText(node, flags) {
- if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated)) {
+ if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated)) {
return false;
}
- if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */) {
- return !!(flags & 8 /* AllowNumericSeparator */);
+ if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* TokenFlags.ContainsSeparator */) {
+ return !!(flags & 8 /* GetLiteralTextFlags.AllowNumericSeparator */);
}
return !ts.isBigIntLiteral(node);
}
@@ -14777,21 +14969,21 @@ var ts;
}
ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName;
function isBlockOrCatchScoped(declaration) {
- return (ts.getCombinedNodeFlags(declaration) & 3 /* BlockScoped */) !== 0 ||
+ return (ts.getCombinedNodeFlags(declaration) & 3 /* NodeFlags.BlockScoped */) !== 0 ||
isCatchClauseVariableDeclarationOrBindingElement(declaration);
}
ts.isBlockOrCatchScoped = isBlockOrCatchScoped;
function isCatchClauseVariableDeclarationOrBindingElement(declaration) {
var node = getRootDeclaration(declaration);
- return node.kind === 253 /* VariableDeclaration */ && node.parent.kind === 291 /* CatchClause */;
+ return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */;
}
ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement;
function isAmbientModule(node) {
- return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* StringLiteral */ || isGlobalScopeAugmentation(node));
+ return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* SyntaxKind.StringLiteral */ || isGlobalScopeAugmentation(node));
}
ts.isAmbientModule = isAmbientModule;
function isModuleWithStringLiteralName(node) {
- return ts.isModuleDeclaration(node) && node.name.kind === 10 /* StringLiteral */;
+ return ts.isModuleDeclaration(node) && node.name.kind === 10 /* SyntaxKind.StringLiteral */;
}
ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName;
function isNonGlobalAmbientModule(node) {
@@ -14815,16 +15007,16 @@ var ts;
ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol;
function isShorthandAmbientModule(node) {
// The only kind of module that can be missing a body is a shorthand ambient module.
- return !!node && node.kind === 260 /* ModuleDeclaration */ && (!node.body);
+ return !!node && node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && (!node.body);
}
function isBlockScopedContainerTopLevel(node) {
- return node.kind === 303 /* SourceFile */ ||
- node.kind === 260 /* ModuleDeclaration */ ||
+ return node.kind === 305 /* SyntaxKind.SourceFile */ ||
+ node.kind === 261 /* SyntaxKind.ModuleDeclaration */ ||
ts.isFunctionLikeOrClassStaticBlockDeclaration(node);
}
ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel;
function isGlobalScopeAugmentation(module) {
- return !!(module.flags & 1024 /* GlobalAugmentation */);
+ return !!(module.flags & 1024 /* NodeFlags.GlobalAugmentation */);
}
ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation;
function isExternalModuleAugmentation(node) {
@@ -14836,9 +15028,9 @@ var ts;
// - defined in the top level scope and source file is an external module
// - defined inside ambient module declaration located in the top level scope and source file not an external module
switch (node.parent.kind) {
- case 303 /* SourceFile */:
+ case 305 /* SyntaxKind.SourceFile */:
return ts.isExternalModule(node.parent);
- case 261 /* ModuleBlock */:
+ case 262 /* SyntaxKind.ModuleBlock */:
return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent);
}
return false;
@@ -14850,7 +15042,7 @@ var ts;
}
ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration;
function isCommonJSContainingModuleKind(kind) {
- return kind === ts.ModuleKind.CommonJS || kind === ts.ModuleKind.Node12 || kind === ts.ModuleKind.NodeNext;
+ return kind === ts.ModuleKind.CommonJS || kind === ts.ModuleKind.Node16 || kind === ts.ModuleKind.NodeNext;
}
function isEffectiveExternalModule(node, compilerOptions) {
return ts.isExternalModule(node) || compilerOptions.isolatedModules || (isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator);
@@ -14862,10 +15054,10 @@ var ts;
function isEffectiveStrictModeSourceFile(node, compilerOptions) {
// We can only verify strict mode for JS/TS files
switch (node.scriptKind) {
- case 1 /* JS */:
- case 3 /* TS */:
- case 2 /* JSX */:
- case 4 /* TSX */:
+ case 1 /* ScriptKind.JS */:
+ case 3 /* ScriptKind.TS */:
+ case 2 /* ScriptKind.JSX */:
+ case 4 /* ScriptKind.TSX */:
break;
default:
return false;
@@ -14895,24 +15087,24 @@ var ts;
ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile;
function isBlockScope(node, parentNode) {
switch (node.kind) {
- case 303 /* SourceFile */:
- case 262 /* CaseBlock */:
- case 291 /* CatchClause */:
- case 260 /* ModuleDeclaration */:
- case 241 /* ForStatement */:
- case 242 /* ForInStatement */:
- case 243 /* ForOfStatement */:
- case 170 /* Constructor */:
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
- case 166 /* PropertyDeclaration */:
- case 169 /* ClassStaticBlockDeclaration */:
+ case 305 /* SyntaxKind.SourceFile */:
+ case 263 /* SyntaxKind.CaseBlock */:
+ case 292 /* SyntaxKind.CatchClause */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 170 /* SyntaxKind.ClassStaticBlockDeclaration */:
return true;
- case 234 /* Block */:
+ case 235 /* SyntaxKind.Block */:
// function block is not considered block-scope container
// see comment in binder.ts: bind(...), case for SyntaxKind.Block
return !ts.isFunctionLikeOrClassStaticBlockDeclaration(parentNode);
@@ -14922,9 +15114,9 @@ var ts;
ts.isBlockScope = isBlockScope;
function isDeclarationWithTypeParameters(node) {
switch (node.kind) {
- case 336 /* JSDocCallbackTag */:
- case 343 /* JSDocTypedefTag */:
- case 321 /* JSDocSignature */:
+ case 338 /* SyntaxKind.JSDocCallbackTag */:
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
+ case 323 /* SyntaxKind.JSDocSignature */:
return true;
default:
ts.assertType(node);
@@ -14934,25 +15126,25 @@ var ts;
ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters;
function isDeclarationWithTypeParameterChildren(node) {
switch (node.kind) {
- case 173 /* CallSignature */:
- case 174 /* ConstructSignature */:
- case 167 /* MethodSignature */:
- case 175 /* IndexSignature */:
- case 178 /* FunctionType */:
- case 179 /* ConstructorType */:
- case 315 /* JSDocFunctionType */:
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- case 257 /* InterfaceDeclaration */:
- case 258 /* TypeAliasDeclaration */:
- case 342 /* JSDocTemplateTag */:
- case 255 /* FunctionDeclaration */:
- case 168 /* MethodDeclaration */:
- case 170 /* Constructor */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 176 /* SyntaxKind.IndexSignature */:
+ case 179 /* SyntaxKind.FunctionType */:
+ case 180 /* SyntaxKind.ConstructorType */:
+ case 317 /* SyntaxKind.JSDocFunctionType */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 344 /* SyntaxKind.JSDocTemplateTag */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
return true;
default:
ts.assertType(node);
@@ -14962,25 +15154,29 @@ var ts;
ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren;
function isAnyImportSyntax(node) {
switch (node.kind) {
- case 265 /* ImportDeclaration */:
- case 264 /* ImportEqualsDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return true;
default:
return false;
}
}
ts.isAnyImportSyntax = isAnyImportSyntax;
+ function isAnyImportOrBareOrAccessedRequire(node) {
+ return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node);
+ }
+ ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire;
function isLateVisibilityPaintedStatement(node) {
switch (node.kind) {
- case 265 /* ImportDeclaration */:
- case 264 /* ImportEqualsDeclaration */:
- case 236 /* VariableStatement */:
- case 256 /* ClassDeclaration */:
- case 255 /* FunctionDeclaration */:
- case 260 /* ModuleDeclaration */:
- case 258 /* TypeAliasDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 259 /* EnumDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 237 /* SyntaxKind.VariableStatement */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
return true;
default:
return false;
@@ -15021,44 +15217,48 @@ var ts;
}
ts.getNameFromIndexInfo = getNameFromIndexInfo;
function isComputedNonLiteralName(name) {
- return name.kind === 161 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression);
+ return name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression);
}
ts.isComputedNonLiteralName = isComputedNonLiteralName;
- function getTextOfPropertyName(name) {
+ function tryGetTextOfPropertyName(name) {
switch (name.kind) {
- case 79 /* Identifier */:
- case 80 /* PrivateIdentifier */:
+ case 79 /* SyntaxKind.Identifier */:
+ case 80 /* SyntaxKind.PrivateIdentifier */:
return name.escapedText;
- case 10 /* StringLiteral */:
- case 8 /* NumericLiteral */:
- case 14 /* NoSubstitutionTemplateLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
return ts.escapeLeadingUnderscores(name.text);
- case 161 /* ComputedPropertyName */:
+ case 162 /* SyntaxKind.ComputedPropertyName */:
if (isStringOrNumericLiteralLike(name.expression))
return ts.escapeLeadingUnderscores(name.expression.text);
- return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames");
+ return undefined;
default:
return ts.Debug.assertNever(name);
}
}
+ ts.tryGetTextOfPropertyName = tryGetTextOfPropertyName;
+ function getTextOfPropertyName(name) {
+ return ts.Debug.checkDefined(tryGetTextOfPropertyName(name));
+ }
ts.getTextOfPropertyName = getTextOfPropertyName;
function entityNameToString(name) {
switch (name.kind) {
- case 108 /* ThisKeyword */:
+ case 108 /* SyntaxKind.ThisKeyword */:
return "this";
- case 80 /* PrivateIdentifier */:
- case 79 /* Identifier */:
+ case 80 /* SyntaxKind.PrivateIdentifier */:
+ case 79 /* SyntaxKind.Identifier */:
return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name);
- case 160 /* QualifiedName */:
+ case 161 /* SyntaxKind.QualifiedName */:
return entityNameToString(name.left) + "." + entityNameToString(name.right);
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) {
return entityNameToString(name.expression) + "." + entityNameToString(name.name);
}
else {
return ts.Debug.assertNever(name.name);
}
- case 309 /* JSDocMemberName */:
+ case 311 /* SyntaxKind.JSDocMemberName */:
return entityNameToString(name.left) + entityNameToString(name.right);
default:
return ts.Debug.assertNever(name);
@@ -15148,7 +15348,7 @@ var ts;
ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition;
function getErrorSpanForArrowFunction(sourceFile, node) {
var pos = ts.skipTrivia(sourceFile.text, node.pos);
- if (node.body && node.body.kind === 234 /* Block */) {
+ if (node.body && node.body.kind === 235 /* SyntaxKind.Block */) {
var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line;
var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line;
if (startLine < endLine) {
@@ -15162,7 +15362,7 @@ var ts;
function getErrorSpanForNode(sourceFile, node) {
var errorNode = node;
switch (node.kind) {
- case 303 /* SourceFile */:
+ case 305 /* SyntaxKind.SourceFile */:
var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false);
if (pos_1 === sourceFile.text.length) {
// file is empty - return span for the beginning of the file
@@ -15171,29 +15371,29 @@ var ts;
return getSpanOfTokenAtPosition(sourceFile, pos_1);
// This list is a work in progress. Add missing node kinds to improve their error
// spans.
- case 253 /* VariableDeclaration */:
- case 202 /* BindingElement */:
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- case 257 /* InterfaceDeclaration */:
- case 260 /* ModuleDeclaration */:
- case 259 /* EnumDeclaration */:
- case 297 /* EnumMember */:
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 258 /* TypeAliasDeclaration */:
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
- case 267 /* NamespaceImport */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
+ case 203 /* SyntaxKind.BindingElement */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 299 /* SyntaxKind.EnumMember */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 268 /* SyntaxKind.NamespaceImport */:
errorNode = node.name;
break;
- case 213 /* ArrowFunction */:
+ case 214 /* SyntaxKind.ArrowFunction */:
return getErrorSpanForArrowFunction(sourceFile, node);
- case 288 /* CaseClause */:
- case 289 /* DefaultClause */:
+ case 289 /* SyntaxKind.CaseClause */:
+ case 290 /* SyntaxKind.DefaultClause */:
var start = ts.skipTrivia(sourceFile.text, node.pos);
var end = node.statements.length > 0 ? node.statements[0].pos : node.end;
return ts.createTextSpanFromBounds(start, end);
@@ -15225,36 +15425,36 @@ var ts;
}
ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule;
function isJsonSourceFile(file) {
- return file.scriptKind === 6 /* JSON */;
+ return file.scriptKind === 6 /* ScriptKind.JSON */;
}
ts.isJsonSourceFile = isJsonSourceFile;
function isEnumConst(node) {
- return !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */);
+ return !!(ts.getCombinedModifierFlags(node) & 2048 /* ModifierFlags.Const */);
}
ts.isEnumConst = isEnumConst;
function isDeclarationReadonly(declaration) {
- return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent));
+ return !!(ts.getCombinedModifierFlags(declaration) & 64 /* ModifierFlags.Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent));
}
ts.isDeclarationReadonly = isDeclarationReadonly;
function isVarConst(node) {
- return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */);
+ return !!(ts.getCombinedNodeFlags(node) & 2 /* NodeFlags.Const */);
}
ts.isVarConst = isVarConst;
function isLet(node) {
- return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */);
+ return !!(ts.getCombinedNodeFlags(node) & 1 /* NodeFlags.Let */);
}
ts.isLet = isLet;
function isSuperCall(n) {
- return n.kind === 207 /* CallExpression */ && n.expression.kind === 106 /* SuperKeyword */;
+ return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 106 /* SyntaxKind.SuperKeyword */;
}
ts.isSuperCall = isSuperCall;
function isImportCall(n) {
- return n.kind === 207 /* CallExpression */ && n.expression.kind === 100 /* ImportKeyword */;
+ return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 100 /* SyntaxKind.ImportKeyword */;
}
ts.isImportCall = isImportCall;
function isImportMeta(n) {
return ts.isMetaProperty(n)
- && n.keywordToken === 100 /* ImportKeyword */
+ && n.keywordToken === 100 /* SyntaxKind.ImportKeyword */
&& n.name.escapedText === "meta";
}
ts.isImportMeta = isImportMeta;
@@ -15263,12 +15463,12 @@ var ts;
}
ts.isLiteralImportTypeNode = isLiteralImportTypeNode;
function isPrologueDirective(node) {
- return node.kind === 237 /* ExpressionStatement */
- && node.expression.kind === 10 /* StringLiteral */;
+ return node.kind === 238 /* SyntaxKind.ExpressionStatement */
+ && node.expression.kind === 10 /* SyntaxKind.StringLiteral */;
}
ts.isPrologueDirective = isPrologueDirective;
function isCustomPrologue(node) {
- return !!(getEmitFlags(node) & 1048576 /* CustomPrologue */);
+ return !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */);
}
ts.isCustomPrologue = isCustomPrologue;
function isHoistedFunction(node) {
@@ -15287,24 +15487,24 @@ var ts;
}
ts.isHoistedVariableStatement = isHoistedVariableStatement;
function getLeadingCommentRangesOfNode(node, sourceFileOfNode) {
- return node.kind !== 11 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined;
+ return node.kind !== 11 /* SyntaxKind.JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined;
}
ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode;
function getJSDocCommentRanges(node, text) {
- var commentRanges = (node.kind === 163 /* Parameter */ ||
- node.kind === 162 /* TypeParameter */ ||
- node.kind === 212 /* FunctionExpression */ ||
- node.kind === 213 /* ArrowFunction */ ||
- node.kind === 211 /* ParenthesizedExpression */ ||
- node.kind === 253 /* VariableDeclaration */ ||
- node.kind === 274 /* ExportSpecifier */) ?
+ var commentRanges = (node.kind === 164 /* SyntaxKind.Parameter */ ||
+ node.kind === 163 /* SyntaxKind.TypeParameter */ ||
+ node.kind === 213 /* SyntaxKind.FunctionExpression */ ||
+ node.kind === 214 /* SyntaxKind.ArrowFunction */ ||
+ node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ ||
+ node.kind === 254 /* SyntaxKind.VariableDeclaration */ ||
+ node.kind === 275 /* SyntaxKind.ExportSpecifier */) ?
ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) :
ts.getLeadingCommentRanges(text, node.pos);
// True if the comment starts with '/**' but not if it is '/**/'
return ts.filter(commentRanges, function (comment) {
- return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ &&
- text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ &&
- text.charCodeAt(comment.pos + 3) !== 47 /* slash */;
+ return text.charCodeAt(comment.pos + 1) === 42 /* CharacterCodes.asterisk */ &&
+ text.charCodeAt(comment.pos + 2) === 42 /* CharacterCodes.asterisk */ &&
+ text.charCodeAt(comment.pos + 3) !== 47 /* CharacterCodes.slash */;
});
}
ts.getJSDocCommentRanges = getJSDocCommentRanges;
@@ -15313,48 +15513,48 @@ var ts;
ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*<amd-dependency\s+path\s*=\s*)(('[^']*')|("[^"]*")).*?\/>/;
var defaultLibReferenceRegEx = /^(\/\/\/\s*<reference\s+no-default-lib\s*=\s*)(('[^']*')|("[^"]*"))\s*\/>/;
function isPartOfTypeNode(node) {
- if (176 /* FirstTypeNode */ <= node.kind && node.kind <= 199 /* LastTypeNode */) {
+ if (177 /* SyntaxKind.FirstTypeNode */ <= node.kind && node.kind <= 200 /* SyntaxKind.LastTypeNode */) {
return true;
}
switch (node.kind) {
- case 130 /* AnyKeyword */:
- case 154 /* UnknownKeyword */:
- case 146 /* NumberKeyword */:
- case 157 /* BigIntKeyword */:
- case 149 /* StringKeyword */:
- case 133 /* BooleanKeyword */:
- case 150 /* SymbolKeyword */:
- case 147 /* ObjectKeyword */:
- case 152 /* UndefinedKeyword */:
- case 143 /* NeverKeyword */:
+ case 130 /* SyntaxKind.AnyKeyword */:
+ case 155 /* SyntaxKind.UnknownKeyword */:
+ case 147 /* SyntaxKind.NumberKeyword */:
+ case 158 /* SyntaxKind.BigIntKeyword */:
+ case 150 /* SyntaxKind.StringKeyword */:
+ case 133 /* SyntaxKind.BooleanKeyword */:
+ case 151 /* SyntaxKind.SymbolKeyword */:
+ case 148 /* SyntaxKind.ObjectKeyword */:
+ case 153 /* SyntaxKind.UndefinedKeyword */:
+ case 143 /* SyntaxKind.NeverKeyword */:
return true;
- case 114 /* VoidKeyword */:
- return node.parent.kind !== 216 /* VoidExpression */;
- case 227 /* ExpressionWithTypeArguments */:
- return !isExpressionWithTypeArgumentsInClassExtendsClause(node);
- case 162 /* TypeParameter */:
- return node.parent.kind === 194 /* MappedType */ || node.parent.kind === 189 /* InferType */;
+ case 114 /* SyntaxKind.VoidKeyword */:
+ return node.parent.kind !== 217 /* SyntaxKind.VoidExpression */;
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
+ return ts.isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
+ case 163 /* SyntaxKind.TypeParameter */:
+ return node.parent.kind === 195 /* SyntaxKind.MappedType */ || node.parent.kind === 190 /* SyntaxKind.InferType */;
// Identifiers and qualified names may be type nodes, depending on their context. Climb
// above them to find the lowest container
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
// If the identifier is the RHS of a qualified name, then it's a type iff its parent is.
- if (node.parent.kind === 160 /* QualifiedName */ && node.parent.right === node) {
+ if (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) {
node = node.parent;
}
- else if (node.parent.kind === 205 /* PropertyAccessExpression */ && node.parent.name === node) {
+ else if (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node) {
node = node.parent;
}
// At this point, node is either a qualified name or an identifier
- ts.Debug.assert(node.kind === 79 /* Identifier */ || node.kind === 160 /* QualifiedName */ || node.kind === 205 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'.");
+ ts.Debug.assert(node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'.");
// falls through
- case 160 /* QualifiedName */:
- case 205 /* PropertyAccessExpression */:
- case 108 /* ThisKeyword */: {
+ case 161 /* SyntaxKind.QualifiedName */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 108 /* SyntaxKind.ThisKeyword */: {
var parent = node.parent;
- if (parent.kind === 180 /* TypeQuery */) {
+ if (parent.kind === 181 /* SyntaxKind.TypeQuery */) {
return false;
}
- if (parent.kind === 199 /* ImportType */) {
+ if (parent.kind === 200 /* SyntaxKind.ImportType */) {
return !parent.isTypeOf;
}
// Do not recursively call isPartOfTypeNode on the parent. In the example:
@@ -15363,40 +15563,40 @@ var ts;
//
// Calling isPartOfTypeNode would consider the qualified name A.B a type node.
// Only C and A.B.C are type nodes.
- if (176 /* FirstTypeNode */ <= parent.kind && parent.kind <= 199 /* LastTypeNode */) {
+ if (177 /* SyntaxKind.FirstTypeNode */ <= parent.kind && parent.kind <= 200 /* SyntaxKind.LastTypeNode */) {
return true;
}
switch (parent.kind) {
- case 227 /* ExpressionWithTypeArguments */:
- return !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
- case 162 /* TypeParameter */:
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
+ return ts.isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
+ case 163 /* SyntaxKind.TypeParameter */:
return node === parent.constraint;
- case 342 /* JSDocTemplateTag */:
+ case 344 /* SyntaxKind.JSDocTemplateTag */:
return node === parent.constraint;
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
- case 163 /* Parameter */:
- case 253 /* VariableDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 164 /* SyntaxKind.Parameter */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return node === parent.type;
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
- case 170 /* Constructor */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
return node === parent.type;
- case 173 /* CallSignature */:
- case 174 /* ConstructSignature */:
- case 175 /* IndexSignature */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 176 /* SyntaxKind.IndexSignature */:
return node === parent.type;
- case 210 /* TypeAssertionExpression */:
+ case 211 /* SyntaxKind.TypeAssertionExpression */:
return node === parent.type;
- case 207 /* CallExpression */:
- case 208 /* NewExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
return ts.contains(parent.typeArguments, node);
- case 209 /* TaggedTemplateExpression */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
// TODO (drosen): TaggedTemplateExpressions may eventually support type arguments.
return false;
}
@@ -15421,23 +15621,23 @@ var ts;
return traverse(body);
function traverse(node) {
switch (node.kind) {
- case 246 /* ReturnStatement */:
+ case 247 /* SyntaxKind.ReturnStatement */:
return visitor(node);
- case 262 /* CaseBlock */:
- case 234 /* Block */:
- case 238 /* IfStatement */:
- case 239 /* DoStatement */:
- case 240 /* WhileStatement */:
- case 241 /* ForStatement */:
- case 242 /* ForInStatement */:
- case 243 /* ForOfStatement */:
- case 247 /* WithStatement */:
- case 248 /* SwitchStatement */:
- case 288 /* CaseClause */:
- case 289 /* DefaultClause */:
- case 249 /* LabeledStatement */:
- case 251 /* TryStatement */:
- case 291 /* CatchClause */:
+ case 263 /* SyntaxKind.CaseBlock */:
+ case 235 /* SyntaxKind.Block */:
+ case 239 /* SyntaxKind.IfStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
+ case 248 /* SyntaxKind.WithStatement */:
+ case 249 /* SyntaxKind.SwitchStatement */:
+ case 289 /* SyntaxKind.CaseClause */:
+ case 290 /* SyntaxKind.DefaultClause */:
+ case 250 /* SyntaxKind.LabeledStatement */:
+ case 252 /* SyntaxKind.TryStatement */:
+ case 292 /* SyntaxKind.CatchClause */:
return ts.forEachChild(node, traverse);
}
}
@@ -15447,23 +15647,23 @@ var ts;
return traverse(body);
function traverse(node) {
switch (node.kind) {
- case 223 /* YieldExpression */:
+ case 224 /* SyntaxKind.YieldExpression */:
visitor(node);
var operand = node.expression;
if (operand) {
traverse(operand);
}
return;
- case 259 /* EnumDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 260 /* ModuleDeclaration */:
- case 258 /* TypeAliasDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
// These are not allowed inside a generator now, but eventually they may be allowed
// as local types. Regardless, skip them to avoid the work.
return;
default:
if (ts.isFunctionLike(node)) {
- if (node.name && node.name.kind === 161 /* ComputedPropertyName */) {
+ if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) {
// Note that we will not include methods/accessors of a class because they would require
// first descending into the class. This is by design.
traverse(node.name.expression);
@@ -15486,10 +15686,10 @@ var ts;
* @param node The type node.
*/
function getRestParameterElementType(node) {
- if (node && node.kind === 182 /* ArrayType */) {
+ if (node && node.kind === 183 /* SyntaxKind.ArrayType */) {
return node.elementType;
}
- else if (node && node.kind === 177 /* TypeReference */) {
+ else if (node && node.kind === 178 /* SyntaxKind.TypeReference */) {
return ts.singleOrUndefined(node.typeArguments);
}
else {
@@ -15499,12 +15699,12 @@ var ts;
ts.getRestParameterElementType = getRestParameterElementType;
function getMembersOfDeclaration(node) {
switch (node.kind) {
- case 257 /* InterfaceDeclaration */:
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- case 181 /* TypeLiteral */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 182 /* SyntaxKind.TypeLiteral */:
return node.members;
- case 204 /* ObjectLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
return node.properties;
}
}
@@ -15512,14 +15712,14 @@ var ts;
function isVariableLike(node) {
if (node) {
switch (node.kind) {
- case 202 /* BindingElement */:
- case 297 /* EnumMember */:
- case 163 /* Parameter */:
- case 294 /* PropertyAssignment */:
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
- case 295 /* ShorthandPropertyAssignment */:
- case 253 /* VariableDeclaration */:
+ case 203 /* SyntaxKind.BindingElement */:
+ case 299 /* SyntaxKind.EnumMember */:
+ case 164 /* SyntaxKind.Parameter */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return true;
}
}
@@ -15531,25 +15731,38 @@ var ts;
}
ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor;
function isVariableDeclarationInVariableStatement(node) {
- return node.parent.kind === 254 /* VariableDeclarationList */
- && node.parent.parent.kind === 236 /* VariableStatement */;
+ return node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */
+ && node.parent.parent.kind === 237 /* SyntaxKind.VariableStatement */;
}
ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement;
+ function isCommonJsExportedExpression(node) {
+ if (!isInJSFile(node))
+ return false;
+ return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* AssignmentDeclarationKind.ModuleExports */) ||
+ isCommonJsExportPropertyAssignment(node.parent);
+ }
+ ts.isCommonJsExportedExpression = isCommonJsExportedExpression;
+ function isCommonJsExportPropertyAssignment(node) {
+ if (!isInJSFile(node))
+ return false;
+ return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* AssignmentDeclarationKind.ExportsProperty */);
+ }
+ ts.isCommonJsExportPropertyAssignment = isCommonJsExportPropertyAssignment;
function isValidESSymbolDeclaration(node) {
- return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
+ return (ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
ts.isPropertyDeclaration(node) ? hasEffectiveReadonlyModifier(node) && hasStaticModifier(node) :
- ts.isPropertySignature(node) && hasEffectiveReadonlyModifier(node);
+ ts.isPropertySignature(node) && hasEffectiveReadonlyModifier(node)) || isCommonJsExportPropertyAssignment(node);
}
ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration;
function introducesArgumentsExoticObject(node) {
switch (node.kind) {
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 170 /* Constructor */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
return true;
}
return false;
@@ -15560,7 +15773,7 @@ var ts;
if (beforeUnwrapLabelCallback) {
beforeUnwrapLabelCallback(node);
}
- if (node.statement.kind !== 249 /* LabeledStatement */) {
+ if (node.statement.kind !== 250 /* SyntaxKind.LabeledStatement */) {
return node.statement;
}
node = node.statement;
@@ -15568,31 +15781,31 @@ var ts;
}
ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel;
function isFunctionBlock(node) {
- return node && node.kind === 234 /* Block */ && ts.isFunctionLike(node.parent);
+ return node && node.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(node.parent);
}
ts.isFunctionBlock = isFunctionBlock;
function isObjectLiteralMethod(node) {
- return node && node.kind === 168 /* MethodDeclaration */ && node.parent.kind === 204 /* ObjectLiteralExpression */;
+ return node && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */;
}
ts.isObjectLiteralMethod = isObjectLiteralMethod;
function isObjectLiteralOrClassExpressionMethodOrAccessor(node) {
- return (node.kind === 168 /* MethodDeclaration */ || node.kind === 171 /* GetAccessor */ || node.kind === 172 /* SetAccessor */) &&
- (node.parent.kind === 204 /* ObjectLiteralExpression */ ||
- node.parent.kind === 225 /* ClassExpression */);
+ return (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) &&
+ (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ ||
+ node.parent.kind === 226 /* SyntaxKind.ClassExpression */);
}
ts.isObjectLiteralOrClassExpressionMethodOrAccessor = isObjectLiteralOrClassExpressionMethodOrAccessor;
function isIdentifierTypePredicate(predicate) {
- return predicate && predicate.kind === 1 /* Identifier */;
+ return predicate && predicate.kind === 1 /* TypePredicateKind.Identifier */;
}
ts.isIdentifierTypePredicate = isIdentifierTypePredicate;
function isThisTypePredicate(predicate) {
- return predicate && predicate.kind === 0 /* This */;
+ return predicate && predicate.kind === 0 /* TypePredicateKind.This */;
}
ts.isThisTypePredicate = isThisTypePredicate;
function getPropertyAssignment(objectLiteral, key, key2) {
return objectLiteral.properties.filter(function (property) {
- if (property.kind === 294 /* PropertyAssignment */) {
- var propName = getTextOfPropertyName(property.name);
+ if (property.kind === 296 /* SyntaxKind.PropertyAssignment */) {
+ var propName = tryGetTextOfPropertyName(property.name);
return key === propName || (!!key2 && key2 === propName);
}
return false;
@@ -15653,14 +15866,14 @@ var ts;
}
ts.getContainingFunctionOrClassStaticBlock = getContainingFunctionOrClassStaticBlock;
function getThisContainer(node, includeArrowFunctions) {
- ts.Debug.assert(node.kind !== 303 /* SourceFile */);
+ ts.Debug.assert(node.kind !== 305 /* SyntaxKind.SourceFile */);
while (true) {
node = node.parent;
if (!node) {
return ts.Debug.fail(); // If we never pass in a SourceFile, this should be unreachable, since we'll stop when we reach that.
}
switch (node.kind) {
- case 161 /* ComputedPropertyName */:
+ case 162 /* SyntaxKind.ComputedPropertyName */:
// If the grandparent node is an object literal (as opposed to a class),
// then the computed property is not a 'this' container.
// A computed property name in a class needs to be a this container
@@ -15675,9 +15888,9 @@ var ts;
// the *body* of the container.
node = node.parent;
break;
- case 164 /* Decorator */:
+ case 165 /* SyntaxKind.Decorator */:
// Decorators are always applied outside of the body of a class or method.
- if (node.parent.kind === 163 /* Parameter */ && ts.isClassElement(node.parent.parent)) {
+ if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) {
// If the decorator's parent is a Parameter, we resolve the this container from
// the grandparent class declaration.
node = node.parent.parent;
@@ -15688,27 +15901,27 @@ var ts;
node = node.parent;
}
break;
- case 213 /* ArrowFunction */:
+ case 214 /* SyntaxKind.ArrowFunction */:
if (!includeArrowFunctions) {
continue;
}
// falls through
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 260 /* ModuleDeclaration */:
- case 169 /* ClassStaticBlockDeclaration */:
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 170 /* Constructor */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 173 /* CallSignature */:
- case 174 /* ConstructSignature */:
- case 175 /* IndexSignature */:
- case 259 /* EnumDeclaration */:
- case 303 /* SourceFile */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 170 /* SyntaxKind.ClassStaticBlockDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 176 /* SyntaxKind.IndexSignature */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 305 /* SyntaxKind.SourceFile */:
return node;
}
}
@@ -15721,17 +15934,17 @@ var ts;
switch (node.kind) {
// Arrow functions use the same scope, but may do so in a "delayed" manner
// For example, `const getThis = () => this` may be before a super() call in a derived constructor
- case 213 /* ArrowFunction */:
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 166 /* PropertyDeclaration */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
return true;
- case 234 /* Block */:
+ case 235 /* SyntaxKind.Block */:
switch (node.parent.kind) {
- case 170 /* Constructor */:
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
// Object properties can have computed names; only method-like bodies start a new scope
return true;
default:
@@ -15755,9 +15968,9 @@ var ts;
var container = getThisContainer(node, /*includeArrowFunctions*/ false);
if (container) {
switch (container.kind) {
- case 170 /* Constructor */:
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
return container;
}
}
@@ -15779,28 +15992,28 @@ var ts;
return node;
}
switch (node.kind) {
- case 161 /* ComputedPropertyName */:
+ case 162 /* SyntaxKind.ComputedPropertyName */:
node = node.parent;
break;
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
if (!stopOnFunctions) {
continue;
}
// falls through
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 170 /* Constructor */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 169 /* ClassStaticBlockDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 170 /* SyntaxKind.ClassStaticBlockDeclaration */:
return node;
- case 164 /* Decorator */:
+ case 165 /* SyntaxKind.Decorator */:
// Decorators are always applied outside of the body of a class or method.
- if (node.parent.kind === 163 /* Parameter */ && ts.isClassElement(node.parent.parent)) {
+ if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) {
// If the decorator's parent is a Parameter, we resolve the this container from
// the grandparent class declaration.
node = node.parent.parent;
@@ -15816,21 +16029,21 @@ var ts;
}
ts.getSuperContainer = getSuperContainer;
function getImmediatelyInvokedFunctionExpression(func) {
- if (func.kind === 212 /* FunctionExpression */ || func.kind === 213 /* ArrowFunction */) {
+ if (func.kind === 213 /* SyntaxKind.FunctionExpression */ || func.kind === 214 /* SyntaxKind.ArrowFunction */) {
var prev = func;
var parent = func.parent;
- while (parent.kind === 211 /* ParenthesizedExpression */) {
+ while (parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) {
prev = parent;
parent = parent.parent;
}
- if (parent.kind === 207 /* CallExpression */ && parent.expression === prev) {
+ if (parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === prev) {
return parent;
}
}
}
ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression;
function isSuperOrSuperProperty(node) {
- return node.kind === 106 /* SuperKeyword */
+ return node.kind === 106 /* SyntaxKind.SuperKeyword */
|| isSuperProperty(node);
}
ts.isSuperOrSuperProperty = isSuperOrSuperProperty;
@@ -15839,8 +16052,8 @@ var ts;
*/
function isSuperProperty(node) {
var kind = node.kind;
- return (kind === 205 /* PropertyAccessExpression */ || kind === 206 /* ElementAccessExpression */)
- && node.expression.kind === 106 /* SuperKeyword */;
+ return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */)
+ && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */;
}
ts.isSuperProperty = isSuperProperty;
/**
@@ -15848,34 +16061,34 @@ var ts;
*/
function isThisProperty(node) {
var kind = node.kind;
- return (kind === 205 /* PropertyAccessExpression */ || kind === 206 /* ElementAccessExpression */)
- && node.expression.kind === 108 /* ThisKeyword */;
+ return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */)
+ && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */;
}
ts.isThisProperty = isThisProperty;
function isThisInitializedDeclaration(node) {
var _a;
- return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* ThisKeyword */;
+ return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* SyntaxKind.ThisKeyword */;
}
ts.isThisInitializedDeclaration = isThisInitializedDeclaration;
function isThisInitializedObjectBindingExpression(node) {
return !!node
&& (ts.isShorthandPropertyAssignment(node) || ts.isPropertyAssignment(node))
&& ts.isBinaryExpression(node.parent.parent)
- && node.parent.parent.operatorToken.kind === 63 /* EqualsToken */
- && node.parent.parent.right.kind === 108 /* ThisKeyword */;
+ && node.parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */
+ && node.parent.parent.right.kind === 108 /* SyntaxKind.ThisKeyword */;
}
ts.isThisInitializedObjectBindingExpression = isThisInitializedObjectBindingExpression;
function getEntityNameFromTypeNode(node) {
switch (node.kind) {
- case 177 /* TypeReference */:
+ case 178 /* SyntaxKind.TypeReference */:
return node.typeName;
- case 227 /* ExpressionWithTypeArguments */:
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
return isEntityNameExpression(node.expression)
? node.expression
: undefined;
// TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s.
- case 79 /* Identifier */:
- case 160 /* QualifiedName */:
+ case 79 /* SyntaxKind.Identifier */:
+ case 161 /* SyntaxKind.QualifiedName */:
return node;
}
return undefined;
@@ -15883,10 +16096,10 @@ var ts;
ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode;
function getInvokedExpression(node) {
switch (node.kind) {
- case 209 /* TaggedTemplateExpression */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
return node.tag;
- case 279 /* JsxOpeningElement */:
- case 278 /* JsxSelfClosingElement */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
return node.tagName;
default:
return node.expression;
@@ -15899,25 +16112,25 @@ var ts;
return false;
}
switch (node.kind) {
- case 256 /* ClassDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
// classes are valid targets
return true;
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
// property declarations are valid if their parent is a class declaration.
- return parent.kind === 256 /* ClassDeclaration */;
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 168 /* MethodDeclaration */:
+ return parent.kind === 257 /* SyntaxKind.ClassDeclaration */;
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
// if this method has a body and its parent is a class declaration, this is a valid target.
return node.body !== undefined
- && parent.kind === 256 /* ClassDeclaration */;
- case 163 /* Parameter */:
+ && parent.kind === 257 /* SyntaxKind.ClassDeclaration */;
+ case 164 /* SyntaxKind.Parameter */:
// if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target;
return parent.body !== undefined
- && (parent.kind === 170 /* Constructor */
- || parent.kind === 168 /* MethodDeclaration */
- || parent.kind === 172 /* SetAccessor */)
- && grandparent.kind === 256 /* ClassDeclaration */;
+ && (parent.kind === 171 /* SyntaxKind.Constructor */
+ || parent.kind === 169 /* SyntaxKind.MethodDeclaration */
+ || parent.kind === 173 /* SyntaxKind.SetAccessor */)
+ && grandparent.kind === 257 /* SyntaxKind.ClassDeclaration */;
}
return false;
}
@@ -15933,11 +16146,11 @@ var ts;
ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated;
function childIsDecorated(node, parent) {
switch (node.kind) {
- case 256 /* ClassDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217
- case 168 /* MethodDeclaration */:
- case 172 /* SetAccessor */:
- case 170 /* Constructor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 171 /* SyntaxKind.Constructor */:
return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217
default:
return false;
@@ -15953,9 +16166,9 @@ var ts;
ts.classOrConstructorParameterIsDecorated = classOrConstructorParameterIsDecorated;
function isJSXTagName(node) {
var parent = node.parent;
- if (parent.kind === 279 /* JsxOpeningElement */ ||
- parent.kind === 278 /* JsxSelfClosingElement */ ||
- parent.kind === 280 /* JsxClosingElement */) {
+ if (parent.kind === 280 /* SyntaxKind.JsxOpeningElement */ ||
+ parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */ ||
+ parent.kind === 281 /* SyntaxKind.JsxClosingElement */) {
return parent.tagName === node;
}
return false;
@@ -15963,64 +16176,64 @@ var ts;
ts.isJSXTagName = isJSXTagName;
function isExpressionNode(node) {
switch (node.kind) {
- case 106 /* SuperKeyword */:
- case 104 /* NullKeyword */:
- case 110 /* TrueKeyword */:
- case 95 /* FalseKeyword */:
- case 13 /* RegularExpressionLiteral */:
- case 203 /* ArrayLiteralExpression */:
- case 204 /* ObjectLiteralExpression */:
- case 205 /* PropertyAccessExpression */:
- case 206 /* ElementAccessExpression */:
- case 207 /* CallExpression */:
- case 208 /* NewExpression */:
- case 209 /* TaggedTemplateExpression */:
- case 228 /* AsExpression */:
- case 210 /* TypeAssertionExpression */:
- case 229 /* NonNullExpression */:
- case 211 /* ParenthesizedExpression */:
- case 212 /* FunctionExpression */:
- case 225 /* ClassExpression */:
- case 213 /* ArrowFunction */:
- case 216 /* VoidExpression */:
- case 214 /* DeleteExpression */:
- case 215 /* TypeOfExpression */:
- case 218 /* PrefixUnaryExpression */:
- case 219 /* PostfixUnaryExpression */:
- case 220 /* BinaryExpression */:
- case 221 /* ConditionalExpression */:
- case 224 /* SpreadElement */:
- case 222 /* TemplateExpression */:
- case 226 /* OmittedExpression */:
- case 277 /* JsxElement */:
- case 278 /* JsxSelfClosingElement */:
- case 281 /* JsxFragment */:
- case 223 /* YieldExpression */:
- case 217 /* AwaitExpression */:
- case 230 /* MetaProperty */:
+ case 106 /* SyntaxKind.SuperKeyword */:
+ case 104 /* SyntaxKind.NullKeyword */:
+ case 110 /* SyntaxKind.TrueKeyword */:
+ case 95 /* SyntaxKind.FalseKeyword */:
+ case 13 /* SyntaxKind.RegularExpressionLiteral */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
+ case 229 /* SyntaxKind.AsExpression */:
+ case 211 /* SyntaxKind.TypeAssertionExpression */:
+ case 230 /* SyntaxKind.NonNullExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 217 /* SyntaxKind.VoidExpression */:
+ case 215 /* SyntaxKind.DeleteExpression */:
+ case 216 /* SyntaxKind.TypeOfExpression */:
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
+ case 220 /* SyntaxKind.PostfixUnaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
+ case 222 /* SyntaxKind.ConditionalExpression */:
+ case 225 /* SyntaxKind.SpreadElement */:
+ case 223 /* SyntaxKind.TemplateExpression */:
+ case 227 /* SyntaxKind.OmittedExpression */:
+ case 278 /* SyntaxKind.JsxElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
+ case 282 /* SyntaxKind.JsxFragment */:
+ case 224 /* SyntaxKind.YieldExpression */:
+ case 218 /* SyntaxKind.AwaitExpression */:
+ case 231 /* SyntaxKind.MetaProperty */:
return true;
- case 160 /* QualifiedName */:
- while (node.parent.kind === 160 /* QualifiedName */) {
+ case 161 /* SyntaxKind.QualifiedName */:
+ while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) {
node = node.parent;
}
- return node.parent.kind === 180 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node);
- case 309 /* JSDocMemberName */:
+ return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node);
+ case 311 /* SyntaxKind.JSDocMemberName */:
while (ts.isJSDocMemberName(node.parent)) {
node = node.parent;
}
- return node.parent.kind === 180 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node);
- case 80 /* PrivateIdentifier */:
- return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* InKeyword */;
- case 79 /* Identifier */:
- if (node.parent.kind === 180 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) {
+ return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node);
+ case 80 /* SyntaxKind.PrivateIdentifier */:
+ return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */;
+ case 79 /* SyntaxKind.Identifier */:
+ if (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) {
return true;
}
// falls through
- case 8 /* NumericLiteral */:
- case 9 /* BigIntLiteral */:
- case 10 /* StringLiteral */:
- case 14 /* NoSubstitutionTemplateLiteral */:
- case 108 /* ThisKeyword */:
+ case 8 /* SyntaxKind.NumericLiteral */:
+ case 9 /* SyntaxKind.BigIntLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
+ case 108 /* SyntaxKind.ThisKeyword */:
return isInExpressionContext(node);
default:
return false;
@@ -16030,49 +16243,49 @@ var ts;
function isInExpressionContext(node) {
var parent = node.parent;
switch (parent.kind) {
- case 253 /* VariableDeclaration */:
- case 163 /* Parameter */:
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
- case 297 /* EnumMember */:
- case 294 /* PropertyAssignment */:
- case 202 /* BindingElement */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
+ case 164 /* SyntaxKind.Parameter */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 299 /* SyntaxKind.EnumMember */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
+ case 203 /* SyntaxKind.BindingElement */:
return parent.initializer === node;
- case 237 /* ExpressionStatement */:
- case 238 /* IfStatement */:
- case 239 /* DoStatement */:
- case 240 /* WhileStatement */:
- case 246 /* ReturnStatement */:
- case 247 /* WithStatement */:
- case 248 /* SwitchStatement */:
- case 288 /* CaseClause */:
- case 250 /* ThrowStatement */:
+ case 238 /* SyntaxKind.ExpressionStatement */:
+ case 239 /* SyntaxKind.IfStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
+ case 247 /* SyntaxKind.ReturnStatement */:
+ case 248 /* SyntaxKind.WithStatement */:
+ case 249 /* SyntaxKind.SwitchStatement */:
+ case 289 /* SyntaxKind.CaseClause */:
+ case 251 /* SyntaxKind.ThrowStatement */:
return parent.expression === node;
- case 241 /* ForStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
var forStatement = parent;
- return (forStatement.initializer === node && forStatement.initializer.kind !== 254 /* VariableDeclarationList */) ||
+ return (forStatement.initializer === node && forStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) ||
forStatement.condition === node ||
forStatement.incrementor === node;
- case 242 /* ForInStatement */:
- case 243 /* ForOfStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
var forInStatement = parent;
- return (forInStatement.initializer === node && forInStatement.initializer.kind !== 254 /* VariableDeclarationList */) ||
+ return (forInStatement.initializer === node && forInStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) ||
forInStatement.expression === node;
- case 210 /* TypeAssertionExpression */:
- case 228 /* AsExpression */:
+ case 211 /* SyntaxKind.TypeAssertionExpression */:
+ case 229 /* SyntaxKind.AsExpression */:
return node === parent.expression;
- case 232 /* TemplateSpan */:
+ case 233 /* SyntaxKind.TemplateSpan */:
return node === parent.expression;
- case 161 /* ComputedPropertyName */:
+ case 162 /* SyntaxKind.ComputedPropertyName */:
return node === parent.expression;
- case 164 /* Decorator */:
- case 287 /* JsxExpression */:
- case 286 /* JsxSpreadAttribute */:
- case 296 /* SpreadAssignment */:
+ case 165 /* SyntaxKind.Decorator */:
+ case 288 /* SyntaxKind.JsxExpression */:
+ case 287 /* SyntaxKind.JsxSpreadAttribute */:
+ case 298 /* SyntaxKind.SpreadAssignment */:
return true;
- case 227 /* ExpressionWithTypeArguments */:
- return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent);
- case 295 /* ShorthandPropertyAssignment */:
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
+ return parent.expression === node && !isPartOfTypeNode(parent);
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
return parent.objectAssignmentInitializer === node;
default:
return isExpressionNode(parent);
@@ -16080,10 +16293,10 @@ var ts;
}
ts.isInExpressionContext = isInExpressionContext;
function isPartOfTypeQuery(node) {
- while (node.kind === 160 /* QualifiedName */ || node.kind === 79 /* Identifier */) {
+ while (node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 79 /* SyntaxKind.Identifier */) {
node = node.parent;
}
- return node.kind === 180 /* TypeQuery */;
+ return node.kind === 181 /* SyntaxKind.TypeQuery */;
}
ts.isPartOfTypeQuery = isPartOfTypeQuery;
function isNamespaceReexportDeclaration(node) {
@@ -16091,7 +16304,7 @@ var ts;
}
ts.isNamespaceReexportDeclaration = isNamespaceReexportDeclaration;
function isExternalModuleImportEqualsDeclaration(node) {
- return node.kind === 264 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 276 /* ExternalModuleReference */;
+ return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */;
}
ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration;
function getExternalModuleImportEqualsDeclarationExpression(node) {
@@ -16104,7 +16317,7 @@ var ts;
}
ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument;
function isInternalModuleImportEqualsDeclaration(node) {
- return node.kind === 264 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 276 /* ExternalModuleReference */;
+ return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */;
}
ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration;
function isSourceFileJS(file) {
@@ -16116,11 +16329,11 @@ var ts;
}
ts.isSourceFileNotJS = isSourceFileNotJS;
function isInJSFile(node) {
- return !!node && !!(node.flags & 131072 /* JavaScriptFile */);
+ return !!node && !!(node.flags & 262144 /* NodeFlags.JavaScriptFile */);
}
ts.isInJSFile = isInJSFile;
function isInJsonFile(node) {
- return !!node && !!(node.flags & 33554432 /* JsonFile */);
+ return !!node && !!(node.flags & 67108864 /* NodeFlags.JsonFile */);
}
ts.isInJsonFile = isInJsonFile;
function isSourceFileNotJson(file) {
@@ -16128,7 +16341,7 @@ var ts;
}
ts.isSourceFileNotJson = isSourceFileNotJson;
function isInJSDoc(node) {
- return !!node && !!(node.flags & 4194304 /* JSDoc */);
+ return !!node && !!(node.flags & 8388608 /* NodeFlags.JSDoc */);
}
ts.isInJSDoc = isInJSDoc;
function isJSDocIndexSignature(node) {
@@ -16136,15 +16349,15 @@ var ts;
ts.isIdentifier(node.typeName) &&
node.typeName.escapedText === "Object" &&
node.typeArguments && node.typeArguments.length === 2 &&
- (node.typeArguments[0].kind === 149 /* StringKeyword */ || node.typeArguments[0].kind === 146 /* NumberKeyword */);
+ (node.typeArguments[0].kind === 150 /* SyntaxKind.StringKeyword */ || node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */);
}
ts.isJSDocIndexSignature = isJSDocIndexSignature;
function isRequireCall(callExpression, requireStringLiteralLikeArgument) {
- if (callExpression.kind !== 207 /* CallExpression */) {
+ if (callExpression.kind !== 208 /* SyntaxKind.CallExpression */) {
return false;
}
var _a = callExpression, expression = _a.expression, args = _a.arguments;
- if (expression.kind !== 79 /* Identifier */ || expression.escapedText !== "require") {
+ if (expression.kind !== 79 /* SyntaxKind.Identifier */ || expression.escapedText !== "require") {
return false;
}
if (args.length !== 1) {
@@ -16170,7 +16383,7 @@ var ts;
}
ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
- if (node.kind === 202 /* BindingElement */) {
+ if (node.kind === 203 /* SyntaxKind.BindingElement */) {
node = node.parent.parent;
}
return ts.isVariableDeclaration(node) &&
@@ -16184,11 +16397,11 @@ var ts;
}
ts.isRequireVariableStatement = isRequireVariableStatement;
function isSingleOrDoubleQuote(charCode) {
- return charCode === 39 /* singleQuote */ || charCode === 34 /* doubleQuote */;
+ return charCode === 39 /* CharacterCodes.singleQuote */ || charCode === 34 /* CharacterCodes.doubleQuote */;
}
ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote;
function isStringDoubleQuoted(str, sourceFile) {
- return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* doubleQuote */;
+ return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */;
}
ts.isStringDoubleQuoted = isStringDoubleQuoted;
function isAssignmentDeclaration(decl) {
@@ -16199,7 +16412,7 @@ var ts;
function getEffectiveInitializer(node) {
if (isInJSFile(node) && node.initializer &&
ts.isBinaryExpression(node.initializer) &&
- (node.initializer.operatorToken.kind === 56 /* BarBarToken */ || node.initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) &&
+ (node.initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) &&
node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) {
return node.initializer.right;
}
@@ -16226,7 +16439,7 @@ var ts;
* We treat the right hand side of assignments with container-like initializers as declarations.
*/
function getAssignedExpandoInitializer(node) {
- if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */) {
+ if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) {
var isPrototypeAssignment = isPrototypeAccess(node.parent.left);
return getExpandoInitializer(node.parent.right, isPrototypeAssignment) ||
getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment);
@@ -16252,11 +16465,11 @@ var ts;
function getExpandoInitializer(initializer, isPrototypeAssignment) {
if (ts.isCallExpression(initializer)) {
var e = skipParentheses(initializer.expression);
- return e.kind === 212 /* FunctionExpression */ || e.kind === 213 /* ArrowFunction */ ? initializer : undefined;
+ return e.kind === 213 /* SyntaxKind.FunctionExpression */ || e.kind === 214 /* SyntaxKind.ArrowFunction */ ? initializer : undefined;
}
- if (initializer.kind === 212 /* FunctionExpression */ ||
- initializer.kind === 225 /* ClassExpression */ ||
- initializer.kind === 213 /* ArrowFunction */) {
+ if (initializer.kind === 213 /* SyntaxKind.FunctionExpression */ ||
+ initializer.kind === 226 /* SyntaxKind.ClassExpression */ ||
+ initializer.kind === 214 /* SyntaxKind.ArrowFunction */) {
return initializer;
}
if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) {
@@ -16274,7 +16487,7 @@ var ts;
*/
function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) {
var e = ts.isBinaryExpression(initializer)
- && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */)
+ && (initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */)
&& getExpandoInitializer(initializer.right, isPrototypeAssignment);
if (e && isSameEntityName(name, initializer.left)) {
return e;
@@ -16282,7 +16495,7 @@ var ts;
}
function isDefaultedExpandoInitializer(node) {
var name = ts.isVariableDeclaration(node.parent) ? node.parent.name :
- ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ ? node.parent.left :
+ ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? node.parent.left :
undefined;
return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left);
}
@@ -16290,8 +16503,8 @@ var ts;
/** Given an expando initializer, return its declaration name, or the left-hand side of the assignment if it's part of an assignment declaration. */
function getNameOfExpando(node) {
if (ts.isBinaryExpression(node.parent)) {
- var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent;
- if (parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(parent.left)) {
+ var parent = ((node.parent.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent;
+ if (parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isIdentifier(parent.left)) {
return parent.left;
}
}
@@ -16313,17 +16526,13 @@ var ts;
if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer);
}
- if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) &&
- (initializer.expression.kind === 108 /* ThisKeyword */ ||
+ if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) &&
+ (initializer.expression.kind === 108 /* SyntaxKind.ThisKeyword */ ||
ts.isIdentifier(initializer.expression) &&
(initializer.expression.escapedText === "window" ||
initializer.expression.escapedText === "self" ||
initializer.expression.escapedText === "global"))) {
- var nameOrArgument = getNameOrArgument(initializer);
- if (ts.isPrivateIdentifier(nameOrArgument)) {
- ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access.");
- }
- return isSameEntityName(name, nameOrArgument);
+ return isSameEntityName(name, getNameOrArgument(initializer));
}
if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) {
return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer)
@@ -16357,7 +16566,7 @@ var ts;
/// assignments we treat as special in the binder
function getAssignmentDeclarationKind(expr) {
var special = getAssignmentDeclarationKindWorker(expr);
- return special === 5 /* Property */ || isInJSFile(expr) ? special : 0 /* None */;
+ return special === 5 /* AssignmentDeclarationKind.Property */ || isInJSFile(expr) ? special : 0 /* AssignmentDeclarationKind.None */;
}
ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind;
function isBindableObjectDefinePropertyCall(expr) {
@@ -16382,14 +16591,14 @@ var ts;
ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess;
/** Any series of property and element accesses. */
function isBindableStaticAccessExpression(node, excludeThisKeyword) {
- return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true))
+ return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true))
|| isBindableStaticElementAccessExpression(node, excludeThisKeyword);
}
ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression;
/** Any series of property and element accesses, ending in a literal element access */
function isBindableStaticElementAccessExpression(node, excludeThisKeyword) {
return isLiteralLikeElementAccess(node)
- && ((!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */) ||
+ && ((!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) ||
isEntityNameExpression(node.expression) ||
isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true));
}
@@ -16408,23 +16617,23 @@ var ts;
function getAssignmentDeclarationKindWorker(expr) {
if (ts.isCallExpression(expr)) {
if (!isBindableObjectDefinePropertyCall(expr)) {
- return 0 /* None */;
+ return 0 /* AssignmentDeclarationKind.None */;
}
var entityName = expr.arguments[0];
if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) {
- return 8 /* ObjectDefinePropertyExports */;
+ return 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */;
}
if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") {
- return 9 /* ObjectDefinePrototypeProperty */;
+ return 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */;
}
- return 7 /* ObjectDefinePropertyValue */;
+ return 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */;
}
- if (expr.operatorToken.kind !== 63 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) {
- return 0 /* None */;
+ if (expr.operatorToken.kind !== 63 /* SyntaxKind.EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) {
+ return 0 /* AssignmentDeclarationKind.None */;
}
if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) {
// F.prototype = { ... }
- return 6 /* Prototype */;
+ return 6 /* AssignmentDeclarationKind.Prototype */;
}
return getAssignmentDeclarationPropertyAccessKind(expr.left);
}
@@ -16461,17 +16670,17 @@ var ts;
}
ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName;
function getAssignmentDeclarationPropertyAccessKind(lhs) {
- if (lhs.expression.kind === 108 /* ThisKeyword */) {
- return 4 /* ThisProperty */;
+ if (lhs.expression.kind === 108 /* SyntaxKind.ThisKeyword */) {
+ return 4 /* AssignmentDeclarationKind.ThisProperty */;
}
else if (isModuleExportsAccessExpression(lhs)) {
// module.exports = expr
- return 2 /* ModuleExports */;
+ return 2 /* AssignmentDeclarationKind.ModuleExports */;
}
else if (isBindableStaticNameExpression(lhs.expression, /*excludeThisKeyword*/ true)) {
if (isPrototypeAccess(lhs.expression)) {
// F.G....prototype.x = expr
- return 3 /* PrototypeProperty */;
+ return 3 /* AssignmentDeclarationKind.PrototypeProperty */;
}
var nextToLast = lhs;
while (!ts.isIdentifier(nextToLast.expression)) {
@@ -16483,14 +16692,14 @@ var ts;
// ExportsProperty does not support binding with computed names
isBindableStaticAccessExpression(lhs)) {
// exports.name = expr OR module.exports.name = expr OR exports["name"] = expr ...
- return 1 /* ExportsProperty */;
+ return 1 /* AssignmentDeclarationKind.ExportsProperty */;
}
if (isBindableStaticNameExpression(lhs, /*excludeThisKeyword*/ true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs))) {
// F.G...x = expr
- return 5 /* Property */;
+ return 5 /* AssignmentDeclarationKind.Property */;
}
}
- return 0 /* None */;
+ return 0 /* AssignmentDeclarationKind.None */;
}
ts.getAssignmentDeclarationPropertyAccessKind = getAssignmentDeclarationPropertyAccessKind;
function getInitializerOfBinaryExpression(expr) {
@@ -16501,12 +16710,12 @@ var ts;
}
ts.getInitializerOfBinaryExpression = getInitializerOfBinaryExpression;
function isPrototypePropertyAssignment(node) {
- return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* PrototypeProperty */;
+ return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* AssignmentDeclarationKind.PrototypeProperty */;
}
ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment;
function isSpecialPropertyDeclaration(expr) {
return isInJSFile(expr) &&
- expr.parent && expr.parent.kind === 237 /* ExpressionStatement */ &&
+ expr.parent && expr.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ &&
(!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) &&
!!ts.getJSDocTypeTag(expr.parent);
}
@@ -16514,7 +16723,7 @@ var ts;
function setValueDeclaration(symbol, node) {
var valueDeclaration = symbol.valueDeclaration;
if (!valueDeclaration ||
- !(node.flags & 8388608 /* Ambient */ && !(valueDeclaration.flags & 8388608 /* Ambient */)) &&
+ !(node.flags & 16777216 /* NodeFlags.Ambient */ && !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */)) &&
(isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) ||
(valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) {
// other kinds of value declarations take precedence over modules and assignment declarations
@@ -16527,18 +16736,18 @@ var ts;
return false;
}
var decl = symbol.valueDeclaration;
- return decl.kind === 255 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer);
+ return decl.kind === 256 /* SyntaxKind.FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer);
}
ts.isFunctionSymbol = isFunctionSymbol;
function tryGetModuleSpecifierFromDeclaration(node) {
- var _a, _b, _c;
+ var _a, _b;
switch (node.kind) {
- case 253 /* VariableDeclaration */:
- return node.initializer.arguments[0].text;
- case 265 /* ImportDeclaration */:
- return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text;
- case 264 /* ImportEqualsDeclaration */:
- return (_c = ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike)) === null || _c === void 0 ? void 0 : _c.text;
+ case 254 /* SyntaxKind.VariableDeclaration */:
+ return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0];
+ case 266 /* SyntaxKind.ImportDeclaration */:
+ return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike);
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike);
default:
ts.Debug.assertNever(node);
}
@@ -16550,14 +16759,14 @@ var ts;
ts.importFromModuleSpecifier = importFromModuleSpecifier;
function tryGetImportFromModuleSpecifier(node) {
switch (node.parent.kind) {
- case 265 /* ImportDeclaration */:
- case 271 /* ExportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
return node.parent;
- case 276 /* ExternalModuleReference */:
+ case 277 /* SyntaxKind.ExternalModuleReference */:
return node.parent.parent;
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined;
- case 195 /* LiteralType */:
+ case 196 /* SyntaxKind.LiteralType */:
ts.Debug.assert(ts.isStringLiteral(node));
return ts.tryCast(node.parent.parent, ts.isImportTypeNode);
default:
@@ -16567,17 +16776,17 @@ var ts;
ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier;
function getExternalModuleName(node) {
switch (node.kind) {
- case 265 /* ImportDeclaration */:
- case 271 /* ExportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
return node.moduleSpecifier;
- case 264 /* ImportEqualsDeclaration */:
- return node.moduleReference.kind === 276 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined;
- case 199 /* ImportType */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ return node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */ ? node.moduleReference.expression : undefined;
+ case 200 /* SyntaxKind.ImportType */:
return isLiteralImportTypeNode(node) ? node.argument.literal : undefined;
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
return node.arguments[0];
- case 260 /* ModuleDeclaration */:
- return node.name.kind === 10 /* StringLiteral */ ? node.name : undefined;
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ return node.name.kind === 10 /* SyntaxKind.StringLiteral */ ? node.name : undefined;
default:
return ts.Debug.assertNever(node);
}
@@ -16585,11 +16794,11 @@ var ts;
ts.getExternalModuleName = getExternalModuleName;
function getNamespaceDeclarationNode(node) {
switch (node.kind) {
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport);
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return node;
- case 271 /* ExportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport);
default:
return ts.Debug.assertNever(node);
@@ -16597,7 +16806,7 @@ var ts;
}
ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode;
function isDefaultImport(node) {
- return node.kind === 265 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name;
+ return node.kind === 266 /* SyntaxKind.ImportDeclaration */ && !!node.importClause && !!node.importClause.name;
}
ts.isDefaultImport = isDefaultImport;
function forEachImportClauseDeclaration(node, action) {
@@ -16618,13 +16827,13 @@ var ts;
function hasQuestionToken(node) {
if (node) {
switch (node.kind) {
- case 163 /* Parameter */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 295 /* ShorthandPropertyAssignment */:
- case 294 /* PropertyAssignment */:
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
+ case 164 /* SyntaxKind.Parameter */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
return node.questionToken !== undefined;
}
}
@@ -16638,7 +16847,7 @@ var ts;
}
ts.isJSDocConstructSignature = isJSDocConstructSignature;
function isJSDocTypeAlias(node) {
- return node.kind === 343 /* JSDocTypedefTag */ || node.kind === 336 /* JSDocCallbackTag */ || node.kind === 337 /* JSDocEnumTag */;
+ return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || node.kind === 338 /* SyntaxKind.JSDocCallbackTag */ || node.kind === 339 /* SyntaxKind.JSDocEnumTag */;
}
ts.isJSDocTypeAlias = isJSDocTypeAlias;
function isTypeAlias(node) {
@@ -16648,27 +16857,27 @@ var ts;
function getSourceOfAssignment(node) {
return ts.isExpressionStatement(node) &&
ts.isBinaryExpression(node.expression) &&
- node.expression.operatorToken.kind === 63 /* EqualsToken */
+ node.expression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */
? getRightMostAssignedExpression(node.expression)
: undefined;
}
function getSourceOfDefaultedAssignment(node) {
return ts.isExpressionStatement(node) &&
ts.isBinaryExpression(node.expression) &&
- getAssignmentDeclarationKind(node.expression) !== 0 /* None */ &&
+ getAssignmentDeclarationKind(node.expression) !== 0 /* AssignmentDeclarationKind.None */ &&
ts.isBinaryExpression(node.expression.right) &&
- (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */)
+ (node.expression.right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */)
? node.expression.right.right
: undefined;
}
function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) {
switch (node.kind) {
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
var v = getSingleVariableOfVariableStatement(node);
return v && v.initializer;
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
return node.initializer;
- case 294 /* PropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
return node.initializer;
}
}
@@ -16680,7 +16889,7 @@ var ts;
function getNestedModuleDeclaration(node) {
return ts.isModuleDeclaration(node) &&
node.body &&
- node.body.kind === 260 /* ModuleDeclaration */
+ node.body.kind === 261 /* SyntaxKind.ModuleDeclaration */
? node.body
: undefined;
}
@@ -16695,11 +16904,11 @@ var ts;
if (ts.hasJSDocNodes(node)) {
result = ts.addRange(result, filterOwnedJSDocTags(hostNode, ts.last(node.jsDoc)));
}
- if (node.kind === 163 /* Parameter */) {
+ if (node.kind === 164 /* SyntaxKind.Parameter */) {
result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node));
break;
}
- if (node.kind === 162 /* TypeParameter */) {
+ if (node.kind === 163 /* SyntaxKind.TypeParameter */) {
result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node));
break;
}
@@ -16728,13 +16937,13 @@ var ts;
}
function getNextJSDocCommentLocation(node) {
var parent = node.parent;
- if (parent.kind === 294 /* PropertyAssignment */ ||
- parent.kind === 270 /* ExportAssignment */ ||
- parent.kind === 166 /* PropertyDeclaration */ ||
- parent.kind === 237 /* ExpressionStatement */ && node.kind === 205 /* PropertyAccessExpression */ ||
- parent.kind === 246 /* ReturnStatement */ ||
+ if (parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ||
+ parent.kind === 271 /* SyntaxKind.ExportAssignment */ ||
+ parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ ||
+ parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ||
+ parent.kind === 247 /* SyntaxKind.ReturnStatement */ ||
getNestedModuleDeclaration(parent) ||
- ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* EqualsToken */) {
+ ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) {
return parent;
}
// Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement.
@@ -16745,7 +16954,7 @@ var ts;
// var x = function(name) { return name.length; }
else if (parent.parent &&
(getSingleVariableOfVariableStatement(parent.parent) === node ||
- ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */)) {
+ ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) {
return parent.parent;
}
else if (parent.parent && parent.parent.parent &&
@@ -16769,7 +16978,7 @@ var ts;
if (!decl) {
return undefined;
}
- var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* Identifier */ && p.name.escapedText === name; });
+ var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* SyntaxKind.Identifier */ && p.name.escapedText === name; });
return parameter && parameter.symbol;
}
ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc;
@@ -16787,7 +16996,11 @@ var ts;
ts.getEffectiveContainerForJSDocTemplateTag = getEffectiveContainerForJSDocTemplateTag;
function getHostSignatureFromJSDoc(node) {
var host = getEffectiveJSDocHost(node);
- return host && ts.isFunctionLike(host) ? host : undefined;
+ if (host) {
+ return ts.isPropertySignature(host) && host.type && ts.isFunctionLike(host.type) ? host.type :
+ ts.isFunctionLike(host) ? host : undefined;
+ }
+ return undefined;
}
ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
function getEffectiveJSDocHost(node) {
@@ -16831,7 +17044,7 @@ var ts;
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 === 316 /* JSDocVariadicType */;
+ return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* SyntaxKind.JSDocVariadicType */;
}
ts.isRestParameter = isRestParameter;
function hasTypeArguments(node) {
@@ -16848,41 +17061,41 @@ var ts;
var parent = node.parent;
while (true) {
switch (parent.kind) {
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
var binaryOperator = parent.operatorToken.kind;
return isAssignmentOperator(binaryOperator) && parent.left === node ?
- binaryOperator === 63 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ :
- 0 /* None */;
- case 218 /* PrefixUnaryExpression */:
- case 219 /* PostfixUnaryExpression */:
+ binaryOperator === 63 /* SyntaxKind.EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* AssignmentKind.Definite */ : 2 /* AssignmentKind.Compound */ :
+ 0 /* AssignmentKind.None */;
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
+ case 220 /* SyntaxKind.PostfixUnaryExpression */:
var unaryOperator = parent.operator;
- return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */;
- case 242 /* ForInStatement */:
- case 243 /* ForOfStatement */:
- return parent.initializer === node ? 1 /* Definite */ : 0 /* None */;
- case 211 /* ParenthesizedExpression */:
- case 203 /* ArrayLiteralExpression */:
- case 224 /* SpreadElement */:
- case 229 /* NonNullExpression */:
+ return unaryOperator === 45 /* SyntaxKind.PlusPlusToken */ || unaryOperator === 46 /* SyntaxKind.MinusMinusToken */ ? 2 /* AssignmentKind.Compound */ : 0 /* AssignmentKind.None */;
+ case 243 /* SyntaxKind.ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
+ return parent.initializer === node ? 1 /* AssignmentKind.Definite */ : 0 /* AssignmentKind.None */;
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
+ case 225 /* SyntaxKind.SpreadElement */:
+ case 230 /* SyntaxKind.NonNullExpression */:
node = parent;
break;
- case 296 /* SpreadAssignment */:
+ case 298 /* SyntaxKind.SpreadAssignment */:
node = parent.parent;
break;
- case 295 /* ShorthandPropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
if (parent.name !== node) {
- return 0 /* None */;
+ return 0 /* AssignmentKind.None */;
}
node = parent.parent;
break;
- case 294 /* PropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
if (parent.name === node) {
- return 0 /* None */;
+ return 0 /* AssignmentKind.None */;
}
node = parent.parent;
break;
default:
- return 0 /* None */;
+ return 0 /* AssignmentKind.None */;
}
parent = node.parent;
}
@@ -16893,7 +17106,7 @@ var ts;
// an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ a }] = xxx'.
// (Note that `p` is not a target in the above examples, only `a`.)
function isAssignmentTarget(node) {
- return getAssignmentTargetKind(node) !== 0 /* None */;
+ return getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */;
}
ts.isAssignmentTarget = isAssignmentTarget;
/**
@@ -16902,22 +17115,22 @@ var ts;
*/
function isNodeWithPossibleHoistedDeclaration(node) {
switch (node.kind) {
- case 234 /* Block */:
- case 236 /* VariableStatement */:
- case 247 /* WithStatement */:
- case 238 /* IfStatement */:
- case 248 /* SwitchStatement */:
- case 262 /* CaseBlock */:
- case 288 /* CaseClause */:
- case 289 /* DefaultClause */:
- case 249 /* LabeledStatement */:
- case 241 /* ForStatement */:
- case 242 /* ForInStatement */:
- case 243 /* ForOfStatement */:
- case 239 /* DoStatement */:
- case 240 /* WhileStatement */:
- case 251 /* TryStatement */:
- case 291 /* CatchClause */:
+ case 235 /* SyntaxKind.Block */:
+ case 237 /* SyntaxKind.VariableStatement */:
+ case 248 /* SyntaxKind.WithStatement */:
+ case 239 /* SyntaxKind.IfStatement */:
+ case 249 /* SyntaxKind.SwitchStatement */:
+ case 263 /* SyntaxKind.CaseBlock */:
+ case 289 /* SyntaxKind.CaseClause */:
+ case 290 /* SyntaxKind.DefaultClause */:
+ case 250 /* SyntaxKind.LabeledStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
+ case 252 /* SyntaxKind.TryStatement */:
+ case 292 /* SyntaxKind.CatchClause */:
return true;
}
return false;
@@ -16934,11 +17147,11 @@ var ts;
return node;
}
function walkUpParenthesizedTypes(node) {
- return walkUp(node, 190 /* ParenthesizedType */);
+ return walkUp(node, 191 /* SyntaxKind.ParenthesizedType */);
}
ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes;
function walkUpParenthesizedExpressions(node) {
- return walkUp(node, 211 /* ParenthesizedExpression */);
+ return walkUp(node, 212 /* SyntaxKind.ParenthesizedExpression */);
}
ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions;
/**
@@ -16948,7 +17161,7 @@ var ts;
*/
function walkUpParenthesizedTypesAndGetParentAndChild(node) {
var child;
- while (node && node.kind === 190 /* ParenthesizedType */) {
+ while (node && node.kind === 191 /* SyntaxKind.ParenthesizedType */) {
child = node;
node = node.parent;
}
@@ -16957,18 +17170,18 @@ var ts;
ts.walkUpParenthesizedTypesAndGetParentAndChild = walkUpParenthesizedTypesAndGetParentAndChild;
function skipParentheses(node, excludeJSDocTypeAssertions) {
var flags = excludeJSDocTypeAssertions ?
- 1 /* Parentheses */ | 16 /* ExcludeJSDocTypeAssertion */ :
- 1 /* Parentheses */;
+ 1 /* OuterExpressionKinds.Parentheses */ | 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ :
+ 1 /* OuterExpressionKinds.Parentheses */;
return ts.skipOuterExpressions(node, flags);
}
ts.skipParentheses = skipParentheses;
// a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped
function isDeleteTarget(node) {
- if (node.kind !== 205 /* PropertyAccessExpression */ && node.kind !== 206 /* ElementAccessExpression */) {
+ if (node.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ && node.kind !== 207 /* SyntaxKind.ElementAccessExpression */) {
return false;
}
node = walkUpParenthesizedExpressions(node.parent);
- return node && node.kind === 214 /* DeleteExpression */;
+ return node && node.kind === 215 /* SyntaxKind.DeleteExpression */;
}
ts.isDeleteTarget = isDeleteTarget;
function isNodeDescendantOf(node, ancestor) {
@@ -16989,13 +17202,13 @@ var ts;
function getDeclarationFromName(name) {
var parent = name.parent;
switch (name.kind) {
- case 10 /* StringLiteral */:
- case 14 /* NoSubstitutionTemplateLiteral */:
- case 8 /* NumericLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
if (ts.isComputedPropertyName(parent))
return parent.parent;
// falls through
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
if (ts.isDeclaration(parent)) {
return parent.name === name ? parent : undefined;
}
@@ -17006,13 +17219,13 @@ var ts;
else {
var binExp = parent.parent;
return ts.isBinaryExpression(binExp) &&
- getAssignmentDeclarationKind(binExp) !== 0 /* None */ &&
+ getAssignmentDeclarationKind(binExp) !== 0 /* AssignmentDeclarationKind.None */ &&
(binExp.left.symbol || binExp.symbol) &&
ts.getNameOfDeclaration(binExp) === name
? binExp
: undefined;
}
- case 80 /* PrivateIdentifier */:
+ case 80 /* SyntaxKind.PrivateIdentifier */:
return ts.isDeclaration(parent) && parent.name === name ? parent : undefined;
default:
return undefined;
@@ -17021,7 +17234,7 @@ var ts;
ts.getDeclarationFromName = getDeclarationFromName;
function isLiteralComputedPropertyDeclarationName(node) {
return isStringOrNumericLiteralLike(node) &&
- node.parent.kind === 161 /* ComputedPropertyName */ &&
+ node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */ &&
ts.isDeclaration(node.parent.parent);
}
ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName;
@@ -17029,27 +17242,30 @@ var ts;
function isIdentifierName(node) {
var parent = node.parent;
switch (parent.kind) {
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 297 /* EnumMember */:
- case 294 /* PropertyAssignment */:
- case 205 /* PropertyAccessExpression */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 299 /* SyntaxKind.EnumMember */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
// Name in member declaration or property name in property access
return parent.name === node;
- case 160 /* QualifiedName */:
+ case 161 /* SyntaxKind.QualifiedName */:
// Name on right hand side of dot in a type query or type reference
return parent.right === node;
- case 202 /* BindingElement */:
- case 269 /* ImportSpecifier */:
+ case 203 /* SyntaxKind.BindingElement */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
// Property name in binding element or import specifier
return parent.propertyName === node;
- case 274 /* ExportSpecifier */:
- case 284 /* JsxAttribute */:
- // Any name in an export specifier or JSX Attribute
+ case 275 /* SyntaxKind.ExportSpecifier */:
+ case 285 /* SyntaxKind.JsxAttribute */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
+ case 281 /* SyntaxKind.JsxClosingElement */:
+ // Any name in an export specifier or JSX Attribute or Jsx Element
return true;
}
return false;
@@ -17065,36 +17281,44 @@ var ts;
// export = <EntityNameExpression>
// export default <EntityNameExpression>
// module.exports = <EntityNameExpression>
- // {<Identifier>}
- // {name: <EntityNameExpression>}
+ // module.exports.x = <EntityNameExpression>
+ // const x = require("...")
+ // const { x } = require("...")
+ // const x = require("...").y
+ // const { x } = require("...").y
function isAliasSymbolDeclaration(node) {
- return node.kind === 264 /* ImportEqualsDeclaration */ ||
- node.kind === 263 /* NamespaceExportDeclaration */ ||
- node.kind === 266 /* ImportClause */ && !!node.name ||
- node.kind === 267 /* NamespaceImport */ ||
- node.kind === 273 /* NamespaceExport */ ||
- node.kind === 269 /* ImportSpecifier */ ||
- node.kind === 274 /* ExportSpecifier */ ||
- node.kind === 270 /* ExportAssignment */ && exportAssignmentIsAlias(node) ||
- ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) ||
- ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableExpression(node.parent.right) ||
- node.kind === 295 /* ShorthandPropertyAssignment */ ||
- node.kind === 294 /* PropertyAssignment */ && isAliasableExpression(node.initializer);
+ if (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ||
+ node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ ||
+ node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name ||
+ node.kind === 268 /* SyntaxKind.NamespaceImport */ ||
+ node.kind === 274 /* SyntaxKind.NamespaceExport */ ||
+ node.kind === 270 /* SyntaxKind.ImportSpecifier */ ||
+ node.kind === 275 /* SyntaxKind.ExportSpecifier */ ||
+ node.kind === 271 /* SyntaxKind.ExportAssignment */ && exportAssignmentIsAlias(node)) {
+ return true;
+ }
+ return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && exportAssignmentIsAlias(node) ||
+ ts.isPropertyAccessExpression(node)
+ && ts.isBinaryExpression(node.parent)
+ && node.parent.left === node
+ && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */
+ && isAliasableExpression(node.parent.right));
}
ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
function getAliasDeclarationFromName(node) {
switch (node.parent.kind) {
- case 266 /* ImportClause */:
- case 269 /* ImportSpecifier */:
- case 267 /* NamespaceImport */:
- case 274 /* ExportSpecifier */:
- case 270 /* ExportAssignment */:
- case 264 /* ImportEqualsDeclaration */:
+ case 267 /* SyntaxKind.ImportClause */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
+ case 268 /* SyntaxKind.NamespaceImport */:
+ case 275 /* SyntaxKind.ExportSpecifier */:
+ case 271 /* SyntaxKind.ExportAssignment */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 274 /* SyntaxKind.NamespaceExport */:
return node.parent;
- case 160 /* QualifiedName */:
+ case 161 /* SyntaxKind.QualifiedName */:
do {
node = node.parent;
- } while (node.parent.kind === 160 /* QualifiedName */);
+ } while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */);
return getAliasDeclarationFromName(node);
}
}
@@ -17113,7 +17337,7 @@ var ts;
}
ts.getExportAssignmentExpression = getExportAssignmentExpression;
function getPropertyAssignmentAliasLikeExpression(node) {
- return node.kind === 295 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 294 /* PropertyAssignment */ ? node.initializer :
+ return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? node.name : node.kind === 296 /* SyntaxKind.PropertyAssignment */ ? node.initializer :
node.parent.right;
}
ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression;
@@ -17130,7 +17354,7 @@ var ts;
}
ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode;
function getClassExtendsHeritageElement(node) {
- var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */);
+ var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */);
return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined;
}
ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement;
@@ -17139,7 +17363,7 @@ var ts;
return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; });
}
else {
- var heritageClause = getHeritageClause(node.heritageClauses, 117 /* ImplementsKeyword */);
+ var heritageClause = getHeritageClause(node.heritageClauses, 117 /* SyntaxKind.ImplementsKeyword */);
return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types;
}
}
@@ -17152,7 +17376,7 @@ var ts;
}
ts.getAllSuperTypeNodes = getAllSuperTypeNodes;
function getInterfaceBaseTypeNodes(node) {
- var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */);
+ var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */);
return heritageClause ? heritageClause.types : undefined;
}
ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes;
@@ -17179,11 +17403,11 @@ var ts;
}
ts.getAncestor = getAncestor;
function isKeyword(token) {
- return 81 /* FirstKeyword */ <= token && token <= 159 /* LastKeyword */;
+ return 81 /* SyntaxKind.FirstKeyword */ <= token && token <= 160 /* SyntaxKind.LastKeyword */;
}
ts.isKeyword = isKeyword;
function isContextualKeyword(token) {
- return 126 /* FirstContextualKeyword */ <= token && token <= 159 /* LastContextualKeyword */;
+ return 126 /* SyntaxKind.FirstContextualKeyword */ <= token && token <= 160 /* SyntaxKind.LastContextualKeyword */;
}
ts.isContextualKeyword = isContextualKeyword;
function isNonContextualKeyword(token) {
@@ -17191,7 +17415,7 @@ var ts;
}
ts.isNonContextualKeyword = isNonContextualKeyword;
function isFutureReservedKeyword(token) {
- return 117 /* FirstFutureReservedWord */ <= token && token <= 125 /* LastFutureReservedWord */;
+ return 117 /* SyntaxKind.FirstFutureReservedWord */ <= token && token <= 125 /* SyntaxKind.LastFutureReservedWord */;
}
ts.isFutureReservedKeyword = isFutureReservedKeyword;
function isStringANonContextualKeyword(name) {
@@ -17210,7 +17434,7 @@ var ts;
}
ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword;
function isTrivia(token) {
- return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */;
+ return 2 /* SyntaxKind.FirstTriviaToken */ <= token && token <= 7 /* SyntaxKind.LastTriviaToken */;
}
ts.isTrivia = isTrivia;
var FunctionFlags;
@@ -17223,38 +17447,38 @@ var ts;
})(FunctionFlags = ts.FunctionFlags || (ts.FunctionFlags = {}));
function getFunctionFlags(node) {
if (!node) {
- return 4 /* Invalid */;
+ return 4 /* FunctionFlags.Invalid */;
}
- var flags = 0 /* Normal */;
+ var flags = 0 /* FunctionFlags.Normal */;
switch (node.kind) {
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 168 /* MethodDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
if (node.asteriskToken) {
- flags |= 1 /* Generator */;
+ flags |= 1 /* FunctionFlags.Generator */;
}
// falls through
- case 213 /* ArrowFunction */:
- if (hasSyntacticModifier(node, 256 /* Async */)) {
- flags |= 2 /* Async */;
+ case 214 /* SyntaxKind.ArrowFunction */:
+ if (hasSyntacticModifier(node, 256 /* ModifierFlags.Async */)) {
+ flags |= 2 /* FunctionFlags.Async */;
}
break;
}
if (!node.body) {
- flags |= 4 /* Invalid */;
+ flags |= 4 /* FunctionFlags.Invalid */;
}
return flags;
}
ts.getFunctionFlags = getFunctionFlags;
function isAsyncFunction(node) {
switch (node.kind) {
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
- case 168 /* MethodDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
return node.body !== undefined
&& node.asteriskToken === undefined
- && hasSyntacticModifier(node, 256 /* Async */);
+ && hasSyntacticModifier(node, 256 /* ModifierFlags.Async */);
}
return false;
}
@@ -17264,7 +17488,7 @@ var ts;
}
ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike;
function isSignedNumericLiteral(node) {
- return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && ts.isNumericLiteral(node.operand);
+ return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* SyntaxKind.PlusToken */ || node.operator === 40 /* SyntaxKind.MinusToken */) && ts.isNumericLiteral(node.operand);
}
ts.isSignedNumericLiteral = isSignedNumericLiteral;
/**
@@ -17281,7 +17505,7 @@ var ts;
}
ts.hasDynamicName = hasDynamicName;
function isDynamicName(name) {
- if (!(name.kind === 161 /* ComputedPropertyName */ || name.kind === 206 /* ElementAccessExpression */)) {
+ if (!(name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || name.kind === 207 /* SyntaxKind.ElementAccessExpression */)) {
return false;
}
var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression;
@@ -17291,19 +17515,19 @@ var ts;
ts.isDynamicName = isDynamicName;
function getPropertyNameForPropertyNameNode(name) {
switch (name.kind) {
- case 79 /* Identifier */:
- case 80 /* PrivateIdentifier */:
+ case 79 /* SyntaxKind.Identifier */:
+ case 80 /* SyntaxKind.PrivateIdentifier */:
return name.escapedText;
- case 10 /* StringLiteral */:
- case 8 /* NumericLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
return ts.escapeLeadingUnderscores(name.text);
- case 161 /* ComputedPropertyName */:
+ case 162 /* SyntaxKind.ComputedPropertyName */:
var nameExpression = name.expression;
if (isStringOrNumericLiteralLike(nameExpression)) {
return ts.escapeLeadingUnderscores(nameExpression.text);
}
else if (isSignedNumericLiteral(nameExpression)) {
- if (nameExpression.operator === 40 /* MinusToken */) {
+ if (nameExpression.operator === 40 /* SyntaxKind.MinusToken */) {
return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text;
}
return nameExpression.operand.text;
@@ -17316,10 +17540,10 @@ var ts;
ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode;
function isPropertyNameLiteral(node) {
switch (node.kind) {
- case 79 /* Identifier */:
- case 10 /* StringLiteral */:
- case 14 /* NoSubstitutionTemplateLiteral */:
- case 8 /* NumericLiteral */:
+ case 79 /* SyntaxKind.Identifier */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
return true;
default:
return false;
@@ -17354,7 +17578,7 @@ var ts;
* Includes the word "Symbol" with unicode escapes
*/
function isESSymbolIdentifier(node) {
- return node.kind === 79 /* Identifier */ && node.escapedText === "Symbol";
+ return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "Symbol";
}
ts.isESSymbolIdentifier = isESSymbolIdentifier;
function isPushOrUnshiftIdentifier(node) {
@@ -17363,11 +17587,11 @@ var ts;
ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier;
function isParameterDeclaration(node) {
var root = getRootDeclaration(node);
- return root.kind === 163 /* Parameter */;
+ return root.kind === 164 /* SyntaxKind.Parameter */;
}
ts.isParameterDeclaration = isParameterDeclaration;
function getRootDeclaration(node) {
- while (node.kind === 202 /* BindingElement */) {
+ while (node.kind === 203 /* SyntaxKind.BindingElement */) {
node = node.parent.parent;
}
return node;
@@ -17375,15 +17599,15 @@ var ts;
ts.getRootDeclaration = getRootDeclaration;
function nodeStartsNewLexicalEnvironment(node) {
var kind = node.kind;
- return kind === 170 /* Constructor */
- || kind === 212 /* FunctionExpression */
- || kind === 255 /* FunctionDeclaration */
- || kind === 213 /* ArrowFunction */
- || kind === 168 /* MethodDeclaration */
- || kind === 171 /* GetAccessor */
- || kind === 172 /* SetAccessor */
- || kind === 260 /* ModuleDeclaration */
- || kind === 303 /* SourceFile */;
+ return kind === 171 /* SyntaxKind.Constructor */
+ || kind === 213 /* SyntaxKind.FunctionExpression */
+ || kind === 256 /* SyntaxKind.FunctionDeclaration */
+ || kind === 214 /* SyntaxKind.ArrowFunction */
+ || kind === 169 /* SyntaxKind.MethodDeclaration */
+ || kind === 172 /* SyntaxKind.GetAccessor */
+ || kind === 173 /* SyntaxKind.SetAccessor */
+ || kind === 261 /* SyntaxKind.ModuleDeclaration */
+ || kind === 305 /* SyntaxKind.SourceFile */;
}
ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment;
function nodeIsSynthesized(range) {
@@ -17402,58 +17626,58 @@ var ts;
})(Associativity = ts.Associativity || (ts.Associativity = {}));
function getExpressionAssociativity(expression) {
var operator = getOperator(expression);
- var hasArguments = expression.kind === 208 /* NewExpression */ && expression.arguments !== undefined;
+ var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined;
return getOperatorAssociativity(expression.kind, operator, hasArguments);
}
ts.getExpressionAssociativity = getExpressionAssociativity;
function getOperatorAssociativity(kind, operator, hasArguments) {
switch (kind) {
- case 208 /* NewExpression */:
- return hasArguments ? 0 /* Left */ : 1 /* Right */;
- case 218 /* PrefixUnaryExpression */:
- case 215 /* TypeOfExpression */:
- case 216 /* VoidExpression */:
- case 214 /* DeleteExpression */:
- case 217 /* AwaitExpression */:
- case 221 /* ConditionalExpression */:
- case 223 /* YieldExpression */:
- return 1 /* Right */;
- case 220 /* BinaryExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
+ return hasArguments ? 0 /* Associativity.Left */ : 1 /* Associativity.Right */;
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
+ case 216 /* SyntaxKind.TypeOfExpression */:
+ case 217 /* SyntaxKind.VoidExpression */:
+ case 215 /* SyntaxKind.DeleteExpression */:
+ case 218 /* SyntaxKind.AwaitExpression */:
+ case 222 /* SyntaxKind.ConditionalExpression */:
+ case 224 /* SyntaxKind.YieldExpression */:
+ return 1 /* Associativity.Right */;
+ case 221 /* SyntaxKind.BinaryExpression */:
switch (operator) {
- case 42 /* AsteriskAsteriskToken */:
- case 63 /* EqualsToken */:
- case 64 /* PlusEqualsToken */:
- case 65 /* MinusEqualsToken */:
- case 67 /* AsteriskAsteriskEqualsToken */:
- case 66 /* AsteriskEqualsToken */:
- case 68 /* SlashEqualsToken */:
- case 69 /* PercentEqualsToken */:
- case 70 /* LessThanLessThanEqualsToken */:
- case 71 /* GreaterThanGreaterThanEqualsToken */:
- case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
- case 73 /* AmpersandEqualsToken */:
- case 78 /* CaretEqualsToken */:
- case 74 /* BarEqualsToken */:
- case 75 /* BarBarEqualsToken */:
- case 76 /* AmpersandAmpersandEqualsToken */:
- case 77 /* QuestionQuestionEqualsToken */:
- return 1 /* Right */;
- }
- }
- return 0 /* Left */;
+ case 42 /* SyntaxKind.AsteriskAsteriskToken */:
+ case 63 /* SyntaxKind.EqualsToken */:
+ case 64 /* SyntaxKind.PlusEqualsToken */:
+ case 65 /* SyntaxKind.MinusEqualsToken */:
+ case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */:
+ case 66 /* SyntaxKind.AsteriskEqualsToken */:
+ case 68 /* SyntaxKind.SlashEqualsToken */:
+ case 69 /* SyntaxKind.PercentEqualsToken */:
+ case 70 /* SyntaxKind.LessThanLessThanEqualsToken */:
+ case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */:
+ case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */:
+ case 73 /* SyntaxKind.AmpersandEqualsToken */:
+ case 78 /* SyntaxKind.CaretEqualsToken */:
+ case 74 /* SyntaxKind.BarEqualsToken */:
+ case 75 /* SyntaxKind.BarBarEqualsToken */:
+ case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */:
+ case 77 /* SyntaxKind.QuestionQuestionEqualsToken */:
+ return 1 /* Associativity.Right */;
+ }
+ }
+ return 0 /* Associativity.Left */;
}
ts.getOperatorAssociativity = getOperatorAssociativity;
function getExpressionPrecedence(expression) {
var operator = getOperator(expression);
- var hasArguments = expression.kind === 208 /* NewExpression */ && expression.arguments !== undefined;
+ var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined;
return getOperatorPrecedence(expression.kind, operator, hasArguments);
}
ts.getExpressionPrecedence = getExpressionPrecedence;
function getOperator(expression) {
- if (expression.kind === 220 /* BinaryExpression */) {
+ if (expression.kind === 221 /* SyntaxKind.BinaryExpression */) {
return expression.operatorToken.kind;
}
- else if (expression.kind === 218 /* PrefixUnaryExpression */ || expression.kind === 219 /* PostfixUnaryExpression */) {
+ else if (expression.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || expression.kind === 220 /* SyntaxKind.PostfixUnaryExpression */) {
return expression.operator;
}
else {
@@ -17632,129 +17856,129 @@ var ts;
})(OperatorPrecedence = ts.OperatorPrecedence || (ts.OperatorPrecedence = {}));
function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) {
switch (nodeKind) {
- case 349 /* CommaListExpression */:
- return 0 /* Comma */;
- case 224 /* SpreadElement */:
- return 1 /* Spread */;
- case 223 /* YieldExpression */:
- return 2 /* Yield */;
- case 221 /* ConditionalExpression */:
- return 4 /* Conditional */;
- case 220 /* BinaryExpression */:
+ case 351 /* SyntaxKind.CommaListExpression */:
+ return 0 /* OperatorPrecedence.Comma */;
+ case 225 /* SyntaxKind.SpreadElement */:
+ return 1 /* OperatorPrecedence.Spread */;
+ case 224 /* SyntaxKind.YieldExpression */:
+ return 2 /* OperatorPrecedence.Yield */;
+ case 222 /* SyntaxKind.ConditionalExpression */:
+ return 4 /* OperatorPrecedence.Conditional */;
+ case 221 /* SyntaxKind.BinaryExpression */:
switch (operatorKind) {
- case 27 /* CommaToken */:
- return 0 /* Comma */;
- case 63 /* EqualsToken */:
- case 64 /* PlusEqualsToken */:
- case 65 /* MinusEqualsToken */:
- case 67 /* AsteriskAsteriskEqualsToken */:
- case 66 /* AsteriskEqualsToken */:
- case 68 /* SlashEqualsToken */:
- case 69 /* PercentEqualsToken */:
- case 70 /* LessThanLessThanEqualsToken */:
- case 71 /* GreaterThanGreaterThanEqualsToken */:
- case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
- case 73 /* AmpersandEqualsToken */:
- case 78 /* CaretEqualsToken */:
- case 74 /* BarEqualsToken */:
- case 75 /* BarBarEqualsToken */:
- case 76 /* AmpersandAmpersandEqualsToken */:
- case 77 /* QuestionQuestionEqualsToken */:
- return 3 /* Assignment */;
+ case 27 /* SyntaxKind.CommaToken */:
+ return 0 /* OperatorPrecedence.Comma */;
+ case 63 /* SyntaxKind.EqualsToken */:
+ case 64 /* SyntaxKind.PlusEqualsToken */:
+ case 65 /* SyntaxKind.MinusEqualsToken */:
+ case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */:
+ case 66 /* SyntaxKind.AsteriskEqualsToken */:
+ case 68 /* SyntaxKind.SlashEqualsToken */:
+ case 69 /* SyntaxKind.PercentEqualsToken */:
+ case 70 /* SyntaxKind.LessThanLessThanEqualsToken */:
+ case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */:
+ case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */:
+ case 73 /* SyntaxKind.AmpersandEqualsToken */:
+ case 78 /* SyntaxKind.CaretEqualsToken */:
+ case 74 /* SyntaxKind.BarEqualsToken */:
+ case 75 /* SyntaxKind.BarBarEqualsToken */:
+ case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */:
+ case 77 /* SyntaxKind.QuestionQuestionEqualsToken */:
+ return 3 /* OperatorPrecedence.Assignment */;
default:
return getBinaryOperatorPrecedence(operatorKind);
}
// TODO: Should prefix `++` and `--` be moved to the `Update` precedence?
- case 210 /* TypeAssertionExpression */:
- case 229 /* NonNullExpression */:
- case 218 /* PrefixUnaryExpression */:
- case 215 /* TypeOfExpression */:
- case 216 /* VoidExpression */:
- case 214 /* DeleteExpression */:
- case 217 /* AwaitExpression */:
- return 16 /* Unary */;
- case 219 /* PostfixUnaryExpression */:
- return 17 /* Update */;
- case 207 /* CallExpression */:
- return 18 /* LeftHandSide */;
- case 208 /* NewExpression */:
- return hasArguments ? 19 /* Member */ : 18 /* LeftHandSide */;
- case 209 /* TaggedTemplateExpression */:
- case 205 /* PropertyAccessExpression */:
- case 206 /* ElementAccessExpression */:
- case 230 /* MetaProperty */:
- return 19 /* Member */;
- case 228 /* AsExpression */:
- return 11 /* Relational */;
- case 108 /* ThisKeyword */:
- case 106 /* SuperKeyword */:
- case 79 /* Identifier */:
- case 80 /* PrivateIdentifier */:
- case 104 /* NullKeyword */:
- case 110 /* TrueKeyword */:
- case 95 /* FalseKeyword */:
- case 8 /* NumericLiteral */:
- case 9 /* BigIntLiteral */:
- case 10 /* StringLiteral */:
- case 203 /* ArrayLiteralExpression */:
- case 204 /* ObjectLiteralExpression */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
- case 225 /* ClassExpression */:
- case 13 /* RegularExpressionLiteral */:
- case 14 /* NoSubstitutionTemplateLiteral */:
- case 222 /* TemplateExpression */:
- case 211 /* ParenthesizedExpression */:
- case 226 /* OmittedExpression */:
- case 277 /* JsxElement */:
- case 278 /* JsxSelfClosingElement */:
- case 281 /* JsxFragment */:
- return 20 /* Primary */;
+ case 211 /* SyntaxKind.TypeAssertionExpression */:
+ case 230 /* SyntaxKind.NonNullExpression */:
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
+ case 216 /* SyntaxKind.TypeOfExpression */:
+ case 217 /* SyntaxKind.VoidExpression */:
+ case 215 /* SyntaxKind.DeleteExpression */:
+ case 218 /* SyntaxKind.AwaitExpression */:
+ return 16 /* OperatorPrecedence.Unary */;
+ case 220 /* SyntaxKind.PostfixUnaryExpression */:
+ return 17 /* OperatorPrecedence.Update */;
+ case 208 /* SyntaxKind.CallExpression */:
+ return 18 /* OperatorPrecedence.LeftHandSide */;
+ case 209 /* SyntaxKind.NewExpression */:
+ return hasArguments ? 19 /* OperatorPrecedence.Member */ : 18 /* OperatorPrecedence.LeftHandSide */;
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
+ case 231 /* SyntaxKind.MetaProperty */:
+ return 19 /* OperatorPrecedence.Member */;
+ case 229 /* SyntaxKind.AsExpression */:
+ return 11 /* OperatorPrecedence.Relational */;
+ case 108 /* SyntaxKind.ThisKeyword */:
+ case 106 /* SyntaxKind.SuperKeyword */:
+ case 79 /* SyntaxKind.Identifier */:
+ case 80 /* SyntaxKind.PrivateIdentifier */:
+ case 104 /* SyntaxKind.NullKeyword */:
+ case 110 /* SyntaxKind.TrueKeyword */:
+ case 95 /* SyntaxKind.FalseKeyword */:
+ case 8 /* SyntaxKind.NumericLiteral */:
+ case 9 /* SyntaxKind.BigIntLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 13 /* SyntaxKind.RegularExpressionLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
+ case 223 /* SyntaxKind.TemplateExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
+ case 227 /* SyntaxKind.OmittedExpression */:
+ case 278 /* SyntaxKind.JsxElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
+ case 282 /* SyntaxKind.JsxFragment */:
+ return 20 /* OperatorPrecedence.Primary */;
default:
- return -1 /* Invalid */;
+ return -1 /* OperatorPrecedence.Invalid */;
}
}
ts.getOperatorPrecedence = getOperatorPrecedence;
function getBinaryOperatorPrecedence(kind) {
switch (kind) {
- case 60 /* QuestionQuestionToken */:
- return 4 /* Coalesce */;
- case 56 /* BarBarToken */:
- return 5 /* LogicalOR */;
- case 55 /* AmpersandAmpersandToken */:
- return 6 /* LogicalAND */;
- case 51 /* BarToken */:
- return 7 /* BitwiseOR */;
- case 52 /* CaretToken */:
- return 8 /* BitwiseXOR */;
- case 50 /* AmpersandToken */:
- return 9 /* BitwiseAND */;
- case 34 /* EqualsEqualsToken */:
- case 35 /* ExclamationEqualsToken */:
- case 36 /* EqualsEqualsEqualsToken */:
- case 37 /* ExclamationEqualsEqualsToken */:
- return 10 /* Equality */;
- case 29 /* LessThanToken */:
- case 31 /* GreaterThanToken */:
- case 32 /* LessThanEqualsToken */:
- case 33 /* GreaterThanEqualsToken */:
- case 102 /* InstanceOfKeyword */:
- case 101 /* InKeyword */:
- case 127 /* AsKeyword */:
- return 11 /* Relational */;
- case 47 /* LessThanLessThanToken */:
- case 48 /* GreaterThanGreaterThanToken */:
- case 49 /* GreaterThanGreaterThanGreaterThanToken */:
- return 12 /* Shift */;
- case 39 /* PlusToken */:
- case 40 /* MinusToken */:
- return 13 /* Additive */;
- case 41 /* AsteriskToken */:
- case 43 /* SlashToken */:
- case 44 /* PercentToken */:
- return 14 /* Multiplicative */;
- case 42 /* AsteriskAsteriskToken */:
- return 15 /* Exponentiation */;
+ case 60 /* SyntaxKind.QuestionQuestionToken */:
+ return 4 /* OperatorPrecedence.Coalesce */;
+ case 56 /* SyntaxKind.BarBarToken */:
+ return 5 /* OperatorPrecedence.LogicalOR */;
+ case 55 /* SyntaxKind.AmpersandAmpersandToken */:
+ return 6 /* OperatorPrecedence.LogicalAND */;
+ case 51 /* SyntaxKind.BarToken */:
+ return 7 /* OperatorPrecedence.BitwiseOR */;
+ case 52 /* SyntaxKind.CaretToken */:
+ return 8 /* OperatorPrecedence.BitwiseXOR */;
+ case 50 /* SyntaxKind.AmpersandToken */:
+ return 9 /* OperatorPrecedence.BitwiseAND */;
+ case 34 /* SyntaxKind.EqualsEqualsToken */:
+ case 35 /* SyntaxKind.ExclamationEqualsToken */:
+ case 36 /* SyntaxKind.EqualsEqualsEqualsToken */:
+ case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */:
+ return 10 /* OperatorPrecedence.Equality */;
+ case 29 /* SyntaxKind.LessThanToken */:
+ case 31 /* SyntaxKind.GreaterThanToken */:
+ case 32 /* SyntaxKind.LessThanEqualsToken */:
+ case 33 /* SyntaxKind.GreaterThanEqualsToken */:
+ case 102 /* SyntaxKind.InstanceOfKeyword */:
+ case 101 /* SyntaxKind.InKeyword */:
+ case 127 /* SyntaxKind.AsKeyword */:
+ return 11 /* OperatorPrecedence.Relational */;
+ case 47 /* SyntaxKind.LessThanLessThanToken */:
+ case 48 /* SyntaxKind.GreaterThanGreaterThanToken */:
+ case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */:
+ return 12 /* OperatorPrecedence.Shift */;
+ case 39 /* SyntaxKind.PlusToken */:
+ case 40 /* SyntaxKind.MinusToken */:
+ return 13 /* OperatorPrecedence.Additive */;
+ case 41 /* SyntaxKind.AsteriskToken */:
+ case 43 /* SyntaxKind.SlashToken */:
+ case 44 /* SyntaxKind.PercentToken */:
+ return 14 /* OperatorPrecedence.Multiplicative */;
+ case 42 /* SyntaxKind.AsteriskAsteriskToken */:
+ return 15 /* OperatorPrecedence.Exponentiation */;
}
// -1 is lower than all other precedences. Returning it will cause binary expression
// parsing to stop.
@@ -17764,9 +17988,9 @@ var ts;
function getSemanticJsxChildren(children) {
return ts.filter(children, function (i) {
switch (i.kind) {
- case 287 /* JsxExpression */:
+ case 288 /* SyntaxKind.JsxExpression */:
return !!i.expression;
- case 11 /* JsxText */:
+ case 11 /* SyntaxKind.JsxText */:
return !i.containsOnlyTriviaWhiteSpaces;
default:
return true;
@@ -17881,9 +18105,9 @@ var ts;
return "\\u" + paddedHexCode;
}
function getReplacement(c, offset, input) {
- if (c.charCodeAt(0) === 0 /* nullCharacter */) {
+ if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) {
var lookAhead = input.charCodeAt(offset + c.length);
- if (lookAhead >= 48 /* _0 */ && lookAhead <= 57 /* _9 */) {
+ if (lookAhead >= 48 /* CharacterCodes._0 */ && lookAhead <= 57 /* CharacterCodes._9 */) {
// If the null character is followed by digits, print as a hex escape to prevent the result from parsing as an octal (which is forbidden in strict mode)
return "\\x00";
}
@@ -17898,8 +18122,8 @@ var ts;
* Note that this doesn't actually wrap the input in double quotes.
*/
function escapeString(s, quoteChar) {
- var escapedCharsRegExp = quoteChar === 96 /* backtick */ ? backtickQuoteEscapedCharsRegExp :
- quoteChar === 39 /* singleQuote */ ? singleQuoteEscapedCharsRegExp :
+ var escapedCharsRegExp = quoteChar === 96 /* CharacterCodes.backtick */ ? backtickQuoteEscapedCharsRegExp :
+ quoteChar === 39 /* CharacterCodes.singleQuote */ ? singleQuoteEscapedCharsRegExp :
doubleQuoteEscapedCharsRegExp;
return s.replace(escapedCharsRegExp, getReplacement);
}
@@ -17929,13 +18153,13 @@ var ts;
return "&#x" + hexCharCode + ";";
}
function getJsxAttributeStringReplacement(c) {
- if (c.charCodeAt(0) === 0 /* nullCharacter */) {
+ if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) {
return "&#0;";
}
return jsxEscapedCharsMap.get(c) || encodeJsxCharacterEntity(c.charCodeAt(0));
}
function escapeJsxAttributeString(s, quoteChar) {
- var escapedCharsRegExp = quoteChar === 39 /* singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp :
+ var escapedCharsRegExp = quoteChar === 39 /* CharacterCodes.singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp :
jsxDoubleQuoteEscapedCharsRegExp;
return s.replace(escapedCharsRegExp, getJsxAttributeStringReplacement);
}
@@ -17954,13 +18178,13 @@ var ts;
}
ts.stripQuotes = stripQuotes;
function isQuoteOrBacktick(charCode) {
- return charCode === 39 /* singleQuote */ ||
- charCode === 34 /* doubleQuote */ ||
- charCode === 96 /* backtick */;
+ return charCode === 39 /* CharacterCodes.singleQuote */ ||
+ charCode === 34 /* CharacterCodes.doubleQuote */ ||
+ charCode === 96 /* CharacterCodes.backtick */;
}
function isIntrinsicJsxName(name) {
var ch = name.charCodeAt(0);
- return (ch >= 97 /* a */ && ch <= 122 /* z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":");
+ return (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":");
}
ts.isIntrinsicJsxName = isIntrinsicJsxName;
var indentStrings = ["", " "];
@@ -17977,6 +18201,10 @@ var ts;
return indentStrings[1].length;
}
ts.getIndentSize = getIndentSize;
+ function isNightly() {
+ return ts.stringContains(ts.version, "-dev") || ts.stringContains(ts.version, "-insiders");
+ }
+ ts.isNightly = isNightly;
function createTextWriter(newLine) {
var output;
var indent;
@@ -18201,12 +18429,22 @@ var ts;
}
ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker;
function getDeclarationEmitExtensionForPath(path) {
- return ts.fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ :
- ts.fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ :
- ts.fileExtensionIsOneOf(path, [".json" /* Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well
- ".d.ts" /* Dts */;
+ return ts.fileExtensionIsOneOf(path, [".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? ".d.mts" /* Extension.Dmts */ :
+ ts.fileExtensionIsOneOf(path, [".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? ".d.cts" /* Extension.Dcts */ :
+ ts.fileExtensionIsOneOf(path, [".json" /* Extension.Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well
+ ".d.ts" /* Extension.Dts */;
}
ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath;
+ /**
+ * This function is an inverse of `getDeclarationEmitExtensionForPath`.
+ */
+ function getPossibleOriginalInputExtensionForExtension(path) {
+ return ts.fileExtensionIsOneOf(path, [".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */] :
+ ts.fileExtensionIsOneOf(path, [".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */] :
+ ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Extension.Json */] :
+ [".tsx" /* Extension.Tsx */, ".ts" /* Extension.Ts */, ".jsx" /* Extension.Jsx */, ".js" /* Extension.Js */];
+ }
+ ts.getPossibleOriginalInputExtensionForExtension = getPossibleOriginalInputExtensionForExtension;
function outFile(options) {
return options.outFile || options.out;
}
@@ -18266,10 +18504,10 @@ var ts;
return ts.combinePaths(newDirPath, sourceFilePath);
}
ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker;
- function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) {
- host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) {
+ function writeFile(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) {
+ host.writeFile(fileName, text, writeByteOrderMark, function (hostErrorMessage) {
diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
- }, sourceFiles);
+ }, sourceFiles, data);
}
ts.writeFile = writeFile;
function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) {
@@ -18332,7 +18570,7 @@ var ts;
}
ts.parameterIsThisKeyword = parameterIsThisKeyword;
function isThisIdentifier(node) {
- return !!node && node.kind === 79 /* Identifier */ && identifierIsThisKeyword(node);
+ return !!node && node.kind === 79 /* SyntaxKind.Identifier */ && identifierIsThisKeyword(node);
}
ts.isThisIdentifier = isThisIdentifier;
function isThisInTypeQuery(node) {
@@ -18342,11 +18580,11 @@ var ts;
while (ts.isQualifiedName(node.parent) && node.parent.left === node) {
node = node.parent;
}
- return node.parent.kind === 180 /* TypeQuery */;
+ return node.parent.kind === 181 /* SyntaxKind.TypeQuery */;
}
ts.isThisInTypeQuery = isThisInTypeQuery;
function identifierIsThisKeyword(id) {
- return id.originalKeywordKind === 108 /* ThisKeyword */;
+ return id.originalKeywordKind === 108 /* SyntaxKind.ThisKeyword */;
}
ts.identifierIsThisKeyword = identifierIsThisKeyword;
function getAllAccessorDeclarations(declarations, accessor) {
@@ -18357,10 +18595,10 @@ var ts;
var setAccessor;
if (hasDynamicName(accessor)) {
firstAccessor = accessor;
- if (accessor.kind === 171 /* GetAccessor */) {
+ if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) {
getAccessor = accessor;
}
- else if (accessor.kind === 172 /* SetAccessor */) {
+ else if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) {
setAccessor = accessor;
}
else {
@@ -18380,10 +18618,10 @@ var ts;
else if (!secondAccessor) {
secondAccessor = member;
}
- if (member.kind === 171 /* GetAccessor */ && !getAccessor) {
+ if (member.kind === 172 /* SyntaxKind.GetAccessor */ && !getAccessor) {
getAccessor = member;
}
- if (member.kind === 172 /* SetAccessor */ && !setAccessor) {
+ if (member.kind === 173 /* SyntaxKind.SetAccessor */ && !setAccessor) {
setAccessor = member;
}
}
@@ -18432,7 +18670,7 @@ var ts;
ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations;
/** template tags are only available when a typedef isn't already using them */
function isNonTypeAliasTemplate(tag) {
- return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 318 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias));
+ return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* SyntaxKind.JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias));
}
/**
* Gets the effective type annotation of the value parameter of a set accessor. If the node
@@ -18549,7 +18787,7 @@ var ts;
}
ts.emitDetachedComments = emitDetachedComments;
function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) {
- if (text.charCodeAt(commentPos + 1) === 42 /* asterisk */) {
+ if (text.charCodeAt(commentPos + 1) === 42 /* CharacterCodes.asterisk */) {
var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos);
var lineCount = lineMap.length;
var firstCommentLineIndent = void 0;
@@ -18624,7 +18862,7 @@ var ts;
function calculateIndent(text, pos, end) {
var currentLineIndent = 0;
for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) {
- if (text.charCodeAt(pos) === 9 /* tab */) {
+ if (text.charCodeAt(pos) === 9 /* CharacterCodes.tab */) {
// Tabs = TabSize = indent size and go to next tabStop
currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize());
}
@@ -18636,11 +18874,11 @@ var ts;
return currentLineIndent;
}
function hasEffectiveModifiers(node) {
- return getEffectiveModifierFlags(node) !== 0 /* None */;
+ return getEffectiveModifierFlags(node) !== 0 /* ModifierFlags.None */;
}
ts.hasEffectiveModifiers = hasEffectiveModifiers;
function hasSyntacticModifiers(node) {
- return getSyntacticModifierFlags(node) !== 0 /* None */;
+ return getSyntacticModifierFlags(node) !== 0 /* ModifierFlags.None */;
}
ts.hasSyntacticModifiers = hasSyntacticModifiers;
function hasEffectiveModifier(node, flags) {
@@ -18657,23 +18895,23 @@ var ts;
}
ts.isStatic = isStatic;
function hasStaticModifier(node) {
- return hasSyntacticModifier(node, 32 /* Static */);
+ return hasSyntacticModifier(node, 32 /* ModifierFlags.Static */);
}
ts.hasStaticModifier = hasStaticModifier;
function hasOverrideModifier(node) {
- return hasEffectiveModifier(node, 16384 /* Override */);
+ return hasEffectiveModifier(node, 16384 /* ModifierFlags.Override */);
}
ts.hasOverrideModifier = hasOverrideModifier;
function hasAbstractModifier(node) {
- return hasSyntacticModifier(node, 128 /* Abstract */);
+ return hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */);
}
ts.hasAbstractModifier = hasAbstractModifier;
function hasAmbientModifier(node) {
- return hasSyntacticModifier(node, 2 /* Ambient */);
+ return hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */);
}
ts.hasAmbientModifier = hasAmbientModifier;
function hasEffectiveReadonlyModifier(node) {
- return hasEffectiveModifier(node, 64 /* Readonly */);
+ return hasEffectiveModifier(node, 64 /* ModifierFlags.Readonly */);
}
ts.hasEffectiveReadonlyModifier = hasEffectiveReadonlyModifier;
function getSelectedEffectiveModifierFlags(node, flags) {
@@ -18685,16 +18923,16 @@ var ts;
}
ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags;
function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) {
- if (node.kind >= 0 /* FirstToken */ && node.kind <= 159 /* LastToken */) {
- return 0 /* None */;
+ if (node.kind >= 0 /* SyntaxKind.FirstToken */ && node.kind <= 160 /* SyntaxKind.LastToken */) {
+ return 0 /* ModifierFlags.None */;
}
- if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) {
- node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* HasComputedFlags */;
+ if (!(node.modifierFlagsCache & 536870912 /* ModifierFlags.HasComputedFlags */)) {
+ node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* ModifierFlags.HasComputedFlags */;
}
- if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) {
- node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* HasComputedJSDocModifiers */;
+ if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* ModifierFlags.HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) {
+ node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* ModifierFlags.HasComputedJSDocModifiers */;
}
- return node.modifierFlagsCache & ~(536870912 /* HasComputedFlags */ | 4096 /* HasComputedJSDocModifiers */);
+ return node.modifierFlagsCache & ~(536870912 /* ModifierFlags.HasComputedFlags */ | 4096 /* ModifierFlags.HasComputedJSDocModifiers */);
}
/**
* Gets the effective ModifierFlags for the provided node, including JSDoc modifiers. The modifiers will be cached on the node to improve performance.
@@ -18719,22 +18957,22 @@ var ts;
}
ts.getSyntacticModifierFlags = getSyntacticModifierFlags;
function getJSDocModifierFlagsNoCache(node) {
- var flags = 0 /* None */;
+ var flags = 0 /* ModifierFlags.None */;
if (!!node.parent && !ts.isParameter(node)) {
if (isInJSFile(node)) {
if (ts.getJSDocPublicTagNoCache(node))
- flags |= 4 /* Public */;
+ flags |= 4 /* ModifierFlags.Public */;
if (ts.getJSDocPrivateTagNoCache(node))
- flags |= 8 /* Private */;
+ flags |= 8 /* ModifierFlags.Private */;
if (ts.getJSDocProtectedTagNoCache(node))
- flags |= 16 /* Protected */;
+ flags |= 16 /* ModifierFlags.Protected */;
if (ts.getJSDocReadonlyTagNoCache(node))
- flags |= 64 /* Readonly */;
+ flags |= 64 /* ModifierFlags.Readonly */;
if (ts.getJSDocOverrideTagNoCache(node))
- flags |= 16384 /* Override */;
+ flags |= 16384 /* ModifierFlags.Override */;
}
if (ts.getJSDocDeprecatedTagNoCache(node))
- flags |= 8192 /* Deprecated */;
+ flags |= 8192 /* ModifierFlags.Deprecated */;
}
return flags;
}
@@ -18754,14 +18992,14 @@ var ts;
*/
function getSyntacticModifierFlagsNoCache(node) {
var flags = modifiersToFlags(node.modifiers);
- if (node.flags & 4 /* NestedNamespace */ || (node.kind === 79 /* Identifier */ && node.isInJSDocNamespace)) {
- flags |= 1 /* Export */;
+ if (node.flags & 4 /* NodeFlags.NestedNamespace */ || (node.kind === 79 /* SyntaxKind.Identifier */ && node.isInJSDocNamespace)) {
+ flags |= 1 /* ModifierFlags.Export */;
}
return flags;
}
ts.getSyntacticModifierFlagsNoCache = getSyntacticModifierFlagsNoCache;
function modifiersToFlags(modifiers) {
- var flags = 0 /* None */;
+ var flags = 0 /* ModifierFlags.None */;
if (modifiers) {
for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) {
var modifier = modifiers_1[_i];
@@ -18773,20 +19011,22 @@ var ts;
ts.modifiersToFlags = modifiersToFlags;
function modifierToFlag(token) {
switch (token) {
- case 124 /* StaticKeyword */: return 32 /* Static */;
- case 123 /* PublicKeyword */: return 4 /* Public */;
- case 122 /* ProtectedKeyword */: return 16 /* Protected */;
- case 121 /* PrivateKeyword */: return 8 /* Private */;
- case 126 /* AbstractKeyword */: return 128 /* Abstract */;
- case 93 /* ExportKeyword */: return 1 /* Export */;
- case 135 /* DeclareKeyword */: return 2 /* Ambient */;
- case 85 /* ConstKeyword */: return 2048 /* Const */;
- case 88 /* DefaultKeyword */: return 512 /* Default */;
- case 131 /* AsyncKeyword */: return 256 /* Async */;
- case 144 /* ReadonlyKeyword */: return 64 /* Readonly */;
- case 158 /* OverrideKeyword */: return 16384 /* Override */;
- }
- return 0 /* None */;
+ case 124 /* SyntaxKind.StaticKeyword */: return 32 /* ModifierFlags.Static */;
+ case 123 /* SyntaxKind.PublicKeyword */: return 4 /* ModifierFlags.Public */;
+ case 122 /* SyntaxKind.ProtectedKeyword */: return 16 /* ModifierFlags.Protected */;
+ case 121 /* SyntaxKind.PrivateKeyword */: return 8 /* ModifierFlags.Private */;
+ case 126 /* SyntaxKind.AbstractKeyword */: return 128 /* ModifierFlags.Abstract */;
+ case 93 /* SyntaxKind.ExportKeyword */: return 1 /* ModifierFlags.Export */;
+ case 135 /* SyntaxKind.DeclareKeyword */: return 2 /* ModifierFlags.Ambient */;
+ case 85 /* SyntaxKind.ConstKeyword */: return 2048 /* ModifierFlags.Const */;
+ case 88 /* SyntaxKind.DefaultKeyword */: return 512 /* ModifierFlags.Default */;
+ case 131 /* SyntaxKind.AsyncKeyword */: return 256 /* ModifierFlags.Async */;
+ case 145 /* SyntaxKind.ReadonlyKeyword */: return 64 /* ModifierFlags.Readonly */;
+ case 159 /* SyntaxKind.OverrideKeyword */: return 16384 /* ModifierFlags.Override */;
+ case 101 /* SyntaxKind.InKeyword */: return 32768 /* ModifierFlags.In */;
+ case 144 /* SyntaxKind.OutKeyword */: return 65536 /* ModifierFlags.Out */;
+ }
+ return 0 /* ModifierFlags.None */;
}
ts.modifierToFlag = modifierToFlag;
function createModifiers(modifierFlags) {
@@ -18794,15 +19034,15 @@ var ts;
}
ts.createModifiers = createModifiers;
function isLogicalOperator(token) {
- return token === 56 /* BarBarToken */
- || token === 55 /* AmpersandAmpersandToken */
- || token === 53 /* ExclamationToken */;
+ return token === 56 /* SyntaxKind.BarBarToken */
+ || token === 55 /* SyntaxKind.AmpersandAmpersandToken */
+ || token === 53 /* SyntaxKind.ExclamationToken */;
}
ts.isLogicalOperator = isLogicalOperator;
function isLogicalOrCoalescingAssignmentOperator(token) {
- return token === 75 /* BarBarEqualsToken */
- || token === 76 /* AmpersandAmpersandEqualsToken */
- || token === 77 /* QuestionQuestionEqualsToken */;
+ return token === 75 /* SyntaxKind.BarBarEqualsToken */
+ || token === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */
+ || token === 77 /* SyntaxKind.QuestionQuestionEqualsToken */;
}
ts.isLogicalOrCoalescingAssignmentOperator = isLogicalOrCoalescingAssignmentOperator;
function isLogicalOrCoalescingAssignmentExpression(expr) {
@@ -18810,7 +19050,7 @@ var ts;
}
ts.isLogicalOrCoalescingAssignmentExpression = isLogicalOrCoalescingAssignmentExpression;
function isAssignmentOperator(token) {
- return token >= 63 /* FirstAssignment */ && token <= 78 /* LastAssignment */;
+ return token >= 63 /* SyntaxKind.FirstAssignment */ && token <= 78 /* SyntaxKind.LastAssignment */;
}
ts.isAssignmentOperator = isAssignmentOperator;
/** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */
@@ -18823,14 +19063,14 @@ var ts;
return ts.isExpressionWithTypeArguments(node)
&& ts.isHeritageClause(node.parent)
&& ts.isClassLike(node.parent.parent)
- ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* ImplementsKeyword */ }
+ ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ }
: undefined;
}
ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments;
function isAssignmentExpression(node, excludeCompoundAssignment) {
return ts.isBinaryExpression(node)
&& (excludeCompoundAssignment
- ? node.operatorToken.kind === 63 /* EqualsToken */
+ ? node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */
: isAssignmentOperator(node.operatorToken.kind))
&& ts.isLeftHandSideExpression(node.left);
}
@@ -18842,8 +19082,8 @@ var ts;
function isDestructuringAssignment(node) {
if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) {
var kind = node.left.kind;
- return kind === 204 /* ObjectLiteralExpression */
- || kind === 203 /* ArrayLiteralExpression */;
+ return kind === 205 /* SyntaxKind.ObjectLiteralExpression */
+ || kind === 204 /* SyntaxKind.ArrayLiteralExpression */;
}
return false;
}
@@ -18853,33 +19093,33 @@ var ts;
}
ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause;
function isEntityNameExpression(node) {
- return node.kind === 79 /* Identifier */ || isPropertyAccessEntityNameExpression(node);
+ return node.kind === 79 /* SyntaxKind.Identifier */ || isPropertyAccessEntityNameExpression(node);
}
ts.isEntityNameExpression = isEntityNameExpression;
function getFirstIdentifier(node) {
switch (node.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return node;
- case 160 /* QualifiedName */:
+ case 161 /* SyntaxKind.QualifiedName */:
do {
node = node.left;
- } while (node.kind !== 79 /* Identifier */);
+ } while (node.kind !== 79 /* SyntaxKind.Identifier */);
return node;
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
do {
node = node.expression;
- } while (node.kind !== 79 /* Identifier */);
+ } while (node.kind !== 79 /* SyntaxKind.Identifier */);
return node;
}
}
ts.getFirstIdentifier = getFirstIdentifier;
function isDottedName(node) {
- return node.kind === 79 /* Identifier */
- || node.kind === 108 /* ThisKeyword */
- || node.kind === 106 /* SuperKeyword */
- || node.kind === 230 /* MetaProperty */
- || node.kind === 205 /* PropertyAccessExpression */ && isDottedName(node.expression)
- || node.kind === 211 /* ParenthesizedExpression */ && isDottedName(node.expression);
+ return node.kind === 79 /* SyntaxKind.Identifier */
+ || node.kind === 108 /* SyntaxKind.ThisKeyword */
+ || node.kind === 106 /* SyntaxKind.SuperKeyword */
+ || node.kind === 231 /* SyntaxKind.MetaProperty */
+ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isDottedName(node.expression)
+ || node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && isDottedName(node.expression);
}
ts.isDottedName = isDottedName;
function isPropertyAccessEntityNameExpression(node) {
@@ -18910,10 +19150,15 @@ var ts;
}
ts.isPrototypeAccess = isPrototypeAccess;
function isRightSideOfQualifiedNameOrPropertyAccess(node) {
- return (node.parent.kind === 160 /* QualifiedName */ && node.parent.right === node) ||
- (node.parent.kind === 205 /* PropertyAccessExpression */ && node.parent.name === node);
+ return (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) ||
+ (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node);
}
ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess;
+ function isRightSideOfAccessExpression(node) {
+ return ts.isPropertyAccessExpression(node.parent) && node.parent.name === node
+ || ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node;
+ }
+ ts.isRightSideOfAccessExpression = isRightSideOfAccessExpression;
function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) {
return ts.isQualifiedName(node.parent) && node.parent.right === node
|| ts.isPropertyAccessExpression(node.parent) && node.parent.name === node
@@ -18921,12 +19166,12 @@ var ts;
}
ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName = isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName;
function isEmptyObjectLiteral(expression) {
- return expression.kind === 204 /* ObjectLiteralExpression */ &&
+ return expression.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ &&
expression.properties.length === 0;
}
ts.isEmptyObjectLiteral = isEmptyObjectLiteral;
function isEmptyArrayLiteral(expression) {
- return expression.kind === 203 /* ArrayLiteralExpression */ &&
+ return expression.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ &&
expression.elements.length === 0;
}
ts.isEmptyArrayLiteral = isEmptyArrayLiteral;
@@ -18942,7 +19187,7 @@ var ts;
}
ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault;
function isExportDefaultSymbol(symbol) {
- return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* Default */);
+ return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* ModifierFlags.Default */);
}
/** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */
function tryExtractTSExtension(fileName) {
@@ -19113,9 +19358,9 @@ var ts;
var lineFeed = "\n";
function getNewLineCharacter(options, getNewLine) {
switch (options.newLine) {
- case 0 /* CarriageReturnLineFeed */:
+ case 0 /* NewLineKind.CarriageReturnLineFeed */:
return carriageReturnLineFeed;
- case 1 /* LineFeed */:
+ case 1 /* NewLineKind.LineFeed */:
return lineFeed;
}
return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed;
@@ -19258,8 +19503,8 @@ var ts;
var parseNode = ts.getParseTreeNode(node);
if (parseNode) {
switch (parseNode.parent.kind) {
- case 259 /* EnumDeclaration */:
- case 260 /* ModuleDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
return parseNode === parseNode.parent.name;
}
}
@@ -19283,32 +19528,32 @@ var ts;
}
ts.closeFileWatcher = closeFileWatcher;
function getCheckFlags(symbol) {
- return symbol.flags & 33554432 /* Transient */ ? symbol.checkFlags : 0;
+ return symbol.flags & 33554432 /* SymbolFlags.Transient */ ? symbol.checkFlags : 0;
}
ts.getCheckFlags = getCheckFlags;
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 === 172 /* SetAccessor */; })) || s.valueDeclaration;
+ var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 173 /* SyntaxKind.SetAccessor */; })) || s.valueDeclaration;
var flags = ts.getCombinedModifierFlags(declaration);
- return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */;
+ return s.parent && s.parent.flags & 32 /* SymbolFlags.Class */ ? flags : flags & ~28 /* ModifierFlags.AccessibilityModifier */;
}
- if (getCheckFlags(s) & 6 /* Synthetic */) {
+ if (getCheckFlags(s) & 6 /* CheckFlags.Synthetic */) {
var checkFlags = s.checkFlags;
- var accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 8 /* Private */ :
- checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ :
- 16 /* Protected */;
- var staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 32 /* Static */ : 0;
+ var accessModifier = checkFlags & 1024 /* CheckFlags.ContainsPrivate */ ? 8 /* ModifierFlags.Private */ :
+ checkFlags & 256 /* CheckFlags.ContainsPublic */ ? 4 /* ModifierFlags.Public */ :
+ 16 /* ModifierFlags.Protected */;
+ var staticModifier = checkFlags & 2048 /* CheckFlags.ContainsStatic */ ? 32 /* ModifierFlags.Static */ : 0;
return accessModifier | staticModifier;
}
- if (s.flags & 4194304 /* Prototype */) {
- return 4 /* Public */ | 32 /* Static */;
+ if (s.flags & 4194304 /* SymbolFlags.Prototype */) {
+ return 4 /* ModifierFlags.Public */ | 32 /* ModifierFlags.Static */;
}
return 0;
}
ts.getDeclarationModifierFlagsFromSymbol = getDeclarationModifierFlagsFromSymbol;
function skipAlias(symbol, checker) {
- return symbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(symbol) : symbol;
+ return symbol.flags & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(symbol) : symbol;
}
ts.skipAlias = skipAlias;
/** See comment on `declareModuleMember` in `binder.ts`. */
@@ -19317,11 +19562,11 @@ var ts;
}
ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags;
function isWriteOnlyAccess(node) {
- return accessKind(node) === 1 /* Write */;
+ return accessKind(node) === 1 /* AccessKind.Write */;
}
ts.isWriteOnlyAccess = isWriteOnlyAccess;
function isWriteAccess(node) {
- return accessKind(node) !== 0 /* Read */;
+ return accessKind(node) !== 0 /* AccessKind.Read */;
}
ts.isWriteAccess = isWriteAccess;
var AccessKind;
@@ -19336,47 +19581,47 @@ var ts;
function accessKind(node) {
var parent = node.parent;
if (!parent)
- return 0 /* Read */;
+ return 0 /* AccessKind.Read */;
switch (parent.kind) {
- case 211 /* ParenthesizedExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
return accessKind(parent);
- case 219 /* PostfixUnaryExpression */:
- case 218 /* PrefixUnaryExpression */:
+ case 220 /* SyntaxKind.PostfixUnaryExpression */:
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
var operator = parent.operator;
- return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */;
- case 220 /* BinaryExpression */:
+ return operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */ ? writeOrReadWrite() : 0 /* AccessKind.Read */;
+ case 221 /* SyntaxKind.BinaryExpression */:
var _a = parent, left = _a.left, operatorToken = _a.operatorToken;
return left === node && isAssignmentOperator(operatorToken.kind) ?
- operatorToken.kind === 63 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite()
- : 0 /* Read */;
- case 205 /* PropertyAccessExpression */:
- return parent.name !== node ? 0 /* Read */ : accessKind(parent);
- case 294 /* PropertyAssignment */: {
+ operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? 1 /* AccessKind.Write */ : writeOrReadWrite()
+ : 0 /* AccessKind.Read */;
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ return parent.name !== node ? 0 /* AccessKind.Read */ : accessKind(parent);
+ case 296 /* SyntaxKind.PropertyAssignment */: {
var parentAccess = accessKind(parent.parent);
// In `({ x: varname }) = { x: 1 }`, the left `x` is a read, the right `x` is a write.
return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess;
}
- case 295 /* ShorthandPropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
// Assume it's the local variable being accessed, since we don't check public properties for --noUnusedLocals.
- return node === parent.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent.parent);
- case 203 /* ArrayLiteralExpression */:
+ return node === parent.objectAssignmentInitializer ? 0 /* AccessKind.Read */ : accessKind(parent.parent);
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
return accessKind(parent);
default:
- return 0 /* Read */;
+ return 0 /* AccessKind.Read */;
}
function writeOrReadWrite() {
// If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect.
- return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 237 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */;
+ return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 238 /* SyntaxKind.ExpressionStatement */ ? 1 /* AccessKind.Write */ : 2 /* AccessKind.ReadWrite */;
}
}
function reverseAccessKind(a) {
switch (a) {
- case 0 /* Read */:
- return 1 /* Write */;
- case 1 /* Write */:
- return 0 /* Read */;
- case 2 /* ReadWrite */:
- return 2 /* ReadWrite */;
+ case 0 /* AccessKind.Read */:
+ return 1 /* AccessKind.Write */;
+ case 1 /* AccessKind.Write */:
+ return 0 /* AccessKind.Read */;
+ case 2 /* AccessKind.ReadWrite */:
+ return 2 /* AccessKind.ReadWrite */;
default:
return ts.Debug.assertNever(a);
}
@@ -19446,9 +19691,9 @@ var ts;
}
ts.mutateMap = mutateMap;
function isAbstractConstructorSymbol(symbol) {
- if (symbol.flags & 32 /* Class */) {
+ if (symbol.flags & 32 /* SymbolFlags.Class */) {
var declaration = getClassLikeDeclarationOfSymbol(symbol);
- return !!declaration && hasSyntacticModifier(declaration, 128 /* Abstract */);
+ return !!declaration && hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */);
}
return false;
}
@@ -19459,11 +19704,11 @@ var ts;
}
ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol;
function getObjectFlags(type) {
- return type.flags & 3899393 /* ObjectFlagsType */ ? type.objectFlags : 0;
+ return type.flags & 3899393 /* TypeFlags.ObjectFlagsType */ ? type.objectFlags : 0;
}
ts.getObjectFlags = getObjectFlags;
function typeHasCallOrConstructSignatures(type, checker) {
- return checker.getSignaturesOfType(type, 0 /* Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* Construct */).length !== 0;
+ return checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length !== 0;
}
ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures;
function forSomeAncestorDirectory(directory, callback) {
@@ -19510,44 +19755,44 @@ var ts;
}
ts.isObjectTypeDeclaration = isObjectTypeDeclaration;
function isTypeNodeKind(kind) {
- return (kind >= 176 /* FirstTypeNode */ && kind <= 199 /* LastTypeNode */)
- || kind === 130 /* AnyKeyword */
- || kind === 154 /* UnknownKeyword */
- || kind === 146 /* NumberKeyword */
- || kind === 157 /* BigIntKeyword */
- || kind === 147 /* ObjectKeyword */
- || kind === 133 /* BooleanKeyword */
- || kind === 149 /* StringKeyword */
- || kind === 150 /* SymbolKeyword */
- || kind === 114 /* VoidKeyword */
- || kind === 152 /* UndefinedKeyword */
- || kind === 143 /* NeverKeyword */
- || kind === 227 /* ExpressionWithTypeArguments */
- || kind === 310 /* JSDocAllType */
- || kind === 311 /* JSDocUnknownType */
- || kind === 312 /* JSDocNullableType */
- || kind === 313 /* JSDocNonNullableType */
- || kind === 314 /* JSDocOptionalType */
- || kind === 315 /* JSDocFunctionType */
- || kind === 316 /* JSDocVariadicType */;
+ return (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */)
+ || kind === 130 /* SyntaxKind.AnyKeyword */
+ || kind === 155 /* SyntaxKind.UnknownKeyword */
+ || kind === 147 /* SyntaxKind.NumberKeyword */
+ || kind === 158 /* SyntaxKind.BigIntKeyword */
+ || kind === 148 /* SyntaxKind.ObjectKeyword */
+ || kind === 133 /* SyntaxKind.BooleanKeyword */
+ || kind === 150 /* SyntaxKind.StringKeyword */
+ || kind === 151 /* SyntaxKind.SymbolKeyword */
+ || kind === 114 /* SyntaxKind.VoidKeyword */
+ || kind === 153 /* SyntaxKind.UndefinedKeyword */
+ || kind === 143 /* SyntaxKind.NeverKeyword */
+ || kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */
+ || kind === 312 /* SyntaxKind.JSDocAllType */
+ || kind === 313 /* SyntaxKind.JSDocUnknownType */
+ || kind === 314 /* SyntaxKind.JSDocNullableType */
+ || kind === 315 /* SyntaxKind.JSDocNonNullableType */
+ || kind === 316 /* SyntaxKind.JSDocOptionalType */
+ || kind === 317 /* SyntaxKind.JSDocFunctionType */
+ || kind === 318 /* SyntaxKind.JSDocVariadicType */;
}
ts.isTypeNodeKind = isTypeNodeKind;
function isAccessExpression(node) {
- return node.kind === 205 /* PropertyAccessExpression */ || node.kind === 206 /* ElementAccessExpression */;
+ return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 207 /* SyntaxKind.ElementAccessExpression */;
}
ts.isAccessExpression = isAccessExpression;
function getNameOfAccessExpression(node) {
- if (node.kind === 205 /* PropertyAccessExpression */) {
+ if (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) {
return node.name;
}
- ts.Debug.assert(node.kind === 206 /* ElementAccessExpression */);
+ ts.Debug.assert(node.kind === 207 /* SyntaxKind.ElementAccessExpression */);
return node.argumentExpression;
}
ts.getNameOfAccessExpression = getNameOfAccessExpression;
function isBundleFileTextLike(section) {
switch (section.kind) {
- case "text" /* Text */:
- case "internal" /* Internal */:
+ case "text" /* BundleFileSectionKind.Text */:
+ case "internal" /* BundleFileSectionKind.Internal */:
return true;
default:
return false;
@@ -19555,7 +19800,7 @@ var ts;
}
ts.isBundleFileTextLike = isBundleFileTextLike;
function isNamedImportsOrExports(node) {
- return node.kind === 268 /* NamedImports */ || node.kind === 272 /* NamedExports */;
+ return node.kind === 269 /* SyntaxKind.NamedImports */ || node.kind === 273 /* SyntaxKind.NamedExports */;
}
ts.isNamedImportsOrExports = isNamedImportsOrExports;
function getLeftmostAccessExpression(expr) {
@@ -19565,31 +19810,66 @@ var ts;
return expr;
}
ts.getLeftmostAccessExpression = getLeftmostAccessExpression;
+ function forEachNameInAccessChainWalkingLeft(name, action) {
+ if (isAccessExpression(name.parent) && isRightSideOfAccessExpression(name)) {
+ return walkAccessExpression(name.parent);
+ }
+ function walkAccessExpression(access) {
+ if (access.kind === 206 /* SyntaxKind.PropertyAccessExpression */) {
+ var res = action(access.name);
+ if (res !== undefined) {
+ return res;
+ }
+ }
+ else if (access.kind === 207 /* SyntaxKind.ElementAccessExpression */) {
+ if (ts.isIdentifier(access.argumentExpression) || ts.isStringLiteralLike(access.argumentExpression)) {
+ var res = action(access.argumentExpression);
+ if (res !== undefined) {
+ return res;
+ }
+ }
+ else {
+ // Chain interrupted by non-static-name access 'x[expr()].y.z'
+ return undefined;
+ }
+ }
+ if (isAccessExpression(access.expression)) {
+ return walkAccessExpression(access.expression);
+ }
+ if (ts.isIdentifier(access.expression)) {
+ // End of chain at Identifier 'x.y.z'
+ return action(access.expression);
+ }
+ // End of chain at non-Identifier 'x().y.z'
+ return undefined;
+ }
+ }
+ ts.forEachNameInAccessChainWalkingLeft = forEachNameInAccessChainWalkingLeft;
function getLeftmostExpression(node, stopAtCallExpressions) {
while (true) {
switch (node.kind) {
- case 219 /* PostfixUnaryExpression */:
+ case 220 /* SyntaxKind.PostfixUnaryExpression */:
node = node.operand;
continue;
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
node = node.left;
continue;
- case 221 /* ConditionalExpression */:
+ case 222 /* SyntaxKind.ConditionalExpression */:
node = node.condition;
continue;
- case 209 /* TaggedTemplateExpression */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
node = node.tag;
continue;
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
if (stopAtCallExpressions) {
return node;
}
// falls through
- case 228 /* AsExpression */:
- case 206 /* ElementAccessExpression */:
- case 205 /* PropertyAccessExpression */:
- case 229 /* NonNullExpression */:
- case 348 /* PartiallyEmittedExpression */:
+ case 229 /* SyntaxKind.AsExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 230 /* SyntaxKind.NonNullExpression */:
+ case 350 /* SyntaxKind.PartiallyEmittedExpression */:
node = node.expression;
continue;
}
@@ -19623,9 +19903,9 @@ var ts;
this.end = end;
this.kind = kind;
this.id = 0;
- this.flags = 0 /* None */;
- this.modifierFlagsCache = 0 /* None */;
- this.transformFlags = 0 /* None */;
+ this.flags = 0 /* NodeFlags.None */;
+ this.modifierFlagsCache = 0 /* ModifierFlags.None */;
+ this.transformFlags = 0 /* TransformFlags.None */;
this.parent = undefined;
this.original = undefined;
}
@@ -19634,8 +19914,8 @@ var ts;
this.end = end;
this.kind = kind;
this.id = 0;
- this.flags = 0 /* None */;
- this.transformFlags = 0 /* None */;
+ this.flags = 0 /* NodeFlags.None */;
+ this.transformFlags = 0 /* TransformFlags.None */;
this.parent = undefined;
}
function Identifier(kind, pos, end) {
@@ -19643,8 +19923,8 @@ var ts;
this.end = end;
this.kind = kind;
this.id = 0;
- this.flags = 0 /* None */;
- this.transformFlags = 0 /* None */;
+ this.flags = 0 /* NodeFlags.None */;
+ this.transformFlags = 0 /* TransformFlags.None */;
this.parent = undefined;
this.original = undefined;
this.flowNode = undefined;
@@ -19839,7 +20119,7 @@ var ts;
function compareDiagnostics(d1, d2) {
return compareDiagnosticsSkipRelatedInformation(d1, d2) ||
compareRelatedInformation(d1, d2) ||
- 0 /* EqualTo */;
+ 0 /* Comparison.EqualTo */;
}
ts.compareDiagnostics = compareDiagnostics;
function compareDiagnosticsSkipRelatedInformation(d1, d2) {
@@ -19848,43 +20128,43 @@ var ts;
ts.compareValues(d1.length, d2.length) ||
ts.compareValues(d1.code, d2.code) ||
compareMessageText(d1.messageText, d2.messageText) ||
- 0 /* EqualTo */;
+ 0 /* Comparison.EqualTo */;
}
ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation;
function compareRelatedInformation(d1, d2) {
if (!d1.relatedInformation && !d2.relatedInformation) {
- return 0 /* EqualTo */;
+ return 0 /* Comparison.EqualTo */;
}
if (d1.relatedInformation && d2.relatedInformation) {
return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) {
var d2i = d2.relatedInformation[index];
return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared
- }) || 0 /* EqualTo */;
+ }) || 0 /* Comparison.EqualTo */;
}
- return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */;
+ return d1.relatedInformation ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */;
}
function compareMessageText(t1, t2) {
if (typeof t1 === "string" && typeof t2 === "string") {
return ts.compareStringsCaseSensitive(t1, t2);
}
else if (typeof t1 === "string") {
- return -1 /* LessThan */;
+ return -1 /* Comparison.LessThan */;
}
else if (typeof t2 === "string") {
- return 1 /* GreaterThan */;
+ return 1 /* Comparison.GreaterThan */;
}
var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText);
if (res) {
return res;
}
if (!t1.next && !t2.next) {
- return 0 /* EqualTo */;
+ return 0 /* Comparison.EqualTo */;
}
if (!t1.next) {
- return -1 /* LessThan */;
+ return -1 /* Comparison.LessThan */;
}
if (!t2.next) {
- return 1 /* GreaterThan */;
+ return 1 /* Comparison.GreaterThan */;
}
var len = Math.min(t1.next.length, t2.next.length);
for (var i = 0; i < len; i++) {
@@ -19894,29 +20174,84 @@ var ts;
}
}
if (t1.next.length < t2.next.length) {
- return -1 /* LessThan */;
+ return -1 /* Comparison.LessThan */;
}
else if (t1.next.length > t2.next.length) {
- return 1 /* GreaterThan */;
+ return 1 /* Comparison.GreaterThan */;
}
- return 0 /* EqualTo */;
+ return 0 /* Comparison.EqualTo */;
}
function getLanguageVariant(scriptKind) {
// .tsx and .jsx files are treated as jsx language variant.
- return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ || scriptKind === 6 /* JSON */ ? 1 /* JSX */ : 0 /* Standard */;
+ return scriptKind === 4 /* ScriptKind.TSX */ || scriptKind === 2 /* ScriptKind.JSX */ || scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 6 /* ScriptKind.JSON */ ? 1 /* LanguageVariant.JSX */ : 0 /* LanguageVariant.Standard */;
}
ts.getLanguageVariant = getLanguageVariant;
+ /**
+ * This is a somewhat unavoidable full tree walk to locate a JSX tag - `import.meta` requires the same,
+ * but we avoid that walk (or parts of it) if at all possible using the `PossiblyContainsImportMeta` node flag.
+ * Unfortunately, there's no `NodeFlag` space to do the same for JSX.
+ */
+ function walkTreeForJSXTags(node) {
+ if (!(node.transformFlags & 2 /* TransformFlags.ContainsJsx */))
+ return undefined;
+ return ts.isJsxOpeningLikeElement(node) || ts.isJsxFragment(node) ? node : ts.forEachChild(node, walkTreeForJSXTags);
+ }
+ function isFileModuleFromUsingJSXTag(file) {
+ // Excludes declaration files - they still require an explicit `export {}` or the like
+ // for back compat purposes. (not that declaration files should contain JSX tags!)
+ return !file.isDeclarationFile ? walkTreeForJSXTags(file) : undefined;
+ }
+ /**
+ * Note that this requires file.impliedNodeFormat be set already; meaning it must be set very early on
+ * in SourceFile construction.
+ */
+ function isFileForcedToBeModuleByFormat(file) {
+ // Excludes declaration files - they still require an explicit `export {}` or the like
+ // for back compat purposes.
+ return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
+ }
+ function getSetExternalModuleIndicator(options) {
+ // TODO: Should this callback be cached?
+ switch (getEmitModuleDetectionKind(options)) {
+ case ts.ModuleDetectionKind.Force:
+ // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
+ return function (file) {
+ file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
+ };
+ case ts.ModuleDetectionKind.Legacy:
+ // Files are modules if they have imports, exports, or import.meta
+ return function (file) {
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file);
+ };
+ case ts.ModuleDetectionKind.Auto:
+ // If module is nodenext or node16, all esm format files are modules
+ // If jsx is react-jsx or react-jsxdev then jsx tags force module-ness
+ // otherwise, the presence of import or export statments (or import.meta) implies module-ness
+ var checks = [ts.isFileProbablyExternalModule];
+ if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) {
+ checks.push(isFileModuleFromUsingJSXTag);
+ }
+ var moduleKind = getEmitModuleKind(options);
+ if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) {
+ 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;
+ }
+ }
+ ts.getSetExternalModuleIndicator = getSetExternalModuleIndicator;
function getEmitScriptTarget(compilerOptions) {
return compilerOptions.target ||
- (compilerOptions.module === ts.ModuleKind.Node12 && 7 /* ES2020 */) ||
- (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ESNext */) ||
- 0 /* ES3 */;
+ (compilerOptions.module === ts.ModuleKind.Node16 && 9 /* ScriptTarget.ES2022 */) ||
+ (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ScriptTarget.ESNext */) ||
+ 0 /* ScriptTarget.ES3 */;
}
ts.getEmitScriptTarget = getEmitScriptTarget;
function getEmitModuleKind(compilerOptions) {
return typeof compilerOptions.module === "number" ?
compilerOptions.module :
- getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS;
+ getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS;
}
ts.getEmitModuleKind = getEmitModuleKind;
function getEmitModuleResolutionKind(compilerOptions) {
@@ -19926,8 +20261,8 @@ var ts;
case ts.ModuleKind.CommonJS:
moduleResolution = ts.ModuleResolutionKind.NodeJs;
break;
- case ts.ModuleKind.Node12:
- moduleResolution = ts.ModuleResolutionKind.Node12;
+ case ts.ModuleKind.Node16:
+ moduleResolution = ts.ModuleResolutionKind.Node16;
break;
case ts.ModuleKind.NodeNext:
moduleResolution = ts.ModuleResolutionKind.NodeNext;
@@ -19940,6 +20275,10 @@ var ts;
return moduleResolution;
}
ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
+ function getEmitModuleDetectionKind(options) {
+ return options.moduleDetection || ts.ModuleDetectionKind.Auto;
+ }
+ ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
function hasJsonModuleEmitEnabled(options) {
switch (getEmitModuleKind(options)) {
case ts.ModuleKind.CommonJS:
@@ -19948,7 +20287,7 @@ var ts;
case ts.ModuleKind.ES2020:
case ts.ModuleKind.ES2022:
case ts.ModuleKind.ESNext:
- case ts.ModuleKind.Node12:
+ case ts.ModuleKind.Node16:
case ts.ModuleKind.NodeNext:
return true;
default:
@@ -19973,7 +20312,7 @@ var ts;
return compilerOptions.esModuleInterop;
}
switch (getEmitModuleKind(compilerOptions)) {
- case ts.ModuleKind.Node12:
+ case ts.ModuleKind.Node16:
case ts.ModuleKind.NodeNext:
return true;
}
@@ -20009,7 +20348,7 @@ var ts;
}
ts.getAllowJSCompilerOption = getAllowJSCompilerOption;
function getUseDefineForClassFields(compilerOptions) {
- return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */ : compilerOptions.useDefineForClassFields;
+ return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ScriptTarget.ES2022 */ : compilerOptions.useDefineForClassFields;
}
ts.getUseDefineForClassFields = getUseDefineForClassFields;
function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) {
@@ -20026,14 +20365,14 @@ var ts;
ts.getCompilerOptionValue = getCompilerOptionValue;
function getJSXTransformEnabled(options) {
var jsx = options.jsx;
- return jsx === 2 /* React */ || jsx === 4 /* ReactJSX */ || jsx === 5 /* ReactJSXDev */;
+ return jsx === 2 /* JsxEmit.React */ || jsx === 4 /* JsxEmit.ReactJSX */ || jsx === 5 /* JsxEmit.ReactJSXDev */;
}
ts.getJSXTransformEnabled = getJSXTransformEnabled;
function getJSXImplicitImportBase(compilerOptions, file) {
var jsxImportSourcePragmas = file === null || file === void 0 ? void 0 : file.pragmas.get("jsximportsource");
var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1] : jsxImportSourcePragmas;
- return compilerOptions.jsx === 4 /* ReactJSX */ ||
- compilerOptions.jsx === 5 /* ReactJSXDev */ ||
+ return compilerOptions.jsx === 4 /* JsxEmit.ReactJSX */ ||
+ compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ ||
compilerOptions.jsxImportSource ||
jsxImportSourcePragma ?
(jsxImportSourcePragma === null || jsxImportSourcePragma === void 0 ? void 0 : jsxImportSourcePragma.arguments.factory) || compilerOptions.jsxImportSource || "react" :
@@ -20041,13 +20380,13 @@ var ts;
}
ts.getJSXImplicitImportBase = getJSXImplicitImportBase;
function getJSXRuntimeImport(base, options) {
- return base ? "".concat(base, "/").concat(options.jsx === 5 /* ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined;
+ return base ? "".concat(base, "/").concat(options.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined;
}
ts.getJSXRuntimeImport = getJSXRuntimeImport;
function hasZeroOrOneAsteriskCharacter(str) {
var seenAsterisk = false;
for (var i = 0; i < str.length; i++) {
- if (str.charCodeAt(i) === 42 /* asterisk */) {
+ if (str.charCodeAt(i) === 42 /* CharacterCodes.asterisk */) {
if (!seenAsterisk) {
seenAsterisk = true;
}
@@ -20146,7 +20485,7 @@ var ts;
function escapeRegExpCharacter(match) {
return "\\" + match;
}
- var wildcardCharCodes = [42 /* asterisk */, 63 /* question */];
+ var wildcardCharCodes = [42 /* CharacterCodes.asterisk */, 63 /* CharacterCodes.question */];
ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"];
var implicitExcludePathRegexPattern = "(?!(".concat(ts.commonPackageFolders.join("|"), ")(/|$))");
var filesMatcher = {
@@ -20250,11 +20589,11 @@ var ts;
// The * and ? wildcards should not match directories or files that start with . if they
// appear first in a component. Dotted directories and files can be included explicitly
// like so: **/.*/.*
- if (component.charCodeAt(0) === 42 /* asterisk */) {
+ if (component.charCodeAt(0) === 42 /* CharacterCodes.asterisk */) {
componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?";
component = component.substr(1);
}
- else if (component.charCodeAt(0) === 63 /* question */) {
+ else if (component.charCodeAt(0) === 63 /* CharacterCodes.question */) {
componentPattern += "[^./]";
component = component.substr(1);
}
@@ -20416,43 +20755,44 @@ var ts;
// If the 'scriptKind' is 'undefined' or 'Unknown' then we attempt
// to get the ScriptKind from the file name. If it cannot be resolved
// from the file name then the default 'TS' script kind is returned.
- return scriptKind || getScriptKindFromFileName(fileName) || 3 /* TS */;
+ return scriptKind || getScriptKindFromFileName(fileName) || 3 /* ScriptKind.TS */;
}
ts.ensureScriptKind = ensureScriptKind;
function getScriptKindFromFileName(fileName) {
var ext = fileName.substr(fileName.lastIndexOf("."));
switch (ext.toLowerCase()) {
- case ".js" /* Js */:
- case ".cjs" /* Cjs */:
- case ".mjs" /* Mjs */:
- return 1 /* JS */;
- case ".jsx" /* Jsx */:
- return 2 /* JSX */;
- case ".ts" /* Ts */:
- case ".cts" /* Cts */:
- case ".mts" /* Mts */:
- return 3 /* TS */;
- case ".tsx" /* Tsx */:
- return 4 /* TSX */;
- case ".json" /* Json */:
- return 6 /* JSON */;
+ case ".js" /* Extension.Js */:
+ case ".cjs" /* Extension.Cjs */:
+ case ".mjs" /* Extension.Mjs */:
+ return 1 /* ScriptKind.JS */;
+ case ".jsx" /* Extension.Jsx */:
+ return 2 /* ScriptKind.JSX */;
+ case ".ts" /* Extension.Ts */:
+ case ".cts" /* Extension.Cts */:
+ case ".mts" /* Extension.Mts */:
+ return 3 /* ScriptKind.TS */;
+ case ".tsx" /* Extension.Tsx */:
+ return 4 /* ScriptKind.TSX */;
+ case ".json" /* Extension.Json */:
+ return 6 /* ScriptKind.JSON */;
default:
- return 0 /* Unknown */;
+ return 0 /* ScriptKind.Unknown */;
}
}
ts.getScriptKindFromFileName = getScriptKindFromFileName;
/**
* Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS)
*/
- ts.supportedTSExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */], [".cts" /* Cts */, ".d.cts" /* Dcts */], [".mts" /* Mts */, ".d.mts" /* Dmts */]];
+ ts.supportedTSExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */]];
ts.supportedTSExtensionsFlat = ts.flatten(ts.supportedTSExtensions);
- var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Json */]], false);
+ var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Extension.Json */]], false);
/** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */
- var supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */, ".cts" /* Cts */, ".mts" /* Mts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".cts" /* Cts */, ".mts" /* Mts */];
- ts.supportedJSExtensions = [[".js" /* Js */, ".jsx" /* Jsx */], [".mjs" /* Mjs */], [".cjs" /* Cjs */]];
+ var supportedTSExtensionsForExtractExtension = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */];
+ ts.supportedJSExtensions = [[".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".mjs" /* Extension.Mjs */], [".cjs" /* Extension.Cjs */]];
ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions);
- var allSupportedExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */, ".js" /* Js */, ".jsx" /* Jsx */], [".cts" /* Cts */, ".d.cts" /* Dcts */, ".cjs" /* Cjs */], [".mts" /* Mts */, ".d.mts" /* Dmts */, ".mjs" /* Mjs */]];
- var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false);
+ var allSupportedExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */]];
+ var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Extension.Json */]], false);
+ ts.supportedDeclarationExtensions = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */];
function getSupportedExtensions(options, extraFileExtensions) {
var needJsExtensions = options && getAllowJSCompilerOption(options);
if (!extraFileExtensions || extraFileExtensions.length === 0) {
@@ -20460,7 +20800,7 @@ var ts;
}
var builtins = needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions;
var flatBuiltins = ts.flatten(builtins);
- var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true);
+ var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* ScriptKind.Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true);
return extensions;
}
ts.getSupportedExtensions = getSupportedExtensions;
@@ -20471,11 +20811,11 @@ var ts;
return allSupportedExtensionsWithJson;
if (supportedExtensions === ts.supportedTSExtensions)
return supportedTSExtensionsWithJson;
- return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Json */]], false);
+ return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Extension.Json */]], false);
}
ts.getSupportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule;
function isJSLike(scriptKind) {
- return scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */;
+ return scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 2 /* ScriptKind.JSX */;
}
function hasJSFileExtension(fileName) {
return ts.some(ts.supportedJSExtensionsFlat, function (extension) { return ts.fileExtensionIs(fileName, extension); });
@@ -20506,7 +20846,7 @@ var ts;
return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2));
}
ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators;
- var extensionsToRemove = [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".mts" /* Mts */, ".cjs" /* Cjs */, ".cts" /* Cts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */, ".json" /* Json */];
+ var extensionsToRemove = [".d.ts" /* Extension.Dts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */, ".ts" /* Extension.Ts */, ".js" /* Extension.Js */, ".tsx" /* Extension.Tsx */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */];
function removeFileExtension(path) {
for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) {
var ext = extensionsToRemove_1[_i];
@@ -20559,11 +20899,11 @@ var ts;
ts.positionIsSynthesized = positionIsSynthesized;
/** True if an extension is one of the supported TypeScript extensions. */
function extensionIsTS(ext) {
- return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */ || ext === ".cts" /* Cts */ || ext === ".mts" /* Mts */ || ext === ".d.mts" /* Dmts */ || ext === ".d.cts" /* Dcts */;
+ return ext === ".ts" /* Extension.Ts */ || ext === ".tsx" /* Extension.Tsx */ || ext === ".d.ts" /* Extension.Dts */ || ext === ".cts" /* Extension.Cts */ || ext === ".mts" /* Extension.Mts */ || ext === ".d.mts" /* Extension.Dmts */ || ext === ".d.cts" /* Extension.Dcts */;
}
ts.extensionIsTS = extensionIsTS;
function resolutionExtensionIsTSOrJson(ext) {
- return extensionIsTS(ext) || ext === ".json" /* Json */;
+ return extensionIsTS(ext) || ext === ".json" /* Extension.Json */;
}
ts.resolutionExtensionIsTSOrJson = resolutionExtensionIsTSOrJson;
/**
@@ -20681,23 +21021,23 @@ var ts;
function parsePseudoBigInt(stringValue) {
var log2Base;
switch (stringValue.charCodeAt(1)) { // "x" in "0x123"
- case 98 /* b */:
- case 66 /* B */: // 0b or 0B
+ case 98 /* CharacterCodes.b */:
+ case 66 /* CharacterCodes.B */: // 0b or 0B
log2Base = 1;
break;
- case 111 /* o */:
- case 79 /* O */: // 0o or 0O
+ case 111 /* CharacterCodes.o */:
+ case 79 /* CharacterCodes.O */: // 0o or 0O
log2Base = 3;
break;
- case 120 /* x */:
- case 88 /* X */: // 0x or 0X
+ case 120 /* CharacterCodes.x */:
+ case 88 /* CharacterCodes.X */: // 0x or 0X
log2Base = 4;
break;
default: // already in decimal; omit trailing "n"
var nIndex = stringValue.length - 1;
// Skip leading 0s
var nonZeroStart = 0;
- while (stringValue.charCodeAt(nonZeroStart) === 48 /* _0 */) {
+ while (stringValue.charCodeAt(nonZeroStart) === 48 /* CharacterCodes._0 */) {
nonZeroStart++;
}
return stringValue.slice(nonZeroStart, nIndex) || "0";
@@ -20713,10 +21053,10 @@ var ts;
var segment = bitOffset >>> 4;
var digitChar = stringValue.charCodeAt(i);
// Find character range: 0-9 < A-F < a-f
- var digit = digitChar <= 57 /* _9 */
- ? digitChar - 48 /* _0 */
+ var digit = digitChar <= 57 /* CharacterCodes._9 */
+ ? digitChar - 48 /* CharacterCodes._0 */
: 10 + digitChar -
- (digitChar <= 70 /* F */ ? 65 /* A */ : 97 /* a */);
+ (digitChar <= 70 /* CharacterCodes.F */ ? 65 /* CharacterCodes.A */ : 97 /* CharacterCodes.a */);
var shiftedDigit = digit << (bitOffset & 15);
segments[segment] |= shiftedDigit;
var residual = shiftedDigit >>> 16;
@@ -20751,7 +21091,7 @@ var ts;
}
ts.pseudoBigIntToString = pseudoBigIntToString;
function isValidTypeOnlyAliasUseSite(useSite) {
- return !!(useSite.flags & 8388608 /* Ambient */)
+ return !!(useSite.flags & 16777216 /* NodeFlags.Ambient */)
|| isPartOfTypeQuery(useSite)
|| isIdentifierInNonEmittingHeritageClause(useSite)
|| isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite)
@@ -20762,34 +21102,34 @@ var ts;
return ts.isIdentifier(useSite) && ts.isShorthandPropertyAssignment(useSite.parent) && useSite.parent.name === useSite;
}
function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) {
- while (node.kind === 79 /* Identifier */ || node.kind === 205 /* PropertyAccessExpression */) {
+ while (node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) {
node = node.parent;
}
- if (node.kind !== 161 /* ComputedPropertyName */) {
+ if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) {
return false;
}
- if (hasSyntacticModifier(node.parent, 128 /* Abstract */)) {
+ if (hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */)) {
return true;
}
var containerKind = node.parent.parent.kind;
- return containerKind === 257 /* InterfaceDeclaration */ || containerKind === 181 /* TypeLiteral */;
+ return containerKind === 258 /* SyntaxKind.InterfaceDeclaration */ || containerKind === 182 /* SyntaxKind.TypeLiteral */;
}
/** Returns true for an identifier in 1) an `implements` clause, and 2) an `extends` clause of an interface. */
function isIdentifierInNonEmittingHeritageClause(node) {
- if (node.kind !== 79 /* Identifier */)
+ if (node.kind !== 79 /* SyntaxKind.Identifier */)
return false;
var heritageClause = ts.findAncestor(node.parent, function (parent) {
switch (parent.kind) {
- case 290 /* HeritageClause */:
+ case 291 /* SyntaxKind.HeritageClause */:
return true;
- case 205 /* PropertyAccessExpression */:
- case 227 /* ExpressionWithTypeArguments */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
return false;
default:
return "quit";
}
});
- return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 257 /* InterfaceDeclaration */;
+ return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* SyntaxKind.ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 258 /* SyntaxKind.InterfaceDeclaration */;
}
function isIdentifierTypeReference(node) {
return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName);
@@ -20930,7 +21270,7 @@ var ts;
node = parent;
continue;
}
- if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* CommaToken */) {
+ if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) {
// left side of comma is always unused
if (node === parent.left)
return true;
@@ -20950,18 +21290,18 @@ var ts;
if (!node.parent)
return undefined;
switch (node.kind) {
- case 162 /* TypeParameter */:
+ case 163 /* SyntaxKind.TypeParameter */:
var parent_1 = node.parent;
- return parent_1.kind === 189 /* InferType */ ? undefined : parent_1.typeParameters;
- case 163 /* Parameter */:
+ return parent_1.kind === 190 /* SyntaxKind.InferType */ ? undefined : parent_1.typeParameters;
+ case 164 /* SyntaxKind.Parameter */:
return node.parent.parameters;
- case 198 /* TemplateLiteralTypeSpan */:
+ case 199 /* SyntaxKind.TemplateLiteralTypeSpan */:
return node.parent.templateSpans;
- case 232 /* TemplateSpan */:
+ case 233 /* SyntaxKind.TemplateSpan */:
return node.parent.templateSpans;
- case 164 /* Decorator */:
+ case 165 /* SyntaxKind.Decorator */:
return node.parent.decorators;
- case 290 /* HeritageClause */:
+ case 291 /* SyntaxKind.HeritageClause */:
return node.parent.heritageClauses;
}
var parent = node.parent;
@@ -20969,45 +21309,45 @@ var ts;
return ts.isJSDocTypeLiteral(node.parent) ? undefined : node.parent.tags;
}
switch (parent.kind) {
- case 181 /* TypeLiteral */:
- case 257 /* InterfaceDeclaration */:
+ case 182 /* SyntaxKind.TypeLiteral */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
return ts.isTypeElement(node) ? parent.members : undefined;
- case 186 /* UnionType */:
- case 187 /* IntersectionType */:
+ case 187 /* SyntaxKind.UnionType */:
+ case 188 /* SyntaxKind.IntersectionType */:
return parent.types;
- case 183 /* TupleType */:
- case 203 /* ArrayLiteralExpression */:
- case 349 /* CommaListExpression */:
- case 268 /* NamedImports */:
- case 272 /* NamedExports */:
+ case 184 /* SyntaxKind.TupleType */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
+ case 351 /* SyntaxKind.CommaListExpression */:
+ case 269 /* SyntaxKind.NamedImports */:
+ case 273 /* SyntaxKind.NamedExports */:
return parent.elements;
- case 204 /* ObjectLiteralExpression */:
- case 285 /* JsxAttributes */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
+ case 286 /* SyntaxKind.JsxAttributes */:
return parent.properties;
- case 207 /* CallExpression */:
- case 208 /* NewExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
return ts.isTypeNode(node) ? parent.typeArguments :
parent.expression === node ? undefined :
parent.arguments;
- case 277 /* JsxElement */:
- case 281 /* JsxFragment */:
+ case 278 /* SyntaxKind.JsxElement */:
+ case 282 /* SyntaxKind.JsxFragment */:
return ts.isJsxChild(node) ? parent.children : undefined;
- case 279 /* JsxOpeningElement */:
- case 278 /* JsxSelfClosingElement */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
return ts.isTypeNode(node) ? parent.typeArguments : undefined;
- case 234 /* Block */:
- case 288 /* CaseClause */:
- case 289 /* DefaultClause */:
- case 261 /* ModuleBlock */:
+ case 235 /* SyntaxKind.Block */:
+ case 289 /* SyntaxKind.CaseClause */:
+ case 290 /* SyntaxKind.DefaultClause */:
+ case 262 /* SyntaxKind.ModuleBlock */:
return parent.statements;
- case 262 /* CaseBlock */:
+ case 263 /* SyntaxKind.CaseBlock */:
return parent.clauses;
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
return ts.isClassElement(node) ? parent.members : undefined;
- case 259 /* EnumDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
return ts.isEnumMember(node) ? parent.members : undefined;
- case 303 /* SourceFile */:
+ case 305 /* SyntaxKind.SourceFile */:
return parent.statements;
}
}
@@ -21019,7 +21359,7 @@ var ts;
if (ts.some(node.parameters, function (p) { return !getEffectiveTypeAnnotationNode(p); })) {
return true;
}
- if (node.kind !== 213 /* ArrowFunction */) {
+ if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) {
// If the first parameter is not an explicit 'this' parameter, then the function has
// an implicit 'this' parameter which is subject to contextual typing.
var parameter = ts.firstOrUndefined(node.parameters);
@@ -21037,7 +21377,7 @@ var ts;
}
ts.isInfinityOrNaNString = isInfinityOrNaNString;
function isCatchClauseVariableDeclaration(node) {
- return node.kind === 253 /* VariableDeclaration */ && node.parent.kind === 291 /* CatchClause */;
+ return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */;
}
ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration;
function isParameterOrCatchClauseVariable(symbol) {
@@ -21046,7 +21386,7 @@ var ts;
}
ts.isParameterOrCatchClauseVariable = isParameterOrCatchClauseVariable;
function isFunctionExpressionOrArrowFunction(node) {
- return node.kind === 212 /* FunctionExpression */ || node.kind === 213 /* ArrowFunction */;
+ return node.kind === 213 /* SyntaxKind.FunctionExpression */ || node.kind === 214 /* SyntaxKind.ArrowFunction */;
}
ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction;
function escapeSnippetText(text) {
@@ -21085,7 +21425,7 @@ var ts;
}
ts.createPropertyNameNodeForIdentifierOrLiteral = createPropertyNameNodeForIdentifierOrLiteral;
function isThisTypeParameter(type) {
- return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
+ return !!(type.flags & 262144 /* TypeFlags.TypeParameter */ && type.isThisType);
}
ts.isThisTypeParameter = isThisTypeParameter;
function getNodeModulePathParts(fullPath) {
@@ -21105,42 +21445,47 @@ var ts;
})(States || (States = {}));
var partStart = 0;
var partEnd = 0;
- var state = 0 /* BeforeNodeModules */;
+ var state = 0 /* States.BeforeNodeModules */;
while (partEnd >= 0) {
partStart = partEnd;
partEnd = fullPath.indexOf("/", partStart + 1);
switch (state) {
- case 0 /* BeforeNodeModules */:
+ case 0 /* States.BeforeNodeModules */:
if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
topLevelNodeModulesIndex = partStart;
topLevelPackageNameIndex = partEnd;
- state = 1 /* NodeModules */;
+ state = 1 /* States.NodeModules */;
}
break;
- case 1 /* NodeModules */:
- case 2 /* Scope */:
- if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") {
- state = 2 /* Scope */;
+ case 1 /* States.NodeModules */:
+ case 2 /* States.Scope */:
+ if (state === 1 /* States.NodeModules */ && fullPath.charAt(partStart + 1) === "@") {
+ state = 2 /* States.Scope */;
}
else {
packageRootIndex = partEnd;
- state = 3 /* PackageContent */;
+ state = 3 /* States.PackageContent */;
}
break;
- case 3 /* PackageContent */:
+ case 3 /* States.PackageContent */:
if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
- state = 1 /* NodeModules */;
+ state = 1 /* States.NodeModules */;
}
else {
- state = 3 /* PackageContent */;
+ state = 3 /* States.PackageContent */;
}
break;
}
}
fileNameIndex = partStart;
- return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
+ return state > 1 /* States.NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
}
ts.getNodeModulePathParts = getNodeModulePathParts;
+ function getParameterTypeNode(parameter) {
+ var _a;
+ return parameter.kind === 340 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type;
+ }
+ ts.getParameterTypeNode = getParameterTypeNode;
})(ts || (ts = {}));
/* @internal */
var ts;
@@ -21204,11 +21549,20 @@ var ts;
parenthesizeExpressionForDisallowedComma: parenthesizeExpressionForDisallowedComma,
parenthesizeExpressionOfExpressionStatement: parenthesizeExpressionOfExpressionStatement,
parenthesizeConciseBodyOfArrowFunction: parenthesizeConciseBodyOfArrowFunction,
- parenthesizeMemberOfConditionalType: parenthesizeMemberOfConditionalType,
- parenthesizeMemberOfElementType: parenthesizeMemberOfElementType,
- parenthesizeElementTypeOfArrayType: parenthesizeElementTypeOfArrayType,
- parenthesizeConstituentTypesOfUnionOrIntersectionType: parenthesizeConstituentTypesOfUnionOrIntersectionType,
+ parenthesizeCheckTypeOfConditionalType: parenthesizeCheckTypeOfConditionalType,
+ parenthesizeExtendsTypeOfConditionalType: parenthesizeExtendsTypeOfConditionalType,
+ parenthesizeConstituentTypesOfUnionType: parenthesizeConstituentTypesOfUnionType,
+ parenthesizeConstituentTypeOfUnionType: parenthesizeConstituentTypeOfUnionType,
+ parenthesizeConstituentTypesOfIntersectionType: parenthesizeConstituentTypesOfIntersectionType,
+ parenthesizeConstituentTypeOfIntersectionType: parenthesizeConstituentTypeOfIntersectionType,
+ parenthesizeOperandOfTypeOperator: parenthesizeOperandOfTypeOperator,
+ parenthesizeOperandOfReadonlyTypeOperator: parenthesizeOperandOfReadonlyTypeOperator,
+ parenthesizeNonArrayTypeOfPostfixType: parenthesizeNonArrayTypeOfPostfixType,
+ parenthesizeElementTypesOfTupleType: parenthesizeElementTypesOfTupleType,
+ parenthesizeElementTypeOfTupleType: parenthesizeElementTypeOfTupleType,
+ parenthesizeTypeOfOptionalType: parenthesizeTypeOfOptionalType,
parenthesizeTypeArguments: parenthesizeTypeArguments,
+ parenthesizeLeadingTypeArgument: parenthesizeLeadingTypeArgument,
};
function getParenthesizeLeftSideOfBinaryForOperator(operatorKind) {
binaryLeftOperandParenthesizerCache || (binaryLeftOperandParenthesizerCache = new ts.Map());
@@ -21254,28 +21608,28 @@ var ts;
//
// If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve
// the intended order of operations: `(a ** b) ** c`
- var binaryOperatorPrecedence = ts.getOperatorPrecedence(220 /* BinaryExpression */, binaryOperator);
- var binaryOperatorAssociativity = ts.getOperatorAssociativity(220 /* BinaryExpression */, binaryOperator);
+ var binaryOperatorPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, binaryOperator);
+ var binaryOperatorAssociativity = ts.getOperatorAssociativity(221 /* SyntaxKind.BinaryExpression */, binaryOperator);
var emittedOperand = ts.skipPartiallyEmittedExpressions(operand);
- if (!isLeftSideOfBinary && operand.kind === 213 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) {
+ if (!isLeftSideOfBinary && operand.kind === 214 /* SyntaxKind.ArrowFunction */ && binaryOperatorPrecedence > 3 /* OperatorPrecedence.Assignment */) {
// We need to parenthesize arrow functions on the right side to avoid it being
// parsed as parenthesized expression: `a && (() => {})`
return true;
}
var operandPrecedence = ts.getExpressionPrecedence(emittedOperand);
switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) {
- case -1 /* LessThan */:
+ case -1 /* Comparison.LessThan */:
// If the operand is the right side of a right-associative binary operation
// and is a yield expression, then we do not need parentheses.
if (!isLeftSideOfBinary
- && binaryOperatorAssociativity === 1 /* Right */
- && operand.kind === 223 /* YieldExpression */) {
+ && binaryOperatorAssociativity === 1 /* Associativity.Right */
+ && operand.kind === 224 /* SyntaxKind.YieldExpression */) {
return false;
}
return true;
- case 1 /* GreaterThan */:
+ case 1 /* Comparison.GreaterThan */:
return false;
- case 0 /* EqualTo */:
+ case 0 /* Comparison.EqualTo */:
if (isLeftSideOfBinary) {
// No need to parenthesize the left operand when the binary operator is
// left associative:
@@ -21286,7 +21640,7 @@ var ts;
// right associative:
// (a/b)**x -> (a/b)**x
// (a**b)**x -> (a**b)**x
- return binaryOperatorAssociativity === 1 /* Right */;
+ return binaryOperatorAssociativity === 1 /* Associativity.Right */;
}
else {
if (ts.isBinaryExpression(emittedOperand)
@@ -21306,8 +21660,8 @@ var ts;
// the same kind (recursively).
// "a"+(1+2) => "a"+(1+2)
// "a"+("b"+"c") => "a"+"b"+"c"
- if (binaryOperator === 39 /* PlusToken */) {
- var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */;
+ if (binaryOperator === 39 /* SyntaxKind.PlusToken */) {
+ var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* SyntaxKind.Unknown */;
if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) {
return false;
}
@@ -21323,7 +21677,7 @@ var ts;
// x/(a*b) -> x/(a*b)
// x**(a/b) -> x**(a/b)
var operandAssociativity = ts.getExpressionAssociativity(emittedOperand);
- return operandAssociativity === 0 /* Left */;
+ return operandAssociativity === 0 /* Associativity.Left */;
}
}
}
@@ -21341,10 +21695,10 @@ var ts;
//
// While addition is associative in mathematics, JavaScript's `+` is not
// guaranteed to be associative as it is overloaded with string concatenation.
- return binaryOperator === 41 /* AsteriskToken */
- || binaryOperator === 51 /* BarToken */
- || binaryOperator === 50 /* AmpersandToken */
- || binaryOperator === 52 /* CaretToken */;
+ return binaryOperator === 41 /* SyntaxKind.AsteriskToken */
+ || binaryOperator === 51 /* SyntaxKind.BarToken */
+ || binaryOperator === 50 /* SyntaxKind.AmpersandToken */
+ || binaryOperator === 52 /* SyntaxKind.CaretToken */;
}
/**
* This function determines whether an expression consists of a homogeneous set of
@@ -21357,7 +21711,7 @@ var ts;
if (ts.isLiteralKind(node.kind)) {
return node.kind;
}
- if (node.kind === 220 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) {
+ if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) {
if (node.cachedLiteralKind !== undefined) {
return node.cachedLiteralKind;
}
@@ -21365,11 +21719,11 @@ var ts;
var literalKind = ts.isLiteralKind(leftKind)
&& leftKind === getLiteralKindOfBinaryPlusOperand(node.right)
? leftKind
- : 0 /* Unknown */;
+ : 0 /* SyntaxKind.Unknown */;
node.cachedLiteralKind = literalKind;
return literalKind;
}
- return 0 /* Unknown */;
+ return 0 /* SyntaxKind.Unknown */;
}
/**
* Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended
@@ -21383,7 +21737,7 @@ var ts;
function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) {
var skipped = ts.skipPartiallyEmittedExpressions(operand);
// If the resulting expression is already parenthesized, we do not need to do any further processing.
- if (skipped.kind === 211 /* ParenthesizedExpression */) {
+ if (skipped.kind === 212 /* SyntaxKind.ParenthesizedExpression */) {
return operand;
}
return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand)
@@ -21400,10 +21754,10 @@ var ts;
return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression;
}
function parenthesizeConditionOfConditionalExpression(condition) {
- var conditionalPrecedence = ts.getOperatorPrecedence(221 /* ConditionalExpression */, 57 /* QuestionToken */);
+ var conditionalPrecedence = ts.getOperatorPrecedence(222 /* SyntaxKind.ConditionalExpression */, 57 /* SyntaxKind.QuestionToken */);
var emittedCondition = ts.skipPartiallyEmittedExpressions(condition);
var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition);
- if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) {
+ if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* Comparison.GreaterThan */) {
return factory.createParenthesizedExpression(condition);
}
return condition;
@@ -21433,8 +21787,8 @@ var ts;
var needsParens = ts.isCommaSequence(check);
if (!needsParens) {
switch (ts.getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) {
- case 225 /* ClassExpression */:
- case 212 /* FunctionExpression */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 213 /* SyntaxKind.FunctionExpression */:
needsParens = true;
}
}
@@ -21447,9 +21801,9 @@ var ts;
function parenthesizeExpressionOfNew(expression) {
var leftmostExpr = ts.getLeftmostExpression(expression, /*stopAtCallExpressions*/ true);
switch (leftmostExpr.kind) {
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
return factory.createParenthesizedExpression(expression);
- case 208 /* NewExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
return !leftmostExpr.arguments
? factory.createParenthesizedExpression(expression)
: expression; // TODO(rbuckton): Verify this assertion holds
@@ -21469,7 +21823,7 @@ var ts;
//
var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
if (ts.isLeftHandSideExpression(emittedExpression)
- && (emittedExpression.kind !== 208 /* NewExpression */ || emittedExpression.arguments)) {
+ && (emittedExpression.kind !== 209 /* SyntaxKind.NewExpression */ || emittedExpression.arguments)) {
// TODO(rbuckton): Verify whether this assertion holds.
return expression;
}
@@ -21491,7 +21845,7 @@ var ts;
function parenthesizeExpressionForDisallowedComma(expression) {
var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression);
- var commaPrecedence = ts.getOperatorPrecedence(220 /* BinaryExpression */, 27 /* CommaToken */);
+ var commaPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, 27 /* SyntaxKind.CommaToken */);
// TODO(rbuckton): Verifiy whether `setTextRange` is needed.
return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression);
}
@@ -21500,53 +21854,211 @@ var ts;
if (ts.isCallExpression(emittedExpression)) {
var callee = emittedExpression.expression;
var kind = ts.skipPartiallyEmittedExpressions(callee).kind;
- if (kind === 212 /* FunctionExpression */ || kind === 213 /* ArrowFunction */) {
+ if (kind === 213 /* SyntaxKind.FunctionExpression */ || kind === 214 /* SyntaxKind.ArrowFunction */) {
// TODO(rbuckton): Verifiy whether `setTextRange` is needed.
var updated = factory.updateCallExpression(emittedExpression, ts.setTextRange(factory.createParenthesizedExpression(callee), callee), emittedExpression.typeArguments, emittedExpression.arguments);
- return factory.restoreOuterExpressions(expression, updated, 8 /* PartiallyEmittedExpressions */);
+ return factory.restoreOuterExpressions(expression, updated, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */);
}
}
var leftmostExpressionKind = ts.getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind;
- if (leftmostExpressionKind === 204 /* ObjectLiteralExpression */ || leftmostExpressionKind === 212 /* FunctionExpression */) {
+ if (leftmostExpressionKind === 205 /* SyntaxKind.ObjectLiteralExpression */ || leftmostExpressionKind === 213 /* SyntaxKind.FunctionExpression */) {
// TODO(rbuckton): Verifiy whether `setTextRange` is needed.
return ts.setTextRange(factory.createParenthesizedExpression(expression), expression);
}
return expression;
}
function parenthesizeConciseBodyOfArrowFunction(body) {
- if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 204 /* ObjectLiteralExpression */)) {
+ if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) {
// TODO(rbuckton): Verifiy whether `setTextRange` is needed.
return ts.setTextRange(factory.createParenthesizedExpression(body), body);
}
return body;
}
- function parenthesizeMemberOfConditionalType(member) {
- return member.kind === 188 /* ConditionalType */ ? factory.createParenthesizedType(member) : member;
- }
- function parenthesizeMemberOfElementType(member) {
- switch (member.kind) {
- case 186 /* UnionType */:
- case 187 /* IntersectionType */:
- case 178 /* FunctionType */:
- case 179 /* ConstructorType */:
- return factory.createParenthesizedType(member);
+ // Type[Extends] :
+ // FunctionOrConstructorType
+ // ConditionalType[?Extends]
+ // ConditionalType[Extends] :
+ // UnionType[?Extends]
+ // [~Extends] UnionType[~Extends] `extends` Type[+Extends] `?` Type[~Extends] `:` Type[~Extends]
+ //
+ // - The check type (the `UnionType`, above) does not allow function, constructor, or conditional types (they must be parenthesized)
+ // - The extends type (the first `Type`, above) does not allow conditional types (they must be parenthesized). Function and constructor types are fine.
+ // - The true and false branch types (the second and third `Type` non-terminals, above) allow any type
+ function parenthesizeCheckTypeOfConditionalType(checkType) {
+ switch (checkType.kind) {
+ case 179 /* SyntaxKind.FunctionType */:
+ case 180 /* SyntaxKind.ConstructorType */:
+ case 189 /* SyntaxKind.ConditionalType */:
+ return factory.createParenthesizedType(checkType);
+ }
+ return checkType;
+ }
+ function parenthesizeExtendsTypeOfConditionalType(extendsType) {
+ switch (extendsType.kind) {
+ case 189 /* SyntaxKind.ConditionalType */:
+ return factory.createParenthesizedType(extendsType);
+ }
+ return extendsType;
+ }
+ // UnionType[Extends] :
+ // `|`? IntersectionType[?Extends]
+ // UnionType[?Extends] `|` IntersectionType[?Extends]
+ //
+ // - A union type constituent has the same precedence as the check type of a conditional type
+ function parenthesizeConstituentTypeOfUnionType(type) {
+ switch (type.kind) {
+ case 187 /* SyntaxKind.UnionType */: // Not strictly necessary, but a union containing a union should have been flattened
+ case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests
+ return factory.createParenthesizedType(type);
}
- return parenthesizeMemberOfConditionalType(member);
+ return parenthesizeCheckTypeOfConditionalType(type);
}
- function parenthesizeElementTypeOfArrayType(member) {
- switch (member.kind) {
- case 180 /* TypeQuery */:
- case 192 /* TypeOperator */:
- case 189 /* InferType */:
- return factory.createParenthesizedType(member);
- }
- return parenthesizeMemberOfElementType(member);
+ function parenthesizeConstituentTypesOfUnionType(members) {
+ return factory.createNodeArray(ts.sameMap(members, parenthesizeConstituentTypeOfUnionType));
+ }
+ // IntersectionType[Extends] :
+ // `&`? TypeOperator[?Extends]
+ // IntersectionType[?Extends] `&` TypeOperator[?Extends]
+ //
+ // - An intersection type constituent does not allow function, constructor, conditional, or union types (they must be parenthesized)
+ function parenthesizeConstituentTypeOfIntersectionType(type) {
+ switch (type.kind) {
+ case 187 /* SyntaxKind.UnionType */:
+ case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened
+ return factory.createParenthesizedType(type);
+ }
+ return parenthesizeConstituentTypeOfUnionType(type);
+ }
+ function parenthesizeConstituentTypesOfIntersectionType(members) {
+ return factory.createNodeArray(ts.sameMap(members, parenthesizeConstituentTypeOfIntersectionType));
+ }
+ // TypeOperator[Extends] :
+ // PostfixType
+ // InferType[?Extends]
+ // `keyof` TypeOperator[?Extends]
+ // `unique` TypeOperator[?Extends]
+ // `readonly` TypeOperator[?Extends]
+ //
+ function parenthesizeOperandOfTypeOperator(type) {
+ switch (type.kind) {
+ case 188 /* SyntaxKind.IntersectionType */:
+ return factory.createParenthesizedType(type);
+ }
+ return parenthesizeConstituentTypeOfIntersectionType(type);
+ }
+ function parenthesizeOperandOfReadonlyTypeOperator(type) {
+ switch (type.kind) {
+ case 193 /* SyntaxKind.TypeOperator */:
+ return factory.createParenthesizedType(type);
+ }
+ return parenthesizeOperandOfTypeOperator(type);
+ }
+ // PostfixType :
+ // NonArrayType
+ // NonArrayType [no LineTerminator here] `!` // JSDoc
+ // NonArrayType [no LineTerminator here] `?` // JSDoc
+ // IndexedAccessType
+ // ArrayType
+ //
+ // IndexedAccessType :
+ // NonArrayType `[` Type[~Extends] `]`
+ //
+ // ArrayType :
+ // NonArrayType `[` `]`
+ //
+ function parenthesizeNonArrayTypeOfPostfixType(type) {
+ switch (type.kind) {
+ case 190 /* SyntaxKind.InferType */:
+ case 193 /* SyntaxKind.TypeOperator */:
+ case 181 /* SyntaxKind.TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests
+ return factory.createParenthesizedType(type);
+ }
+ return parenthesizeOperandOfTypeOperator(type);
+ }
+ // TupleType :
+ // `[` Elision? `]`
+ // `[` NamedTupleElementTypes `]`
+ // `[` NamedTupleElementTypes `,` Elision? `]`
+ // `[` TupleElementTypes `]`
+ // `[` TupleElementTypes `,` Elision? `]`
+ //
+ // NamedTupleElementTypes :
+ // Elision? NamedTupleMember
+ // NamedTupleElementTypes `,` Elision? NamedTupleMember
+ //
+ // NamedTupleMember :
+ // Identifier `?`? `:` Type[~Extends]
+ // `...` Identifier `:` Type[~Extends]
+ //
+ // TupleElementTypes :
+ // Elision? TupleElementType
+ // TupleElementTypes `,` Elision? TupleElementType
+ //
+ // TupleElementType :
+ // Type[~Extends] // NOTE: Needs cover grammar to disallow JSDoc postfix-optional
+ // OptionalType
+ // RestType
+ //
+ // OptionalType :
+ // Type[~Extends] `?` // NOTE: Needs cover grammar to disallow JSDoc postfix-optional
+ //
+ // RestType :
+ // `...` Type[~Extends]
+ //
+ function parenthesizeElementTypesOfTupleType(types) {
+ return factory.createNodeArray(ts.sameMap(types, parenthesizeElementTypeOfTupleType));
+ }
+ function parenthesizeElementTypeOfTupleType(type) {
+ if (hasJSDocPostfixQuestion(type))
+ return factory.createParenthesizedType(type);
+ return type;
}
- function parenthesizeConstituentTypesOfUnionOrIntersectionType(members) {
- return factory.createNodeArray(ts.sameMap(members, parenthesizeMemberOfElementType));
+ function hasJSDocPostfixQuestion(type) {
+ if (ts.isJSDocNullableType(type))
+ return type.postfix;
+ if (ts.isNamedTupleMember(type))
+ return hasJSDocPostfixQuestion(type.type);
+ if (ts.isFunctionTypeNode(type) || ts.isConstructorTypeNode(type) || ts.isTypeOperatorNode(type))
+ return hasJSDocPostfixQuestion(type.type);
+ if (ts.isConditionalTypeNode(type))
+ return hasJSDocPostfixQuestion(type.falseType);
+ if (ts.isUnionTypeNode(type))
+ return hasJSDocPostfixQuestion(ts.last(type.types));
+ if (ts.isIntersectionTypeNode(type))
+ return hasJSDocPostfixQuestion(ts.last(type.types));
+ if (ts.isInferTypeNode(type))
+ return !!type.typeParameter.constraint && hasJSDocPostfixQuestion(type.typeParameter.constraint);
+ return false;
+ }
+ function parenthesizeTypeOfOptionalType(type) {
+ if (hasJSDocPostfixQuestion(type))
+ return factory.createParenthesizedType(type);
+ return parenthesizeNonArrayTypeOfPostfixType(type);
+ }
+ // function parenthesizeMemberOfElementType(member: TypeNode): TypeNode {
+ // switch (member.kind) {
+ // case SyntaxKind.UnionType:
+ // case SyntaxKind.IntersectionType:
+ // case SyntaxKind.FunctionType:
+ // case SyntaxKind.ConstructorType:
+ // return factory.createParenthesizedType(member);
+ // }
+ // return parenthesizeMemberOfConditionalType(member);
+ // }
+ // function parenthesizeElementTypeOfArrayType(member: TypeNode): TypeNode {
+ // switch (member.kind) {
+ // case SyntaxKind.TypeQuery:
+ // case SyntaxKind.TypeOperator:
+ // case SyntaxKind.InferType:
+ // return factory.createParenthesizedType(member);
+ // }
+ // return parenthesizeMemberOfElementType(member);
+ // }
+ function parenthesizeLeadingTypeArgument(node) {
+ return ts.isFunctionOrConstructorTypeNode(node) && node.typeParameters ? factory.createParenthesizedType(node) : node;
}
function parenthesizeOrdinalTypeArgument(node, i) {
- return i === 0 && ts.isFunctionOrConstructorTypeNode(node) && node.typeParameters ? factory.createParenthesizedType(node) : node;
+ return i === 0 ? parenthesizeLeadingTypeArgument(node) : node;
}
function parenthesizeTypeArguments(typeArguments) {
if (ts.some(typeArguments)) {
@@ -21572,11 +22084,20 @@ var ts;
parenthesizeExpressionForDisallowedComma: ts.identity,
parenthesizeExpressionOfExpressionStatement: ts.identity,
parenthesizeConciseBodyOfArrowFunction: ts.identity,
- parenthesizeMemberOfConditionalType: ts.identity,
- parenthesizeMemberOfElementType: ts.identity,
- parenthesizeElementTypeOfArrayType: ts.identity,
- parenthesizeConstituentTypesOfUnionOrIntersectionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
+ parenthesizeCheckTypeOfConditionalType: ts.identity,
+ parenthesizeExtendsTypeOfConditionalType: ts.identity,
+ parenthesizeConstituentTypesOfUnionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
+ parenthesizeConstituentTypeOfUnionType: ts.identity,
+ parenthesizeConstituentTypesOfIntersectionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
+ parenthesizeConstituentTypeOfIntersectionType: ts.identity,
+ parenthesizeOperandOfTypeOperator: ts.identity,
+ parenthesizeOperandOfReadonlyTypeOperator: ts.identity,
+ parenthesizeNonArrayTypeOfPostfixType: ts.identity,
+ parenthesizeElementTypesOfTupleType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
+ parenthesizeElementTypeOfTupleType: ts.identity,
+ parenthesizeTypeOfOptionalType: ts.identity,
parenthesizeTypeArguments: function (nodes) { return nodes && ts.cast(nodes, ts.isNodeArray); },
+ parenthesizeLeadingTypeArgument: ts.identity,
};
})(ts || (ts = {}));
/* @internal */
@@ -21643,11 +22164,11 @@ var ts;
}
function convertToAssignmentPattern(node) {
switch (node.kind) {
- case 201 /* ArrayBindingPattern */:
- case 203 /* ArrayLiteralExpression */:
+ case 202 /* SyntaxKind.ArrayBindingPattern */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
return convertToArrayAssignmentPattern(node);
- case 200 /* ObjectBindingPattern */:
- case 204 /* ObjectLiteralExpression */:
+ case 201 /* SyntaxKind.ObjectBindingPattern */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
return convertToObjectAssignmentPattern(node);
}
}
@@ -21705,10 +22226,10 @@ var ts;
*/
/* @internal */
function createNodeFactory(flags, baseFactory) {
- var update = flags & 8 /* NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal;
+ var update = flags & 8 /* NodeFactoryFlags.NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal;
// Lazily load the parenthesizer, node converters, and some factory methods until they are used.
- var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); });
- var converters = ts.memoize(function () { return flags & 2 /* NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); });
+ var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NodeFactoryFlags.NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); });
+ var converters = ts.memoize(function () { return flags & 2 /* NodeFactoryFlags.NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); });
// lazy initializaton of common operator factories
var getBinaryCreateFunction = ts.memoizeOne(function (operator) { return function (left, right) { return createBinaryExpression(left, operator, right); }; });
var getPrefixUnaryCreateFunction = ts.memoizeOne(function (operator) { return function (operand) { return createPrefixUnaryExpression(operator, operand); }; });
@@ -21716,6 +22237,8 @@ var ts;
var getJSDocPrimaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function () { return createJSDocPrimaryTypeWorker(kind); }; });
var getJSDocUnaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function (type) { return createJSDocUnaryTypeWorker(kind, type); }; });
var getJSDocUnaryTypeUpdateFunction = ts.memoizeOne(function (kind) { return function (node, type) { return updateJSDocUnaryTypeWorker(kind, node, type); }; });
+ var getJSDocPrePostfixUnaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function (type, postfix) { return createJSDocPrePostfixUnaryTypeWorker(kind, type, postfix); }; });
+ var getJSDocPrePostfixUnaryTypeUpdateFunction = ts.memoizeOne(function (kind) { return function (node, type) { return updateJSDocPrePostfixUnaryTypeWorker(kind, node, type); }; });
var getJSDocSimpleTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, comment) { return createJSDocSimpleTagWorker(kind, tagName, comment); }; });
var getJSDocSimpleTagUpdateFunction = ts.memoizeOne(function (kind) { return function (node, tagName, comment) { return updateJSDocSimpleTagWorker(kind, node, tagName, comment); }; });
var getJSDocTypeLikeTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, typeExpression, comment) { return createJSDocTypeLikeTagWorker(kind, tagName, typeExpression, comment); }; });
@@ -21723,6 +22246,8 @@ var ts;
var factory = {
get parenthesizer() { return parenthesizerRules(); },
get converters() { return converters(); },
+ baseFactory: baseFactory,
+ flags: flags,
createNodeArray: createNodeArray,
createNumericLiteral: createNumericLiteral,
createBigIntLiteral: createBigIntLiteral,
@@ -21835,12 +22360,12 @@ var ts;
updateArrayLiteralExpression: updateArrayLiteralExpression,
createObjectLiteralExpression: createObjectLiteralExpression,
updateObjectLiteralExpression: updateObjectLiteralExpression,
- createPropertyAccessExpression: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ?
- function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* NoIndentation */); } :
+ createPropertyAccessExpression: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ?
+ function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* EmitFlags.NoIndentation */); } :
createPropertyAccessExpression,
updatePropertyAccessExpression: updatePropertyAccessExpression,
- createPropertyAccessChain: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ?
- function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* NoIndentation */); } :
+ createPropertyAccessChain: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ?
+ function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* EmitFlags.NoIndentation */); } :
createPropertyAccessChain,
updatePropertyAccessChain: updatePropertyAccessChain,
createElementAccessExpression: createElementAccessExpression,
@@ -21974,6 +22499,8 @@ var ts;
updateAssertClause: updateAssertClause,
createAssertEntry: createAssertEntry,
updateAssertEntry: updateAssertEntry,
+ createImportTypeAssertionContainer: createImportTypeAssertionContainer,
+ updateImportTypeAssertionContainer: updateImportTypeAssertionContainer,
createNamespaceImport: createNamespaceImport,
updateNamespaceImport: updateNamespaceImport,
createNamespaceExport: createNamespaceExport,
@@ -21994,18 +22521,18 @@ var ts;
createExternalModuleReference: createExternalModuleReference,
updateExternalModuleReference: updateExternalModuleReference,
// lazily load factory members for JSDoc types with similar structure
- get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(310 /* JSDocAllType */); },
- get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(311 /* JSDocUnknownType */); },
- get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(313 /* JSDocNonNullableType */); },
- get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(313 /* JSDocNonNullableType */); },
- get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(312 /* JSDocNullableType */); },
- get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(312 /* JSDocNullableType */); },
- get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(314 /* JSDocOptionalType */); },
- get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(314 /* JSDocOptionalType */); },
- get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(316 /* JSDocVariadicType */); },
- get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(316 /* JSDocVariadicType */); },
- get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(317 /* JSDocNamepathType */); },
- get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(317 /* JSDocNamepathType */); },
+ get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* SyntaxKind.JSDocAllType */); },
+ get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* SyntaxKind.JSDocUnknownType */); },
+ get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* SyntaxKind.JSDocNonNullableType */); },
+ get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* SyntaxKind.JSDocNonNullableType */); },
+ get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* SyntaxKind.JSDocNullableType */); },
+ get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* SyntaxKind.JSDocNullableType */); },
+ get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* SyntaxKind.JSDocOptionalType */); },
+ get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* SyntaxKind.JSDocOptionalType */); },
+ get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* SyntaxKind.JSDocVariadicType */); },
+ get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(318 /* SyntaxKind.JSDocVariadicType */); },
+ get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(319 /* SyntaxKind.JSDocNamepathType */); },
+ get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(319 /* SyntaxKind.JSDocNamepathType */); },
createJSDocFunctionType: createJSDocFunctionType,
updateJSDocFunctionType: updateJSDocFunctionType,
createJSDocTypeLiteral: createJSDocTypeLiteral,
@@ -22041,30 +22568,30 @@ var ts;
createJSDocLinkPlain: createJSDocLinkPlain,
updateJSDocLinkPlain: updateJSDocLinkPlain,
// lazily load factory members for JSDoc tags with similar structure
- get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(341 /* JSDocTypeTag */); },
- get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* JSDocTypeTag */); },
- get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(339 /* JSDocReturnTag */); },
- get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* JSDocReturnTag */); },
- get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(340 /* JSDocThisTag */); },
- get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(340 /* JSDocThisTag */); },
- get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(337 /* JSDocEnumTag */); },
- get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(337 /* JSDocEnumTag */); },
- get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(328 /* JSDocAuthorTag */); },
- get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(328 /* JSDocAuthorTag */); },
- get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(330 /* JSDocClassTag */); },
- get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(330 /* JSDocClassTag */); },
- get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(331 /* JSDocPublicTag */); },
- get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(331 /* JSDocPublicTag */); },
- get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(332 /* JSDocPrivateTag */); },
- get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(332 /* JSDocPrivateTag */); },
- get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(333 /* JSDocProtectedTag */); },
- get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(333 /* JSDocProtectedTag */); },
- get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(334 /* JSDocReadonlyTag */); },
- get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(334 /* JSDocReadonlyTag */); },
- get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(335 /* JSDocOverrideTag */); },
- get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(335 /* JSDocOverrideTag */); },
- get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(329 /* JSDocDeprecatedTag */); },
- get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(329 /* JSDocDeprecatedTag */); },
+ get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(343 /* SyntaxKind.JSDocTypeTag */); },
+ get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(343 /* SyntaxKind.JSDocTypeTag */); },
+ get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(341 /* SyntaxKind.JSDocReturnTag */); },
+ get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* SyntaxKind.JSDocReturnTag */); },
+ get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(342 /* SyntaxKind.JSDocThisTag */); },
+ get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(342 /* SyntaxKind.JSDocThisTag */); },
+ get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(339 /* SyntaxKind.JSDocEnumTag */); },
+ get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* SyntaxKind.JSDocEnumTag */); },
+ get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(330 /* SyntaxKind.JSDocAuthorTag */); },
+ get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(330 /* SyntaxKind.JSDocAuthorTag */); },
+ get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(332 /* SyntaxKind.JSDocClassTag */); },
+ get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(332 /* SyntaxKind.JSDocClassTag */); },
+ get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(333 /* SyntaxKind.JSDocPublicTag */); },
+ get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(333 /* SyntaxKind.JSDocPublicTag */); },
+ get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(334 /* SyntaxKind.JSDocPrivateTag */); },
+ get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(334 /* SyntaxKind.JSDocPrivateTag */); },
+ get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(335 /* SyntaxKind.JSDocProtectedTag */); },
+ get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(335 /* SyntaxKind.JSDocProtectedTag */); },
+ get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); },
+ get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); },
+ get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(337 /* SyntaxKind.JSDocOverrideTag */); },
+ get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(337 /* SyntaxKind.JSDocOverrideTag */); },
+ get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); },
+ get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); },
createJSDocUnknownTag: createJSDocUnknownTag,
updateJSDocUnknownTag: updateJSDocUnknownTag,
createJSDocText: createJSDocText,
@@ -22132,38 +22659,38 @@ var ts;
updateSyntheticReferenceExpression: updateSyntheticReferenceExpression,
cloneNode: cloneNode,
// Lazily load factory methods for common operator factories and utilities
- get createComma() { return getBinaryCreateFunction(27 /* CommaToken */); },
- get createAssignment() { return getBinaryCreateFunction(63 /* EqualsToken */); },
- get createLogicalOr() { return getBinaryCreateFunction(56 /* BarBarToken */); },
- get createLogicalAnd() { return getBinaryCreateFunction(55 /* AmpersandAmpersandToken */); },
- get createBitwiseOr() { return getBinaryCreateFunction(51 /* BarToken */); },
- get createBitwiseXor() { return getBinaryCreateFunction(52 /* CaretToken */); },
- get createBitwiseAnd() { return getBinaryCreateFunction(50 /* AmpersandToken */); },
- get createStrictEquality() { return getBinaryCreateFunction(36 /* EqualsEqualsEqualsToken */); },
- get createStrictInequality() { return getBinaryCreateFunction(37 /* ExclamationEqualsEqualsToken */); },
- get createEquality() { return getBinaryCreateFunction(34 /* EqualsEqualsToken */); },
- get createInequality() { return getBinaryCreateFunction(35 /* ExclamationEqualsToken */); },
- get createLessThan() { return getBinaryCreateFunction(29 /* LessThanToken */); },
- get createLessThanEquals() { return getBinaryCreateFunction(32 /* LessThanEqualsToken */); },
- get createGreaterThan() { return getBinaryCreateFunction(31 /* GreaterThanToken */); },
- get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* GreaterThanEqualsToken */); },
- get createLeftShift() { return getBinaryCreateFunction(47 /* LessThanLessThanToken */); },
- get createRightShift() { return getBinaryCreateFunction(48 /* GreaterThanGreaterThanToken */); },
- get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* GreaterThanGreaterThanGreaterThanToken */); },
- get createAdd() { return getBinaryCreateFunction(39 /* PlusToken */); },
- get createSubtract() { return getBinaryCreateFunction(40 /* MinusToken */); },
- get createMultiply() { return getBinaryCreateFunction(41 /* AsteriskToken */); },
- get createDivide() { return getBinaryCreateFunction(43 /* SlashToken */); },
- get createModulo() { return getBinaryCreateFunction(44 /* PercentToken */); },
- get createExponent() { return getBinaryCreateFunction(42 /* AsteriskAsteriskToken */); },
- get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* PlusToken */); },
- get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* MinusToken */); },
- get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* PlusPlusToken */); },
- get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* MinusMinusToken */); },
- get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* TildeToken */); },
- get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* ExclamationToken */); },
- get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* PlusPlusToken */); },
- get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* MinusMinusToken */); },
+ get createComma() { return getBinaryCreateFunction(27 /* SyntaxKind.CommaToken */); },
+ get createAssignment() { return getBinaryCreateFunction(63 /* SyntaxKind.EqualsToken */); },
+ get createLogicalOr() { return getBinaryCreateFunction(56 /* SyntaxKind.BarBarToken */); },
+ get createLogicalAnd() { return getBinaryCreateFunction(55 /* SyntaxKind.AmpersandAmpersandToken */); },
+ get createBitwiseOr() { return getBinaryCreateFunction(51 /* SyntaxKind.BarToken */); },
+ get createBitwiseXor() { return getBinaryCreateFunction(52 /* SyntaxKind.CaretToken */); },
+ get createBitwiseAnd() { return getBinaryCreateFunction(50 /* SyntaxKind.AmpersandToken */); },
+ get createStrictEquality() { return getBinaryCreateFunction(36 /* SyntaxKind.EqualsEqualsEqualsToken */); },
+ get createStrictInequality() { return getBinaryCreateFunction(37 /* SyntaxKind.ExclamationEqualsEqualsToken */); },
+ get createEquality() { return getBinaryCreateFunction(34 /* SyntaxKind.EqualsEqualsToken */); },
+ get createInequality() { return getBinaryCreateFunction(35 /* SyntaxKind.ExclamationEqualsToken */); },
+ get createLessThan() { return getBinaryCreateFunction(29 /* SyntaxKind.LessThanToken */); },
+ get createLessThanEquals() { return getBinaryCreateFunction(32 /* SyntaxKind.LessThanEqualsToken */); },
+ get createGreaterThan() { return getBinaryCreateFunction(31 /* SyntaxKind.GreaterThanToken */); },
+ get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* SyntaxKind.GreaterThanEqualsToken */); },
+ get createLeftShift() { return getBinaryCreateFunction(47 /* SyntaxKind.LessThanLessThanToken */); },
+ get createRightShift() { return getBinaryCreateFunction(48 /* SyntaxKind.GreaterThanGreaterThanToken */); },
+ get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */); },
+ get createAdd() { return getBinaryCreateFunction(39 /* SyntaxKind.PlusToken */); },
+ get createSubtract() { return getBinaryCreateFunction(40 /* SyntaxKind.MinusToken */); },
+ get createMultiply() { return getBinaryCreateFunction(41 /* SyntaxKind.AsteriskToken */); },
+ get createDivide() { return getBinaryCreateFunction(43 /* SyntaxKind.SlashToken */); },
+ get createModulo() { return getBinaryCreateFunction(44 /* SyntaxKind.PercentToken */); },
+ get createExponent() { return getBinaryCreateFunction(42 /* SyntaxKind.AsteriskAsteriskToken */); },
+ get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* SyntaxKind.PlusToken */); },
+ get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* SyntaxKind.MinusToken */); },
+ get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); },
+ get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); },
+ get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* SyntaxKind.TildeToken */); },
+ get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* SyntaxKind.ExclamationToken */); },
+ get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); },
+ get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); },
// Compound nodes
createImmediatelyInvokedFunctionExpression: createImmediatelyInvokedFunctionExpression,
createImmediatelyInvokedArrowFunction: createImmediatelyInvokedArrowFunction,
@@ -22267,11 +22794,11 @@ var ts;
// don't propagate child flags.
if (name) {
switch (node.kind) {
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 166 /* PropertyDeclaration */:
- case 294 /* PropertyAssignment */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
if (ts.isIdentifier(name)) {
node.transformFlags |= propagateIdentifierNameFlags(name);
break;
@@ -22289,7 +22816,7 @@ var ts;
node.typeParameters = asNodeArray(typeParameters);
node.transformFlags |= propagateChildrenFlags(node.typeParameters);
if (typeParameters)
- node.transformFlags |= 1 /* ContainsTypeScript */;
+ node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
function createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type) {
@@ -22300,7 +22827,7 @@ var ts;
propagateChildrenFlags(node.parameters) |
propagateChildFlags(node.type);
if (type)
- node.transformFlags |= 1 /* ContainsTypeScript */;
+ node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
function updateBaseSignatureDeclaration(updated, original) {
@@ -22312,9 +22839,9 @@ var ts;
function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) {
var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type);
node.body = body;
- node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* ContainsPossibleTopLevelAwait */;
+ node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */;
if (!body)
- node.transformFlags |= 1 /* ContainsTypeScript */;
+ node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
function updateBaseFunctionLikeDeclaration(updated, original) {
@@ -22348,7 +22875,7 @@ var ts;
node.type = type;
node.transformFlags |= propagateChildFlags(type);
if (type)
- node.transformFlags |= 1 /* ContainsTypeScript */;
+ node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
//
@@ -22361,21 +22888,21 @@ var ts;
}
// @api
function createNumericLiteral(value, numericLiteralFlags) {
- if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* None */; }
- var node = createBaseLiteral(8 /* NumericLiteral */, typeof value === "number" ? value + "" : value);
+ if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* TokenFlags.None */; }
+ var node = createBaseLiteral(8 /* SyntaxKind.NumericLiteral */, typeof value === "number" ? value + "" : value);
node.numericLiteralFlags = numericLiteralFlags;
- if (numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */)
- node.transformFlags |= 1024 /* ContainsES2015 */;
+ if (numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */)
+ node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */;
return node;
}
// @api
function createBigIntLiteral(value) {
- var node = createBaseLiteral(9 /* BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n");
- node.transformFlags |= 4 /* ContainsESNext */;
+ var node = createBaseLiteral(9 /* SyntaxKind.BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n");
+ node.transformFlags |= 4 /* TransformFlags.ContainsESNext */;
return node;
}
function createBaseStringLiteral(text, isSingleQuote) {
- var node = createBaseLiteral(10 /* StringLiteral */, text);
+ var node = createBaseLiteral(10 /* SyntaxKind.StringLiteral */, text);
node.singleQuote = isSingleQuote;
return node;
}
@@ -22384,7 +22911,7 @@ var ts;
var node = createBaseStringLiteral(text, isSingleQuote);
node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape;
if (hasExtendedUnicodeEscape)
- node.transformFlags |= 1024 /* ContainsES2015 */;
+ node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */;
return node;
}
// @api
@@ -22395,19 +22922,19 @@ var ts;
}
// @api
function createRegularExpressionLiteral(text) {
- var node = createBaseLiteral(13 /* RegularExpressionLiteral */, text);
+ var node = createBaseLiteral(13 /* SyntaxKind.RegularExpressionLiteral */, text);
return node;
}
// @api
function createLiteralLikeNode(kind, text) {
switch (kind) {
- case 8 /* NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0);
- case 9 /* BigIntLiteral */: return createBigIntLiteral(text);
- case 10 /* StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined);
- case 11 /* JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false);
- case 12 /* JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true);
- case 13 /* RegularExpressionLiteral */: return createRegularExpressionLiteral(text);
- case 14 /* NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0);
+ case 8 /* SyntaxKind.NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0);
+ case 9 /* SyntaxKind.BigIntLiteral */: return createBigIntLiteral(text);
+ case 10 /* SyntaxKind.StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined);
+ case 11 /* SyntaxKind.JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false);
+ case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true);
+ case 13 /* SyntaxKind.RegularExpressionLiteral */: return createRegularExpressionLiteral(text);
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0);
}
}
//
@@ -22417,10 +22944,10 @@ var ts;
if (originalKeywordKind === undefined && text) {
originalKeywordKind = ts.stringToToken(text);
}
- if (originalKeywordKind === 79 /* Identifier */) {
+ if (originalKeywordKind === 79 /* SyntaxKind.Identifier */) {
originalKeywordKind = undefined;
}
- var node = baseFactory.createBaseIdentifierNode(79 /* Identifier */);
+ var node = baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */);
node.originalKeywordKind = originalKeywordKind;
node.escapedText = ts.escapeLeadingUnderscores(text);
return node;
@@ -22439,8 +22966,8 @@ var ts;
// NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations
node.typeArguments = createNodeArray(typeArguments);
}
- if (node.originalKeywordKind === 132 /* AwaitKeyword */) {
- node.transformFlags |= 16777216 /* ContainsPossibleTopLevelAwait */;
+ if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) {
+ node.transformFlags |= 16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */;
}
return node;
}
@@ -22452,9 +22979,9 @@ var ts;
}
// @api
function createTempVariable(recordTempVariable, reservedInNestedScopes) {
- var flags = 1 /* Auto */;
+ var flags = 1 /* GeneratedIdentifierFlags.Auto */;
if (reservedInNestedScopes)
- flags |= 8 /* ReservedInNestedScopes */;
+ flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */;
var name = createBaseGeneratedIdentifier("", flags);
if (recordTempVariable) {
recordTempVariable(name);
@@ -22464,25 +22991,25 @@ var ts;
/** Create a unique temporary variable for use in a loop. */
// @api
function createLoopVariable(reservedInNestedScopes) {
- var flags = 2 /* Loop */;
+ var flags = 2 /* GeneratedIdentifierFlags.Loop */;
if (reservedInNestedScopes)
- flags |= 8 /* ReservedInNestedScopes */;
+ flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */;
return createBaseGeneratedIdentifier("", flags);
}
/** Create a unique name based on the supplied text. */
// @api
function createUniqueName(text, flags) {
- if (flags === void 0) { flags = 0 /* None */; }
- ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags");
- ts.Debug.assert((flags & (16 /* Optimistic */ | 32 /* FileLevel */)) !== 32 /* FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic");
- return createBaseGeneratedIdentifier(text, 3 /* Unique */ | flags);
+ if (flags === void 0) { flags = 0 /* GeneratedIdentifierFlags.None */; }
+ ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags");
+ ts.Debug.assert((flags & (16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)) !== 32 /* GeneratedIdentifierFlags.FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic");
+ return createBaseGeneratedIdentifier(text, 3 /* GeneratedIdentifierFlags.Unique */ | flags);
}
/** Create a unique name generated for a node. */
// @api
function getGeneratedNameForNode(node, flags) {
if (flags === void 0) { flags = 0; }
- ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags");
- var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* Node */ | flags);
+ ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags");
+ var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* GeneratedIdentifierFlags.Node */ | flags);
name.original = node;
return name;
}
@@ -22490,9 +23017,9 @@ var ts;
function createPrivateIdentifier(text) {
if (!ts.startsWith(text, "#"))
ts.Debug.fail("First character of private identifier must be #: " + text);
- var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */);
+ var node = baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */);
node.escapedText = ts.escapeLeadingUnderscores(text);
- node.transformFlags |= 8388608 /* ContainsClassFields */;
+ node.transformFlags |= 8388608 /* TransformFlags.ContainsClassFields */;
return node;
}
//
@@ -22502,49 +23029,51 @@ var ts;
return baseFactory.createBaseTokenNode(kind);
}
function createToken(token) {
- ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 159 /* LastToken */, "Invalid token");
- ts.Debug.assert(token <= 14 /* FirstTemplateToken */ || token >= 17 /* LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals.");
- ts.Debug.assert(token <= 8 /* FirstLiteralToken */ || token >= 14 /* LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals.");
- ts.Debug.assert(token !== 79 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers");
+ ts.Debug.assert(token >= 0 /* SyntaxKind.FirstToken */ && token <= 160 /* SyntaxKind.LastToken */, "Invalid token");
+ ts.Debug.assert(token <= 14 /* SyntaxKind.FirstTemplateToken */ || token >= 17 /* SyntaxKind.LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals.");
+ ts.Debug.assert(token <= 8 /* SyntaxKind.FirstLiteralToken */ || token >= 14 /* SyntaxKind.LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals.");
+ ts.Debug.assert(token !== 79 /* SyntaxKind.Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers");
var node = createBaseToken(token);
- var transformFlags = 0 /* None */;
+ var transformFlags = 0 /* TransformFlags.None */;
switch (token) {
- case 131 /* AsyncKeyword */:
+ case 131 /* SyntaxKind.AsyncKeyword */:
// 'async' modifier is ES2017 (async functions) or ES2018 (async generators)
transformFlags =
- 256 /* ContainsES2017 */ |
- 128 /* ContainsES2018 */;
+ 256 /* TransformFlags.ContainsES2017 */ |
+ 128 /* TransformFlags.ContainsES2018 */;
break;
- case 123 /* PublicKeyword */:
- case 121 /* PrivateKeyword */:
- case 122 /* ProtectedKeyword */:
- case 144 /* ReadonlyKeyword */:
- case 126 /* AbstractKeyword */:
- case 135 /* DeclareKeyword */:
- case 85 /* ConstKeyword */:
- case 130 /* AnyKeyword */:
- case 146 /* NumberKeyword */:
- case 157 /* BigIntKeyword */:
- case 143 /* NeverKeyword */:
- case 147 /* ObjectKeyword */:
- case 158 /* OverrideKeyword */:
- case 149 /* StringKeyword */:
- case 133 /* BooleanKeyword */:
- case 150 /* SymbolKeyword */:
- case 114 /* VoidKeyword */:
- case 154 /* UnknownKeyword */:
- case 152 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case.
- transformFlags = 1 /* ContainsTypeScript */;
+ case 123 /* SyntaxKind.PublicKeyword */:
+ case 121 /* SyntaxKind.PrivateKeyword */:
+ case 122 /* SyntaxKind.ProtectedKeyword */:
+ case 145 /* SyntaxKind.ReadonlyKeyword */:
+ case 126 /* SyntaxKind.AbstractKeyword */:
+ case 135 /* SyntaxKind.DeclareKeyword */:
+ case 85 /* SyntaxKind.ConstKeyword */:
+ case 130 /* SyntaxKind.AnyKeyword */:
+ case 147 /* SyntaxKind.NumberKeyword */:
+ case 158 /* SyntaxKind.BigIntKeyword */:
+ case 143 /* SyntaxKind.NeverKeyword */:
+ case 148 /* SyntaxKind.ObjectKeyword */:
+ case 101 /* SyntaxKind.InKeyword */:
+ case 144 /* SyntaxKind.OutKeyword */:
+ case 159 /* SyntaxKind.OverrideKeyword */:
+ case 150 /* SyntaxKind.StringKeyword */:
+ case 133 /* SyntaxKind.BooleanKeyword */:
+ case 151 /* SyntaxKind.SymbolKeyword */:
+ case 114 /* SyntaxKind.VoidKeyword */:
+ case 155 /* SyntaxKind.UnknownKeyword */:
+ case 153 /* SyntaxKind.UndefinedKeyword */: // `undefined` is an Identifier in the expression case.
+ transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
break;
- case 106 /* SuperKeyword */:
- transformFlags = 1024 /* ContainsES2015 */ | 33554432 /* ContainsLexicalSuper */;
+ case 106 /* SyntaxKind.SuperKeyword */:
+ transformFlags = 1024 /* TransformFlags.ContainsES2015 */ | 33554432 /* TransformFlags.ContainsLexicalSuper */;
break;
- case 124 /* StaticKeyword */:
- transformFlags = 1024 /* ContainsES2015 */;
+ case 124 /* SyntaxKind.StaticKeyword */:
+ transformFlags = 1024 /* TransformFlags.ContainsES2015 */;
break;
- case 108 /* ThisKeyword */:
+ case 108 /* SyntaxKind.ThisKeyword */:
// 'this' indicates a lexical 'this'
- transformFlags = 8192 /* ContainsLexicalThis */;
+ transformFlags = 8192 /* TransformFlags.ContainsLexicalThis */;
break;
}
if (transformFlags) {
@@ -22557,23 +23086,23 @@ var ts;
//
// @api
function createSuper() {
- return createToken(106 /* SuperKeyword */);
+ return createToken(106 /* SyntaxKind.SuperKeyword */);
}
// @api
function createThis() {
- return createToken(108 /* ThisKeyword */);
+ return createToken(108 /* SyntaxKind.ThisKeyword */);
}
// @api
function createNull() {
- return createToken(104 /* NullKeyword */);
+ return createToken(104 /* SyntaxKind.NullKeyword */);
}
// @api
function createTrue() {
- return createToken(110 /* TrueKeyword */);
+ return createToken(110 /* SyntaxKind.TrueKeyword */);
}
// @api
function createFalse() {
- return createToken(95 /* FalseKeyword */);
+ return createToken(95 /* SyntaxKind.FalseKeyword */);
}
//
// Modifiers
@@ -22585,30 +23114,34 @@ var ts;
// @api
function createModifiersFromModifierFlags(flags) {
var result = [];
- if (flags & 1 /* Export */)
- result.push(createModifier(93 /* ExportKeyword */));
- if (flags & 2 /* Ambient */)
- result.push(createModifier(135 /* DeclareKeyword */));
- if (flags & 512 /* Default */)
- result.push(createModifier(88 /* DefaultKeyword */));
- if (flags & 2048 /* Const */)
- result.push(createModifier(85 /* ConstKeyword */));
- if (flags & 4 /* Public */)
- result.push(createModifier(123 /* PublicKeyword */));
- if (flags & 8 /* Private */)
- result.push(createModifier(121 /* PrivateKeyword */));
- if (flags & 16 /* Protected */)
- result.push(createModifier(122 /* ProtectedKeyword */));
- if (flags & 128 /* Abstract */)
- result.push(createModifier(126 /* AbstractKeyword */));
- if (flags & 32 /* Static */)
- result.push(createModifier(124 /* StaticKeyword */));
- if (flags & 16384 /* Override */)
- result.push(createModifier(158 /* OverrideKeyword */));
- if (flags & 64 /* Readonly */)
- result.push(createModifier(144 /* ReadonlyKeyword */));
- if (flags & 256 /* Async */)
- result.push(createModifier(131 /* AsyncKeyword */));
+ if (flags & 1 /* ModifierFlags.Export */)
+ result.push(createModifier(93 /* SyntaxKind.ExportKeyword */));
+ if (flags & 2 /* ModifierFlags.Ambient */)
+ result.push(createModifier(135 /* SyntaxKind.DeclareKeyword */));
+ if (flags & 512 /* ModifierFlags.Default */)
+ result.push(createModifier(88 /* SyntaxKind.DefaultKeyword */));
+ if (flags & 2048 /* ModifierFlags.Const */)
+ result.push(createModifier(85 /* SyntaxKind.ConstKeyword */));
+ if (flags & 4 /* ModifierFlags.Public */)
+ result.push(createModifier(123 /* SyntaxKind.PublicKeyword */));
+ if (flags & 8 /* ModifierFlags.Private */)
+ result.push(createModifier(121 /* SyntaxKind.PrivateKeyword */));
+ if (flags & 16 /* ModifierFlags.Protected */)
+ result.push(createModifier(122 /* SyntaxKind.ProtectedKeyword */));
+ if (flags & 128 /* ModifierFlags.Abstract */)
+ result.push(createModifier(126 /* SyntaxKind.AbstractKeyword */));
+ if (flags & 32 /* ModifierFlags.Static */)
+ result.push(createModifier(124 /* SyntaxKind.StaticKeyword */));
+ if (flags & 16384 /* ModifierFlags.Override */)
+ result.push(createModifier(159 /* SyntaxKind.OverrideKeyword */));
+ if (flags & 64 /* ModifierFlags.Readonly */)
+ result.push(createModifier(145 /* SyntaxKind.ReadonlyKeyword */));
+ if (flags & 256 /* ModifierFlags.Async */)
+ result.push(createModifier(131 /* SyntaxKind.AsyncKeyword */));
+ if (flags & 32768 /* ModifierFlags.In */)
+ result.push(createModifier(101 /* SyntaxKind.InKeyword */));
+ if (flags & 65536 /* ModifierFlags.Out */)
+ result.push(createModifier(144 /* SyntaxKind.OutKeyword */));
return result.length ? result : undefined;
}
//
@@ -22616,7 +23149,7 @@ var ts;
//
// @api
function createQualifiedName(left, right) {
- var node = createBaseNode(160 /* QualifiedName */);
+ var node = createBaseNode(161 /* SyntaxKind.QualifiedName */);
node.left = left;
node.right = asName(right);
node.transformFlags |=
@@ -22633,12 +23166,12 @@ var ts;
}
// @api
function createComputedPropertyName(expression) {
- var node = createBaseNode(161 /* ComputedPropertyName */);
+ var node = createBaseNode(162 /* SyntaxKind.ComputedPropertyName */);
node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression);
node.transformFlags |=
propagateChildFlags(node.expression) |
- 1024 /* ContainsES2015 */ |
- 65536 /* ContainsComputedPropertyName */;
+ 1024 /* TransformFlags.ContainsES2015 */ |
+ 65536 /* TransformFlags.ContainsComputedPropertyName */;
return node;
}
// @api
@@ -22647,45 +23180,66 @@ var ts;
? update(createComputedPropertyName(expression), node)
: node;
}
- //
- // Signature elements
- //
- // @api
- function createTypeParameterDeclaration(name, constraint, defaultType) {
- var node = createBaseNamedDeclaration(162 /* TypeParameter */,
- /*decorators*/ undefined,
- /*modifiers*/ undefined, name);
+ 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 /* SyntaxKind.TypeParameter */,
+ /*decorators*/ undefined, modifiers, name);
node.constraint = constraint;
node.default = defaultType;
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
- // @api
- function updateTypeParameterDeclaration(node, name, constraint, defaultType) {
- return node.name !== name
+ 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;
+ }
+ return node.modifiers !== modifiers
+ || node.name !== name
|| node.constraint !== constraint
|| node.default !== defaultType
- ? update(createTypeParameterDeclaration(name, constraint, defaultType), node)
+ ? update(createTypeParameterDeclaration(modifiers, name, constraint, defaultType), node)
: node;
}
// @api
function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) {
- var node = createBaseVariableLikeDeclaration(163 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer));
+ var node = createBaseVariableLikeDeclaration(164 /* SyntaxKind.Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer));
node.dotDotDotToken = dotDotDotToken;
node.questionToken = questionToken;
if (ts.isThisIdentifier(node.name)) {
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
}
else {
node.transformFlags |=
propagateChildFlags(node.dotDotDotToken) |
propagateChildFlags(node.questionToken);
if (questionToken)
- node.transformFlags |= 1 /* ContainsTypeScript */;
- if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */)
- node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */;
+ node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */;
+ if (ts.modifiersToFlags(node.modifiers) & 16476 /* ModifierFlags.ParameterPropertyModifier */)
+ node.transformFlags |= 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */;
if (initializer || dotDotDotToken)
- node.transformFlags |= 1024 /* ContainsES2015 */;
+ node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */;
}
return node;
}
@@ -22703,12 +23257,12 @@ var ts;
}
// @api
function createDecorator(expression) {
- var node = createBaseNode(164 /* Decorator */);
+ var node = createBaseNode(165 /* SyntaxKind.Decorator */);
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
node.transformFlags |=
propagateChildFlags(node.expression) |
- 1 /* ContainsTypeScript */ |
- 4096 /* ContainsTypeScriptClassSyntax */;
+ 1 /* TransformFlags.ContainsTypeScript */ |
+ 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */;
return node;
}
// @api
@@ -22722,11 +23276,11 @@ var ts;
//
// @api
function createPropertySignature(modifiers, name, questionToken, type) {
- var node = createBaseNamedDeclaration(165 /* PropertySignature */,
+ var node = createBaseNamedDeclaration(166 /* SyntaxKind.PropertySignature */,
/*decorators*/ undefined, modifiers, name);
node.type = type;
node.questionToken = questionToken;
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -22740,18 +23294,18 @@ var ts;
}
// @api
function createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer) {
- var node = createBaseVariableLikeDeclaration(166 /* PropertyDeclaration */, decorators, modifiers, name, type, initializer);
+ var node = createBaseVariableLikeDeclaration(167 /* SyntaxKind.PropertyDeclaration */, decorators, 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 /* ContainsClassFields */;
+ 8388608 /* TransformFlags.ContainsClassFields */;
if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) {
- node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */;
+ node.transformFlags |= 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */;
}
- if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) {
- node.transformFlags |= 1 /* ContainsTypeScript */;
+ if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) {
+ node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */;
}
return node;
}
@@ -22769,10 +23323,10 @@ var ts;
}
// @api
function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) {
- var node = createBaseSignatureDeclaration(167 /* MethodSignature */,
+ var node = createBaseSignatureDeclaration(168 /* SyntaxKind.MethodSignature */,
/*decorators*/ undefined, modifiers, name, typeParameters, parameters, type);
node.questionToken = questionToken;
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -22788,26 +23342,26 @@ var ts;
}
// @api
function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) {
- var node = createBaseFunctionLikeDeclaration(168 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body);
+ var node = createBaseFunctionLikeDeclaration(169 /* SyntaxKind.MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body);
node.asteriskToken = asteriskToken;
node.questionToken = questionToken;
node.transformFlags |=
propagateChildFlags(node.asteriskToken) |
propagateChildFlags(node.questionToken) |
- 1024 /* ContainsES2015 */;
+ 1024 /* TransformFlags.ContainsES2015 */;
if (questionToken) {
- node.transformFlags |= 1 /* ContainsTypeScript */;
+ node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */;
}
- if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) {
+ if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) {
if (asteriskToken) {
- node.transformFlags |= 128 /* ContainsES2018 */;
+ node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */;
}
else {
- node.transformFlags |= 256 /* ContainsES2017 */;
+ node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */;
}
}
else if (asteriskToken) {
- node.transformFlags |= 2048 /* ContainsGenerator */;
+ node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */;
}
return node;
}
@@ -22827,11 +23381,11 @@ var ts;
}
// @api
function createClassStaticBlockDeclaration(decorators, modifiers, body) {
- var node = createBaseGenericNamedDeclaration(169 /* ClassStaticBlockDeclaration */, decorators, modifiers,
+ var node = createBaseGenericNamedDeclaration(170 /* SyntaxKind.ClassStaticBlockDeclaration */, decorators, modifiers,
/*name*/ undefined,
/*typeParameters*/ undefined);
node.body = body;
- node.transformFlags = propagateChildFlags(body) | 8388608 /* ContainsClassFields */;
+ node.transformFlags = propagateChildFlags(body) | 8388608 /* TransformFlags.ContainsClassFields */;
return node;
}
// @api
@@ -22844,11 +23398,11 @@ var ts;
}
// @api
function createConstructorDeclaration(decorators, modifiers, parameters, body) {
- var node = createBaseFunctionLikeDeclaration(170 /* Constructor */, decorators, modifiers,
+ var node = createBaseFunctionLikeDeclaration(171 /* SyntaxKind.Constructor */, decorators, modifiers,
/*name*/ undefined,
/*typeParameters*/ undefined, parameters,
/*type*/ undefined, body);
- node.transformFlags |= 1024 /* ContainsES2015 */;
+ node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */;
return node;
}
// @api
@@ -22862,7 +23416,7 @@ var ts;
}
// @api
function createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) {
- return createBaseFunctionLikeDeclaration(171 /* GetAccessor */, decorators, modifiers, name,
+ return createBaseFunctionLikeDeclaration(172 /* SyntaxKind.GetAccessor */, decorators, modifiers, name,
/*typeParameters*/ undefined, parameters, type, body);
}
// @api
@@ -22878,7 +23432,7 @@ var ts;
}
// @api
function createSetAccessorDeclaration(decorators, modifiers, name, parameters, body) {
- return createBaseFunctionLikeDeclaration(172 /* SetAccessor */, decorators, modifiers, name,
+ return createBaseFunctionLikeDeclaration(173 /* SyntaxKind.SetAccessor */, decorators, modifiers, name,
/*typeParameters*/ undefined, parameters,
/*type*/ undefined, body);
}
@@ -22894,11 +23448,11 @@ var ts;
}
// @api
function createCallSignature(typeParameters, parameters, type) {
- var node = createBaseSignatureDeclaration(173 /* CallSignature */,
+ var node = createBaseSignatureDeclaration(174 /* SyntaxKind.CallSignature */,
/*decorators*/ undefined,
/*modifiers*/ undefined,
/*name*/ undefined, typeParameters, parameters, type);
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -22911,11 +23465,11 @@ var ts;
}
// @api
function createConstructSignature(typeParameters, parameters, type) {
- var node = createBaseSignatureDeclaration(174 /* ConstructSignature */,
+ var node = createBaseSignatureDeclaration(175 /* SyntaxKind.ConstructSignature */,
/*decorators*/ undefined,
/*modifiers*/ undefined,
/*name*/ undefined, typeParameters, parameters, type);
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -22928,10 +23482,10 @@ var ts;
}
// @api
function createIndexSignature(decorators, modifiers, parameters, type) {
- var node = createBaseSignatureDeclaration(175 /* IndexSignature */, decorators, modifiers,
+ var node = createBaseSignatureDeclaration(176 /* SyntaxKind.IndexSignature */, decorators, modifiers,
/*name*/ undefined,
/*typeParameters*/ undefined, parameters, type);
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -22945,10 +23499,10 @@ var ts;
}
// @api
function createTemplateLiteralTypeSpan(type, literal) {
- var node = createBaseNode(198 /* TemplateLiteralTypeSpan */);
+ var node = createBaseNode(199 /* SyntaxKind.TemplateLiteralTypeSpan */);
node.type = type;
node.literal = literal;
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -22967,11 +23521,11 @@ var ts;
}
// @api
function createTypePredicateNode(assertsModifier, parameterName, type) {
- var node = createBaseNode(176 /* TypePredicate */);
+ var node = createBaseNode(177 /* SyntaxKind.TypePredicate */);
node.assertsModifier = assertsModifier;
node.parameterName = asName(parameterName);
node.type = type;
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -22984,10 +23538,10 @@ var ts;
}
// @api
function createTypeReferenceNode(typeName, typeArguments) {
- var node = createBaseNode(177 /* TypeReference */);
+ var node = createBaseNode(178 /* SyntaxKind.TypeReference */);
node.typeName = asName(typeName);
node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments));
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -22999,11 +23553,11 @@ var ts;
}
// @api
function createFunctionTypeNode(typeParameters, parameters, type) {
- var node = createBaseSignatureDeclaration(178 /* FunctionType */,
+ var node = createBaseSignatureDeclaration(179 /* SyntaxKind.FunctionType */,
/*decorators*/ undefined,
/*modifiers*/ undefined,
/*name*/ undefined, typeParameters, parameters, type);
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -23025,10 +23579,10 @@ var ts;
ts.Debug.fail("Incorrect number of arguments specified.");
}
function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) {
- var node = createBaseSignatureDeclaration(179 /* ConstructorType */,
+ var node = createBaseSignatureDeclaration(180 /* SyntaxKind.ConstructorType */,
/*decorators*/ undefined, modifiers,
/*name*/ undefined, typeParameters, parameters, type);
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
/** @deprecated */
@@ -23058,23 +23612,25 @@ var ts;
return updateConstructorTypeNode1(node, node.modifiers, typeParameters, parameters, type);
}
// @api
- function createTypeQueryNode(exprName) {
- var node = createBaseNode(180 /* TypeQuery */);
+ function createTypeQueryNode(exprName, typeArguments) {
+ var node = createBaseNode(181 /* SyntaxKind.TypeQuery */);
node.exprName = exprName;
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
- function updateTypeQueryNode(node, exprName) {
+ function updateTypeQueryNode(node, exprName, typeArguments) {
return node.exprName !== exprName
- ? update(createTypeQueryNode(exprName), node)
+ || node.typeArguments !== typeArguments
+ ? update(createTypeQueryNode(exprName, typeArguments), node)
: node;
}
// @api
function createTypeLiteralNode(members) {
- var node = createBaseNode(181 /* TypeLiteral */);
+ var node = createBaseNode(182 /* SyntaxKind.TypeLiteral */);
node.members = createNodeArray(members);
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -23085,9 +23641,9 @@ var ts;
}
// @api
function createArrayTypeNode(elementType) {
- var node = createBaseNode(182 /* ArrayType */);
- node.elementType = parenthesizerRules().parenthesizeElementTypeOfArrayType(elementType);
- node.transformFlags = 1 /* ContainsTypeScript */;
+ var node = createBaseNode(183 /* SyntaxKind.ArrayType */);
+ node.elementType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(elementType);
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -23098,9 +23654,9 @@ var ts;
}
// @api
function createTupleTypeNode(elements) {
- var node = createBaseNode(183 /* TupleType */);
- node.elements = createNodeArray(elements);
- node.transformFlags = 1 /* ContainsTypeScript */;
+ var node = createBaseNode(184 /* SyntaxKind.TupleType */);
+ node.elements = createNodeArray(parenthesizerRules().parenthesizeElementTypesOfTupleType(elements));
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -23111,12 +23667,12 @@ var ts;
}
// @api
function createNamedTupleMember(dotDotDotToken, name, questionToken, type) {
- var node = createBaseNode(196 /* NamedTupleMember */);
+ var node = createBaseNode(197 /* SyntaxKind.NamedTupleMember */);
node.dotDotDotToken = dotDotDotToken;
node.name = name;
node.questionToken = questionToken;
node.type = type;
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -23130,9 +23686,9 @@ var ts;
}
// @api
function createOptionalTypeNode(type) {
- var node = createBaseNode(184 /* OptionalType */);
- node.type = parenthesizerRules().parenthesizeElementTypeOfArrayType(type);
- node.transformFlags = 1 /* ContainsTypeScript */;
+ var node = createBaseNode(185 /* SyntaxKind.OptionalType */);
+ node.type = parenthesizerRules().parenthesizeTypeOfOptionalType(type);
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -23143,9 +23699,9 @@ var ts;
}
// @api
function createRestTypeNode(type) {
- var node = createBaseNode(185 /* RestType */);
+ var node = createBaseNode(186 /* SyntaxKind.RestType */);
node.type = type;
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -23154,41 +23710,41 @@ var ts;
? update(createRestTypeNode(type), node)
: node;
}
- function createUnionOrIntersectionTypeNode(kind, types) {
+ function createUnionOrIntersectionTypeNode(kind, types, parenthesize) {
var node = createBaseNode(kind);
- node.types = parenthesizerRules().parenthesizeConstituentTypesOfUnionOrIntersectionType(types);
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.types = factory.createNodeArray(parenthesize(types));
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
- function updateUnionOrIntersectionTypeNode(node, types) {
+ function updateUnionOrIntersectionTypeNode(node, types, parenthesize) {
return node.types !== types
- ? update(createUnionOrIntersectionTypeNode(node.kind, types), node)
+ ? update(createUnionOrIntersectionTypeNode(node.kind, types, parenthesize), node)
: node;
}
// @api
function createUnionTypeNode(types) {
- return createUnionOrIntersectionTypeNode(186 /* UnionType */, types);
+ return createUnionOrIntersectionTypeNode(187 /* SyntaxKind.UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType);
}
// @api
function updateUnionTypeNode(node, types) {
- return updateUnionOrIntersectionTypeNode(node, types);
+ return updateUnionOrIntersectionTypeNode(node, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType);
}
// @api
function createIntersectionTypeNode(types) {
- return createUnionOrIntersectionTypeNode(187 /* IntersectionType */, types);
+ return createUnionOrIntersectionTypeNode(188 /* SyntaxKind.IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType);
}
// @api
function updateIntersectionTypeNode(node, types) {
- return updateUnionOrIntersectionTypeNode(node, types);
+ return updateUnionOrIntersectionTypeNode(node, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType);
}
// @api
function createConditionalTypeNode(checkType, extendsType, trueType, falseType) {
- var node = createBaseNode(188 /* ConditionalType */);
- node.checkType = parenthesizerRules().parenthesizeMemberOfConditionalType(checkType);
- node.extendsType = parenthesizerRules().parenthesizeMemberOfConditionalType(extendsType);
+ var node = createBaseNode(189 /* SyntaxKind.ConditionalType */);
+ node.checkType = parenthesizerRules().parenthesizeCheckTypeOfConditionalType(checkType);
+ node.extendsType = parenthesizerRules().parenthesizeExtendsTypeOfConditionalType(extendsType);
node.trueType = trueType;
node.falseType = falseType;
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -23202,9 +23758,9 @@ var ts;
}
// @api
function createInferTypeNode(typeParameter) {
- var node = createBaseNode(189 /* InferType */);
+ var node = createBaseNode(190 /* SyntaxKind.InferType */);
node.typeParameter = typeParameter;
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -23215,10 +23771,10 @@ var ts;
}
// @api
function createTemplateLiteralType(head, templateSpans) {
- var node = createBaseNode(197 /* TemplateLiteralType */);
+ var node = createBaseNode(198 /* SyntaxKind.TemplateLiteralType */);
node.head = head;
node.templateSpans = createNodeArray(templateSpans);
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -23228,32 +23784,40 @@ var ts;
? update(createTemplateLiteralType(head, templateSpans), node)
: node;
}
- // @api
- function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) {
- if (isTypeOf === void 0) { isTypeOf = false; }
- var node = createBaseNode(199 /* ImportType */);
+ function createImportTypeNode(argument, qualifierOrAssertions, typeArgumentsOrQualifier, isTypeOfOrTypeArguments, isTypeOf) {
+ var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */ ? 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;
+ var node = createBaseNode(200 /* SyntaxKind.ImportType */);
node.argument = argument;
+ node.assertions = assertion;
node.qualifier = qualifier;
node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
node.isTypeOf = isTypeOf;
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
- // @api
- function updateImportTypeNode(node, argument, qualifier, typeArguments, isTypeOf) {
- if (isTypeOf === void 0) { isTypeOf = node.isTypeOf; }
+ function updateImportTypeNode(node, argument, qualifierOrAssertions, typeArgumentsOrQualifier, isTypeOfOrTypeArguments, isTypeOf) {
+ var assertion = qualifierOrAssertions && qualifierOrAssertions.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */ ? 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;
return node.argument !== argument
+ || node.assertions !== assertion
|| node.qualifier !== qualifier
|| node.typeArguments !== typeArguments
|| node.isTypeOf !== isTypeOf
- ? update(createImportTypeNode(argument, qualifier, typeArguments, isTypeOf), node)
+ ? update(createImportTypeNode(argument, assertion, qualifier, typeArguments, isTypeOf), node)
: node;
}
// @api
function createParenthesizedType(type) {
- var node = createBaseNode(190 /* ParenthesizedType */);
+ var node = createBaseNode(191 /* SyntaxKind.ParenthesizedType */);
node.type = type;
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -23264,16 +23828,18 @@ var ts;
}
// @api
function createThisTypeNode() {
- var node = createBaseNode(191 /* ThisType */);
- node.transformFlags = 1 /* ContainsTypeScript */;
+ var node = createBaseNode(192 /* SyntaxKind.ThisType */);
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
function createTypeOperatorNode(operator, type) {
- var node = createBaseNode(192 /* TypeOperator */);
+ var node = createBaseNode(193 /* SyntaxKind.TypeOperator */);
node.operator = operator;
- node.type = parenthesizerRules().parenthesizeMemberOfElementType(type);
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.type = operator === 145 /* SyntaxKind.ReadonlyKeyword */ ?
+ parenthesizerRules().parenthesizeOperandOfReadonlyTypeOperator(type) :
+ parenthesizerRules().parenthesizeOperandOfTypeOperator(type);
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -23284,10 +23850,10 @@ var ts;
}
// @api
function createIndexedAccessTypeNode(objectType, indexType) {
- var node = createBaseNode(193 /* IndexedAccessType */);
- node.objectType = parenthesizerRules().parenthesizeMemberOfElementType(objectType);
+ var node = createBaseNode(194 /* SyntaxKind.IndexedAccessType */);
+ node.objectType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(objectType);
node.indexType = indexType;
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -23299,14 +23865,14 @@ var ts;
}
// @api
function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members) {
- var node = createBaseNode(194 /* MappedType */);
+ var node = createBaseNode(195 /* SyntaxKind.MappedType */);
node.readonlyToken = readonlyToken;
node.typeParameter = typeParameter;
node.nameType = nameType;
node.questionToken = questionToken;
node.type = type;
node.members = members && createNodeArray(members);
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -23322,9 +23888,9 @@ var ts;
}
// @api
function createLiteralTypeNode(literal) {
- var node = createBaseNode(195 /* LiteralType */);
+ var node = createBaseNode(196 /* SyntaxKind.LiteralType */);
node.literal = literal;
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -23338,16 +23904,16 @@ var ts;
//
// @api
function createObjectBindingPattern(elements) {
- var node = createBaseNode(200 /* ObjectBindingPattern */);
+ var node = createBaseNode(201 /* SyntaxKind.ObjectBindingPattern */);
node.elements = createNodeArray(elements);
node.transformFlags |=
propagateChildrenFlags(node.elements) |
- 1024 /* ContainsES2015 */ |
- 262144 /* ContainsBindingPattern */;
- if (node.transformFlags & 16384 /* ContainsRestOrSpread */) {
+ 1024 /* TransformFlags.ContainsES2015 */ |
+ 262144 /* TransformFlags.ContainsBindingPattern */;
+ if (node.transformFlags & 16384 /* TransformFlags.ContainsRestOrSpread */) {
node.transformFlags |=
- 128 /* ContainsES2018 */ |
- 32768 /* ContainsObjectRestOrSpread */;
+ 128 /* TransformFlags.ContainsES2018 */ |
+ 32768 /* TransformFlags.ContainsObjectRestOrSpread */;
}
return node;
}
@@ -23359,12 +23925,12 @@ var ts;
}
// @api
function createArrayBindingPattern(elements) {
- var node = createBaseNode(201 /* ArrayBindingPattern */);
+ var node = createBaseNode(202 /* SyntaxKind.ArrayBindingPattern */);
node.elements = createNodeArray(elements);
node.transformFlags |=
propagateChildrenFlags(node.elements) |
- 1024 /* ContainsES2015 */ |
- 262144 /* ContainsBindingPattern */;
+ 1024 /* TransformFlags.ContainsES2015 */ |
+ 262144 /* TransformFlags.ContainsBindingPattern */;
return node;
}
// @api
@@ -23375,21 +23941,21 @@ var ts;
}
// @api
function createBindingElement(dotDotDotToken, propertyName, name, initializer) {
- var node = createBaseBindingLikeDeclaration(202 /* BindingElement */,
+ var node = createBaseBindingLikeDeclaration(203 /* SyntaxKind.BindingElement */,
/*decorators*/ undefined,
/*modifiers*/ undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer));
node.propertyName = asName(propertyName);
node.dotDotDotToken = dotDotDotToken;
node.transformFlags |=
propagateChildFlags(node.dotDotDotToken) |
- 1024 /* ContainsES2015 */;
+ 1024 /* TransformFlags.ContainsES2015 */;
if (node.propertyName) {
node.transformFlags |= ts.isIdentifier(node.propertyName) ?
propagateIdentifierNameFlags(node.propertyName) :
propagateChildFlags(node.propertyName);
}
if (dotDotDotToken)
- node.transformFlags |= 16384 /* ContainsRestOrSpread */;
+ node.transformFlags |= 16384 /* TransformFlags.ContainsRestOrSpread */;
return node;
}
// @api
@@ -23411,7 +23977,7 @@ var ts;
}
// @api
function createArrayLiteralExpression(elements, multiLine) {
- var node = createBaseExpression(203 /* ArrayLiteralExpression */);
+ var node = createBaseExpression(204 /* SyntaxKind.ArrayLiteralExpression */);
// Ensure we add a trailing comma for something like `[NumericLiteral(1), NumericLiteral(2), OmittedExpresion]` so that
// we end up with `[1, 2, ,]` instead of `[1, 2, ]` otherwise the `OmittedExpression` will just end up being treated like
// a trailing comma.
@@ -23430,7 +23996,7 @@ var ts;
}
// @api
function createObjectLiteralExpression(properties, multiLine) {
- var node = createBaseExpression(204 /* ObjectLiteralExpression */);
+ var node = createBaseExpression(205 /* SyntaxKind.ObjectLiteralExpression */);
node.properties = createNodeArray(properties);
node.multiLine = multiLine;
node.transformFlags |= propagateChildrenFlags(node.properties);
@@ -23444,7 +24010,7 @@ var ts;
}
// @api
function createPropertyAccessExpression(expression, name) {
- var node = createBaseExpression(205 /* PropertyAccessExpression */);
+ var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */);
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
node.name = asName(name);
node.transformFlags =
@@ -23456,8 +24022,8 @@ var ts;
// super method calls require a lexical 'this'
// super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators
node.transformFlags |=
- 256 /* ContainsES2017 */ |
- 128 /* ContainsES2018 */;
+ 256 /* TransformFlags.ContainsES2017 */ |
+ 128 /* TransformFlags.ContainsES2018 */;
}
return node;
}
@@ -23473,13 +24039,13 @@ var ts;
}
// @api
function createPropertyAccessChain(expression, questionDotToken, name) {
- var node = createBaseExpression(205 /* PropertyAccessExpression */);
- node.flags |= 32 /* OptionalChain */;
+ var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */);
+ node.flags |= 32 /* NodeFlags.OptionalChain */;
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
node.questionDotToken = questionDotToken;
node.name = asName(name);
node.transformFlags |=
- 32 /* ContainsES2020 */ |
+ 32 /* TransformFlags.ContainsES2020 */ |
propagateChildFlags(node.expression) |
propagateChildFlags(node.questionDotToken) |
(ts.isIdentifier(node.name) ?
@@ -23489,7 +24055,7 @@ var ts;
}
// @api
function updatePropertyAccessChain(node, expression, questionDotToken, name) {
- ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead.");
+ ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead.");
// Because we are updating an existing PropertyAccessChain we want to inherit its emitFlags
// instead of using the default from createPropertyAccess
return node.expression !== expression
@@ -23500,7 +24066,7 @@ var ts;
}
// @api
function createElementAccessExpression(expression, index) {
- var node = createBaseExpression(206 /* ElementAccessExpression */);
+ var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */);
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
node.argumentExpression = asExpression(index);
node.transformFlags |=
@@ -23510,8 +24076,8 @@ var ts;
// super method calls require a lexical 'this'
// super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators
node.transformFlags |=
- 256 /* ContainsES2017 */ |
- 128 /* ContainsES2018 */;
+ 256 /* TransformFlags.ContainsES2017 */ |
+ 128 /* TransformFlags.ContainsES2018 */;
}
return node;
}
@@ -23527,8 +24093,8 @@ var ts;
}
// @api
function createElementAccessChain(expression, questionDotToken, index) {
- var node = createBaseExpression(206 /* ElementAccessExpression */);
- node.flags |= 32 /* OptionalChain */;
+ var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */);
+ node.flags |= 32 /* NodeFlags.OptionalChain */;
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
node.questionDotToken = questionDotToken;
node.argumentExpression = asExpression(index);
@@ -23536,12 +24102,12 @@ var ts;
propagateChildFlags(node.expression) |
propagateChildFlags(node.questionDotToken) |
propagateChildFlags(node.argumentExpression) |
- 32 /* ContainsES2020 */;
+ 32 /* TransformFlags.ContainsES2020 */;
return node;
}
// @api
function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) {
- ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead.");
+ ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead.");
// Because we are updating an existing ElementAccessChain we want to inherit its emitFlags
// instead of using the default from createElementAccess
return node.expression !== expression
@@ -23552,7 +24118,7 @@ var ts;
}
// @api
function createCallExpression(expression, typeArguments, argumentsArray) {
- var node = createBaseExpression(207 /* CallExpression */);
+ var node = createBaseExpression(208 /* SyntaxKind.CallExpression */);
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
node.typeArguments = asNodeArray(typeArguments);
node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
@@ -23561,13 +24127,13 @@ var ts;
propagateChildrenFlags(node.typeArguments) |
propagateChildrenFlags(node.arguments);
if (node.typeArguments) {
- node.transformFlags |= 1 /* ContainsTypeScript */;
+ node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */;
}
if (ts.isImportKeyword(node.expression)) {
- node.transformFlags |= 4194304 /* ContainsDynamicImport */;
+ node.transformFlags |= 4194304 /* TransformFlags.ContainsDynamicImport */;
}
else if (ts.isSuperProperty(node.expression)) {
- node.transformFlags |= 8192 /* ContainsLexicalThis */;
+ node.transformFlags |= 8192 /* TransformFlags.ContainsLexicalThis */;
}
return node;
}
@@ -23584,8 +24150,8 @@ var ts;
}
// @api
function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) {
- var node = createBaseExpression(207 /* CallExpression */);
- node.flags |= 32 /* OptionalChain */;
+ var node = createBaseExpression(208 /* SyntaxKind.CallExpression */);
+ node.flags |= 32 /* NodeFlags.OptionalChain */;
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
node.questionDotToken = questionDotToken;
node.typeArguments = asNodeArray(typeArguments);
@@ -23595,18 +24161,18 @@ var ts;
propagateChildFlags(node.questionDotToken) |
propagateChildrenFlags(node.typeArguments) |
propagateChildrenFlags(node.arguments) |
- 32 /* ContainsES2020 */;
+ 32 /* TransformFlags.ContainsES2020 */;
if (node.typeArguments) {
- node.transformFlags |= 1 /* ContainsTypeScript */;
+ node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */;
}
if (ts.isSuperProperty(node.expression)) {
- node.transformFlags |= 8192 /* ContainsLexicalThis */;
+ node.transformFlags |= 8192 /* TransformFlags.ContainsLexicalThis */;
}
return node;
}
// @api
function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) {
- ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead.");
+ ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead.");
return node.expression !== expression
|| node.questionDotToken !== questionDotToken
|| node.typeArguments !== typeArguments
@@ -23616,7 +24182,7 @@ var ts;
}
// @api
function createNewExpression(expression, typeArguments, argumentsArray) {
- var node = createBaseExpression(208 /* NewExpression */);
+ var node = createBaseExpression(209 /* SyntaxKind.NewExpression */);
node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression);
node.typeArguments = asNodeArray(typeArguments);
node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined;
@@ -23624,9 +24190,9 @@ var ts;
propagateChildFlags(node.expression) |
propagateChildrenFlags(node.typeArguments) |
propagateChildrenFlags(node.arguments) |
- 32 /* ContainsES2020 */;
+ 32 /* TransformFlags.ContainsES2020 */;
if (node.typeArguments) {
- node.transformFlags |= 1 /* ContainsTypeScript */;
+ node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */;
}
return node;
}
@@ -23640,7 +24206,7 @@ var ts;
}
// @api
function createTaggedTemplateExpression(tag, typeArguments, template) {
- var node = createBaseExpression(209 /* TaggedTemplateExpression */);
+ var node = createBaseExpression(210 /* SyntaxKind.TaggedTemplateExpression */);
node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag);
node.typeArguments = asNodeArray(typeArguments);
node.template = template;
@@ -23648,12 +24214,12 @@ var ts;
propagateChildFlags(node.tag) |
propagateChildrenFlags(node.typeArguments) |
propagateChildFlags(node.template) |
- 1024 /* ContainsES2015 */;
+ 1024 /* TransformFlags.ContainsES2015 */;
if (node.typeArguments) {
- node.transformFlags |= 1 /* ContainsTypeScript */;
+ node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */;
}
if (ts.hasInvalidEscape(node.template)) {
- node.transformFlags |= 128 /* ContainsES2018 */;
+ node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */;
}
return node;
}
@@ -23667,13 +24233,13 @@ var ts;
}
// @api
function createTypeAssertion(type, expression) {
- var node = createBaseExpression(210 /* TypeAssertionExpression */);
+ var node = createBaseExpression(211 /* SyntaxKind.TypeAssertionExpression */);
node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression);
node.type = type;
node.transformFlags |=
propagateChildFlags(node.expression) |
propagateChildFlags(node.type) |
- 1 /* ContainsTypeScript */;
+ 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -23685,7 +24251,7 @@ var ts;
}
// @api
function createParenthesizedExpression(expression) {
- var node = createBaseExpression(211 /* ParenthesizedExpression */);
+ var node = createBaseExpression(212 /* SyntaxKind.ParenthesizedExpression */);
node.expression = expression;
node.transformFlags = propagateChildFlags(node.expression);
return node;
@@ -23698,23 +24264,23 @@ var ts;
}
// @api
function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
- var node = createBaseFunctionLikeDeclaration(212 /* FunctionExpression */,
+ var node = createBaseFunctionLikeDeclaration(213 /* SyntaxKind.FunctionExpression */,
/*decorators*/ undefined, modifiers, name, typeParameters, parameters, type, body);
node.asteriskToken = asteriskToken;
node.transformFlags |= propagateChildFlags(node.asteriskToken);
if (node.typeParameters) {
- node.transformFlags |= 1 /* ContainsTypeScript */;
+ node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */;
}
- if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) {
+ if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) {
if (node.asteriskToken) {
- node.transformFlags |= 128 /* ContainsES2018 */;
+ node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */;
}
else {
- node.transformFlags |= 256 /* ContainsES2017 */;
+ node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */;
}
}
else if (node.asteriskToken) {
- node.transformFlags |= 2048 /* ContainsGenerator */;
+ node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */;
}
return node;
}
@@ -23732,15 +24298,15 @@ var ts;
}
// @api
function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) {
- var node = createBaseFunctionLikeDeclaration(213 /* ArrowFunction */,
+ var node = createBaseFunctionLikeDeclaration(214 /* SyntaxKind.ArrowFunction */,
/*decorators*/ undefined, modifiers,
/*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body));
- node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */);
+ node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* SyntaxKind.EqualsGreaterThanToken */);
node.transformFlags |=
propagateChildFlags(node.equalsGreaterThanToken) |
- 1024 /* ContainsES2015 */;
- if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) {
- node.transformFlags |= 256 /* ContainsES2017 */ | 8192 /* ContainsLexicalThis */;
+ 1024 /* TransformFlags.ContainsES2015 */;
+ if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) {
+ node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */ | 8192 /* TransformFlags.ContainsLexicalThis */;
}
return node;
}
@@ -23757,7 +24323,7 @@ var ts;
}
// @api
function createDeleteExpression(expression) {
- var node = createBaseExpression(214 /* DeleteExpression */);
+ var node = createBaseExpression(215 /* SyntaxKind.DeleteExpression */);
node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression);
node.transformFlags |= propagateChildFlags(node.expression);
return node;
@@ -23770,7 +24336,7 @@ var ts;
}
// @api
function createTypeOfExpression(expression) {
- var node = createBaseExpression(215 /* TypeOfExpression */);
+ var node = createBaseExpression(216 /* SyntaxKind.TypeOfExpression */);
node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression);
node.transformFlags |= propagateChildFlags(node.expression);
return node;
@@ -23783,7 +24349,7 @@ var ts;
}
// @api
function createVoidExpression(expression) {
- var node = createBaseExpression(216 /* VoidExpression */);
+ var node = createBaseExpression(217 /* SyntaxKind.VoidExpression */);
node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression);
node.transformFlags |= propagateChildFlags(node.expression);
return node;
@@ -23796,13 +24362,13 @@ var ts;
}
// @api
function createAwaitExpression(expression) {
- var node = createBaseExpression(217 /* AwaitExpression */);
+ var node = createBaseExpression(218 /* SyntaxKind.AwaitExpression */);
node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression);
node.transformFlags |=
propagateChildFlags(node.expression) |
- 256 /* ContainsES2017 */ |
- 128 /* ContainsES2018 */ |
- 1048576 /* ContainsAwait */;
+ 256 /* TransformFlags.ContainsES2017 */ |
+ 128 /* TransformFlags.ContainsES2018 */ |
+ 1048576 /* TransformFlags.ContainsAwait */;
return node;
}
// @api
@@ -23813,17 +24379,17 @@ var ts;
}
// @api
function createPrefixUnaryExpression(operator, operand) {
- var node = createBaseExpression(218 /* PrefixUnaryExpression */);
+ var node = createBaseExpression(219 /* SyntaxKind.PrefixUnaryExpression */);
node.operator = operator;
node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand);
node.transformFlags |= propagateChildFlags(node.operand);
// Only set this flag for non-generated identifiers and non-"local" names. See the
// comment in `visitPreOrPostfixUnaryExpression` in module.ts
- if ((operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */) &&
+ if ((operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */) &&
ts.isIdentifier(node.operand) &&
!ts.isGeneratedIdentifier(node.operand) &&
!ts.isLocalName(node.operand)) {
- node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */;
+ node.transformFlags |= 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */;
}
return node;
}
@@ -23835,7 +24401,7 @@ var ts;
}
// @api
function createPostfixUnaryExpression(operand, operator) {
- var node = createBaseExpression(219 /* PostfixUnaryExpression */);
+ var node = createBaseExpression(220 /* SyntaxKind.PostfixUnaryExpression */);
node.operator = operator;
node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand);
node.transformFlags |= propagateChildFlags(node.operand);
@@ -23844,7 +24410,7 @@ var ts;
if (ts.isIdentifier(node.operand) &&
!ts.isGeneratedIdentifier(node.operand) &&
!ts.isLocalName(node.operand)) {
- node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */;
+ node.transformFlags |= 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */;
}
return node;
}
@@ -23856,7 +24422,7 @@ var ts;
}
// @api
function createBinaryExpression(left, operator, right) {
- var node = createBaseExpression(220 /* BinaryExpression */);
+ var node = createBaseExpression(221 /* SyntaxKind.BinaryExpression */);
var operatorToken = asToken(operator);
var operatorKind = operatorToken.kind;
node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left);
@@ -23866,46 +24432,46 @@ var ts;
propagateChildFlags(node.left) |
propagateChildFlags(node.operatorToken) |
propagateChildFlags(node.right);
- if (operatorKind === 60 /* QuestionQuestionToken */) {
- node.transformFlags |= 32 /* ContainsES2020 */;
+ if (operatorKind === 60 /* SyntaxKind.QuestionQuestionToken */) {
+ node.transformFlags |= 32 /* TransformFlags.ContainsES2020 */;
}
- else if (operatorKind === 63 /* EqualsToken */) {
+ else if (operatorKind === 63 /* SyntaxKind.EqualsToken */) {
if (ts.isObjectLiteralExpression(node.left)) {
node.transformFlags |=
- 1024 /* ContainsES2015 */ |
- 128 /* ContainsES2018 */ |
- 4096 /* ContainsDestructuringAssignment */ |
+ 1024 /* TransformFlags.ContainsES2015 */ |
+ 128 /* TransformFlags.ContainsES2018 */ |
+ 4096 /* TransformFlags.ContainsDestructuringAssignment */ |
propagateAssignmentPatternFlags(node.left);
}
else if (ts.isArrayLiteralExpression(node.left)) {
node.transformFlags |=
- 1024 /* ContainsES2015 */ |
- 4096 /* ContainsDestructuringAssignment */ |
+ 1024 /* TransformFlags.ContainsES2015 */ |
+ 4096 /* TransformFlags.ContainsDestructuringAssignment */ |
propagateAssignmentPatternFlags(node.left);
}
}
- else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 67 /* AsteriskAsteriskEqualsToken */) {
- node.transformFlags |= 512 /* ContainsES2016 */;
+ else if (operatorKind === 42 /* SyntaxKind.AsteriskAsteriskToken */ || operatorKind === 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */) {
+ node.transformFlags |= 512 /* TransformFlags.ContainsES2016 */;
}
else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) {
- node.transformFlags |= 16 /* ContainsES2021 */;
+ node.transformFlags |= 16 /* TransformFlags.ContainsES2021 */;
}
return node;
}
function propagateAssignmentPatternFlags(node) {
- if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */)
- return 32768 /* ContainsObjectRestOrSpread */;
- if (node.transformFlags & 128 /* ContainsES2018 */) {
+ if (node.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */)
+ return 32768 /* TransformFlags.ContainsObjectRestOrSpread */;
+ if (node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) {
// check for nested spread assignments, otherwise '{ x: { a, ...b } = foo } = c'
// will not be correctly interpreted by the ES2018 transformer
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 /* ContainsObjectRestOrSpread */) {
- return 32768 /* ContainsObjectRestOrSpread */;
+ if (target.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) {
+ return 32768 /* TransformFlags.ContainsObjectRestOrSpread */;
}
- if (target.transformFlags & 128 /* ContainsES2018 */) {
+ if (target.transformFlags & 128 /* TransformFlags.ContainsES2018 */) {
var flags_1 = propagateAssignmentPatternFlags(target);
if (flags_1)
return flags_1;
@@ -23913,7 +24479,7 @@ var ts;
}
}
}
- return 0 /* None */;
+ return 0 /* TransformFlags.None */;
}
// @api
function updateBinaryExpression(node, left, operator, right) {
@@ -23925,11 +24491,11 @@ var ts;
}
// @api
function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) {
- var node = createBaseExpression(221 /* ConditionalExpression */);
+ var node = createBaseExpression(222 /* SyntaxKind.ConditionalExpression */);
node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition);
- node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* QuestionToken */);
+ node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* SyntaxKind.QuestionToken */);
node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue);
- node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* ColonToken */);
+ node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* SyntaxKind.ColonToken */);
node.whenFalse = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenFalse);
node.transformFlags |=
propagateChildFlags(node.condition) |
@@ -23951,13 +24517,13 @@ var ts;
}
// @api
function createTemplateExpression(head, templateSpans) {
- var node = createBaseExpression(222 /* TemplateExpression */);
+ var node = createBaseExpression(223 /* SyntaxKind.TemplateExpression */);
node.head = head;
node.templateSpans = createNodeArray(templateSpans);
node.transformFlags |=
propagateChildFlags(node.head) |
propagateChildrenFlags(node.templateSpans) |
- 1024 /* ContainsES2015 */;
+ 1024 /* TransformFlags.ContainsES2015 */;
return node;
}
// @api
@@ -23968,8 +24534,8 @@ var ts;
: node;
}
function createTemplateLiteralLikeNodeChecked(kind, text, rawText, templateFlags) {
- if (templateFlags === void 0) { templateFlags = 0 /* None */; }
- ts.Debug.assert(!(templateFlags & ~2048 /* TemplateLiteralLikeFlags */), "Unsupported template flags.");
+ if (templateFlags === void 0) { templateFlags = 0 /* TokenFlags.None */; }
+ ts.Debug.assert(!(templateFlags & ~2048 /* TokenFlags.TemplateLiteralLikeFlags */), "Unsupported template flags.");
// NOTE: without the assignment to `undefined`, we don't narrow the initial type of `cooked`.
// eslint-disable-next-line no-undef-init
var cooked = undefined;
@@ -23995,41 +24561,41 @@ var ts;
var node = createBaseToken(kind);
node.text = text;
node.rawText = rawText;
- node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */;
- node.transformFlags |= 1024 /* ContainsES2015 */;
+ node.templateFlags = templateFlags & 2048 /* TokenFlags.TemplateLiteralLikeFlags */;
+ node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */;
if (node.templateFlags) {
- node.transformFlags |= 128 /* ContainsES2018 */;
+ node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */;
}
return node;
}
// @api
function createTemplateHead(text, rawText, templateFlags) {
- return createTemplateLiteralLikeNodeChecked(15 /* TemplateHead */, text, rawText, templateFlags);
+ return createTemplateLiteralLikeNodeChecked(15 /* SyntaxKind.TemplateHead */, text, rawText, templateFlags);
}
// @api
function createTemplateMiddle(text, rawText, templateFlags) {
- return createTemplateLiteralLikeNodeChecked(16 /* TemplateMiddle */, text, rawText, templateFlags);
+ return createTemplateLiteralLikeNodeChecked(16 /* SyntaxKind.TemplateMiddle */, text, rawText, templateFlags);
}
// @api
function createTemplateTail(text, rawText, templateFlags) {
- return createTemplateLiteralLikeNodeChecked(17 /* TemplateTail */, text, rawText, templateFlags);
+ return createTemplateLiteralLikeNodeChecked(17 /* SyntaxKind.TemplateTail */, text, rawText, templateFlags);
}
// @api
function createNoSubstitutionTemplateLiteral(text, rawText, templateFlags) {
- return createTemplateLiteralLikeNodeChecked(14 /* NoSubstitutionTemplateLiteral */, text, rawText, templateFlags);
+ return createTemplateLiteralLikeNodeChecked(14 /* SyntaxKind.NoSubstitutionTemplateLiteral */, text, rawText, templateFlags);
}
// @api
function createYieldExpression(asteriskToken, expression) {
ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression.");
- var node = createBaseExpression(223 /* YieldExpression */);
+ var node = createBaseExpression(224 /* SyntaxKind.YieldExpression */);
node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
node.asteriskToken = asteriskToken;
node.transformFlags |=
propagateChildFlags(node.expression) |
propagateChildFlags(node.asteriskToken) |
- 1024 /* ContainsES2015 */ |
- 128 /* ContainsES2018 */ |
- 524288 /* ContainsYield */;
+ 1024 /* TransformFlags.ContainsES2015 */ |
+ 128 /* TransformFlags.ContainsES2018 */ |
+ 524288 /* TransformFlags.ContainsYield */;
return node;
}
// @api
@@ -24041,12 +24607,12 @@ var ts;
}
// @api
function createSpreadElement(expression) {
- var node = createBaseExpression(224 /* SpreadElement */);
+ var node = createBaseExpression(225 /* SyntaxKind.SpreadElement */);
node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
node.transformFlags |=
propagateChildFlags(node.expression) |
- 1024 /* ContainsES2015 */ |
- 16384 /* ContainsRestOrSpread */;
+ 1024 /* TransformFlags.ContainsES2015 */ |
+ 16384 /* TransformFlags.ContainsRestOrSpread */;
return node;
}
// @api
@@ -24057,8 +24623,8 @@ var ts;
}
// @api
function createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members) {
- var node = createBaseClassLikeDeclaration(225 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members);
- node.transformFlags |= 1024 /* ContainsES2015 */;
+ var node = createBaseClassLikeDeclaration(226 /* SyntaxKind.ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members);
+ node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */;
return node;
}
// @api
@@ -24074,17 +24640,17 @@ var ts;
}
// @api
function createOmittedExpression() {
- return createBaseExpression(226 /* OmittedExpression */);
+ return createBaseExpression(227 /* SyntaxKind.OmittedExpression */);
}
// @api
function createExpressionWithTypeArguments(expression, typeArguments) {
- var node = createBaseNode(227 /* ExpressionWithTypeArguments */);
+ var node = createBaseNode(228 /* SyntaxKind.ExpressionWithTypeArguments */);
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
node.transformFlags |=
propagateChildFlags(node.expression) |
propagateChildrenFlags(node.typeArguments) |
- 1024 /* ContainsES2015 */;
+ 1024 /* TransformFlags.ContainsES2015 */;
return node;
}
// @api
@@ -24096,13 +24662,13 @@ var ts;
}
// @api
function createAsExpression(expression, type) {
- var node = createBaseExpression(228 /* AsExpression */);
+ var node = createBaseExpression(229 /* SyntaxKind.AsExpression */);
node.expression = expression;
node.type = type;
node.transformFlags |=
propagateChildFlags(node.expression) |
propagateChildFlags(node.type) |
- 1 /* ContainsTypeScript */;
+ 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -24114,11 +24680,11 @@ var ts;
}
// @api
function createNonNullExpression(expression) {
- var node = createBaseExpression(229 /* NonNullExpression */);
+ var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */);
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
node.transformFlags |=
propagateChildFlags(node.expression) |
- 1 /* ContainsTypeScript */;
+ 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -24132,33 +24698,33 @@ var ts;
}
// @api
function createNonNullChain(expression) {
- var node = createBaseExpression(229 /* NonNullExpression */);
- node.flags |= 32 /* OptionalChain */;
+ var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */);
+ node.flags |= 32 /* NodeFlags.OptionalChain */;
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
node.transformFlags |=
propagateChildFlags(node.expression) |
- 1 /* ContainsTypeScript */;
+ 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
function updateNonNullChain(node, expression) {
- ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead.");
+ ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead.");
return node.expression !== expression
? update(createNonNullChain(expression), node)
: node;
}
// @api
function createMetaProperty(keywordToken, name) {
- var node = createBaseExpression(230 /* MetaProperty */);
+ var node = createBaseExpression(231 /* SyntaxKind.MetaProperty */);
node.keywordToken = keywordToken;
node.name = name;
node.transformFlags |= propagateChildFlags(node.name);
switch (keywordToken) {
- case 103 /* NewKeyword */:
- node.transformFlags |= 1024 /* ContainsES2015 */;
+ case 103 /* SyntaxKind.NewKeyword */:
+ node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */;
break;
- case 100 /* ImportKeyword */:
- node.transformFlags |= 4 /* ContainsESNext */;
+ case 100 /* SyntaxKind.ImportKeyword */:
+ node.transformFlags |= 4 /* TransformFlags.ContainsESNext */;
break;
default:
return ts.Debug.assertNever(keywordToken);
@@ -24176,13 +24742,13 @@ var ts;
//
// @api
function createTemplateSpan(expression, literal) {
- var node = createBaseNode(232 /* TemplateSpan */);
+ var node = createBaseNode(233 /* SyntaxKind.TemplateSpan */);
node.expression = expression;
node.literal = literal;
node.transformFlags |=
propagateChildFlags(node.expression) |
propagateChildFlags(node.literal) |
- 1024 /* ContainsES2015 */;
+ 1024 /* TransformFlags.ContainsES2015 */;
return node;
}
// @api
@@ -24194,8 +24760,8 @@ var ts;
}
// @api
function createSemicolonClassElement() {
- var node = createBaseNode(233 /* SemicolonClassElement */);
- node.transformFlags |= 1024 /* ContainsES2015 */;
+ var node = createBaseNode(234 /* SyntaxKind.SemicolonClassElement */);
+ node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */;
return node;
}
//
@@ -24203,7 +24769,7 @@ var ts;
//
// @api
function createBlock(statements, multiLine) {
- var node = createBaseNode(234 /* Block */);
+ var node = createBaseNode(235 /* SyntaxKind.Block */);
node.statements = createNodeArray(statements);
node.multiLine = multiLine;
node.transformFlags |= propagateChildrenFlags(node.statements);
@@ -24217,12 +24783,12 @@ var ts;
}
// @api
function createVariableStatement(modifiers, declarationList) {
- var node = createBaseDeclaration(236 /* VariableStatement */, /*decorators*/ undefined, modifiers);
+ var node = createBaseDeclaration(237 /* SyntaxKind.VariableStatement */, /*decorators*/ undefined, modifiers);
node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList;
node.transformFlags |=
propagateChildFlags(node.declarationList);
- if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) {
- node.transformFlags = 1 /* ContainsTypeScript */;
+ if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) {
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
}
return node;
}
@@ -24235,11 +24801,11 @@ var ts;
}
// @api
function createEmptyStatement() {
- return createBaseNode(235 /* EmptyStatement */);
+ return createBaseNode(236 /* SyntaxKind.EmptyStatement */);
}
// @api
function createExpressionStatement(expression) {
- var node = createBaseNode(237 /* ExpressionStatement */);
+ var node = createBaseNode(238 /* SyntaxKind.ExpressionStatement */);
node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression);
node.transformFlags |= propagateChildFlags(node.expression);
return node;
@@ -24252,7 +24818,7 @@ var ts;
}
// @api
function createIfStatement(expression, thenStatement, elseStatement) {
- var node = createBaseNode(238 /* IfStatement */);
+ var node = createBaseNode(239 /* SyntaxKind.IfStatement */);
node.expression = expression;
node.thenStatement = asEmbeddedStatement(thenStatement);
node.elseStatement = asEmbeddedStatement(elseStatement);
@@ -24272,7 +24838,7 @@ var ts;
}
// @api
function createDoStatement(statement, expression) {
- var node = createBaseNode(239 /* DoStatement */);
+ var node = createBaseNode(240 /* SyntaxKind.DoStatement */);
node.statement = asEmbeddedStatement(statement);
node.expression = expression;
node.transformFlags |=
@@ -24289,7 +24855,7 @@ var ts;
}
// @api
function createWhileStatement(expression, statement) {
- var node = createBaseNode(240 /* WhileStatement */);
+ var node = createBaseNode(241 /* SyntaxKind.WhileStatement */);
node.expression = expression;
node.statement = asEmbeddedStatement(statement);
node.transformFlags |=
@@ -24306,7 +24872,7 @@ var ts;
}
// @api
function createForStatement(initializer, condition, incrementor, statement) {
- var node = createBaseNode(241 /* ForStatement */);
+ var node = createBaseNode(242 /* SyntaxKind.ForStatement */);
node.initializer = initializer;
node.condition = condition;
node.incrementor = incrementor;
@@ -24329,7 +24895,7 @@ var ts;
}
// @api
function createForInStatement(initializer, expression, statement) {
- var node = createBaseNode(242 /* ForInStatement */);
+ var node = createBaseNode(243 /* SyntaxKind.ForInStatement */);
node.initializer = initializer;
node.expression = expression;
node.statement = asEmbeddedStatement(statement);
@@ -24349,7 +24915,7 @@ var ts;
}
// @api
function createForOfStatement(awaitModifier, initializer, expression, statement) {
- var node = createBaseNode(243 /* ForOfStatement */);
+ var node = createBaseNode(244 /* SyntaxKind.ForOfStatement */);
node.awaitModifier = awaitModifier;
node.initializer = initializer;
node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
@@ -24359,9 +24925,9 @@ var ts;
propagateChildFlags(node.initializer) |
propagateChildFlags(node.expression) |
propagateChildFlags(node.statement) |
- 1024 /* ContainsES2015 */;
+ 1024 /* TransformFlags.ContainsES2015 */;
if (awaitModifier)
- node.transformFlags |= 128 /* ContainsES2018 */;
+ node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */;
return node;
}
// @api
@@ -24375,11 +24941,11 @@ var ts;
}
// @api
function createContinueStatement(label) {
- var node = createBaseNode(244 /* ContinueStatement */);
+ var node = createBaseNode(245 /* SyntaxKind.ContinueStatement */);
node.label = asName(label);
node.transformFlags |=
propagateChildFlags(node.label) |
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
+ 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */;
return node;
}
// @api
@@ -24390,11 +24956,11 @@ var ts;
}
// @api
function createBreakStatement(label) {
- var node = createBaseNode(245 /* BreakStatement */);
+ var node = createBaseNode(246 /* SyntaxKind.BreakStatement */);
node.label = asName(label);
node.transformFlags |=
propagateChildFlags(node.label) |
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
+ 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */;
return node;
}
// @api
@@ -24405,13 +24971,13 @@ var ts;
}
// @api
function createReturnStatement(expression) {
- var node = createBaseNode(246 /* ReturnStatement */);
+ var node = createBaseNode(247 /* SyntaxKind.ReturnStatement */);
node.expression = expression;
// return in an ES2018 async generator must be awaited
node.transformFlags |=
propagateChildFlags(node.expression) |
- 128 /* ContainsES2018 */ |
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
+ 128 /* TransformFlags.ContainsES2018 */ |
+ 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */;
return node;
}
// @api
@@ -24422,7 +24988,7 @@ var ts;
}
// @api
function createWithStatement(expression, statement) {
- var node = createBaseNode(247 /* WithStatement */);
+ var node = createBaseNode(248 /* SyntaxKind.WithStatement */);
node.expression = expression;
node.statement = asEmbeddedStatement(statement);
node.transformFlags |=
@@ -24439,7 +25005,7 @@ var ts;
}
// @api
function createSwitchStatement(expression, caseBlock) {
- var node = createBaseNode(248 /* SwitchStatement */);
+ var node = createBaseNode(249 /* SyntaxKind.SwitchStatement */);
node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
node.caseBlock = caseBlock;
node.transformFlags |=
@@ -24456,7 +25022,7 @@ var ts;
}
// @api
function createLabeledStatement(label, statement) {
- var node = createBaseNode(249 /* LabeledStatement */);
+ var node = createBaseNode(250 /* SyntaxKind.LabeledStatement */);
node.label = asName(label);
node.statement = asEmbeddedStatement(statement);
node.transformFlags |=
@@ -24473,7 +25039,7 @@ var ts;
}
// @api
function createThrowStatement(expression) {
- var node = createBaseNode(250 /* ThrowStatement */);
+ var node = createBaseNode(251 /* SyntaxKind.ThrowStatement */);
node.expression = expression;
node.transformFlags |= propagateChildFlags(node.expression);
return node;
@@ -24486,7 +25052,7 @@ var ts;
}
// @api
function createTryStatement(tryBlock, catchClause, finallyBlock) {
- var node = createBaseNode(251 /* TryStatement */);
+ var node = createBaseNode(252 /* SyntaxKind.TryStatement */);
node.tryBlock = tryBlock;
node.catchClause = catchClause;
node.finallyBlock = finallyBlock;
@@ -24506,17 +25072,17 @@ var ts;
}
// @api
function createDebuggerStatement() {
- return createBaseNode(252 /* DebuggerStatement */);
+ return createBaseNode(253 /* SyntaxKind.DebuggerStatement */);
}
// @api
function createVariableDeclaration(name, exclamationToken, type, initializer) {
- var node = createBaseVariableLikeDeclaration(253 /* VariableDeclaration */,
+ var node = createBaseVariableLikeDeclaration(254 /* SyntaxKind.VariableDeclaration */,
/*decorators*/ undefined,
/*modifiers*/ undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer));
node.exclamationToken = exclamationToken;
node.transformFlags |= propagateChildFlags(node.exclamationToken);
if (exclamationToken) {
- node.transformFlags |= 1 /* ContainsTypeScript */;
+ node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */;
}
return node;
}
@@ -24531,17 +25097,17 @@ var ts;
}
// @api
function createVariableDeclarationList(declarations, flags) {
- if (flags === void 0) { flags = 0 /* None */; }
- var node = createBaseNode(254 /* VariableDeclarationList */);
- node.flags |= flags & 3 /* BlockScoped */;
+ if (flags === void 0) { flags = 0 /* NodeFlags.None */; }
+ var node = createBaseNode(255 /* SyntaxKind.VariableDeclarationList */);
+ node.flags |= flags & 3 /* NodeFlags.BlockScoped */;
node.declarations = createNodeArray(declarations);
node.transformFlags |=
propagateChildrenFlags(node.declarations) |
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
- if (flags & 3 /* BlockScoped */) {
+ 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */;
+ if (flags & 3 /* NodeFlags.BlockScoped */) {
node.transformFlags |=
- 1024 /* ContainsES2015 */ |
- 131072 /* ContainsBlockScopedBinding */;
+ 1024 /* TransformFlags.ContainsES2015 */ |
+ 131072 /* TransformFlags.ContainsBlockScopedBinding */;
}
return node;
}
@@ -24553,25 +25119,25 @@ var ts;
}
// @api
function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
- var node = createBaseFunctionLikeDeclaration(255 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body);
+ var node = createBaseFunctionLikeDeclaration(256 /* SyntaxKind.FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body);
node.asteriskToken = asteriskToken;
- if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) {
- node.transformFlags = 1 /* ContainsTypeScript */;
+ if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) {
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
}
else {
node.transformFlags |=
propagateChildFlags(node.asteriskToken) |
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
- if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) {
+ 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */;
+ if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) {
if (node.asteriskToken) {
- node.transformFlags |= 128 /* ContainsES2018 */;
+ node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */;
}
else {
- node.transformFlags |= 256 /* ContainsES2017 */;
+ node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */;
}
}
else if (node.asteriskToken) {
- node.transformFlags |= 2048 /* ContainsGenerator */;
+ node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */;
}
}
return node;
@@ -24591,14 +25157,14 @@ var ts;
}
// @api
function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) {
- var node = createBaseClassLikeDeclaration(256 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members);
- if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) {
- node.transformFlags = 1 /* ContainsTypeScript */;
+ var node = createBaseClassLikeDeclaration(257 /* SyntaxKind.ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members);
+ if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) {
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
}
else {
- node.transformFlags |= 1024 /* ContainsES2015 */;
- if (node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */) {
- node.transformFlags |= 1 /* ContainsTypeScript */;
+ node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */;
+ if (node.transformFlags & 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */) {
+ node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */;
}
}
return node;
@@ -24616,9 +25182,9 @@ var ts;
}
// @api
function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) {
- var node = createBaseInterfaceOrClassLikeDeclaration(257 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses);
+ var node = createBaseInterfaceOrClassLikeDeclaration(258 /* SyntaxKind.InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses);
node.members = createNodeArray(members);
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -24634,9 +25200,9 @@ var ts;
}
// @api
function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) {
- var node = createBaseGenericNamedDeclaration(258 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters);
+ var node = createBaseGenericNamedDeclaration(259 /* SyntaxKind.TypeAliasDeclaration */, decorators, modifiers, name, typeParameters);
node.type = type;
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -24651,12 +25217,12 @@ var ts;
}
// @api
function createEnumDeclaration(decorators, modifiers, name, members) {
- var node = createBaseNamedDeclaration(259 /* EnumDeclaration */, decorators, modifiers, name);
+ var node = createBaseNamedDeclaration(260 /* SyntaxKind.EnumDeclaration */, decorators, modifiers, name);
node.members = createNodeArray(members);
node.transformFlags |=
propagateChildrenFlags(node.members) |
- 1 /* ContainsTypeScript */;
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await`
+ 1 /* TransformFlags.ContainsTypeScript */;
+ node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await`
return node;
}
// @api
@@ -24670,21 +25236,21 @@ var ts;
}
// @api
function createModuleDeclaration(decorators, modifiers, name, body, flags) {
- if (flags === void 0) { flags = 0 /* None */; }
- var node = createBaseDeclaration(260 /* ModuleDeclaration */, decorators, modifiers);
- node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */);
+ if (flags === void 0) { flags = 0 /* NodeFlags.None */; }
+ var node = createBaseDeclaration(261 /* SyntaxKind.ModuleDeclaration */, decorators, modifiers);
+ node.flags |= flags & (16 /* NodeFlags.Namespace */ | 4 /* NodeFlags.NestedNamespace */ | 1024 /* NodeFlags.GlobalAugmentation */);
node.name = name;
node.body = body;
- if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) {
- node.transformFlags = 1 /* ContainsTypeScript */;
+ if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) {
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
}
else {
node.transformFlags |=
propagateChildFlags(node.name) |
propagateChildFlags(node.body) |
- 1 /* ContainsTypeScript */;
+ 1 /* TransformFlags.ContainsTypeScript */;
}
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`.
+ node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`.
return node;
}
// @api
@@ -24698,7 +25264,7 @@ var ts;
}
// @api
function createModuleBlock(statements) {
- var node = createBaseNode(261 /* ModuleBlock */);
+ var node = createBaseNode(262 /* SyntaxKind.ModuleBlock */);
node.statements = createNodeArray(statements);
node.transformFlags |= propagateChildrenFlags(node.statements);
return node;
@@ -24711,7 +25277,7 @@ var ts;
}
// @api
function createCaseBlock(clauses) {
- var node = createBaseNode(262 /* CaseBlock */);
+ var node = createBaseNode(263 /* SyntaxKind.CaseBlock */);
node.clauses = createNodeArray(clauses);
node.transformFlags |= propagateChildrenFlags(node.clauses);
return node;
@@ -24724,10 +25290,10 @@ var ts;
}
// @api
function createNamespaceExportDeclaration(name) {
- var node = createBaseNamedDeclaration(263 /* NamespaceExportDeclaration */,
+ var node = createBaseNamedDeclaration(264 /* SyntaxKind.NamespaceExportDeclaration */,
/*decorators*/ undefined,
/*modifiers*/ undefined, name);
- node.transformFlags = 1 /* ContainsTypeScript */;
+ node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -24738,13 +25304,13 @@ var ts;
}
// @api
function createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference) {
- var node = createBaseNamedDeclaration(264 /* ImportEqualsDeclaration */, decorators, modifiers, name);
+ var node = createBaseNamedDeclaration(265 /* SyntaxKind.ImportEqualsDeclaration */, decorators, modifiers, name);
node.isTypeOnly = isTypeOnly;
node.moduleReference = moduleReference;
node.transformFlags |= propagateChildFlags(node.moduleReference);
if (!ts.isExternalModuleReference(node.moduleReference))
- node.transformFlags |= 1 /* ContainsTypeScript */;
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context
+ node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */;
+ node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context
return node;
}
// @api
@@ -24759,14 +25325,14 @@ var ts;
}
// @api
function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, assertClause) {
- var node = createBaseDeclaration(265 /* ImportDeclaration */, decorators, modifiers);
+ var node = createBaseDeclaration(266 /* SyntaxKind.ImportDeclaration */, decorators, modifiers);
node.importClause = importClause;
node.moduleSpecifier = moduleSpecifier;
node.assertClause = assertClause;
node.transformFlags |=
propagateChildFlags(node.importClause) |
propagateChildFlags(node.moduleSpecifier);
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
+ node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context
return node;
}
// @api
@@ -24781,7 +25347,7 @@ var ts;
}
// @api
function createImportClause(isTypeOnly, name, namedBindings) {
- var node = createBaseNode(266 /* ImportClause */);
+ var node = createBaseNode(267 /* SyntaxKind.ImportClause */);
node.isTypeOnly = isTypeOnly;
node.name = name;
node.namedBindings = namedBindings;
@@ -24789,9 +25355,9 @@ var ts;
propagateChildFlags(node.name) |
propagateChildFlags(node.namedBindings);
if (isTypeOnly) {
- node.transformFlags |= 1 /* ContainsTypeScript */;
+ node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */;
}
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
+ node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context
return node;
}
// @api
@@ -24804,10 +25370,10 @@ var ts;
}
// @api
function createAssertClause(elements, multiLine) {
- var node = createBaseNode(292 /* AssertClause */);
+ var node = createBaseNode(293 /* SyntaxKind.AssertClause */);
node.elements = createNodeArray(elements);
node.multiLine = multiLine;
- node.transformFlags |= 4 /* ContainsESNext */;
+ node.transformFlags |= 4 /* TransformFlags.ContainsESNext */;
return node;
}
// @api
@@ -24819,10 +25385,10 @@ var ts;
}
// @api
function createAssertEntry(name, value) {
- var node = createBaseNode(293 /* AssertEntry */);
+ var node = createBaseNode(294 /* SyntaxKind.AssertEntry */);
node.name = name;
node.value = value;
- node.transformFlags |= 4 /* ContainsESNext */;
+ node.transformFlags |= 4 /* TransformFlags.ContainsESNext */;
return node;
}
// @api
@@ -24833,11 +25399,25 @@ var ts;
: node;
}
// @api
+ function createImportTypeAssertionContainer(clause, multiLine) {
+ var node = createBaseNode(295 /* SyntaxKind.ImportTypeAssertionContainer */);
+ node.assertClause = clause;
+ node.multiLine = multiLine;
+ return node;
+ }
+ // @api
+ function updateImportTypeAssertionContainer(node, clause, multiLine) {
+ return node.assertClause !== clause
+ || node.multiLine !== multiLine
+ ? update(createImportTypeAssertionContainer(clause, multiLine), node)
+ : node;
+ }
+ // @api
function createNamespaceImport(name) {
- var node = createBaseNode(267 /* NamespaceImport */);
+ var node = createBaseNode(268 /* SyntaxKind.NamespaceImport */);
node.name = name;
node.transformFlags |= propagateChildFlags(node.name);
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
+ node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context
return node;
}
// @api
@@ -24848,12 +25428,12 @@ var ts;
}
// @api
function createNamespaceExport(name) {
- var node = createBaseNode(273 /* NamespaceExport */);
+ var node = createBaseNode(274 /* SyntaxKind.NamespaceExport */);
node.name = name;
node.transformFlags |=
propagateChildFlags(node.name) |
- 4 /* ContainsESNext */;
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
+ 4 /* TransformFlags.ContainsESNext */;
+ node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context
return node;
}
// @api
@@ -24864,10 +25444,10 @@ var ts;
}
// @api
function createNamedImports(elements) {
- var node = createBaseNode(268 /* NamedImports */);
+ var node = createBaseNode(269 /* SyntaxKind.NamedImports */);
node.elements = createNodeArray(elements);
node.transformFlags |= propagateChildrenFlags(node.elements);
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
+ node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context
return node;
}
// @api
@@ -24878,14 +25458,14 @@ var ts;
}
// @api
function createImportSpecifier(isTypeOnly, propertyName, name) {
- var node = createBaseNode(269 /* ImportSpecifier */);
+ var node = createBaseNode(270 /* SyntaxKind.ImportSpecifier */);
node.isTypeOnly = isTypeOnly;
node.propertyName = propertyName;
node.name = name;
node.transformFlags |=
propagateChildFlags(node.propertyName) |
propagateChildFlags(node.name);
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
+ node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context
return node;
}
// @api
@@ -24898,13 +25478,13 @@ var ts;
}
// @api
function createExportAssignment(decorators, modifiers, isExportEquals, expression) {
- var node = createBaseDeclaration(270 /* ExportAssignment */, decorators, modifiers);
+ var node = createBaseDeclaration(271 /* SyntaxKind.ExportAssignment */, decorators, modifiers);
node.isExportEquals = isExportEquals;
node.expression = isExportEquals
- ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression)
+ ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* SyntaxKind.EqualsToken */, /*leftSide*/ undefined, expression)
: parenthesizerRules().parenthesizeExpressionOfExportDefault(expression);
node.transformFlags |= propagateChildFlags(node.expression);
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
+ node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context
return node;
}
// @api
@@ -24917,7 +25497,7 @@ var ts;
}
// @api
function createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause) {
- var node = createBaseDeclaration(271 /* ExportDeclaration */, decorators, modifiers);
+ var node = createBaseDeclaration(272 /* SyntaxKind.ExportDeclaration */, decorators, modifiers);
node.isTypeOnly = isTypeOnly;
node.exportClause = exportClause;
node.moduleSpecifier = moduleSpecifier;
@@ -24925,7 +25505,7 @@ var ts;
node.transformFlags |=
propagateChildFlags(node.exportClause) |
propagateChildFlags(node.moduleSpecifier);
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
+ node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context
return node;
}
// @api
@@ -24941,10 +25521,10 @@ var ts;
}
// @api
function createNamedExports(elements) {
- var node = createBaseNode(272 /* NamedExports */);
+ var node = createBaseNode(273 /* SyntaxKind.NamedExports */);
node.elements = createNodeArray(elements);
node.transformFlags |= propagateChildrenFlags(node.elements);
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
+ node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context
return node;
}
// @api
@@ -24955,14 +25535,14 @@ var ts;
}
// @api
function createExportSpecifier(isTypeOnly, propertyName, name) {
- var node = createBaseNode(274 /* ExportSpecifier */);
+ var node = createBaseNode(275 /* SyntaxKind.ExportSpecifier */);
node.isTypeOnly = isTypeOnly;
node.propertyName = asName(propertyName);
node.name = asName(name);
node.transformFlags |=
propagateChildFlags(node.propertyName) |
propagateChildFlags(node.name);
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
+ node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context
return node;
}
// @api
@@ -24975,7 +25555,7 @@ var ts;
}
// @api
function createMissingDeclaration() {
- var node = createBaseDeclaration(275 /* MissingDeclaration */,
+ var node = createBaseDeclaration(276 /* SyntaxKind.MissingDeclaration */,
/*decorators*/ undefined,
/*modifiers*/ undefined);
return node;
@@ -24985,10 +25565,10 @@ var ts;
//
// @api
function createExternalModuleReference(expression) {
- var node = createBaseNode(276 /* ExternalModuleReference */);
+ var node = createBaseNode(277 /* SyntaxKind.ExternalModuleReference */);
node.expression = expression;
node.transformFlags |= propagateChildFlags(node.expression);
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
+ node.transformFlags &= ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context
return node;
}
// @api
@@ -25007,8 +25587,15 @@ var ts;
return createBaseNode(kind);
}
// @api
- // createJSDocNonNullableType
// createJSDocNullableType
+ // createJSDocNonNullableType
+ function createJSDocPrePostfixUnaryTypeWorker(kind, type, postfix) {
+ if (postfix === void 0) { postfix = false; }
+ var node = createJSDocUnaryTypeWorker(kind, postfix ? type && parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(type) : type);
+ node.postfix = postfix;
+ return node;
+ }
+ // @api
// createJSDocOptionalType
// createJSDocVariadicType
// createJSDocNamepathType
@@ -25020,6 +25607,12 @@ var ts;
// @api
// updateJSDocNonNullableType
// updateJSDocNullableType
+ function updateJSDocPrePostfixUnaryTypeWorker(kind, node, type) {
+ return node.type !== type
+ ? update(createJSDocPrePostfixUnaryTypeWorker(kind, type, node.postfix), node)
+ : node;
+ }
+ // @api
// updateJSDocOptionalType
// updateJSDocVariadicType
// updateJSDocNamepathType
@@ -25030,7 +25623,7 @@ var ts;
}
// @api
function createJSDocFunctionType(parameters, type) {
- var node = createBaseSignatureDeclaration(315 /* JSDocFunctionType */,
+ var node = createBaseSignatureDeclaration(317 /* SyntaxKind.JSDocFunctionType */,
/*decorators*/ undefined,
/*modifiers*/ undefined,
/*name*/ undefined,
@@ -25047,7 +25640,7 @@ var ts;
// @api
function createJSDocTypeLiteral(propertyTags, isArrayType) {
if (isArrayType === void 0) { isArrayType = false; }
- var node = createBaseNode(320 /* JSDocTypeLiteral */);
+ var node = createBaseNode(322 /* SyntaxKind.JSDocTypeLiteral */);
node.jsDocPropertyTags = asNodeArray(propertyTags);
node.isArrayType = isArrayType;
return node;
@@ -25061,7 +25654,7 @@ var ts;
}
// @api
function createJSDocTypeExpression(type) {
- var node = createBaseNode(307 /* JSDocTypeExpression */);
+ var node = createBaseNode(309 /* SyntaxKind.JSDocTypeExpression */);
node.type = type;
return node;
}
@@ -25073,7 +25666,7 @@ var ts;
}
// @api
function createJSDocSignature(typeParameters, parameters, type) {
- var node = createBaseNode(321 /* JSDocSignature */);
+ var node = createBaseNode(323 /* SyntaxKind.JSDocSignature */);
node.typeParameters = asNodeArray(typeParameters);
node.parameters = createNodeArray(parameters);
node.type = type;
@@ -25102,7 +25695,7 @@ var ts;
}
// @api
function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) {
- var node = createBaseJSDocTag(342 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment);
+ var node = createBaseJSDocTag(344 /* SyntaxKind.JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment);
node.constraint = constraint;
node.typeParameters = createNodeArray(typeParameters);
return node;
@@ -25119,7 +25712,7 @@ var ts;
}
// @api
function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) {
- var node = createBaseJSDocTag(343 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment);
+ var node = createBaseJSDocTag(345 /* SyntaxKind.JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment);
node.typeExpression = typeExpression;
node.fullName = fullName;
node.name = ts.getJSDocTypeAliasName(fullName);
@@ -25137,7 +25730,7 @@ var ts;
}
// @api
function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) {
- var node = createBaseJSDocTag(338 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment);
+ var node = createBaseJSDocTag(340 /* SyntaxKind.JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment);
node.typeExpression = typeExpression;
node.name = name;
node.isNameFirst = !!isNameFirst;
@@ -25158,7 +25751,7 @@ var ts;
}
// @api
function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) {
- var node = createBaseJSDocTag(345 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment);
+ var node = createBaseJSDocTag(347 /* SyntaxKind.JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment);
node.typeExpression = typeExpression;
node.name = name;
node.isNameFirst = !!isNameFirst;
@@ -25179,7 +25772,7 @@ var ts;
}
// @api
function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) {
- var node = createBaseJSDocTag(336 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment);
+ var node = createBaseJSDocTag(338 /* SyntaxKind.JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment);
node.typeExpression = typeExpression;
node.fullName = fullName;
node.name = ts.getJSDocTypeAliasName(fullName);
@@ -25197,7 +25790,7 @@ var ts;
}
// @api
function createJSDocAugmentsTag(tagName, className, comment) {
- var node = createBaseJSDocTag(326 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment);
+ var node = createBaseJSDocTag(328 /* SyntaxKind.JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment);
node.class = className;
return node;
}
@@ -25212,13 +25805,13 @@ var ts;
}
// @api
function createJSDocImplementsTag(tagName, className, comment) {
- var node = createBaseJSDocTag(327 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment);
+ var node = createBaseJSDocTag(329 /* SyntaxKind.JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment);
node.class = className;
return node;
}
// @api
function createJSDocSeeTag(tagName, name, comment) {
- var node = createBaseJSDocTag(344 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment);
+ var node = createBaseJSDocTag(346 /* SyntaxKind.JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment);
node.name = name;
return node;
}
@@ -25232,7 +25825,7 @@ var ts;
}
// @api
function createJSDocNameReference(name) {
- var node = createBaseNode(308 /* JSDocNameReference */);
+ var node = createBaseNode(310 /* SyntaxKind.JSDocNameReference */);
node.name = name;
return node;
}
@@ -25244,7 +25837,7 @@ var ts;
}
// @api
function createJSDocMemberName(left, right) {
- var node = createBaseNode(309 /* JSDocMemberName */);
+ var node = createBaseNode(311 /* SyntaxKind.JSDocMemberName */);
node.left = left;
node.right = right;
node.transformFlags |=
@@ -25261,7 +25854,7 @@ var ts;
}
// @api
function createJSDocLink(name, text) {
- var node = createBaseNode(322 /* JSDocLink */);
+ var node = createBaseNode(324 /* SyntaxKind.JSDocLink */);
node.name = name;
node.text = text;
return node;
@@ -25274,7 +25867,7 @@ var ts;
}
// @api
function createJSDocLinkCode(name, text) {
- var node = createBaseNode(323 /* JSDocLinkCode */);
+ var node = createBaseNode(325 /* SyntaxKind.JSDocLinkCode */);
node.name = name;
node.text = text;
return node;
@@ -25287,7 +25880,7 @@ var ts;
}
// @api
function createJSDocLinkPlain(name, text) {
- var node = createBaseNode(324 /* JSDocLinkPlain */);
+ var node = createBaseNode(326 /* SyntaxKind.JSDocLinkPlain */);
node.name = name;
node.text = text;
return node;
@@ -25359,7 +25952,7 @@ var ts;
}
// @api
function createJSDocUnknownTag(tagName, comment) {
- var node = createBaseJSDocTag(325 /* JSDocTag */, tagName, comment);
+ var node = createBaseJSDocTag(327 /* SyntaxKind.JSDocTag */, tagName, comment);
return node;
}
// @api
@@ -25371,7 +25964,7 @@ var ts;
}
// @api
function createJSDocText(text) {
- var node = createBaseNode(319 /* JSDocText */);
+ var node = createBaseNode(321 /* SyntaxKind.JSDocText */);
node.text = text;
return node;
}
@@ -25383,7 +25976,7 @@ var ts;
}
// @api
function createJSDocComment(comment, tags) {
- var node = createBaseNode(318 /* JSDocComment */);
+ var node = createBaseNode(320 /* SyntaxKind.JSDoc */);
node.comment = comment;
node.tags = asNodeArray(tags);
return node;
@@ -25400,7 +25993,7 @@ var ts;
//
// @api
function createJsxElement(openingElement, children, closingElement) {
- var node = createBaseNode(277 /* JsxElement */);
+ var node = createBaseNode(278 /* SyntaxKind.JsxElement */);
node.openingElement = openingElement;
node.children = createNodeArray(children);
node.closingElement = closingElement;
@@ -25408,7 +26001,7 @@ var ts;
propagateChildFlags(node.openingElement) |
propagateChildrenFlags(node.children) |
propagateChildFlags(node.closingElement) |
- 2 /* ContainsJsx */;
+ 2 /* TransformFlags.ContainsJsx */;
return node;
}
// @api
@@ -25421,7 +26014,7 @@ var ts;
}
// @api
function createJsxSelfClosingElement(tagName, typeArguments, attributes) {
- var node = createBaseNode(278 /* JsxSelfClosingElement */);
+ var node = createBaseNode(279 /* SyntaxKind.JsxSelfClosingElement */);
node.tagName = tagName;
node.typeArguments = asNodeArray(typeArguments);
node.attributes = attributes;
@@ -25429,9 +26022,9 @@ var ts;
propagateChildFlags(node.tagName) |
propagateChildrenFlags(node.typeArguments) |
propagateChildFlags(node.attributes) |
- 2 /* ContainsJsx */;
+ 2 /* TransformFlags.ContainsJsx */;
if (node.typeArguments) {
- node.transformFlags |= 1 /* ContainsTypeScript */;
+ node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */;
}
return node;
}
@@ -25445,7 +26038,7 @@ var ts;
}
// @api
function createJsxOpeningElement(tagName, typeArguments, attributes) {
- var node = createBaseNode(279 /* JsxOpeningElement */);
+ var node = createBaseNode(280 /* SyntaxKind.JsxOpeningElement */);
node.tagName = tagName;
node.typeArguments = asNodeArray(typeArguments);
node.attributes = attributes;
@@ -25453,9 +26046,9 @@ var ts;
propagateChildFlags(node.tagName) |
propagateChildrenFlags(node.typeArguments) |
propagateChildFlags(node.attributes) |
- 2 /* ContainsJsx */;
+ 2 /* TransformFlags.ContainsJsx */;
if (typeArguments) {
- node.transformFlags |= 1 /* ContainsTypeScript */;
+ node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */;
}
return node;
}
@@ -25469,11 +26062,11 @@ var ts;
}
// @api
function createJsxClosingElement(tagName) {
- var node = createBaseNode(280 /* JsxClosingElement */);
+ var node = createBaseNode(281 /* SyntaxKind.JsxClosingElement */);
node.tagName = tagName;
node.transformFlags |=
propagateChildFlags(node.tagName) |
- 2 /* ContainsJsx */;
+ 2 /* TransformFlags.ContainsJsx */;
return node;
}
// @api
@@ -25484,7 +26077,7 @@ var ts;
}
// @api
function createJsxFragment(openingFragment, children, closingFragment) {
- var node = createBaseNode(281 /* JsxFragment */);
+ var node = createBaseNode(282 /* SyntaxKind.JsxFragment */);
node.openingFragment = openingFragment;
node.children = createNodeArray(children);
node.closingFragment = closingFragment;
@@ -25492,7 +26085,7 @@ var ts;
propagateChildFlags(node.openingFragment) |
propagateChildrenFlags(node.children) |
propagateChildFlags(node.closingFragment) |
- 2 /* ContainsJsx */;
+ 2 /* TransformFlags.ContainsJsx */;
return node;
}
// @api
@@ -25505,10 +26098,10 @@ var ts;
}
// @api
function createJsxText(text, containsOnlyTriviaWhiteSpaces) {
- var node = createBaseNode(11 /* JsxText */);
+ var node = createBaseNode(11 /* SyntaxKind.JsxText */);
node.text = text;
node.containsOnlyTriviaWhiteSpaces = !!containsOnlyTriviaWhiteSpaces;
- node.transformFlags |= 2 /* ContainsJsx */;
+ node.transformFlags |= 2 /* TransformFlags.ContainsJsx */;
return node;
}
// @api
@@ -25520,25 +26113,25 @@ var ts;
}
// @api
function createJsxOpeningFragment() {
- var node = createBaseNode(282 /* JsxOpeningFragment */);
- node.transformFlags |= 2 /* ContainsJsx */;
+ var node = createBaseNode(283 /* SyntaxKind.JsxOpeningFragment */);
+ node.transformFlags |= 2 /* TransformFlags.ContainsJsx */;
return node;
}
// @api
function createJsxJsxClosingFragment() {
- var node = createBaseNode(283 /* JsxClosingFragment */);
- node.transformFlags |= 2 /* ContainsJsx */;
+ var node = createBaseNode(284 /* SyntaxKind.JsxClosingFragment */);
+ node.transformFlags |= 2 /* TransformFlags.ContainsJsx */;
return node;
}
// @api
function createJsxAttribute(name, initializer) {
- var node = createBaseNode(284 /* JsxAttribute */);
+ var node = createBaseNode(285 /* SyntaxKind.JsxAttribute */);
node.name = name;
node.initializer = initializer;
node.transformFlags |=
propagateChildFlags(node.name) |
propagateChildFlags(node.initializer) |
- 2 /* ContainsJsx */;
+ 2 /* TransformFlags.ContainsJsx */;
return node;
}
// @api
@@ -25550,11 +26143,11 @@ var ts;
}
// @api
function createJsxAttributes(properties) {
- var node = createBaseNode(285 /* JsxAttributes */);
+ var node = createBaseNode(286 /* SyntaxKind.JsxAttributes */);
node.properties = createNodeArray(properties);
node.transformFlags |=
propagateChildrenFlags(node.properties) |
- 2 /* ContainsJsx */;
+ 2 /* TransformFlags.ContainsJsx */;
return node;
}
// @api
@@ -25565,11 +26158,11 @@ var ts;
}
// @api
function createJsxSpreadAttribute(expression) {
- var node = createBaseNode(286 /* JsxSpreadAttribute */);
+ var node = createBaseNode(287 /* SyntaxKind.JsxSpreadAttribute */);
node.expression = expression;
node.transformFlags |=
propagateChildFlags(node.expression) |
- 2 /* ContainsJsx */;
+ 2 /* TransformFlags.ContainsJsx */;
return node;
}
// @api
@@ -25580,13 +26173,13 @@ var ts;
}
// @api
function createJsxExpression(dotDotDotToken, expression) {
- var node = createBaseNode(287 /* JsxExpression */);
+ var node = createBaseNode(288 /* SyntaxKind.JsxExpression */);
node.dotDotDotToken = dotDotDotToken;
node.expression = expression;
node.transformFlags |=
propagateChildFlags(node.dotDotDotToken) |
propagateChildFlags(node.expression) |
- 2 /* ContainsJsx */;
+ 2 /* TransformFlags.ContainsJsx */;
return node;
}
// @api
@@ -25600,7 +26193,7 @@ var ts;
//
// @api
function createCaseClause(expression, statements) {
- var node = createBaseNode(288 /* CaseClause */);
+ var node = createBaseNode(289 /* SyntaxKind.CaseClause */);
node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
node.statements = createNodeArray(statements);
node.transformFlags |=
@@ -25617,7 +26210,7 @@ var ts;
}
// @api
function createDefaultClause(statements) {
- var node = createBaseNode(289 /* DefaultClause */);
+ var node = createBaseNode(290 /* SyntaxKind.DefaultClause */);
node.statements = createNodeArray(statements);
node.transformFlags = propagateChildrenFlags(node.statements);
return node;
@@ -25630,16 +26223,16 @@ var ts;
}
// @api
function createHeritageClause(token, types) {
- var node = createBaseNode(290 /* HeritageClause */);
+ var node = createBaseNode(291 /* SyntaxKind.HeritageClause */);
node.token = token;
node.types = createNodeArray(types);
node.transformFlags |= propagateChildrenFlags(node.types);
switch (token) {
- case 94 /* ExtendsKeyword */:
- node.transformFlags |= 1024 /* ContainsES2015 */;
+ case 94 /* SyntaxKind.ExtendsKeyword */:
+ node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */;
break;
- case 117 /* ImplementsKeyword */:
- node.transformFlags |= 1 /* ContainsTypeScript */;
+ case 117 /* SyntaxKind.ImplementsKeyword */:
+ node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */;
break;
default:
return ts.Debug.assertNever(token);
@@ -25654,7 +26247,7 @@ var ts;
}
// @api
function createCatchClause(variableDeclaration, block) {
- var node = createBaseNode(291 /* CatchClause */);
+ var node = createBaseNode(292 /* SyntaxKind.CatchClause */);
if (typeof variableDeclaration === "string" || variableDeclaration && !ts.isVariableDeclaration(variableDeclaration)) {
variableDeclaration = createVariableDeclaration(variableDeclaration,
/*exclamationToken*/ undefined,
@@ -25667,7 +26260,7 @@ var ts;
propagateChildFlags(node.variableDeclaration) |
propagateChildFlags(node.block);
if (!variableDeclaration)
- node.transformFlags |= 64 /* ContainsES2019 */;
+ node.transformFlags |= 64 /* TransformFlags.ContainsES2019 */;
return node;
}
// @api
@@ -25682,7 +26275,7 @@ var ts;
//
// @api
function createPropertyAssignment(name, initializer) {
- var node = createBaseNamedDeclaration(294 /* PropertyAssignment */,
+ var node = createBaseNamedDeclaration(296 /* SyntaxKind.PropertyAssignment */,
/*decorators*/ undefined,
/*modifiers*/ undefined, name);
node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer);
@@ -25712,13 +26305,13 @@ var ts;
}
// @api
function createShorthandPropertyAssignment(name, objectAssignmentInitializer) {
- var node = createBaseNamedDeclaration(295 /* ShorthandPropertyAssignment */,
+ var node = createBaseNamedDeclaration(297 /* SyntaxKind.ShorthandPropertyAssignment */,
/*decorators*/ undefined,
/*modifiers*/ undefined, name);
node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer);
node.transformFlags |=
propagateChildFlags(node.objectAssignmentInitializer) |
- 1024 /* ContainsES2015 */;
+ 1024 /* TransformFlags.ContainsES2015 */;
return node;
}
function finishUpdateShorthandPropertyAssignment(updated, original) {
@@ -25744,12 +26337,12 @@ var ts;
}
// @api
function createSpreadAssignment(expression) {
- var node = createBaseNode(296 /* SpreadAssignment */);
+ var node = createBaseNode(298 /* SyntaxKind.SpreadAssignment */);
node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
node.transformFlags |=
propagateChildFlags(node.expression) |
- 128 /* ContainsES2018 */ |
- 32768 /* ContainsObjectRestOrSpread */;
+ 128 /* TransformFlags.ContainsES2018 */ |
+ 32768 /* TransformFlags.ContainsObjectRestOrSpread */;
return node;
}
// @api
@@ -25763,13 +26356,13 @@ var ts;
//
// @api
function createEnumMember(name, initializer) {
- var node = createBaseNode(297 /* EnumMember */);
+ var node = createBaseNode(299 /* SyntaxKind.EnumMember */);
node.name = asName(name);
node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer);
node.transformFlags |=
propagateChildFlags(node.name) |
propagateChildFlags(node.initializer) |
- 1 /* ContainsTypeScript */;
+ 1 /* TransformFlags.ContainsTypeScript */;
return node;
}
// @api
@@ -25784,7 +26377,7 @@ var ts;
//
// @api
function createSourceFile(statements, endOfFileToken, flags) {
- var node = baseFactory.createBaseSourceFileNode(303 /* SourceFile */);
+ var node = baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */);
node.statements = createNodeArray(statements);
node.endOfFileToken = endOfFileToken;
node.flags |= flags;
@@ -25801,7 +26394,7 @@ var ts;
return node;
}
function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) {
- var node = baseFactory.createBaseSourceFileNode(303 /* SourceFile */);
+ var node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */));
for (var p in source) {
if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p))
continue;
@@ -25840,7 +26433,7 @@ var ts;
// @api
function createBundle(sourceFiles, prepends) {
if (prepends === void 0) { prepends = ts.emptyArray; }
- var node = createBaseNode(304 /* Bundle */);
+ var node = createBaseNode(306 /* SyntaxKind.Bundle */);
node.prepends = prepends;
node.sourceFiles = sourceFiles;
return node;
@@ -25855,7 +26448,7 @@ var ts;
}
// @api
function createUnparsedSource(prologues, syntheticReferences, texts) {
- var node = createBaseNode(305 /* UnparsedSource */);
+ var node = createBaseNode(307 /* SyntaxKind.UnparsedSource */);
node.prologues = prologues;
node.syntheticReferences = syntheticReferences;
node.texts = texts;
@@ -25873,28 +26466,28 @@ var ts;
}
// @api
function createUnparsedPrologue(data) {
- return createBaseUnparsedNode(298 /* UnparsedPrologue */, data);
+ return createBaseUnparsedNode(300 /* SyntaxKind.UnparsedPrologue */, data);
}
// @api
function createUnparsedPrepend(data, texts) {
- var node = createBaseUnparsedNode(299 /* UnparsedPrepend */, data);
+ var node = createBaseUnparsedNode(301 /* SyntaxKind.UnparsedPrepend */, data);
node.texts = texts;
return node;
}
// @api
function createUnparsedTextLike(data, internal) {
- return createBaseUnparsedNode(internal ? 301 /* UnparsedInternalText */ : 300 /* UnparsedText */, data);
+ return createBaseUnparsedNode(internal ? 303 /* SyntaxKind.UnparsedInternalText */ : 302 /* SyntaxKind.UnparsedText */, data);
}
// @api
function createUnparsedSyntheticReference(section) {
- var node = createBaseNode(302 /* UnparsedSyntheticReference */);
+ var node = createBaseNode(304 /* SyntaxKind.UnparsedSyntheticReference */);
node.data = section.data;
node.section = section;
return node;
}
// @api
function createInputFiles() {
- var node = createBaseNode(306 /* InputFiles */);
+ var node = createBaseNode(308 /* SyntaxKind.InputFiles */);
node.javascriptText = "";
node.declarationText = "";
return node;
@@ -25905,7 +26498,7 @@ var ts;
// @api
function createSyntheticExpression(type, isSpread, tupleNameSource) {
if (isSpread === void 0) { isSpread = false; }
- var node = createBaseNode(231 /* SyntheticExpression */);
+ var node = createBaseNode(232 /* SyntaxKind.SyntheticExpression */);
node.type = type;
node.isSpread = isSpread;
node.tupleNameSource = tupleNameSource;
@@ -25913,7 +26506,7 @@ var ts;
}
// @api
function createSyntaxList(children) {
- var node = createBaseNode(346 /* SyntaxList */);
+ var node = createBaseNode(348 /* SyntaxKind.SyntaxList */);
node._children = children;
return node;
}
@@ -25928,7 +26521,7 @@ var ts;
*/
// @api
function createNotEmittedStatement(original) {
- var node = createBaseNode(347 /* NotEmittedStatement */);
+ var node = createBaseNode(349 /* SyntaxKind.NotEmittedStatement */);
node.original = original;
ts.setTextRange(node, original);
return node;
@@ -25942,12 +26535,12 @@ var ts;
*/
// @api
function createPartiallyEmittedExpression(expression, original) {
- var node = createBaseNode(348 /* PartiallyEmittedExpression */);
+ var node = createBaseNode(350 /* SyntaxKind.PartiallyEmittedExpression */);
node.expression = expression;
node.original = original;
node.transformFlags |=
propagateChildFlags(node.expression) |
- 1 /* ContainsTypeScript */;
+ 1 /* TransformFlags.ContainsTypeScript */;
ts.setTextRange(node, original);
return node;
}
@@ -25970,7 +26563,7 @@ var ts;
}
// @api
function createCommaListExpression(elements) {
- var node = createBaseNode(349 /* CommaListExpression */);
+ var node = createBaseNode(351 /* SyntaxKind.CommaListExpression */);
node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements));
node.transformFlags |= propagateChildrenFlags(node.elements);
return node;
@@ -25987,7 +26580,7 @@ var ts;
*/
// @api
function createEndOfDeclarationMarker(original) {
- var node = createBaseNode(351 /* EndOfDeclarationMarker */);
+ var node = createBaseNode(353 /* SyntaxKind.EndOfDeclarationMarker */);
node.emitNode = {};
node.original = original;
return node;
@@ -25998,14 +26591,14 @@ var ts;
*/
// @api
function createMergeDeclarationMarker(original) {
- var node = createBaseNode(350 /* MergeDeclarationMarker */);
+ var node = createBaseNode(352 /* SyntaxKind.MergeDeclarationMarker */);
node.emitNode = {};
node.original = original;
return node;
}
// @api
function createSyntheticReferenceExpression(expression, thisArg) {
- var node = createBaseNode(352 /* SyntheticReferenceExpression */);
+ var node = createBaseNode(354 /* SyntaxKind.SyntheticReferenceExpression */);
node.expression = expression;
node.thisArg = thisArg;
node.transformFlags |=
@@ -26027,12 +26620,12 @@ var ts;
if (node === undefined) {
return node;
}
- var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(303 /* SourceFile */) :
- ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* Identifier */) :
- ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */) :
+ var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */) :
+ ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */) :
+ ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */) :
!ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) :
baseFactory.createBaseNode(node.kind);
- clone.flags |= (node.flags & ~8 /* Synthesized */);
+ clone.flags |= (node.flags & ~8 /* NodeFlags.Synthesized */);
clone.transformFlags = node.transformFlags;
setOriginalNode(clone, node);
for (var key in node) {
@@ -26146,11 +26739,11 @@ var ts;
}
function updateOuterExpression(outerExpression, expression) {
switch (outerExpression.kind) {
- case 211 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression);
- case 210 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression);
- case 228 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type);
- case 229 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression);
- case 348 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression);
+ case 212 /* SyntaxKind.ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression);
+ case 211 /* SyntaxKind.TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression);
+ case 229 /* SyntaxKind.AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type);
+ case 230 /* SyntaxKind.NonNullExpression */: return updateNonNullExpression(outerExpression, expression);
+ case 350 /* SyntaxKind.PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression);
}
}
/**
@@ -26176,7 +26769,7 @@ var ts;
&& !ts.some(ts.getSyntheticTrailingComments(node));
}
function restoreOuterExpressions(outerExpression, innerExpression, kinds) {
- if (kinds === void 0) { kinds = 15 /* All */; }
+ if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; }
if (outerExpression && ts.isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) {
return updateOuterExpression(outerExpression, restoreOuterExpressions(outerExpression.expression, innerExpression));
}
@@ -26197,20 +26790,20 @@ var ts;
function shouldBeCapturedInTempVariable(node, cacheIdentifiers) {
var target = ts.skipParentheses(node);
switch (target.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return cacheIdentifiers;
- case 108 /* ThisKeyword */:
- case 8 /* NumericLiteral */:
- case 9 /* BigIntLiteral */:
- case 10 /* StringLiteral */:
+ case 108 /* SyntaxKind.ThisKeyword */:
+ case 8 /* SyntaxKind.NumericLiteral */:
+ case 9 /* SyntaxKind.BigIntLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
return false;
- case 203 /* ArrayLiteralExpression */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
var elements = target.elements;
if (elements.length === 0) {
return false;
}
return true;
- case 204 /* ObjectLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
return target.properties.length > 0;
default:
return true;
@@ -26218,7 +26811,7 @@ var ts;
}
function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) {
if (cacheIdentifiers === void 0) { cacheIdentifiers = false; }
- var callee = ts.skipOuterExpressions(expression, 15 /* All */);
+ var callee = ts.skipOuterExpressions(expression, 15 /* OuterExpressionKinds.All */);
var thisArg;
var target;
if (ts.isSuperProperty(callee)) {
@@ -26227,11 +26820,11 @@ var ts;
}
else if (ts.isSuperKeyword(callee)) {
thisArg = createThis();
- target = languageVersion !== undefined && languageVersion < 2 /* ES2015 */
+ target = languageVersion !== undefined && languageVersion < 2 /* ScriptTarget.ES2015 */
? ts.setTextRange(createIdentifier("_super"), callee)
: callee;
}
- else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) {
+ else if (ts.getEmitFlags(callee) & 4096 /* EmitFlags.HelperName */) {
thisArg = createVoidZero();
target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee);
}
@@ -26298,9 +26891,9 @@ var ts;
var name = ts.setParent(ts.setTextRange(cloneNode(nodeName), nodeName), nodeName.parent);
emitFlags |= ts.getEmitFlags(nodeName);
if (!allowSourceMaps)
- emitFlags |= 48 /* NoSourceMap */;
+ emitFlags |= 48 /* EmitFlags.NoSourceMap */;
if (!allowComments)
- emitFlags |= 1536 /* NoComments */;
+ emitFlags |= 1536 /* EmitFlags.NoComments */;
if (emitFlags)
ts.setEmitFlags(name, emitFlags);
return name;
@@ -26319,7 +26912,7 @@ var ts;
* @param allowSourceMaps A value indicating whether source maps may be emitted for the name.
*/
function getInternalName(node, allowComments, allowSourceMaps) {
- return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */ | 32768 /* InternalName */);
+ return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */ | 32768 /* EmitFlags.InternalName */);
}
/**
* Gets the local name of a declaration. This is primarily used for declarations that can be
@@ -26332,7 +26925,7 @@ var ts;
* @param allowSourceMaps A value indicating whether source maps may be emitted for the name.
*/
function getLocalName(node, allowComments, allowSourceMaps) {
- return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */);
+ return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */);
}
/**
* Gets the export name of a declaration. This is primarily used for declarations that can be
@@ -26345,7 +26938,7 @@ var ts;
* @param allowSourceMaps A value indicating whether source maps may be emitted for the name.
*/
function getExportName(node, allowComments, allowSourceMaps) {
- return getName(node, allowComments, allowSourceMaps, 8192 /* ExportName */);
+ return getName(node, allowComments, allowSourceMaps, 8192 /* EmitFlags.ExportName */);
}
/**
* Gets the name of a declaration for use in declarations.
@@ -26370,9 +26963,9 @@ var ts;
ts.setTextRange(qualifiedName, name);
var emitFlags = 0;
if (!allowSourceMaps)
- emitFlags |= 48 /* NoSourceMap */;
+ emitFlags |= 48 /* EmitFlags.NoSourceMap */;
if (!allowComments)
- emitFlags |= 1536 /* NoComments */;
+ emitFlags |= 1536 /* EmitFlags.NoComments */;
if (emitFlags)
ts.setEmitFlags(qualifiedName, emitFlags);
return qualifiedName;
@@ -26389,7 +26982,7 @@ var ts;
* @param allowSourceMaps A value indicating whether source maps may be emitted for the name.
*/
function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) {
- if (ns && ts.hasSyntacticModifier(node, 1 /* Export */)) {
+ if (ns && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) {
return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps);
}
return getExportName(node, allowComments, allowSourceMaps);
@@ -26447,7 +27040,7 @@ var ts;
var numStatements = source.length;
while (statementOffset !== undefined && statementOffset < numStatements) {
var statement = source[statementOffset];
- if (ts.getEmitFlags(statement) & 1048576 /* CustomPrologue */ && filter(statement)) {
+ if (ts.getEmitFlags(statement) & 1048576 /* EmitFlags.CustomPrologue */ && filter(statement)) {
ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement);
}
else {
@@ -26636,24 +27229,24 @@ var ts;
}
function getDefaultTagNameForKind(kind) {
switch (kind) {
- case 341 /* JSDocTypeTag */: return "type";
- case 339 /* JSDocReturnTag */: return "returns";
- case 340 /* JSDocThisTag */: return "this";
- case 337 /* JSDocEnumTag */: return "enum";
- case 328 /* JSDocAuthorTag */: return "author";
- case 330 /* JSDocClassTag */: return "class";
- case 331 /* JSDocPublicTag */: return "public";
- case 332 /* JSDocPrivateTag */: return "private";
- case 333 /* JSDocProtectedTag */: return "protected";
- case 334 /* JSDocReadonlyTag */: return "readonly";
- case 335 /* JSDocOverrideTag */: return "override";
- case 342 /* JSDocTemplateTag */: return "template";
- case 343 /* JSDocTypedefTag */: return "typedef";
- case 338 /* JSDocParameterTag */: return "param";
- case 345 /* JSDocPropertyTag */: return "prop";
- case 336 /* JSDocCallbackTag */: return "callback";
- case 326 /* JSDocAugmentsTag */: return "augments";
- case 327 /* JSDocImplementsTag */: return "implements";
+ case 343 /* SyntaxKind.JSDocTypeTag */: return "type";
+ case 341 /* SyntaxKind.JSDocReturnTag */: return "returns";
+ case 342 /* SyntaxKind.JSDocThisTag */: return "this";
+ case 339 /* SyntaxKind.JSDocEnumTag */: return "enum";
+ case 330 /* SyntaxKind.JSDocAuthorTag */: return "author";
+ case 332 /* SyntaxKind.JSDocClassTag */: return "class";
+ case 333 /* SyntaxKind.JSDocPublicTag */: return "public";
+ case 334 /* SyntaxKind.JSDocPrivateTag */: return "private";
+ case 335 /* SyntaxKind.JSDocProtectedTag */: return "protected";
+ case 336 /* SyntaxKind.JSDocReadonlyTag */: return "readonly";
+ case 337 /* SyntaxKind.JSDocOverrideTag */: return "override";
+ case 344 /* SyntaxKind.JSDocTemplateTag */: return "template";
+ case 345 /* SyntaxKind.JSDocTypedefTag */: return "typedef";
+ case 340 /* SyntaxKind.JSDocParameterTag */: return "param";
+ case 347 /* SyntaxKind.JSDocPropertyTag */: return "prop";
+ case 338 /* SyntaxKind.JSDocCallbackTag */: return "callback";
+ case 328 /* SyntaxKind.JSDocAugmentsTag */: return "augments";
+ case 329 /* SyntaxKind.JSDocImplementsTag */: return "implements";
default:
return ts.Debug.fail("Unsupported kind: ".concat(ts.Debug.formatSyntaxKind(kind)));
}
@@ -26662,26 +27255,26 @@ var ts;
var invalidValueSentinel = {};
function getCookedText(kind, rawText) {
if (!rawTextScanner) {
- rawTextScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */);
+ rawTextScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 0 /* LanguageVariant.Standard */);
}
switch (kind) {
- case 14 /* NoSubstitutionTemplateLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
rawTextScanner.setText("`" + rawText + "`");
break;
- case 15 /* TemplateHead */:
+ case 15 /* SyntaxKind.TemplateHead */:
// tslint:disable-next-line no-invalid-template-strings
rawTextScanner.setText("`" + rawText + "${");
break;
- case 16 /* TemplateMiddle */:
+ case 16 /* SyntaxKind.TemplateMiddle */:
// tslint:disable-next-line no-invalid-template-strings
rawTextScanner.setText("}" + rawText + "${");
break;
- case 17 /* TemplateTail */:
+ case 17 /* SyntaxKind.TemplateTail */:
rawTextScanner.setText("}" + rawText + "`");
break;
}
var token = rawTextScanner.scan();
- if (token === 19 /* CloseBraceToken */) {
+ if (token === 19 /* SyntaxKind.CloseBraceToken */) {
token = rawTextScanner.reScanTemplateToken(/*isTaggedTemplate*/ false);
}
if (rawTextScanner.isUnterminated()) {
@@ -26690,14 +27283,14 @@ var ts;
}
var tokenValue;
switch (token) {
- case 14 /* NoSubstitutionTemplateLiteral */:
- case 15 /* TemplateHead */:
- case 16 /* TemplateMiddle */:
- case 17 /* TemplateTail */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
+ case 15 /* SyntaxKind.TemplateHead */:
+ case 16 /* SyntaxKind.TemplateMiddle */:
+ case 17 /* SyntaxKind.TemplateTail */:
tokenValue = rawTextScanner.getTokenValue();
break;
}
- if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* EndOfFileToken */) {
+ if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* SyntaxKind.EndOfFileToken */) {
rawTextScanner.setText(undefined);
return invalidValueSentinel;
}
@@ -26706,22 +27299,22 @@ var ts;
}
function propagateIdentifierNameFlags(node) {
// An IdentifierName is allowed to be `await`
- return propagateChildFlags(node) & ~16777216 /* ContainsPossibleTopLevelAwait */;
+ return propagateChildFlags(node) & ~16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */;
}
function propagatePropertyNameFlagsOfChild(node, transformFlags) {
- return transformFlags | (node.transformFlags & 33562624 /* PropertyNamePropagatingFlags */);
+ return transformFlags | (node.transformFlags & 33562624 /* TransformFlags.PropertyNamePropagatingFlags */);
}
function propagateChildFlags(child) {
if (!child)
- return 0 /* None */;
+ return 0 /* TransformFlags.None */;
var childFlags = child.transformFlags & ~getTransformFlagsSubtreeExclusions(child.kind);
return ts.isNamedDeclaration(child) && ts.isPropertyName(child.name) ? propagatePropertyNameFlagsOfChild(child.name, childFlags) : childFlags;
}
function propagateChildrenFlags(children) {
- return children ? children.transformFlags : 0 /* None */;
+ return children ? children.transformFlags : 0 /* TransformFlags.None */;
}
function aggregateChildrenFlags(children) {
- var subtreeFlags = 0 /* None */;
+ var subtreeFlags = 0 /* TransformFlags.None */;
for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
var child = children_2[_i];
subtreeFlags |= propagateChildFlags(child);
@@ -26733,78 +27326,78 @@ var ts;
*/
/* @internal */
function getTransformFlagsSubtreeExclusions(kind) {
- if (kind >= 176 /* FirstTypeNode */ && kind <= 199 /* LastTypeNode */) {
- return -2 /* TypeExcludes */;
+ if (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */) {
+ return -2 /* TransformFlags.TypeExcludes */;
}
switch (kind) {
- case 207 /* CallExpression */:
- case 208 /* NewExpression */:
- case 203 /* ArrayLiteralExpression */:
- return 536887296 /* ArrayLiteralOrCallOrNewExcludes */;
- case 260 /* ModuleDeclaration */:
- return 589443072 /* ModuleExcludes */;
- case 163 /* Parameter */:
- return 536870912 /* ParameterExcludes */;
- case 213 /* ArrowFunction */:
- return 557748224 /* ArrowFunctionExcludes */;
- case 212 /* FunctionExpression */:
- case 255 /* FunctionDeclaration */:
- return 591310848 /* FunctionExcludes */;
- case 254 /* VariableDeclarationList */:
- return 537165824 /* VariableDeclarationListExcludes */;
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- return 536940544 /* ClassExcludes */;
- case 170 /* Constructor */:
- return 591306752 /* ConstructorExcludes */;
- case 166 /* PropertyDeclaration */:
- return 570433536 /* PropertyExcludes */;
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- return 574529536 /* MethodOrAccessorExcludes */;
- case 130 /* AnyKeyword */:
- case 146 /* NumberKeyword */:
- case 157 /* BigIntKeyword */:
- case 143 /* NeverKeyword */:
- case 149 /* StringKeyword */:
- case 147 /* ObjectKeyword */:
- case 133 /* BooleanKeyword */:
- case 150 /* SymbolKeyword */:
- case 114 /* VoidKeyword */:
- case 162 /* TypeParameter */:
- case 165 /* PropertySignature */:
- case 167 /* MethodSignature */:
- case 173 /* CallSignature */:
- case 174 /* ConstructSignature */:
- case 175 /* IndexSignature */:
- case 257 /* InterfaceDeclaration */:
- case 258 /* TypeAliasDeclaration */:
- return -2 /* TypeExcludes */;
- case 204 /* ObjectLiteralExpression */:
- return 536973312 /* ObjectLiteralExcludes */;
- case 291 /* CatchClause */:
- return 536903680 /* CatchClauseExcludes */;
- case 200 /* ObjectBindingPattern */:
- case 201 /* ArrayBindingPattern */:
- return 536887296 /* BindingPatternExcludes */;
- case 210 /* TypeAssertionExpression */:
- case 228 /* AsExpression */:
- case 348 /* PartiallyEmittedExpression */:
- case 211 /* ParenthesizedExpression */:
- case 106 /* SuperKeyword */:
- return 536870912 /* OuterExpressionExcludes */;
- case 205 /* PropertyAccessExpression */:
- case 206 /* ElementAccessExpression */:
- return 536870912 /* PropertyAccessExcludes */;
+ case 208 /* SyntaxKind.CallExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
+ return 536887296 /* TransformFlags.ArrayLiteralOrCallOrNewExcludes */;
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ return 589443072 /* TransformFlags.ModuleExcludes */;
+ case 164 /* SyntaxKind.Parameter */:
+ return 536870912 /* TransformFlags.ParameterExcludes */;
+ case 214 /* SyntaxKind.ArrowFunction */:
+ return 557748224 /* TransformFlags.ArrowFunctionExcludes */;
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ return 591310848 /* TransformFlags.FunctionExcludes */;
+ case 255 /* SyntaxKind.VariableDeclarationList */:
+ return 537165824 /* TransformFlags.VariableDeclarationListExcludes */;
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ return 536940544 /* TransformFlags.ClassExcludes */;
+ case 171 /* SyntaxKind.Constructor */:
+ return 591306752 /* TransformFlags.ConstructorExcludes */;
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ return 570433536 /* TransformFlags.PropertyExcludes */;
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ return 574529536 /* TransformFlags.MethodOrAccessorExcludes */;
+ case 130 /* SyntaxKind.AnyKeyword */:
+ case 147 /* SyntaxKind.NumberKeyword */:
+ case 158 /* SyntaxKind.BigIntKeyword */:
+ case 143 /* SyntaxKind.NeverKeyword */:
+ case 150 /* SyntaxKind.StringKeyword */:
+ case 148 /* SyntaxKind.ObjectKeyword */:
+ case 133 /* SyntaxKind.BooleanKeyword */:
+ case 151 /* SyntaxKind.SymbolKeyword */:
+ case 114 /* SyntaxKind.VoidKeyword */:
+ case 163 /* SyntaxKind.TypeParameter */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 176 /* SyntaxKind.IndexSignature */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ return -2 /* TransformFlags.TypeExcludes */;
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
+ return 536973312 /* TransformFlags.ObjectLiteralExcludes */;
+ case 292 /* SyntaxKind.CatchClause */:
+ return 536903680 /* TransformFlags.CatchClauseExcludes */;
+ case 201 /* SyntaxKind.ObjectBindingPattern */:
+ case 202 /* SyntaxKind.ArrayBindingPattern */:
+ return 536887296 /* TransformFlags.BindingPatternExcludes */;
+ case 211 /* SyntaxKind.TypeAssertionExpression */:
+ case 229 /* SyntaxKind.AsExpression */:
+ case 350 /* SyntaxKind.PartiallyEmittedExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
+ case 106 /* SyntaxKind.SuperKeyword */:
+ return 536870912 /* TransformFlags.OuterExpressionExcludes */;
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
+ return 536870912 /* TransformFlags.PropertyAccessExcludes */;
default:
- return 536870912 /* NodeExcludes */;
+ return 536870912 /* TransformFlags.NodeExcludes */;
}
}
ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions;
var baseFactory = ts.createBaseNodeFactory();
function makeSynthetic(node) {
- node.flags |= 8 /* Synthesized */;
+ node.flags |= 8 /* NodeFlags.Synthesized */;
return node;
}
var syntheticFactory = {
@@ -26814,7 +27407,7 @@ var ts;
createBaseTokenNode: function (kind) { return makeSynthetic(baseFactory.createBaseTokenNode(kind)); },
createBaseNode: function (kind) { return makeSynthetic(baseFactory.createBaseNode(kind)); },
};
- ts.factory = createNodeFactory(4 /* NoIndentationOnFreshPropertyAccess */, syntheticFactory);
+ ts.factory = createNodeFactory(4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */, syntheticFactory);
function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) {
var stripInternal;
var bundleFileInfo;
@@ -26877,44 +27470,50 @@ var ts;
for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) {
var section = _a[_i];
switch (section.kind) {
- case "prologue" /* Prologue */:
+ case "prologue" /* BundleFileSectionKind.Prologue */:
prologues = ts.append(prologues, ts.setTextRange(ts.factory.createUnparsedPrologue(section.data), section));
break;
- case "emitHelpers" /* EmitHelpers */:
+ case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */:
helpers = ts.append(helpers, ts.getAllUnscopedEmitHelpers().get(section.data));
break;
- case "no-default-lib" /* NoDefaultLib */:
+ case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */:
hasNoDefaultLib = true;
break;
- case "reference" /* Reference */:
+ case "reference" /* BundleFileSectionKind.Reference */:
referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data });
break;
- case "type" /* Type */:
- typeReferenceDirectives = ts.append(typeReferenceDirectives, section.data);
+ case "type" /* BundleFileSectionKind.Type */:
+ typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
+ break;
+ case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */:
+ typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.ESNext });
+ break;
+ case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */:
+ typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.CommonJS });
break;
- case "lib" /* Lib */:
+ case "lib" /* BundleFileSectionKind.Lib */:
libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
break;
- case "prepend" /* Prepend */:
+ case "prepend" /* BundleFileSectionKind.Prepend */:
var prependTexts = void 0;
for (var _b = 0, _c = section.texts; _b < _c.length; _b++) {
var text = _c[_b];
- if (!stripInternal || text.kind !== "internal" /* Internal */) {
- prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* Internal */), text));
+ if (!stripInternal || text.kind !== "internal" /* BundleFileSectionKind.Internal */) {
+ prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* BundleFileSectionKind.Internal */), text));
}
}
prependChildren = ts.addRange(prependChildren, prependTexts);
texts = ts.append(texts, ts.factory.createUnparsedPrepend(section.data, prependTexts !== null && prependTexts !== void 0 ? prependTexts : ts.emptyArray));
break;
- case "internal" /* Internal */:
+ case "internal" /* BundleFileSectionKind.Internal */:
if (stripInternal) {
if (!texts)
texts = [];
break;
}
// falls through
- case "text" /* Text */:
- texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section));
+ case "text" /* BundleFileSectionKind.Text */:
+ texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section));
break;
default:
ts.Debug.assertNever(section);
@@ -26942,20 +27541,22 @@ var ts;
for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) {
var section = _a[_i];
switch (section.kind) {
- case "internal" /* Internal */:
- case "text" /* Text */:
- texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section));
+ case "internal" /* BundleFileSectionKind.Internal */:
+ case "text" /* BundleFileSectionKind.Text */:
+ texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section));
break;
- case "no-default-lib" /* NoDefaultLib */:
- case "reference" /* Reference */:
- case "type" /* Type */:
- case "lib" /* Lib */:
+ case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */:
+ case "reference" /* BundleFileSectionKind.Reference */:
+ case "type" /* BundleFileSectionKind.Type */:
+ case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */:
+ case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */:
+ case "lib" /* BundleFileSectionKind.Lib */:
syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section));
break;
// Ignore
- case "prologue" /* Prologue */:
- case "emitHelpers" /* EmitHelpers */:
- case "prepend" /* Prepend */:
+ case "prologue" /* BundleFileSectionKind.Prologue */:
+ case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */:
+ case "prepend" /* BundleFileSectionKind.Prepend */:
break;
default:
ts.Debug.assertNever(section);
@@ -27052,7 +27653,7 @@ var ts;
if (trailingComments)
destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments);
if (flags)
- destEmitNode.flags = flags & ~268435456 /* Immutable */;
+ destEmitNode.flags = flags & ~268435456 /* EmitFlags.Immutable */;
if (commentRange)
destEmitNode.commentRange = commentRange;
if (sourceMapRange)
@@ -27094,7 +27695,7 @@ var ts;
// To avoid holding onto transformation artifacts, we keep track of any
// parse tree node we are annotating. This allows us to clean them up after
// all transformations have completed.
- if (node.kind === 303 /* SourceFile */) {
+ if (node.kind === 305 /* SyntaxKind.SourceFile */) {
return node.emitNode = { annotatedNodes: [node] };
}
var sourceFile = (_a = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node)))) !== null && _a !== void 0 ? _a : ts.Debug.fail("Could not determine parsed source file.");
@@ -27103,7 +27704,7 @@ var ts;
node.emitNode = {};
}
else {
- ts.Debug.assert(!(node.emitNode.flags & 268435456 /* Immutable */), "Invalid attempt to mutate an immutable node.");
+ ts.Debug.assert(!(node.emitNode.flags & 268435456 /* EmitFlags.Immutable */), "Invalid attempt to mutate an immutable node.");
}
return node.emitNode;
}
@@ -27135,7 +27736,7 @@ var ts;
*/
function removeAllComments(node) {
var emitNode = getOrCreateEmitNode(node);
- emitNode.flags |= 1536 /* NoComments */;
+ emitNode.flags |= 1536 /* EmitFlags.NoComments */;
emitNode.leadingComments = undefined;
emitNode.trailingComments = undefined;
return node;
@@ -27371,18 +27972,31 @@ var ts;
ts.setSnippetElement = setSnippetElement;
/* @internal */
function ignoreSourceNewlines(node) {
- getOrCreateEmitNode(node).flags |= 134217728 /* IgnoreSourceNewlines */;
+ getOrCreateEmitNode(node).flags |= 134217728 /* EmitFlags.IgnoreSourceNewlines */;
return node;
}
ts.ignoreSourceNewlines = ignoreSourceNewlines;
+ /* @internal */
+ function setTypeNode(node, type) {
+ var emitNode = getOrCreateEmitNode(node);
+ emitNode.typeNode = type;
+ return node;
+ }
+ ts.setTypeNode = setTypeNode;
+ /* @internal */
+ function getTypeNode(node) {
+ var _a;
+ return (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.typeNode;
+ }
+ ts.getTypeNode = getTypeNode;
})(ts || (ts = {}));
/* @internal */
var ts;
(function (ts) {
function createEmitHelperFactory(context) {
var factory = context.factory;
- var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* Immutable */); });
- var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* Immutable */); });
+ var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* EmitFlags.Immutable */); });
+ var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* EmitFlags.Immutable */); });
return {
getUnscopedHelperName: getUnscopedHelperName,
// TypeScript Helpers
@@ -27423,7 +28037,7 @@ var ts;
* Gets an identifier for the name of an *unscoped* emit helper.
*/
function getUnscopedHelperName(name) {
- return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */);
+ return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* EmitFlags.HelperName */ | 2 /* EmitFlags.AdviseOnEmitNode */);
}
// TypeScript Helpers
function createDecorateHelper(decoratorExpressions, target, memberName, descriptor) {
@@ -27458,7 +28072,7 @@ var ts;
}
// ES2018 Helpers
function createAssignHelper(attributesSegments) {
- if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) {
+ if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) {
return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "assign"),
/*typeArguments*/ undefined, attributesSegments);
}
@@ -27474,7 +28088,7 @@ var ts;
context.requestEmitHelper(ts.awaitHelper);
context.requestEmitHelper(ts.asyncGeneratorHelper);
// Mark this node as originally an async function
- (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */;
+ (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */;
return factory.createCallExpression(getUnscopedHelperName("__asyncGenerator"),
/*typeArguments*/ undefined, [
hasLexicalThis ? factory.createThis() : factory.createVoidZero(),
@@ -27528,13 +28142,13 @@ var ts;
function createAwaiterHelper(hasLexicalThis, hasLexicalArguments, promiseConstructor, body) {
context.requestEmitHelper(ts.awaiterHelper);
var generatorFunc = factory.createFunctionExpression(
- /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */),
+ /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */),
/*name*/ undefined,
/*typeParameters*/ undefined,
/*parameters*/ [],
/*type*/ undefined, body);
// Mark this node as originally an async function
- (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */;
+ (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */;
return factory.createCallExpression(getUnscopedHelperName("__awaiter"),
/*typeArguments*/ undefined, [
hasLexicalThis ? factory.createThis() : factory.createVoidZero(),
@@ -27547,7 +28161,7 @@ var ts;
function createExtendsHelper(name) {
context.requestEmitHelper(ts.extendsHelper);
return factory.createCallExpression(getUnscopedHelperName("__extends"),
- /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */)]);
+ /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)]);
}
function createTemplateObjectHelper(cooked, raw) {
context.requestEmitHelper(ts.templateObjectHelper);
@@ -27637,13 +28251,13 @@ var ts;
/* @internal */
function compareEmitHelpers(x, y) {
if (x === y)
- return 0 /* EqualTo */;
+ return 0 /* Comparison.EqualTo */;
if (x.priority === y.priority)
- return 0 /* EqualTo */;
+ return 0 /* Comparison.EqualTo */;
if (x.priority === undefined)
- return 1 /* GreaterThan */;
+ return 1 /* Comparison.GreaterThan */;
if (y.priority === undefined)
- return -1 /* LessThan */;
+ return -1 /* Comparison.LessThan */;
return ts.compareValues(x.priority, y.priority);
}
ts.compareEmitHelpers = compareEmitHelpers;
@@ -28050,7 +28664,7 @@ var ts;
function isCallToHelper(firstSegment, helperName) {
return ts.isCallExpression(firstSegment)
&& ts.isIdentifier(firstSegment.expression)
- && (ts.getEmitFlags(firstSegment.expression) & 4096 /* HelperName */) !== 0
+ && (ts.getEmitFlags(firstSegment.expression) & 4096 /* EmitFlags.HelperName */) !== 0
&& firstSegment.expression.escapedText === helperName;
}
ts.isCallToHelper = isCallToHelper;
@@ -28059,741 +28673,741 @@ var ts;
(function (ts) {
// Literals
function isNumericLiteral(node) {
- return node.kind === 8 /* NumericLiteral */;
+ return node.kind === 8 /* SyntaxKind.NumericLiteral */;
}
ts.isNumericLiteral = isNumericLiteral;
function isBigIntLiteral(node) {
- return node.kind === 9 /* BigIntLiteral */;
+ return node.kind === 9 /* SyntaxKind.BigIntLiteral */;
}
ts.isBigIntLiteral = isBigIntLiteral;
function isStringLiteral(node) {
- return node.kind === 10 /* StringLiteral */;
+ return node.kind === 10 /* SyntaxKind.StringLiteral */;
}
ts.isStringLiteral = isStringLiteral;
function isJsxText(node) {
- return node.kind === 11 /* JsxText */;
+ return node.kind === 11 /* SyntaxKind.JsxText */;
}
ts.isJsxText = isJsxText;
function isRegularExpressionLiteral(node) {
- return node.kind === 13 /* RegularExpressionLiteral */;
+ return node.kind === 13 /* SyntaxKind.RegularExpressionLiteral */;
}
ts.isRegularExpressionLiteral = isRegularExpressionLiteral;
function isNoSubstitutionTemplateLiteral(node) {
- return node.kind === 14 /* NoSubstitutionTemplateLiteral */;
+ return node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */;
}
ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral;
// Pseudo-literals
function isTemplateHead(node) {
- return node.kind === 15 /* TemplateHead */;
+ return node.kind === 15 /* SyntaxKind.TemplateHead */;
}
ts.isTemplateHead = isTemplateHead;
function isTemplateMiddle(node) {
- return node.kind === 16 /* TemplateMiddle */;
+ return node.kind === 16 /* SyntaxKind.TemplateMiddle */;
}
ts.isTemplateMiddle = isTemplateMiddle;
function isTemplateTail(node) {
- return node.kind === 17 /* TemplateTail */;
+ return node.kind === 17 /* SyntaxKind.TemplateTail */;
}
ts.isTemplateTail = isTemplateTail;
// Punctuation
function isDotDotDotToken(node) {
- return node.kind === 25 /* DotDotDotToken */;
+ return node.kind === 25 /* SyntaxKind.DotDotDotToken */;
}
ts.isDotDotDotToken = isDotDotDotToken;
/*@internal*/
function isCommaToken(node) {
- return node.kind === 27 /* CommaToken */;
+ return node.kind === 27 /* SyntaxKind.CommaToken */;
}
ts.isCommaToken = isCommaToken;
function isPlusToken(node) {
- return node.kind === 39 /* PlusToken */;
+ return node.kind === 39 /* SyntaxKind.PlusToken */;
}
ts.isPlusToken = isPlusToken;
function isMinusToken(node) {
- return node.kind === 40 /* MinusToken */;
+ return node.kind === 40 /* SyntaxKind.MinusToken */;
}
ts.isMinusToken = isMinusToken;
function isAsteriskToken(node) {
- return node.kind === 41 /* AsteriskToken */;
+ return node.kind === 41 /* SyntaxKind.AsteriskToken */;
}
ts.isAsteriskToken = isAsteriskToken;
/*@internal*/
function isExclamationToken(node) {
- return node.kind === 53 /* ExclamationToken */;
+ return node.kind === 53 /* SyntaxKind.ExclamationToken */;
}
ts.isExclamationToken = isExclamationToken;
/*@internal*/
function isQuestionToken(node) {
- return node.kind === 57 /* QuestionToken */;
+ return node.kind === 57 /* SyntaxKind.QuestionToken */;
}
ts.isQuestionToken = isQuestionToken;
/*@internal*/
function isColonToken(node) {
- return node.kind === 58 /* ColonToken */;
+ return node.kind === 58 /* SyntaxKind.ColonToken */;
}
ts.isColonToken = isColonToken;
/*@internal*/
function isQuestionDotToken(node) {
- return node.kind === 28 /* QuestionDotToken */;
+ return node.kind === 28 /* SyntaxKind.QuestionDotToken */;
}
ts.isQuestionDotToken = isQuestionDotToken;
/*@internal*/
function isEqualsGreaterThanToken(node) {
- return node.kind === 38 /* EqualsGreaterThanToken */;
+ return node.kind === 38 /* SyntaxKind.EqualsGreaterThanToken */;
}
ts.isEqualsGreaterThanToken = isEqualsGreaterThanToken;
// Identifiers
function isIdentifier(node) {
- return node.kind === 79 /* Identifier */;
+ return node.kind === 79 /* SyntaxKind.Identifier */;
}
ts.isIdentifier = isIdentifier;
function isPrivateIdentifier(node) {
- return node.kind === 80 /* PrivateIdentifier */;
+ return node.kind === 80 /* SyntaxKind.PrivateIdentifier */;
}
ts.isPrivateIdentifier = isPrivateIdentifier;
// Reserved Words
/* @internal */
function isExportModifier(node) {
- return node.kind === 93 /* ExportKeyword */;
+ return node.kind === 93 /* SyntaxKind.ExportKeyword */;
}
ts.isExportModifier = isExportModifier;
/* @internal */
function isAsyncModifier(node) {
- return node.kind === 131 /* AsyncKeyword */;
+ return node.kind === 131 /* SyntaxKind.AsyncKeyword */;
}
ts.isAsyncModifier = isAsyncModifier;
/* @internal */
function isAssertsKeyword(node) {
- return node.kind === 128 /* AssertsKeyword */;
+ return node.kind === 128 /* SyntaxKind.AssertsKeyword */;
}
ts.isAssertsKeyword = isAssertsKeyword;
/* @internal */
function isAwaitKeyword(node) {
- return node.kind === 132 /* AwaitKeyword */;
+ return node.kind === 132 /* SyntaxKind.AwaitKeyword */;
}
ts.isAwaitKeyword = isAwaitKeyword;
/* @internal */
function isReadonlyKeyword(node) {
- return node.kind === 144 /* ReadonlyKeyword */;
+ return node.kind === 145 /* SyntaxKind.ReadonlyKeyword */;
}
ts.isReadonlyKeyword = isReadonlyKeyword;
/* @internal */
function isStaticModifier(node) {
- return node.kind === 124 /* StaticKeyword */;
+ return node.kind === 124 /* SyntaxKind.StaticKeyword */;
}
ts.isStaticModifier = isStaticModifier;
/* @internal */
function isAbstractModifier(node) {
- return node.kind === 126 /* AbstractKeyword */;
+ return node.kind === 126 /* SyntaxKind.AbstractKeyword */;
}
ts.isAbstractModifier = isAbstractModifier;
/*@internal*/
function isSuperKeyword(node) {
- return node.kind === 106 /* SuperKeyword */;
+ return node.kind === 106 /* SyntaxKind.SuperKeyword */;
}
ts.isSuperKeyword = isSuperKeyword;
/*@internal*/
function isImportKeyword(node) {
- return node.kind === 100 /* ImportKeyword */;
+ return node.kind === 100 /* SyntaxKind.ImportKeyword */;
}
ts.isImportKeyword = isImportKeyword;
// Names
function isQualifiedName(node) {
- return node.kind === 160 /* QualifiedName */;
+ return node.kind === 161 /* SyntaxKind.QualifiedName */;
}
ts.isQualifiedName = isQualifiedName;
function isComputedPropertyName(node) {
- return node.kind === 161 /* ComputedPropertyName */;
+ return node.kind === 162 /* SyntaxKind.ComputedPropertyName */;
}
ts.isComputedPropertyName = isComputedPropertyName;
// Signature elements
function isTypeParameterDeclaration(node) {
- return node.kind === 162 /* TypeParameter */;
+ return node.kind === 163 /* SyntaxKind.TypeParameter */;
}
ts.isTypeParameterDeclaration = isTypeParameterDeclaration;
// TODO(rbuckton): Rename to 'isParameterDeclaration'
function isParameter(node) {
- return node.kind === 163 /* Parameter */;
+ return node.kind === 164 /* SyntaxKind.Parameter */;
}
ts.isParameter = isParameter;
function isDecorator(node) {
- return node.kind === 164 /* Decorator */;
+ return node.kind === 165 /* SyntaxKind.Decorator */;
}
ts.isDecorator = isDecorator;
// TypeMember
function isPropertySignature(node) {
- return node.kind === 165 /* PropertySignature */;
+ return node.kind === 166 /* SyntaxKind.PropertySignature */;
}
ts.isPropertySignature = isPropertySignature;
function isPropertyDeclaration(node) {
- return node.kind === 166 /* PropertyDeclaration */;
+ return node.kind === 167 /* SyntaxKind.PropertyDeclaration */;
}
ts.isPropertyDeclaration = isPropertyDeclaration;
function isMethodSignature(node) {
- return node.kind === 167 /* MethodSignature */;
+ return node.kind === 168 /* SyntaxKind.MethodSignature */;
}
ts.isMethodSignature = isMethodSignature;
function isMethodDeclaration(node) {
- return node.kind === 168 /* MethodDeclaration */;
+ return node.kind === 169 /* SyntaxKind.MethodDeclaration */;
}
ts.isMethodDeclaration = isMethodDeclaration;
function isClassStaticBlockDeclaration(node) {
- return node.kind === 169 /* ClassStaticBlockDeclaration */;
+ return node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */;
}
ts.isClassStaticBlockDeclaration = isClassStaticBlockDeclaration;
function isConstructorDeclaration(node) {
- return node.kind === 170 /* Constructor */;
+ return node.kind === 171 /* SyntaxKind.Constructor */;
}
ts.isConstructorDeclaration = isConstructorDeclaration;
function isGetAccessorDeclaration(node) {
- return node.kind === 171 /* GetAccessor */;
+ return node.kind === 172 /* SyntaxKind.GetAccessor */;
}
ts.isGetAccessorDeclaration = isGetAccessorDeclaration;
function isSetAccessorDeclaration(node) {
- return node.kind === 172 /* SetAccessor */;
+ return node.kind === 173 /* SyntaxKind.SetAccessor */;
}
ts.isSetAccessorDeclaration = isSetAccessorDeclaration;
function isCallSignatureDeclaration(node) {
- return node.kind === 173 /* CallSignature */;
+ return node.kind === 174 /* SyntaxKind.CallSignature */;
}
ts.isCallSignatureDeclaration = isCallSignatureDeclaration;
function isConstructSignatureDeclaration(node) {
- return node.kind === 174 /* ConstructSignature */;
+ return node.kind === 175 /* SyntaxKind.ConstructSignature */;
}
ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration;
function isIndexSignatureDeclaration(node) {
- return node.kind === 175 /* IndexSignature */;
+ return node.kind === 176 /* SyntaxKind.IndexSignature */;
}
ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration;
// Type
function isTypePredicateNode(node) {
- return node.kind === 176 /* TypePredicate */;
+ return node.kind === 177 /* SyntaxKind.TypePredicate */;
}
ts.isTypePredicateNode = isTypePredicateNode;
function isTypeReferenceNode(node) {
- return node.kind === 177 /* TypeReference */;
+ return node.kind === 178 /* SyntaxKind.TypeReference */;
}
ts.isTypeReferenceNode = isTypeReferenceNode;
function isFunctionTypeNode(node) {
- return node.kind === 178 /* FunctionType */;
+ return node.kind === 179 /* SyntaxKind.FunctionType */;
}
ts.isFunctionTypeNode = isFunctionTypeNode;
function isConstructorTypeNode(node) {
- return node.kind === 179 /* ConstructorType */;
+ return node.kind === 180 /* SyntaxKind.ConstructorType */;
}
ts.isConstructorTypeNode = isConstructorTypeNode;
function isTypeQueryNode(node) {
- return node.kind === 180 /* TypeQuery */;
+ return node.kind === 181 /* SyntaxKind.TypeQuery */;
}
ts.isTypeQueryNode = isTypeQueryNode;
function isTypeLiteralNode(node) {
- return node.kind === 181 /* TypeLiteral */;
+ return node.kind === 182 /* SyntaxKind.TypeLiteral */;
}
ts.isTypeLiteralNode = isTypeLiteralNode;
function isArrayTypeNode(node) {
- return node.kind === 182 /* ArrayType */;
+ return node.kind === 183 /* SyntaxKind.ArrayType */;
}
ts.isArrayTypeNode = isArrayTypeNode;
function isTupleTypeNode(node) {
- return node.kind === 183 /* TupleType */;
+ return node.kind === 184 /* SyntaxKind.TupleType */;
}
ts.isTupleTypeNode = isTupleTypeNode;
function isNamedTupleMember(node) {
- return node.kind === 196 /* NamedTupleMember */;
+ return node.kind === 197 /* SyntaxKind.NamedTupleMember */;
}
ts.isNamedTupleMember = isNamedTupleMember;
function isOptionalTypeNode(node) {
- return node.kind === 184 /* OptionalType */;
+ return node.kind === 185 /* SyntaxKind.OptionalType */;
}
ts.isOptionalTypeNode = isOptionalTypeNode;
function isRestTypeNode(node) {
- return node.kind === 185 /* RestType */;
+ return node.kind === 186 /* SyntaxKind.RestType */;
}
ts.isRestTypeNode = isRestTypeNode;
function isUnionTypeNode(node) {
- return node.kind === 186 /* UnionType */;
+ return node.kind === 187 /* SyntaxKind.UnionType */;
}
ts.isUnionTypeNode = isUnionTypeNode;
function isIntersectionTypeNode(node) {
- return node.kind === 187 /* IntersectionType */;
+ return node.kind === 188 /* SyntaxKind.IntersectionType */;
}
ts.isIntersectionTypeNode = isIntersectionTypeNode;
function isConditionalTypeNode(node) {
- return node.kind === 188 /* ConditionalType */;
+ return node.kind === 189 /* SyntaxKind.ConditionalType */;
}
ts.isConditionalTypeNode = isConditionalTypeNode;
function isInferTypeNode(node) {
- return node.kind === 189 /* InferType */;
+ return node.kind === 190 /* SyntaxKind.InferType */;
}
ts.isInferTypeNode = isInferTypeNode;
function isParenthesizedTypeNode(node) {
- return node.kind === 190 /* ParenthesizedType */;
+ return node.kind === 191 /* SyntaxKind.ParenthesizedType */;
}
ts.isParenthesizedTypeNode = isParenthesizedTypeNode;
function isThisTypeNode(node) {
- return node.kind === 191 /* ThisType */;
+ return node.kind === 192 /* SyntaxKind.ThisType */;
}
ts.isThisTypeNode = isThisTypeNode;
function isTypeOperatorNode(node) {
- return node.kind === 192 /* TypeOperator */;
+ return node.kind === 193 /* SyntaxKind.TypeOperator */;
}
ts.isTypeOperatorNode = isTypeOperatorNode;
function isIndexedAccessTypeNode(node) {
- return node.kind === 193 /* IndexedAccessType */;
+ return node.kind === 194 /* SyntaxKind.IndexedAccessType */;
}
ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode;
function isMappedTypeNode(node) {
- return node.kind === 194 /* MappedType */;
+ return node.kind === 195 /* SyntaxKind.MappedType */;
}
ts.isMappedTypeNode = isMappedTypeNode;
function isLiteralTypeNode(node) {
- return node.kind === 195 /* LiteralType */;
+ return node.kind === 196 /* SyntaxKind.LiteralType */;
}
ts.isLiteralTypeNode = isLiteralTypeNode;
function isImportTypeNode(node) {
- return node.kind === 199 /* ImportType */;
+ return node.kind === 200 /* SyntaxKind.ImportType */;
}
ts.isImportTypeNode = isImportTypeNode;
function isTemplateLiteralTypeSpan(node) {
- return node.kind === 198 /* TemplateLiteralTypeSpan */;
+ return node.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */;
}
ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan;
function isTemplateLiteralTypeNode(node) {
- return node.kind === 197 /* TemplateLiteralType */;
+ return node.kind === 198 /* SyntaxKind.TemplateLiteralType */;
}
ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode;
// Binding patterns
function isObjectBindingPattern(node) {
- return node.kind === 200 /* ObjectBindingPattern */;
+ return node.kind === 201 /* SyntaxKind.ObjectBindingPattern */;
}
ts.isObjectBindingPattern = isObjectBindingPattern;
function isArrayBindingPattern(node) {
- return node.kind === 201 /* ArrayBindingPattern */;
+ return node.kind === 202 /* SyntaxKind.ArrayBindingPattern */;
}
ts.isArrayBindingPattern = isArrayBindingPattern;
function isBindingElement(node) {
- return node.kind === 202 /* BindingElement */;
+ return node.kind === 203 /* SyntaxKind.BindingElement */;
}
ts.isBindingElement = isBindingElement;
// Expression
function isArrayLiteralExpression(node) {
- return node.kind === 203 /* ArrayLiteralExpression */;
+ return node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */;
}
ts.isArrayLiteralExpression = isArrayLiteralExpression;
function isObjectLiteralExpression(node) {
- return node.kind === 204 /* ObjectLiteralExpression */;
+ return node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */;
}
ts.isObjectLiteralExpression = isObjectLiteralExpression;
function isPropertyAccessExpression(node) {
- return node.kind === 205 /* PropertyAccessExpression */;
+ return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */;
}
ts.isPropertyAccessExpression = isPropertyAccessExpression;
function isElementAccessExpression(node) {
- return node.kind === 206 /* ElementAccessExpression */;
+ return node.kind === 207 /* SyntaxKind.ElementAccessExpression */;
}
ts.isElementAccessExpression = isElementAccessExpression;
function isCallExpression(node) {
- return node.kind === 207 /* CallExpression */;
+ return node.kind === 208 /* SyntaxKind.CallExpression */;
}
ts.isCallExpression = isCallExpression;
function isNewExpression(node) {
- return node.kind === 208 /* NewExpression */;
+ return node.kind === 209 /* SyntaxKind.NewExpression */;
}
ts.isNewExpression = isNewExpression;
function isTaggedTemplateExpression(node) {
- return node.kind === 209 /* TaggedTemplateExpression */;
+ return node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */;
}
ts.isTaggedTemplateExpression = isTaggedTemplateExpression;
function isTypeAssertionExpression(node) {
- return node.kind === 210 /* TypeAssertionExpression */;
+ return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */;
}
ts.isTypeAssertionExpression = isTypeAssertionExpression;
function isParenthesizedExpression(node) {
- return node.kind === 211 /* ParenthesizedExpression */;
+ return node.kind === 212 /* SyntaxKind.ParenthesizedExpression */;
}
ts.isParenthesizedExpression = isParenthesizedExpression;
function isFunctionExpression(node) {
- return node.kind === 212 /* FunctionExpression */;
+ return node.kind === 213 /* SyntaxKind.FunctionExpression */;
}
ts.isFunctionExpression = isFunctionExpression;
function isArrowFunction(node) {
- return node.kind === 213 /* ArrowFunction */;
+ return node.kind === 214 /* SyntaxKind.ArrowFunction */;
}
ts.isArrowFunction = isArrowFunction;
function isDeleteExpression(node) {
- return node.kind === 214 /* DeleteExpression */;
+ return node.kind === 215 /* SyntaxKind.DeleteExpression */;
}
ts.isDeleteExpression = isDeleteExpression;
function isTypeOfExpression(node) {
- return node.kind === 215 /* TypeOfExpression */;
+ return node.kind === 216 /* SyntaxKind.TypeOfExpression */;
}
ts.isTypeOfExpression = isTypeOfExpression;
function isVoidExpression(node) {
- return node.kind === 216 /* VoidExpression */;
+ return node.kind === 217 /* SyntaxKind.VoidExpression */;
}
ts.isVoidExpression = isVoidExpression;
function isAwaitExpression(node) {
- return node.kind === 217 /* AwaitExpression */;
+ return node.kind === 218 /* SyntaxKind.AwaitExpression */;
}
ts.isAwaitExpression = isAwaitExpression;
function isPrefixUnaryExpression(node) {
- return node.kind === 218 /* PrefixUnaryExpression */;
+ return node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */;
}
ts.isPrefixUnaryExpression = isPrefixUnaryExpression;
function isPostfixUnaryExpression(node) {
- return node.kind === 219 /* PostfixUnaryExpression */;
+ return node.kind === 220 /* SyntaxKind.PostfixUnaryExpression */;
}
ts.isPostfixUnaryExpression = isPostfixUnaryExpression;
function isBinaryExpression(node) {
- return node.kind === 220 /* BinaryExpression */;
+ return node.kind === 221 /* SyntaxKind.BinaryExpression */;
}
ts.isBinaryExpression = isBinaryExpression;
function isConditionalExpression(node) {
- return node.kind === 221 /* ConditionalExpression */;
+ return node.kind === 222 /* SyntaxKind.ConditionalExpression */;
}
ts.isConditionalExpression = isConditionalExpression;
function isTemplateExpression(node) {
- return node.kind === 222 /* TemplateExpression */;
+ return node.kind === 223 /* SyntaxKind.TemplateExpression */;
}
ts.isTemplateExpression = isTemplateExpression;
function isYieldExpression(node) {
- return node.kind === 223 /* YieldExpression */;
+ return node.kind === 224 /* SyntaxKind.YieldExpression */;
}
ts.isYieldExpression = isYieldExpression;
function isSpreadElement(node) {
- return node.kind === 224 /* SpreadElement */;
+ return node.kind === 225 /* SyntaxKind.SpreadElement */;
}
ts.isSpreadElement = isSpreadElement;
function isClassExpression(node) {
- return node.kind === 225 /* ClassExpression */;
+ return node.kind === 226 /* SyntaxKind.ClassExpression */;
}
ts.isClassExpression = isClassExpression;
function isOmittedExpression(node) {
- return node.kind === 226 /* OmittedExpression */;
+ return node.kind === 227 /* SyntaxKind.OmittedExpression */;
}
ts.isOmittedExpression = isOmittedExpression;
function isExpressionWithTypeArguments(node) {
- return node.kind === 227 /* ExpressionWithTypeArguments */;
+ return node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */;
}
ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments;
function isAsExpression(node) {
- return node.kind === 228 /* AsExpression */;
+ return node.kind === 229 /* SyntaxKind.AsExpression */;
}
ts.isAsExpression = isAsExpression;
function isNonNullExpression(node) {
- return node.kind === 229 /* NonNullExpression */;
+ return node.kind === 230 /* SyntaxKind.NonNullExpression */;
}
ts.isNonNullExpression = isNonNullExpression;
function isMetaProperty(node) {
- return node.kind === 230 /* MetaProperty */;
+ return node.kind === 231 /* SyntaxKind.MetaProperty */;
}
ts.isMetaProperty = isMetaProperty;
function isSyntheticExpression(node) {
- return node.kind === 231 /* SyntheticExpression */;
+ return node.kind === 232 /* SyntaxKind.SyntheticExpression */;
}
ts.isSyntheticExpression = isSyntheticExpression;
function isPartiallyEmittedExpression(node) {
- return node.kind === 348 /* PartiallyEmittedExpression */;
+ return node.kind === 350 /* SyntaxKind.PartiallyEmittedExpression */;
}
ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression;
function isCommaListExpression(node) {
- return node.kind === 349 /* CommaListExpression */;
+ return node.kind === 351 /* SyntaxKind.CommaListExpression */;
}
ts.isCommaListExpression = isCommaListExpression;
// Misc
function isTemplateSpan(node) {
- return node.kind === 232 /* TemplateSpan */;
+ return node.kind === 233 /* SyntaxKind.TemplateSpan */;
}
ts.isTemplateSpan = isTemplateSpan;
function isSemicolonClassElement(node) {
- return node.kind === 233 /* SemicolonClassElement */;
+ return node.kind === 234 /* SyntaxKind.SemicolonClassElement */;
}
ts.isSemicolonClassElement = isSemicolonClassElement;
// Elements
function isBlock(node) {
- return node.kind === 234 /* Block */;
+ return node.kind === 235 /* SyntaxKind.Block */;
}
ts.isBlock = isBlock;
function isVariableStatement(node) {
- return node.kind === 236 /* VariableStatement */;
+ return node.kind === 237 /* SyntaxKind.VariableStatement */;
}
ts.isVariableStatement = isVariableStatement;
function isEmptyStatement(node) {
- return node.kind === 235 /* EmptyStatement */;
+ return node.kind === 236 /* SyntaxKind.EmptyStatement */;
}
ts.isEmptyStatement = isEmptyStatement;
function isExpressionStatement(node) {
- return node.kind === 237 /* ExpressionStatement */;
+ return node.kind === 238 /* SyntaxKind.ExpressionStatement */;
}
ts.isExpressionStatement = isExpressionStatement;
function isIfStatement(node) {
- return node.kind === 238 /* IfStatement */;
+ return node.kind === 239 /* SyntaxKind.IfStatement */;
}
ts.isIfStatement = isIfStatement;
function isDoStatement(node) {
- return node.kind === 239 /* DoStatement */;
+ return node.kind === 240 /* SyntaxKind.DoStatement */;
}
ts.isDoStatement = isDoStatement;
function isWhileStatement(node) {
- return node.kind === 240 /* WhileStatement */;
+ return node.kind === 241 /* SyntaxKind.WhileStatement */;
}
ts.isWhileStatement = isWhileStatement;
function isForStatement(node) {
- return node.kind === 241 /* ForStatement */;
+ return node.kind === 242 /* SyntaxKind.ForStatement */;
}
ts.isForStatement = isForStatement;
function isForInStatement(node) {
- return node.kind === 242 /* ForInStatement */;
+ return node.kind === 243 /* SyntaxKind.ForInStatement */;
}
ts.isForInStatement = isForInStatement;
function isForOfStatement(node) {
- return node.kind === 243 /* ForOfStatement */;
+ return node.kind === 244 /* SyntaxKind.ForOfStatement */;
}
ts.isForOfStatement = isForOfStatement;
function isContinueStatement(node) {
- return node.kind === 244 /* ContinueStatement */;
+ return node.kind === 245 /* SyntaxKind.ContinueStatement */;
}
ts.isContinueStatement = isContinueStatement;
function isBreakStatement(node) {
- return node.kind === 245 /* BreakStatement */;
+ return node.kind === 246 /* SyntaxKind.BreakStatement */;
}
ts.isBreakStatement = isBreakStatement;
function isReturnStatement(node) {
- return node.kind === 246 /* ReturnStatement */;
+ return node.kind === 247 /* SyntaxKind.ReturnStatement */;
}
ts.isReturnStatement = isReturnStatement;
function isWithStatement(node) {
- return node.kind === 247 /* WithStatement */;
+ return node.kind === 248 /* SyntaxKind.WithStatement */;
}
ts.isWithStatement = isWithStatement;
function isSwitchStatement(node) {
- return node.kind === 248 /* SwitchStatement */;
+ return node.kind === 249 /* SyntaxKind.SwitchStatement */;
}
ts.isSwitchStatement = isSwitchStatement;
function isLabeledStatement(node) {
- return node.kind === 249 /* LabeledStatement */;
+ return node.kind === 250 /* SyntaxKind.LabeledStatement */;
}
ts.isLabeledStatement = isLabeledStatement;
function isThrowStatement(node) {
- return node.kind === 250 /* ThrowStatement */;
+ return node.kind === 251 /* SyntaxKind.ThrowStatement */;
}
ts.isThrowStatement = isThrowStatement;
function isTryStatement(node) {
- return node.kind === 251 /* TryStatement */;
+ return node.kind === 252 /* SyntaxKind.TryStatement */;
}
ts.isTryStatement = isTryStatement;
function isDebuggerStatement(node) {
- return node.kind === 252 /* DebuggerStatement */;
+ return node.kind === 253 /* SyntaxKind.DebuggerStatement */;
}
ts.isDebuggerStatement = isDebuggerStatement;
function isVariableDeclaration(node) {
- return node.kind === 253 /* VariableDeclaration */;
+ return node.kind === 254 /* SyntaxKind.VariableDeclaration */;
}
ts.isVariableDeclaration = isVariableDeclaration;
function isVariableDeclarationList(node) {
- return node.kind === 254 /* VariableDeclarationList */;
+ return node.kind === 255 /* SyntaxKind.VariableDeclarationList */;
}
ts.isVariableDeclarationList = isVariableDeclarationList;
function isFunctionDeclaration(node) {
- return node.kind === 255 /* FunctionDeclaration */;
+ return node.kind === 256 /* SyntaxKind.FunctionDeclaration */;
}
ts.isFunctionDeclaration = isFunctionDeclaration;
function isClassDeclaration(node) {
- return node.kind === 256 /* ClassDeclaration */;
+ return node.kind === 257 /* SyntaxKind.ClassDeclaration */;
}
ts.isClassDeclaration = isClassDeclaration;
function isInterfaceDeclaration(node) {
- return node.kind === 257 /* InterfaceDeclaration */;
+ return node.kind === 258 /* SyntaxKind.InterfaceDeclaration */;
}
ts.isInterfaceDeclaration = isInterfaceDeclaration;
function isTypeAliasDeclaration(node) {
- return node.kind === 258 /* TypeAliasDeclaration */;
+ return node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */;
}
ts.isTypeAliasDeclaration = isTypeAliasDeclaration;
function isEnumDeclaration(node) {
- return node.kind === 259 /* EnumDeclaration */;
+ return node.kind === 260 /* SyntaxKind.EnumDeclaration */;
}
ts.isEnumDeclaration = isEnumDeclaration;
function isModuleDeclaration(node) {
- return node.kind === 260 /* ModuleDeclaration */;
+ return node.kind === 261 /* SyntaxKind.ModuleDeclaration */;
}
ts.isModuleDeclaration = isModuleDeclaration;
function isModuleBlock(node) {
- return node.kind === 261 /* ModuleBlock */;
+ return node.kind === 262 /* SyntaxKind.ModuleBlock */;
}
ts.isModuleBlock = isModuleBlock;
function isCaseBlock(node) {
- return node.kind === 262 /* CaseBlock */;
+ return node.kind === 263 /* SyntaxKind.CaseBlock */;
}
ts.isCaseBlock = isCaseBlock;
function isNamespaceExportDeclaration(node) {
- return node.kind === 263 /* NamespaceExportDeclaration */;
+ return node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */;
}
ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration;
function isImportEqualsDeclaration(node) {
- return node.kind === 264 /* ImportEqualsDeclaration */;
+ return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */;
}
ts.isImportEqualsDeclaration = isImportEqualsDeclaration;
function isImportDeclaration(node) {
- return node.kind === 265 /* ImportDeclaration */;
+ return node.kind === 266 /* SyntaxKind.ImportDeclaration */;
}
ts.isImportDeclaration = isImportDeclaration;
function isImportClause(node) {
- return node.kind === 266 /* ImportClause */;
+ return node.kind === 267 /* SyntaxKind.ImportClause */;
}
ts.isImportClause = isImportClause;
function isAssertClause(node) {
- return node.kind === 292 /* AssertClause */;
+ return node.kind === 293 /* SyntaxKind.AssertClause */;
}
ts.isAssertClause = isAssertClause;
function isAssertEntry(node) {
- return node.kind === 293 /* AssertEntry */;
+ return node.kind === 294 /* SyntaxKind.AssertEntry */;
}
ts.isAssertEntry = isAssertEntry;
function isNamespaceImport(node) {
- return node.kind === 267 /* NamespaceImport */;
+ return node.kind === 268 /* SyntaxKind.NamespaceImport */;
}
ts.isNamespaceImport = isNamespaceImport;
function isNamespaceExport(node) {
- return node.kind === 273 /* NamespaceExport */;
+ return node.kind === 274 /* SyntaxKind.NamespaceExport */;
}
ts.isNamespaceExport = isNamespaceExport;
function isNamedImports(node) {
- return node.kind === 268 /* NamedImports */;
+ return node.kind === 269 /* SyntaxKind.NamedImports */;
}
ts.isNamedImports = isNamedImports;
function isImportSpecifier(node) {
- return node.kind === 269 /* ImportSpecifier */;
+ return node.kind === 270 /* SyntaxKind.ImportSpecifier */;
}
ts.isImportSpecifier = isImportSpecifier;
function isExportAssignment(node) {
- return node.kind === 270 /* ExportAssignment */;
+ return node.kind === 271 /* SyntaxKind.ExportAssignment */;
}
ts.isExportAssignment = isExportAssignment;
function isExportDeclaration(node) {
- return node.kind === 271 /* ExportDeclaration */;
+ return node.kind === 272 /* SyntaxKind.ExportDeclaration */;
}
ts.isExportDeclaration = isExportDeclaration;
function isNamedExports(node) {
- return node.kind === 272 /* NamedExports */;
+ return node.kind === 273 /* SyntaxKind.NamedExports */;
}
ts.isNamedExports = isNamedExports;
function isExportSpecifier(node) {
- return node.kind === 274 /* ExportSpecifier */;
+ return node.kind === 275 /* SyntaxKind.ExportSpecifier */;
}
ts.isExportSpecifier = isExportSpecifier;
function isMissingDeclaration(node) {
- return node.kind === 275 /* MissingDeclaration */;
+ return node.kind === 276 /* SyntaxKind.MissingDeclaration */;
}
ts.isMissingDeclaration = isMissingDeclaration;
function isNotEmittedStatement(node) {
- return node.kind === 347 /* NotEmittedStatement */;
+ return node.kind === 349 /* SyntaxKind.NotEmittedStatement */;
}
ts.isNotEmittedStatement = isNotEmittedStatement;
/* @internal */
function isSyntheticReference(node) {
- return node.kind === 352 /* SyntheticReferenceExpression */;
+ return node.kind === 354 /* SyntaxKind.SyntheticReferenceExpression */;
}
ts.isSyntheticReference = isSyntheticReference;
/* @internal */
function isMergeDeclarationMarker(node) {
- return node.kind === 350 /* MergeDeclarationMarker */;
+ return node.kind === 352 /* SyntaxKind.MergeDeclarationMarker */;
}
ts.isMergeDeclarationMarker = isMergeDeclarationMarker;
/* @internal */
function isEndOfDeclarationMarker(node) {
- return node.kind === 351 /* EndOfDeclarationMarker */;
+ return node.kind === 353 /* SyntaxKind.EndOfDeclarationMarker */;
}
ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker;
// Module References
function isExternalModuleReference(node) {
- return node.kind === 276 /* ExternalModuleReference */;
+ return node.kind === 277 /* SyntaxKind.ExternalModuleReference */;
}
ts.isExternalModuleReference = isExternalModuleReference;
// JSX
function isJsxElement(node) {
- return node.kind === 277 /* JsxElement */;
+ return node.kind === 278 /* SyntaxKind.JsxElement */;
}
ts.isJsxElement = isJsxElement;
function isJsxSelfClosingElement(node) {
- return node.kind === 278 /* JsxSelfClosingElement */;
+ return node.kind === 279 /* SyntaxKind.JsxSelfClosingElement */;
}
ts.isJsxSelfClosingElement = isJsxSelfClosingElement;
function isJsxOpeningElement(node) {
- return node.kind === 279 /* JsxOpeningElement */;
+ return node.kind === 280 /* SyntaxKind.JsxOpeningElement */;
}
ts.isJsxOpeningElement = isJsxOpeningElement;
function isJsxClosingElement(node) {
- return node.kind === 280 /* JsxClosingElement */;
+ return node.kind === 281 /* SyntaxKind.JsxClosingElement */;
}
ts.isJsxClosingElement = isJsxClosingElement;
function isJsxFragment(node) {
- return node.kind === 281 /* JsxFragment */;
+ return node.kind === 282 /* SyntaxKind.JsxFragment */;
}
ts.isJsxFragment = isJsxFragment;
function isJsxOpeningFragment(node) {
- return node.kind === 282 /* JsxOpeningFragment */;
+ return node.kind === 283 /* SyntaxKind.JsxOpeningFragment */;
}
ts.isJsxOpeningFragment = isJsxOpeningFragment;
function isJsxClosingFragment(node) {
- return node.kind === 283 /* JsxClosingFragment */;
+ return node.kind === 284 /* SyntaxKind.JsxClosingFragment */;
}
ts.isJsxClosingFragment = isJsxClosingFragment;
function isJsxAttribute(node) {
- return node.kind === 284 /* JsxAttribute */;
+ return node.kind === 285 /* SyntaxKind.JsxAttribute */;
}
ts.isJsxAttribute = isJsxAttribute;
function isJsxAttributes(node) {
- return node.kind === 285 /* JsxAttributes */;
+ return node.kind === 286 /* SyntaxKind.JsxAttributes */;
}
ts.isJsxAttributes = isJsxAttributes;
function isJsxSpreadAttribute(node) {
- return node.kind === 286 /* JsxSpreadAttribute */;
+ return node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */;
}
ts.isJsxSpreadAttribute = isJsxSpreadAttribute;
function isJsxExpression(node) {
- return node.kind === 287 /* JsxExpression */;
+ return node.kind === 288 /* SyntaxKind.JsxExpression */;
}
ts.isJsxExpression = isJsxExpression;
// Clauses
function isCaseClause(node) {
- return node.kind === 288 /* CaseClause */;
+ return node.kind === 289 /* SyntaxKind.CaseClause */;
}
ts.isCaseClause = isCaseClause;
function isDefaultClause(node) {
- return node.kind === 289 /* DefaultClause */;
+ return node.kind === 290 /* SyntaxKind.DefaultClause */;
}
ts.isDefaultClause = isDefaultClause;
function isHeritageClause(node) {
- return node.kind === 290 /* HeritageClause */;
+ return node.kind === 291 /* SyntaxKind.HeritageClause */;
}
ts.isHeritageClause = isHeritageClause;
function isCatchClause(node) {
- return node.kind === 291 /* CatchClause */;
+ return node.kind === 292 /* SyntaxKind.CatchClause */;
}
ts.isCatchClause = isCatchClause;
// Property assignments
function isPropertyAssignment(node) {
- return node.kind === 294 /* PropertyAssignment */;
+ return node.kind === 296 /* SyntaxKind.PropertyAssignment */;
}
ts.isPropertyAssignment = isPropertyAssignment;
function isShorthandPropertyAssignment(node) {
- return node.kind === 295 /* ShorthandPropertyAssignment */;
+ return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */;
}
ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment;
function isSpreadAssignment(node) {
- return node.kind === 296 /* SpreadAssignment */;
+ return node.kind === 298 /* SyntaxKind.SpreadAssignment */;
}
ts.isSpreadAssignment = isSpreadAssignment;
// Enum
function isEnumMember(node) {
- return node.kind === 297 /* EnumMember */;
+ return node.kind === 299 /* SyntaxKind.EnumMember */;
}
ts.isEnumMember = isEnumMember;
// Unparsed
// TODO(rbuckton): isUnparsedPrologue
function isUnparsedPrepend(node) {
- return node.kind === 299 /* UnparsedPrepend */;
+ return node.kind === 301 /* SyntaxKind.UnparsedPrepend */;
}
ts.isUnparsedPrepend = isUnparsedPrepend;
// TODO(rbuckton): isUnparsedText
@@ -28801,176 +29415,176 @@ var ts;
// TODO(rbuckton): isUnparsedSyntheticReference
// Top-level nodes
function isSourceFile(node) {
- return node.kind === 303 /* SourceFile */;
+ return node.kind === 305 /* SyntaxKind.SourceFile */;
}
ts.isSourceFile = isSourceFile;
function isBundle(node) {
- return node.kind === 304 /* Bundle */;
+ return node.kind === 306 /* SyntaxKind.Bundle */;
}
ts.isBundle = isBundle;
function isUnparsedSource(node) {
- return node.kind === 305 /* UnparsedSource */;
+ return node.kind === 307 /* SyntaxKind.UnparsedSource */;
}
ts.isUnparsedSource = isUnparsedSource;
// TODO(rbuckton): isInputFiles
// JSDoc Elements
function isJSDocTypeExpression(node) {
- return node.kind === 307 /* JSDocTypeExpression */;
+ return node.kind === 309 /* SyntaxKind.JSDocTypeExpression */;
}
ts.isJSDocTypeExpression = isJSDocTypeExpression;
function isJSDocNameReference(node) {
- return node.kind === 308 /* JSDocNameReference */;
+ return node.kind === 310 /* SyntaxKind.JSDocNameReference */;
}
ts.isJSDocNameReference = isJSDocNameReference;
function isJSDocMemberName(node) {
- return node.kind === 309 /* JSDocMemberName */;
+ return node.kind === 311 /* SyntaxKind.JSDocMemberName */;
}
ts.isJSDocMemberName = isJSDocMemberName;
function isJSDocLink(node) {
- return node.kind === 322 /* JSDocLink */;
+ return node.kind === 324 /* SyntaxKind.JSDocLink */;
}
ts.isJSDocLink = isJSDocLink;
function isJSDocLinkCode(node) {
- return node.kind === 323 /* JSDocLinkCode */;
+ return node.kind === 325 /* SyntaxKind.JSDocLinkCode */;
}
ts.isJSDocLinkCode = isJSDocLinkCode;
function isJSDocLinkPlain(node) {
- return node.kind === 324 /* JSDocLinkPlain */;
+ return node.kind === 326 /* SyntaxKind.JSDocLinkPlain */;
}
ts.isJSDocLinkPlain = isJSDocLinkPlain;
function isJSDocAllType(node) {
- return node.kind === 310 /* JSDocAllType */;
+ return node.kind === 312 /* SyntaxKind.JSDocAllType */;
}
ts.isJSDocAllType = isJSDocAllType;
function isJSDocUnknownType(node) {
- return node.kind === 311 /* JSDocUnknownType */;
+ return node.kind === 313 /* SyntaxKind.JSDocUnknownType */;
}
ts.isJSDocUnknownType = isJSDocUnknownType;
function isJSDocNullableType(node) {
- return node.kind === 312 /* JSDocNullableType */;
+ return node.kind === 314 /* SyntaxKind.JSDocNullableType */;
}
ts.isJSDocNullableType = isJSDocNullableType;
function isJSDocNonNullableType(node) {
- return node.kind === 313 /* JSDocNonNullableType */;
+ return node.kind === 315 /* SyntaxKind.JSDocNonNullableType */;
}
ts.isJSDocNonNullableType = isJSDocNonNullableType;
function isJSDocOptionalType(node) {
- return node.kind === 314 /* JSDocOptionalType */;
+ return node.kind === 316 /* SyntaxKind.JSDocOptionalType */;
}
ts.isJSDocOptionalType = isJSDocOptionalType;
function isJSDocFunctionType(node) {
- return node.kind === 315 /* JSDocFunctionType */;
+ return node.kind === 317 /* SyntaxKind.JSDocFunctionType */;
}
ts.isJSDocFunctionType = isJSDocFunctionType;
function isJSDocVariadicType(node) {
- return node.kind === 316 /* JSDocVariadicType */;
+ return node.kind === 318 /* SyntaxKind.JSDocVariadicType */;
}
ts.isJSDocVariadicType = isJSDocVariadicType;
function isJSDocNamepathType(node) {
- return node.kind === 317 /* JSDocNamepathType */;
+ return node.kind === 319 /* SyntaxKind.JSDocNamepathType */;
}
ts.isJSDocNamepathType = isJSDocNamepathType;
function isJSDoc(node) {
- return node.kind === 318 /* JSDocComment */;
+ return node.kind === 320 /* SyntaxKind.JSDoc */;
}
ts.isJSDoc = isJSDoc;
function isJSDocTypeLiteral(node) {
- return node.kind === 320 /* JSDocTypeLiteral */;
+ return node.kind === 322 /* SyntaxKind.JSDocTypeLiteral */;
}
ts.isJSDocTypeLiteral = isJSDocTypeLiteral;
function isJSDocSignature(node) {
- return node.kind === 321 /* JSDocSignature */;
+ return node.kind === 323 /* SyntaxKind.JSDocSignature */;
}
ts.isJSDocSignature = isJSDocSignature;
// JSDoc Tags
function isJSDocAugmentsTag(node) {
- return node.kind === 326 /* JSDocAugmentsTag */;
+ return node.kind === 328 /* SyntaxKind.JSDocAugmentsTag */;
}
ts.isJSDocAugmentsTag = isJSDocAugmentsTag;
function isJSDocAuthorTag(node) {
- return node.kind === 328 /* JSDocAuthorTag */;
+ return node.kind === 330 /* SyntaxKind.JSDocAuthorTag */;
}
ts.isJSDocAuthorTag = isJSDocAuthorTag;
function isJSDocClassTag(node) {
- return node.kind === 330 /* JSDocClassTag */;
+ return node.kind === 332 /* SyntaxKind.JSDocClassTag */;
}
ts.isJSDocClassTag = isJSDocClassTag;
function isJSDocCallbackTag(node) {
- return node.kind === 336 /* JSDocCallbackTag */;
+ return node.kind === 338 /* SyntaxKind.JSDocCallbackTag */;
}
ts.isJSDocCallbackTag = isJSDocCallbackTag;
function isJSDocPublicTag(node) {
- return node.kind === 331 /* JSDocPublicTag */;
+ return node.kind === 333 /* SyntaxKind.JSDocPublicTag */;
}
ts.isJSDocPublicTag = isJSDocPublicTag;
function isJSDocPrivateTag(node) {
- return node.kind === 332 /* JSDocPrivateTag */;
+ return node.kind === 334 /* SyntaxKind.JSDocPrivateTag */;
}
ts.isJSDocPrivateTag = isJSDocPrivateTag;
function isJSDocProtectedTag(node) {
- return node.kind === 333 /* JSDocProtectedTag */;
+ return node.kind === 335 /* SyntaxKind.JSDocProtectedTag */;
}
ts.isJSDocProtectedTag = isJSDocProtectedTag;
function isJSDocReadonlyTag(node) {
- return node.kind === 334 /* JSDocReadonlyTag */;
+ return node.kind === 336 /* SyntaxKind.JSDocReadonlyTag */;
}
ts.isJSDocReadonlyTag = isJSDocReadonlyTag;
function isJSDocOverrideTag(node) {
- return node.kind === 335 /* JSDocOverrideTag */;
+ return node.kind === 337 /* SyntaxKind.JSDocOverrideTag */;
}
ts.isJSDocOverrideTag = isJSDocOverrideTag;
function isJSDocDeprecatedTag(node) {
- return node.kind === 329 /* JSDocDeprecatedTag */;
+ return node.kind === 331 /* SyntaxKind.JSDocDeprecatedTag */;
}
ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag;
function isJSDocSeeTag(node) {
- return node.kind === 344 /* JSDocSeeTag */;
+ return node.kind === 346 /* SyntaxKind.JSDocSeeTag */;
}
ts.isJSDocSeeTag = isJSDocSeeTag;
function isJSDocEnumTag(node) {
- return node.kind === 337 /* JSDocEnumTag */;
+ return node.kind === 339 /* SyntaxKind.JSDocEnumTag */;
}
ts.isJSDocEnumTag = isJSDocEnumTag;
function isJSDocParameterTag(node) {
- return node.kind === 338 /* JSDocParameterTag */;
+ return node.kind === 340 /* SyntaxKind.JSDocParameterTag */;
}
ts.isJSDocParameterTag = isJSDocParameterTag;
function isJSDocReturnTag(node) {
- return node.kind === 339 /* JSDocReturnTag */;
+ return node.kind === 341 /* SyntaxKind.JSDocReturnTag */;
}
ts.isJSDocReturnTag = isJSDocReturnTag;
function isJSDocThisTag(node) {
- return node.kind === 340 /* JSDocThisTag */;
+ return node.kind === 342 /* SyntaxKind.JSDocThisTag */;
}
ts.isJSDocThisTag = isJSDocThisTag;
function isJSDocTypeTag(node) {
- return node.kind === 341 /* JSDocTypeTag */;
+ return node.kind === 343 /* SyntaxKind.JSDocTypeTag */;
}
ts.isJSDocTypeTag = isJSDocTypeTag;
function isJSDocTemplateTag(node) {
- return node.kind === 342 /* JSDocTemplateTag */;
+ return node.kind === 344 /* SyntaxKind.JSDocTemplateTag */;
}
ts.isJSDocTemplateTag = isJSDocTemplateTag;
function isJSDocTypedefTag(node) {
- return node.kind === 343 /* JSDocTypedefTag */;
+ return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */;
}
ts.isJSDocTypedefTag = isJSDocTypedefTag;
function isJSDocUnknownTag(node) {
- return node.kind === 325 /* JSDocTag */;
+ return node.kind === 327 /* SyntaxKind.JSDocTag */;
}
ts.isJSDocUnknownTag = isJSDocUnknownTag;
function isJSDocPropertyTag(node) {
- return node.kind === 345 /* JSDocPropertyTag */;
+ return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */;
}
ts.isJSDocPropertyTag = isJSDocPropertyTag;
function isJSDocImplementsTag(node) {
- return node.kind === 327 /* JSDocImplementsTag */;
+ return node.kind === 329 /* SyntaxKind.JSDocImplementsTag */;
}
ts.isJSDocImplementsTag = isJSDocImplementsTag;
// Synthesized list
/* @internal */
function isSyntaxList(n) {
- return n.kind === 346 /* SyntaxList */;
+ return n.kind === 348 /* SyntaxKind.SyntaxList */;
}
ts.isSyntaxList = isSyntaxList;
})(ts || (ts = {}));
@@ -28990,7 +29604,7 @@ var ts;
var expression = ts.setTextRange(ts.isMemberName(memberName)
? factory.createPropertyAccessExpression(target, memberName)
: factory.createElementAccessExpression(target, memberName), memberName);
- ts.getOrCreateEmitNode(expression).flags |= 64 /* NoNestedSourceMaps */;
+ ts.getOrCreateEmitNode(expression).flags |= 64 /* EmitFlags.NoNestedSourceMaps */;
return expression;
}
}
@@ -29169,14 +29783,14 @@ var ts;
ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals.");
}
switch (property.kind) {
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine);
- case 294 /* PropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
return createExpressionForPropertyAssignment(factory, property, receiver);
- case 295 /* ShorthandPropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
return createExpressionForShorthandPropertyAssignment(factory, property, receiver);
- case 168 /* MethodDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
return createExpressionForMethodDeclaration(factory, property, receiver);
}
}
@@ -29215,7 +29829,7 @@ var ts;
*/
function expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, recordTempVariable, resultVariable) {
var operator = node.operator;
- ts.Debug.assert(operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression");
+ ts.Debug.assert(operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression");
var temp = factory.createTempVariable(recordTempVariable);
expression = factory.createAssignment(temp, expression);
ts.setTextRange(expression, node.operand);
@@ -29240,14 +29854,14 @@ var ts;
* Gets whether an identifier should only be referred to by its internal name.
*/
function isInternalName(node) {
- return (ts.getEmitFlags(node) & 32768 /* InternalName */) !== 0;
+ return (ts.getEmitFlags(node) & 32768 /* EmitFlags.InternalName */) !== 0;
}
ts.isInternalName = isInternalName;
/**
* Gets whether an identifier should only be referred to by its local name.
*/
function isLocalName(node) {
- return (ts.getEmitFlags(node) & 16384 /* LocalName */) !== 0;
+ return (ts.getEmitFlags(node) & 16384 /* EmitFlags.LocalName */) !== 0;
}
ts.isLocalName = isLocalName;
/**
@@ -29255,7 +29869,7 @@ var ts;
* name points to an exported symbol.
*/
function isExportName(node) {
- return (ts.getEmitFlags(node) & 8192 /* ExportName */) !== 0;
+ return (ts.getEmitFlags(node) & 8192 /* EmitFlags.ExportName */) !== 0;
}
ts.isExportName = isExportName;
function isUseStrictPrologue(node) {
@@ -29284,8 +29898,8 @@ var ts;
}
ts.startsWithUseStrict = startsWithUseStrict;
function isCommaSequence(node) {
- return node.kind === 220 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ ||
- node.kind === 349 /* CommaListExpression */;
+ return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ ||
+ node.kind === 351 /* SyntaxKind.CommaListExpression */;
}
ts.isCommaSequence = isCommaSequence;
function isJSDocTypeAssertion(node) {
@@ -29301,26 +29915,26 @@ var ts;
}
ts.getJSDocTypeAssertionType = getJSDocTypeAssertionType;
function isOuterExpression(node, kinds) {
- if (kinds === void 0) { kinds = 15 /* All */; }
+ if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; }
switch (node.kind) {
- case 211 /* ParenthesizedExpression */:
- if (kinds & 16 /* ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) {
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
+ if (kinds & 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) {
return false;
}
- return (kinds & 1 /* Parentheses */) !== 0;
- case 210 /* TypeAssertionExpression */:
- case 228 /* AsExpression */:
- return (kinds & 2 /* TypeAssertions */) !== 0;
- case 229 /* NonNullExpression */:
- return (kinds & 4 /* NonNullAssertions */) !== 0;
- case 348 /* PartiallyEmittedExpression */:
- return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0;
+ return (kinds & 1 /* OuterExpressionKinds.Parentheses */) !== 0;
+ case 211 /* SyntaxKind.TypeAssertionExpression */:
+ case 229 /* SyntaxKind.AsExpression */:
+ return (kinds & 2 /* OuterExpressionKinds.TypeAssertions */) !== 0;
+ case 230 /* SyntaxKind.NonNullExpression */:
+ return (kinds & 4 /* OuterExpressionKinds.NonNullAssertions */) !== 0;
+ case 350 /* SyntaxKind.PartiallyEmittedExpression */:
+ return (kinds & 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */) !== 0;
}
return false;
}
ts.isOuterExpression = isOuterExpression;
function skipOuterExpressions(node, kinds) {
- if (kinds === void 0) { kinds = 15 /* All */; }
+ if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; }
while (isOuterExpression(node, kinds)) {
node = node.expression;
}
@@ -29328,7 +29942,7 @@ var ts;
}
ts.skipOuterExpressions = skipOuterExpressions;
function skipAssertions(node) {
- return skipOuterExpressions(node, 6 /* Assertions */);
+ return skipOuterExpressions(node, 6 /* OuterExpressionKinds.Assertions */);
}
ts.skipAssertions = skipAssertions;
function startOnNewLine(node) {
@@ -29390,7 +30004,7 @@ var ts;
/*decorators*/ undefined,
/*modifiers*/ undefined, nodeFactory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, namedBindings), nodeFactory.createStringLiteral(ts.externalHelpersModuleNameText),
/*assertClause*/ undefined);
- ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */);
+ ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* EmitFlags.NeverApplyImportHelper */);
return externalHelpersImportDeclaration;
}
}
@@ -29435,10 +30049,10 @@ var ts;
var name = namespaceDeclaration.name;
return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name));
}
- if (node.kind === 265 /* ImportDeclaration */ && node.importClause) {
+ if (node.kind === 266 /* SyntaxKind.ImportDeclaration */ && node.importClause) {
return factory.getGeneratedNameForNode(node);
}
- if (node.kind === 271 /* ExportDeclaration */ && node.moduleSpecifier) {
+ if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ && node.moduleSpecifier) {
return factory.getGeneratedNameForNode(node);
}
return undefined;
@@ -29557,7 +30171,7 @@ var ts;
}
if (ts.isObjectLiteralElementLike(bindingElement)) {
switch (bindingElement.kind) {
- case 294 /* PropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
// `b` in `({ a: b } = ...)`
// `b` in `({ a: b = 1 } = ...)`
// `{b}` in `({ a: {b} } = ...)`
@@ -29569,11 +30183,11 @@ var ts;
// `b[0]` in `({ a: b[0] } = ...)`
// `b[0]` in `({ a: b[0] = 1 } = ...)`
return getTargetOfBindingOrAssignmentElement(bindingElement.initializer);
- case 295 /* ShorthandPropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
// `a` in `({ a } = ...)`
// `a` in `({ a = 1 } = ...)`
return bindingElement.name;
- case 296 /* SpreadAssignment */:
+ case 298 /* SyntaxKind.SpreadAssignment */:
// `a` in `({ ...a } = ...)`
return getTargetOfBindingOrAssignmentElement(bindingElement.expression);
}
@@ -29605,12 +30219,12 @@ var ts;
*/
function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) {
switch (bindingElement.kind) {
- case 163 /* Parameter */:
- case 202 /* BindingElement */:
+ case 164 /* SyntaxKind.Parameter */:
+ case 203 /* SyntaxKind.BindingElement */:
// `...` in `let [...a] = ...`
return bindingElement.dotDotDotToken;
- case 224 /* SpreadElement */:
- case 296 /* SpreadAssignment */:
+ case 225 /* SyntaxKind.SpreadElement */:
+ case 298 /* SyntaxKind.SpreadAssignment */:
// `...` in `[...a] = ...`
return bindingElement;
}
@@ -29628,7 +30242,7 @@ var ts;
ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement;
function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) {
switch (bindingElement.kind) {
- case 202 /* BindingElement */:
+ case 203 /* SyntaxKind.BindingElement */:
// `a` in `let { a: b } = ...`
// `[a]` in `let { [a]: b } = ...`
// `"a"` in `let { "a": b } = ...`
@@ -29643,7 +30257,7 @@ var ts;
: propertyName;
}
break;
- case 294 /* PropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
// `a` in `({ a: b } = ...)`
// `[a]` in `({ [a]: b } = ...)`
// `"a"` in `({ "a": b } = ...)`
@@ -29658,7 +30272,7 @@ var ts;
: propertyName;
}
break;
- case 296 /* SpreadAssignment */:
+ case 298 /* SyntaxKind.SpreadAssignment */:
// `a` in `({ ...a } = ...)`
if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) {
return ts.Debug.failBadSyntaxKind(bindingElement.name);
@@ -29673,21 +30287,21 @@ var ts;
ts.tryGetPropertyNameOfBindingOrAssignmentElement = tryGetPropertyNameOfBindingOrAssignmentElement;
function isStringOrNumericLiteral(node) {
var kind = node.kind;
- return kind === 10 /* StringLiteral */
- || kind === 8 /* NumericLiteral */;
+ return kind === 10 /* SyntaxKind.StringLiteral */
+ || kind === 8 /* SyntaxKind.NumericLiteral */;
}
/**
* Gets the elements of a BindingOrAssignmentPattern
*/
function getElementsOfBindingOrAssignmentPattern(name) {
switch (name.kind) {
- case 200 /* ObjectBindingPattern */:
- case 201 /* ArrayBindingPattern */:
- case 203 /* ArrayLiteralExpression */:
+ case 201 /* SyntaxKind.ObjectBindingPattern */:
+ case 202 /* SyntaxKind.ArrayBindingPattern */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
// `a` in `{a}`
// `a` in `[a]`
return name.elements;
- case 204 /* ObjectLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
// `a` in `{a}`
return name.properties;
}
@@ -29708,29 +30322,29 @@ var ts;
ts.getJSDocTypeAliasName = getJSDocTypeAliasName;
function canHaveModifiers(node) {
var kind = node.kind;
- return kind === 163 /* Parameter */
- || kind === 165 /* PropertySignature */
- || kind === 166 /* PropertyDeclaration */
- || kind === 167 /* MethodSignature */
- || kind === 168 /* MethodDeclaration */
- || kind === 170 /* Constructor */
- || kind === 171 /* GetAccessor */
- || kind === 172 /* SetAccessor */
- || kind === 175 /* IndexSignature */
- || kind === 212 /* FunctionExpression */
- || kind === 213 /* ArrowFunction */
- || kind === 225 /* ClassExpression */
- || kind === 236 /* VariableStatement */
- || kind === 255 /* FunctionDeclaration */
- || kind === 256 /* ClassDeclaration */
- || kind === 257 /* InterfaceDeclaration */
- || kind === 258 /* TypeAliasDeclaration */
- || kind === 259 /* EnumDeclaration */
- || kind === 260 /* ModuleDeclaration */
- || kind === 264 /* ImportEqualsDeclaration */
- || kind === 265 /* ImportDeclaration */
- || kind === 270 /* ExportAssignment */
- || kind === 271 /* ExportDeclaration */;
+ return kind === 164 /* SyntaxKind.Parameter */
+ || kind === 166 /* SyntaxKind.PropertySignature */
+ || kind === 167 /* SyntaxKind.PropertyDeclaration */
+ || kind === 168 /* SyntaxKind.MethodSignature */
+ || kind === 169 /* SyntaxKind.MethodDeclaration */
+ || kind === 171 /* SyntaxKind.Constructor */
+ || kind === 172 /* SyntaxKind.GetAccessor */
+ || kind === 173 /* SyntaxKind.SetAccessor */
+ || kind === 176 /* SyntaxKind.IndexSignature */
+ || kind === 213 /* SyntaxKind.FunctionExpression */
+ || kind === 214 /* SyntaxKind.ArrowFunction */
+ || kind === 226 /* SyntaxKind.ClassExpression */
+ || kind === 237 /* SyntaxKind.VariableStatement */
+ || kind === 256 /* SyntaxKind.FunctionDeclaration */
+ || kind === 257 /* SyntaxKind.ClassDeclaration */
+ || kind === 258 /* SyntaxKind.InterfaceDeclaration */
+ || kind === 259 /* SyntaxKind.TypeAliasDeclaration */
+ || kind === 260 /* SyntaxKind.EnumDeclaration */
+ || kind === 261 /* SyntaxKind.ModuleDeclaration */
+ || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */
+ || kind === 266 /* SyntaxKind.ImportDeclaration */
+ || kind === 271 /* SyntaxKind.ExportAssignment */
+ || kind === 272 /* SyntaxKind.ExportDeclaration */;
}
ts.canHaveModifiers = canHaveModifiers;
ts.isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration);
@@ -29741,68 +30355,68 @@ var ts;
ts.isModuleName = ts.or(ts.isIdentifier, ts.isStringLiteral);
function isLiteralTypeLikeExpression(node) {
var kind = node.kind;
- return kind === 104 /* NullKeyword */
- || kind === 110 /* TrueKeyword */
- || kind === 95 /* FalseKeyword */
+ return kind === 104 /* SyntaxKind.NullKeyword */
+ || kind === 110 /* SyntaxKind.TrueKeyword */
+ || kind === 95 /* SyntaxKind.FalseKeyword */
|| ts.isLiteralExpression(node)
|| ts.isPrefixUnaryExpression(node);
}
ts.isLiteralTypeLikeExpression = isLiteralTypeLikeExpression;
function isExponentiationOperator(kind) {
- return kind === 42 /* AsteriskAsteriskToken */;
+ return kind === 42 /* SyntaxKind.AsteriskAsteriskToken */;
}
function isMultiplicativeOperator(kind) {
- return kind === 41 /* AsteriskToken */
- || kind === 43 /* SlashToken */
- || kind === 44 /* PercentToken */;
+ return kind === 41 /* SyntaxKind.AsteriskToken */
+ || kind === 43 /* SyntaxKind.SlashToken */
+ || kind === 44 /* SyntaxKind.PercentToken */;
}
function isMultiplicativeOperatorOrHigher(kind) {
return isExponentiationOperator(kind)
|| isMultiplicativeOperator(kind);
}
function isAdditiveOperator(kind) {
- return kind === 39 /* PlusToken */
- || kind === 40 /* MinusToken */;
+ return kind === 39 /* SyntaxKind.PlusToken */
+ || kind === 40 /* SyntaxKind.MinusToken */;
}
function isAdditiveOperatorOrHigher(kind) {
return isAdditiveOperator(kind)
|| isMultiplicativeOperatorOrHigher(kind);
}
function isShiftOperator(kind) {
- return kind === 47 /* LessThanLessThanToken */
- || kind === 48 /* GreaterThanGreaterThanToken */
- || kind === 49 /* GreaterThanGreaterThanGreaterThanToken */;
+ return kind === 47 /* SyntaxKind.LessThanLessThanToken */
+ || kind === 48 /* SyntaxKind.GreaterThanGreaterThanToken */
+ || kind === 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */;
}
function isShiftOperatorOrHigher(kind) {
return isShiftOperator(kind)
|| isAdditiveOperatorOrHigher(kind);
}
function isRelationalOperator(kind) {
- return kind === 29 /* LessThanToken */
- || kind === 32 /* LessThanEqualsToken */
- || kind === 31 /* GreaterThanToken */
- || kind === 33 /* GreaterThanEqualsToken */
- || kind === 102 /* InstanceOfKeyword */
- || kind === 101 /* InKeyword */;
+ return kind === 29 /* SyntaxKind.LessThanToken */
+ || kind === 32 /* SyntaxKind.LessThanEqualsToken */
+ || kind === 31 /* SyntaxKind.GreaterThanToken */
+ || kind === 33 /* SyntaxKind.GreaterThanEqualsToken */
+ || kind === 102 /* SyntaxKind.InstanceOfKeyword */
+ || kind === 101 /* SyntaxKind.InKeyword */;
}
function isRelationalOperatorOrHigher(kind) {
return isRelationalOperator(kind)
|| isShiftOperatorOrHigher(kind);
}
function isEqualityOperator(kind) {
- return kind === 34 /* EqualsEqualsToken */
- || kind === 36 /* EqualsEqualsEqualsToken */
- || kind === 35 /* ExclamationEqualsToken */
- || kind === 37 /* ExclamationEqualsEqualsToken */;
+ return kind === 34 /* SyntaxKind.EqualsEqualsToken */
+ || kind === 36 /* SyntaxKind.EqualsEqualsEqualsToken */
+ || kind === 35 /* SyntaxKind.ExclamationEqualsToken */
+ || kind === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */;
}
function isEqualityOperatorOrHigher(kind) {
return isEqualityOperator(kind)
|| isRelationalOperatorOrHigher(kind);
}
function isBitwiseOperator(kind) {
- return kind === 50 /* AmpersandToken */
- || kind === 51 /* BarToken */
- || kind === 52 /* CaretToken */;
+ return kind === 50 /* SyntaxKind.AmpersandToken */
+ || kind === 51 /* SyntaxKind.BarToken */
+ || kind === 52 /* SyntaxKind.CaretToken */;
}
function isBitwiseOperatorOrHigher(kind) {
return isBitwiseOperator(kind)
@@ -29810,21 +30424,21 @@ var ts;
}
// NOTE: The version in utilities includes ExclamationToken, which is not a binary operator.
function isLogicalOperator(kind) {
- return kind === 55 /* AmpersandAmpersandToken */
- || kind === 56 /* BarBarToken */;
+ return kind === 55 /* SyntaxKind.AmpersandAmpersandToken */
+ || kind === 56 /* SyntaxKind.BarBarToken */;
}
function isLogicalOperatorOrHigher(kind) {
return isLogicalOperator(kind)
|| isBitwiseOperatorOrHigher(kind);
}
function isAssignmentOperatorOrHigher(kind) {
- return kind === 60 /* QuestionQuestionToken */
+ return kind === 60 /* SyntaxKind.QuestionQuestionToken */
|| isLogicalOperatorOrHigher(kind)
|| ts.isAssignmentOperator(kind);
}
function isBinaryOperator(kind) {
return isAssignmentOperatorOrHigher(kind)
- || kind === 27 /* CommaToken */;
+ || kind === 27 /* SyntaxKind.CommaToken */;
}
function isBinaryOperatorToken(node) {
return isBinaryOperator(node.kind);
@@ -29957,7 +30571,7 @@ var ts;
return stackIndex;
}
function checkCircularity(stackIndex, nodeStack, node) {
- if (ts.Debug.shouldAssert(2 /* Aggressive */)) {
+ if (ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */)) {
while (stackIndex >= 0) {
ts.Debug.assert(nodeStack[stackIndex] !== node, "Circular traversal detected.");
stackIndex--;
@@ -30038,7 +30652,7 @@ var ts;
createBaseNode: function (kind) { return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, -1, -1); },
};
/* @internal */
- ts.parseNodeFactory = ts.createNodeFactory(1 /* NoParenthesizerRules */, ts.parseBaseNodeFactory);
+ ts.parseNodeFactory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */, ts.parseBaseNodeFactory);
function visitNode(cbNode, node) {
return node && cbNode(node);
}
@@ -30058,11 +30672,41 @@ var ts;
}
/*@internal*/
function isJSDocLikeText(text, start) {
- return text.charCodeAt(start + 1) === 42 /* asterisk */ &&
- text.charCodeAt(start + 2) === 42 /* asterisk */ &&
- text.charCodeAt(start + 3) !== 47 /* slash */;
+ return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ &&
+ text.charCodeAt(start + 2) === 42 /* CharacterCodes.asterisk */ &&
+ text.charCodeAt(start + 3) !== 47 /* CharacterCodes.slash */;
}
ts.isJSDocLikeText = isJSDocLikeText;
+ /*@internal*/
+ function isFileProbablyExternalModule(sourceFile) {
+ // Try to use the first top-level import/export when available, then
+ // fall back to looking for an 'import.meta' somewhere in the tree if necessary.
+ return ts.forEach(sourceFile.statements, isAnExternalModuleIndicatorNode) ||
+ getImportMetaIfNecessary(sourceFile);
+ }
+ ts.isFileProbablyExternalModule = isFileProbablyExternalModule;
+ function isAnExternalModuleIndicatorNode(node) {
+ return hasModifierOfKind(node, 93 /* SyntaxKind.ExportKeyword */)
+ || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference)
+ || ts.isImportDeclaration(node)
+ || ts.isExportAssignment(node)
+ || ts.isExportDeclaration(node) ? node : undefined;
+ }
+ function getImportMetaIfNecessary(sourceFile) {
+ return sourceFile.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */ ?
+ walkTreeForImportMeta(sourceFile) :
+ undefined;
+ }
+ function walkTreeForImportMeta(node) {
+ return isImportMeta(node) ? node : forEachChild(node, walkTreeForImportMeta);
+ }
+ /** Do not use hasModifier inside the parser; it relies on parent pointers. Use this instead. */
+ function hasModifierOfKind(node, kind) {
+ return ts.some(node.modifiers, function (m) { return m.kind === kind; });
+ }
+ function isImportMeta(node) {
+ return ts.isMetaProperty(node) && node.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && node.name.escapedText === "meta";
+ }
/**
* Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes
* stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise,
@@ -30077,19 +30721,20 @@ var ts;
* that they appear in the source code. The language service depends on this property to locate nodes by position.
*/
function forEachChild(node, cbNode, cbNodes) {
- if (!node || node.kind <= 159 /* LastToken */) {
+ if (!node || node.kind <= 160 /* SyntaxKind.LastToken */) {
return;
}
switch (node.kind) {
- case 160 /* QualifiedName */:
+ case 161 /* SyntaxKind.QualifiedName */:
return visitNode(cbNode, node.left) ||
visitNode(cbNode, node.right);
- case 162 /* TypeParameter */:
- return visitNode(cbNode, node.name) ||
+ case 163 /* SyntaxKind.TypeParameter */:
+ return visitNodes(cbNode, cbNodes, node.modifiers) ||
+ visitNode(cbNode, node.name) ||
visitNode(cbNode, node.constraint) ||
visitNode(cbNode, node.default) ||
visitNode(cbNode, node.expression);
- case 295 /* ShorthandPropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, node.name) ||
@@ -30097,9 +30742,9 @@ var ts;
visitNode(cbNode, node.exclamationToken) ||
visitNode(cbNode, node.equalsToken) ||
visitNode(cbNode, node.objectAssignmentInitializer);
- case 296 /* SpreadAssignment */:
+ case 298 /* SyntaxKind.SpreadAssignment */:
return visitNode(cbNode, node.expression);
- case 163 /* Parameter */:
+ case 164 /* SyntaxKind.Parameter */:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, node.dotDotDotToken) ||
@@ -30107,7 +30752,7 @@ var ts;
visitNode(cbNode, node.questionToken) ||
visitNode(cbNode, node.type) ||
visitNode(cbNode, node.initializer);
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, node.name) ||
@@ -30115,51 +30760,51 @@ var ts;
visitNode(cbNode, node.exclamationToken) ||
visitNode(cbNode, node.type) ||
visitNode(cbNode, node.initializer);
- case 165 /* PropertySignature */:
+ case 166 /* SyntaxKind.PropertySignature */:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, node.name) ||
visitNode(cbNode, node.questionToken) ||
visitNode(cbNode, node.type) ||
visitNode(cbNode, node.initializer);
- case 294 /* PropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, node.name) ||
visitNode(cbNode, node.questionToken) ||
visitNode(cbNode, node.initializer);
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, node.name) ||
visitNode(cbNode, node.exclamationToken) ||
visitNode(cbNode, node.type) ||
visitNode(cbNode, node.initializer);
- case 202 /* BindingElement */:
+ case 203 /* SyntaxKind.BindingElement */:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, node.dotDotDotToken) ||
visitNode(cbNode, node.propertyName) ||
visitNode(cbNode, node.name) ||
visitNode(cbNode, node.initializer);
- case 178 /* FunctionType */:
- case 179 /* ConstructorType */:
- case 173 /* CallSignature */:
- case 174 /* ConstructSignature */:
- case 175 /* IndexSignature */:
+ case 179 /* SyntaxKind.FunctionType */:
+ case 180 /* SyntaxKind.ConstructorType */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 176 /* SyntaxKind.IndexSignature */:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNodes(cbNode, cbNodes, node.typeParameters) ||
visitNodes(cbNode, cbNodes, node.parameters) ||
visitNode(cbNode, node.type);
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 170 /* Constructor */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 212 /* FunctionExpression */:
- case 255 /* FunctionDeclaration */:
- case 213 /* ArrowFunction */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 214 /* SyntaxKind.ArrowFunction */:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, node.asteriskToken) ||
@@ -30171,341 +30816,345 @@ var ts;
visitNode(cbNode, node.type) ||
visitNode(cbNode, node.equalsGreaterThanToken) ||
visitNode(cbNode, node.body);
- case 169 /* ClassStaticBlockDeclaration */:
+ case 170 /* SyntaxKind.ClassStaticBlockDeclaration */:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, node.body);
- case 177 /* TypeReference */:
+ case 178 /* SyntaxKind.TypeReference */:
return visitNode(cbNode, node.typeName) ||
visitNodes(cbNode, cbNodes, node.typeArguments);
- case 176 /* TypePredicate */:
+ case 177 /* SyntaxKind.TypePredicate */:
return visitNode(cbNode, node.assertsModifier) ||
visitNode(cbNode, node.parameterName) ||
visitNode(cbNode, node.type);
- case 180 /* TypeQuery */:
- return visitNode(cbNode, node.exprName);
- case 181 /* TypeLiteral */:
+ case 181 /* SyntaxKind.TypeQuery */:
+ return visitNode(cbNode, node.exprName) ||
+ visitNodes(cbNode, cbNodes, node.typeArguments);
+ case 182 /* SyntaxKind.TypeLiteral */:
return visitNodes(cbNode, cbNodes, node.members);
- case 182 /* ArrayType */:
+ case 183 /* SyntaxKind.ArrayType */:
return visitNode(cbNode, node.elementType);
- case 183 /* TupleType */:
+ case 184 /* SyntaxKind.TupleType */:
return visitNodes(cbNode, cbNodes, node.elements);
- case 186 /* UnionType */:
- case 187 /* IntersectionType */:
+ case 187 /* SyntaxKind.UnionType */:
+ case 188 /* SyntaxKind.IntersectionType */:
return visitNodes(cbNode, cbNodes, node.types);
- case 188 /* ConditionalType */:
+ case 189 /* SyntaxKind.ConditionalType */:
return visitNode(cbNode, node.checkType) ||
visitNode(cbNode, node.extendsType) ||
visitNode(cbNode, node.trueType) ||
visitNode(cbNode, node.falseType);
- case 189 /* InferType */:
+ case 190 /* SyntaxKind.InferType */:
return visitNode(cbNode, node.typeParameter);
- case 199 /* ImportType */:
+ case 200 /* SyntaxKind.ImportType */:
return visitNode(cbNode, node.argument) ||
+ visitNode(cbNode, node.assertions) ||
visitNode(cbNode, node.qualifier) ||
visitNodes(cbNode, cbNodes, node.typeArguments);
- case 190 /* ParenthesizedType */:
- case 192 /* TypeOperator */:
+ case 295 /* SyntaxKind.ImportTypeAssertionContainer */:
+ return visitNode(cbNode, node.assertClause);
+ case 191 /* SyntaxKind.ParenthesizedType */:
+ case 193 /* SyntaxKind.TypeOperator */:
return visitNode(cbNode, node.type);
- case 193 /* IndexedAccessType */:
+ case 194 /* SyntaxKind.IndexedAccessType */:
return visitNode(cbNode, node.objectType) ||
visitNode(cbNode, node.indexType);
- case 194 /* MappedType */:
+ case 195 /* SyntaxKind.MappedType */:
return visitNode(cbNode, node.readonlyToken) ||
visitNode(cbNode, node.typeParameter) ||
visitNode(cbNode, node.nameType) ||
visitNode(cbNode, node.questionToken) ||
visitNode(cbNode, node.type) ||
visitNodes(cbNode, cbNodes, node.members);
- case 195 /* LiteralType */:
+ case 196 /* SyntaxKind.LiteralType */:
return visitNode(cbNode, node.literal);
- case 196 /* NamedTupleMember */:
+ case 197 /* SyntaxKind.NamedTupleMember */:
return visitNode(cbNode, node.dotDotDotToken) ||
visitNode(cbNode, node.name) ||
visitNode(cbNode, node.questionToken) ||
visitNode(cbNode, node.type);
- case 200 /* ObjectBindingPattern */:
- case 201 /* ArrayBindingPattern */:
+ case 201 /* SyntaxKind.ObjectBindingPattern */:
+ case 202 /* SyntaxKind.ArrayBindingPattern */:
return visitNodes(cbNode, cbNodes, node.elements);
- case 203 /* ArrayLiteralExpression */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
return visitNodes(cbNode, cbNodes, node.elements);
- case 204 /* ObjectLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
return visitNodes(cbNode, cbNodes, node.properties);
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
return visitNode(cbNode, node.expression) ||
visitNode(cbNode, node.questionDotToken) ||
visitNode(cbNode, node.name);
- case 206 /* ElementAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
return visitNode(cbNode, node.expression) ||
visitNode(cbNode, node.questionDotToken) ||
visitNode(cbNode, node.argumentExpression);
- case 207 /* CallExpression */:
- case 208 /* NewExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
return visitNode(cbNode, node.expression) ||
visitNode(cbNode, node.questionDotToken) ||
visitNodes(cbNode, cbNodes, node.typeArguments) ||
visitNodes(cbNode, cbNodes, node.arguments);
- case 209 /* TaggedTemplateExpression */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
return visitNode(cbNode, node.tag) ||
visitNode(cbNode, node.questionDotToken) ||
visitNodes(cbNode, cbNodes, node.typeArguments) ||
visitNode(cbNode, node.template);
- case 210 /* TypeAssertionExpression */:
+ case 211 /* SyntaxKind.TypeAssertionExpression */:
return visitNode(cbNode, node.type) ||
visitNode(cbNode, node.expression);
- case 211 /* ParenthesizedExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
return visitNode(cbNode, node.expression);
- case 214 /* DeleteExpression */:
+ case 215 /* SyntaxKind.DeleteExpression */:
return visitNode(cbNode, node.expression);
- case 215 /* TypeOfExpression */:
+ case 216 /* SyntaxKind.TypeOfExpression */:
return visitNode(cbNode, node.expression);
- case 216 /* VoidExpression */:
+ case 217 /* SyntaxKind.VoidExpression */:
return visitNode(cbNode, node.expression);
- case 218 /* PrefixUnaryExpression */:
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
return visitNode(cbNode, node.operand);
- case 223 /* YieldExpression */:
+ case 224 /* SyntaxKind.YieldExpression */:
return visitNode(cbNode, node.asteriskToken) ||
visitNode(cbNode, node.expression);
- case 217 /* AwaitExpression */:
+ case 218 /* SyntaxKind.AwaitExpression */:
return visitNode(cbNode, node.expression);
- case 219 /* PostfixUnaryExpression */:
+ case 220 /* SyntaxKind.PostfixUnaryExpression */:
return visitNode(cbNode, node.operand);
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return visitNode(cbNode, node.left) ||
visitNode(cbNode, node.operatorToken) ||
visitNode(cbNode, node.right);
- case 228 /* AsExpression */:
+ case 229 /* SyntaxKind.AsExpression */:
return visitNode(cbNode, node.expression) ||
visitNode(cbNode, node.type);
- case 229 /* NonNullExpression */:
+ case 230 /* SyntaxKind.NonNullExpression */:
return visitNode(cbNode, node.expression);
- case 230 /* MetaProperty */:
+ case 231 /* SyntaxKind.MetaProperty */:
return visitNode(cbNode, node.name);
- case 221 /* ConditionalExpression */:
+ case 222 /* SyntaxKind.ConditionalExpression */:
return visitNode(cbNode, node.condition) ||
visitNode(cbNode, node.questionToken) ||
visitNode(cbNode, node.whenTrue) ||
visitNode(cbNode, node.colonToken) ||
visitNode(cbNode, node.whenFalse);
- case 224 /* SpreadElement */:
+ case 225 /* SyntaxKind.SpreadElement */:
return visitNode(cbNode, node.expression);
- case 234 /* Block */:
- case 261 /* ModuleBlock */:
+ case 235 /* SyntaxKind.Block */:
+ case 262 /* SyntaxKind.ModuleBlock */:
return visitNodes(cbNode, cbNodes, node.statements);
- case 303 /* SourceFile */:
+ case 305 /* SyntaxKind.SourceFile */:
return visitNodes(cbNode, cbNodes, node.statements) ||
visitNode(cbNode, node.endOfFileToken);
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, node.declarationList);
- case 254 /* VariableDeclarationList */:
+ case 255 /* SyntaxKind.VariableDeclarationList */:
return visitNodes(cbNode, cbNodes, node.declarations);
- case 237 /* ExpressionStatement */:
+ case 238 /* SyntaxKind.ExpressionStatement */:
return visitNode(cbNode, node.expression);
- case 238 /* IfStatement */:
+ case 239 /* SyntaxKind.IfStatement */:
return visitNode(cbNode, node.expression) ||
visitNode(cbNode, node.thenStatement) ||
visitNode(cbNode, node.elseStatement);
- case 239 /* DoStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
return visitNode(cbNode, node.statement) ||
visitNode(cbNode, node.expression);
- case 240 /* WhileStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
return visitNode(cbNode, node.expression) ||
visitNode(cbNode, node.statement);
- case 241 /* ForStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
return visitNode(cbNode, node.initializer) ||
visitNode(cbNode, node.condition) ||
visitNode(cbNode, node.incrementor) ||
visitNode(cbNode, node.statement);
- case 242 /* ForInStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
return visitNode(cbNode, node.initializer) ||
visitNode(cbNode, node.expression) ||
visitNode(cbNode, node.statement);
- case 243 /* ForOfStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
return visitNode(cbNode, node.awaitModifier) ||
visitNode(cbNode, node.initializer) ||
visitNode(cbNode, node.expression) ||
visitNode(cbNode, node.statement);
- case 244 /* ContinueStatement */:
- case 245 /* BreakStatement */:
+ case 245 /* SyntaxKind.ContinueStatement */:
+ case 246 /* SyntaxKind.BreakStatement */:
return visitNode(cbNode, node.label);
- case 246 /* ReturnStatement */:
+ case 247 /* SyntaxKind.ReturnStatement */:
return visitNode(cbNode, node.expression);
- case 247 /* WithStatement */:
+ case 248 /* SyntaxKind.WithStatement */:
return visitNode(cbNode, node.expression) ||
visitNode(cbNode, node.statement);
- case 248 /* SwitchStatement */:
+ case 249 /* SyntaxKind.SwitchStatement */:
return visitNode(cbNode, node.expression) ||
visitNode(cbNode, node.caseBlock);
- case 262 /* CaseBlock */:
+ case 263 /* SyntaxKind.CaseBlock */:
return visitNodes(cbNode, cbNodes, node.clauses);
- case 288 /* CaseClause */:
+ case 289 /* SyntaxKind.CaseClause */:
return visitNode(cbNode, node.expression) ||
visitNodes(cbNode, cbNodes, node.statements);
- case 289 /* DefaultClause */:
+ case 290 /* SyntaxKind.DefaultClause */:
return visitNodes(cbNode, cbNodes, node.statements);
- case 249 /* LabeledStatement */:
+ case 250 /* SyntaxKind.LabeledStatement */:
return visitNode(cbNode, node.label) ||
visitNode(cbNode, node.statement);
- case 250 /* ThrowStatement */:
+ case 251 /* SyntaxKind.ThrowStatement */:
return visitNode(cbNode, node.expression);
- case 251 /* TryStatement */:
+ case 252 /* SyntaxKind.TryStatement */:
return visitNode(cbNode, node.tryBlock) ||
visitNode(cbNode, node.catchClause) ||
visitNode(cbNode, node.finallyBlock);
- case 291 /* CatchClause */:
+ case 292 /* SyntaxKind.CatchClause */:
return visitNode(cbNode, node.variableDeclaration) ||
visitNode(cbNode, node.block);
- case 164 /* Decorator */:
+ case 165 /* SyntaxKind.Decorator */:
return visitNode(cbNode, node.expression);
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
return visitNodes(cbNode, cbNodes, node.decorators) ||
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 257 /* InterfaceDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
return visitNodes(cbNode, cbNodes, node.decorators) ||
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 /* TypeAliasDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, node.name) ||
visitNodes(cbNode, cbNodes, node.typeParameters) ||
visitNode(cbNode, node.type);
- case 259 /* EnumDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, node.name) ||
visitNodes(cbNode, cbNodes, node.members);
- case 297 /* EnumMember */:
+ case 299 /* SyntaxKind.EnumMember */:
return visitNode(cbNode, node.name) ||
visitNode(cbNode, node.initializer);
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, node.name) ||
visitNode(cbNode, node.body);
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, node.name) ||
visitNode(cbNode, node.moduleReference);
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, node.importClause) ||
visitNode(cbNode, node.moduleSpecifier) ||
visitNode(cbNode, node.assertClause);
- case 266 /* ImportClause */:
+ case 267 /* SyntaxKind.ImportClause */:
return visitNode(cbNode, node.name) ||
visitNode(cbNode, node.namedBindings);
- case 292 /* AssertClause */:
+ case 293 /* SyntaxKind.AssertClause */:
return visitNodes(cbNode, cbNodes, node.elements);
- case 293 /* AssertEntry */:
+ case 294 /* SyntaxKind.AssertEntry */:
return visitNode(cbNode, node.name) ||
visitNode(cbNode, node.value);
- case 263 /* NamespaceExportDeclaration */:
+ case 264 /* SyntaxKind.NamespaceExportDeclaration */:
return visitNode(cbNode, node.name);
- case 267 /* NamespaceImport */:
+ case 268 /* SyntaxKind.NamespaceImport */:
return visitNode(cbNode, node.name);
- case 273 /* NamespaceExport */:
+ case 274 /* SyntaxKind.NamespaceExport */:
return visitNode(cbNode, node.name);
- case 268 /* NamedImports */:
- case 272 /* NamedExports */:
+ case 269 /* SyntaxKind.NamedImports */:
+ case 273 /* SyntaxKind.NamedExports */:
return visitNodes(cbNode, cbNodes, node.elements);
- case 271 /* ExportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, node.exportClause) ||
visitNode(cbNode, node.moduleSpecifier) ||
visitNode(cbNode, node.assertClause);
- case 269 /* ImportSpecifier */:
- case 274 /* ExportSpecifier */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
+ case 275 /* SyntaxKind.ExportSpecifier */:
return visitNode(cbNode, node.propertyName) ||
visitNode(cbNode, node.name);
- case 270 /* ExportAssignment */:
+ case 271 /* SyntaxKind.ExportAssignment */:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, node.expression);
- case 222 /* TemplateExpression */:
+ case 223 /* SyntaxKind.TemplateExpression */:
return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans);
- case 232 /* TemplateSpan */:
+ case 233 /* SyntaxKind.TemplateSpan */:
return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal);
- case 197 /* TemplateLiteralType */:
+ case 198 /* SyntaxKind.TemplateLiteralType */:
return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans);
- case 198 /* TemplateLiteralTypeSpan */:
+ case 199 /* SyntaxKind.TemplateLiteralTypeSpan */:
return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal);
- case 161 /* ComputedPropertyName */:
+ case 162 /* SyntaxKind.ComputedPropertyName */:
return visitNode(cbNode, node.expression);
- case 290 /* HeritageClause */:
+ case 291 /* SyntaxKind.HeritageClause */:
return visitNodes(cbNode, cbNodes, node.types);
- case 227 /* ExpressionWithTypeArguments */:
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
return visitNode(cbNode, node.expression) ||
visitNodes(cbNode, cbNodes, node.typeArguments);
- case 276 /* ExternalModuleReference */:
+ case 277 /* SyntaxKind.ExternalModuleReference */:
return visitNode(cbNode, node.expression);
- case 275 /* MissingDeclaration */:
+ case 276 /* SyntaxKind.MissingDeclaration */:
return visitNodes(cbNode, cbNodes, node.decorators);
- case 349 /* CommaListExpression */:
+ case 351 /* SyntaxKind.CommaListExpression */:
return visitNodes(cbNode, cbNodes, node.elements);
- case 277 /* JsxElement */:
+ case 278 /* SyntaxKind.JsxElement */:
return visitNode(cbNode, node.openingElement) ||
visitNodes(cbNode, cbNodes, node.children) ||
visitNode(cbNode, node.closingElement);
- case 281 /* JsxFragment */:
+ case 282 /* SyntaxKind.JsxFragment */:
return visitNode(cbNode, node.openingFragment) ||
visitNodes(cbNode, cbNodes, node.children) ||
visitNode(cbNode, node.closingFragment);
- case 278 /* JsxSelfClosingElement */:
- case 279 /* JsxOpeningElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
return visitNode(cbNode, node.tagName) ||
visitNodes(cbNode, cbNodes, node.typeArguments) ||
visitNode(cbNode, node.attributes);
- case 285 /* JsxAttributes */:
+ case 286 /* SyntaxKind.JsxAttributes */:
return visitNodes(cbNode, cbNodes, node.properties);
- case 284 /* JsxAttribute */:
+ case 285 /* SyntaxKind.JsxAttribute */:
return visitNode(cbNode, node.name) ||
visitNode(cbNode, node.initializer);
- case 286 /* JsxSpreadAttribute */:
+ case 287 /* SyntaxKind.JsxSpreadAttribute */:
return visitNode(cbNode, node.expression);
- case 287 /* JsxExpression */:
+ case 288 /* SyntaxKind.JsxExpression */:
return visitNode(cbNode, node.dotDotDotToken) ||
visitNode(cbNode, node.expression);
- case 280 /* JsxClosingElement */:
+ case 281 /* SyntaxKind.JsxClosingElement */:
return visitNode(cbNode, node.tagName);
- case 184 /* OptionalType */:
- case 185 /* RestType */:
- case 307 /* JSDocTypeExpression */:
- case 313 /* JSDocNonNullableType */:
- case 312 /* JSDocNullableType */:
- case 314 /* JSDocOptionalType */:
- case 316 /* JSDocVariadicType */:
+ case 185 /* SyntaxKind.OptionalType */:
+ case 186 /* SyntaxKind.RestType */:
+ case 309 /* SyntaxKind.JSDocTypeExpression */:
+ case 315 /* SyntaxKind.JSDocNonNullableType */:
+ case 314 /* SyntaxKind.JSDocNullableType */:
+ case 316 /* SyntaxKind.JSDocOptionalType */:
+ case 318 /* SyntaxKind.JSDocVariadicType */:
return visitNode(cbNode, node.type);
- case 315 /* JSDocFunctionType */:
+ case 317 /* SyntaxKind.JSDocFunctionType */:
return visitNodes(cbNode, cbNodes, node.parameters) ||
visitNode(cbNode, node.type);
- case 318 /* JSDocComment */:
+ case 320 /* SyntaxKind.JSDoc */:
return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))
|| visitNodes(cbNode, cbNodes, node.tags);
- case 344 /* JSDocSeeTag */:
+ case 346 /* SyntaxKind.JSDocSeeTag */:
return visitNode(cbNode, node.tagName) ||
visitNode(cbNode, node.name) ||
(typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment));
- case 308 /* JSDocNameReference */:
+ case 310 /* SyntaxKind.JSDocNameReference */:
return visitNode(cbNode, node.name);
- case 309 /* JSDocMemberName */:
+ case 311 /* SyntaxKind.JSDocMemberName */:
return visitNode(cbNode, node.left) ||
visitNode(cbNode, node.right);
- case 338 /* JSDocParameterTag */:
- case 345 /* JSDocPropertyTag */:
+ case 340 /* SyntaxKind.JSDocParameterTag */:
+ case 347 /* SyntaxKind.JSDocPropertyTag */:
return visitNode(cbNode, node.tagName) ||
(node.isNameFirst
? visitNode(cbNode, node.name) ||
@@ -30514,64 +31163,64 @@ var ts;
: visitNode(cbNode, node.typeExpression) ||
visitNode(cbNode, node.name) ||
(typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)));
- case 328 /* JSDocAuthorTag */:
+ case 330 /* SyntaxKind.JSDocAuthorTag */:
return visitNode(cbNode, node.tagName) ||
(typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment));
- case 327 /* JSDocImplementsTag */:
+ case 329 /* SyntaxKind.JSDocImplementsTag */:
return visitNode(cbNode, node.tagName) ||
visitNode(cbNode, node.class) ||
(typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment));
- case 326 /* JSDocAugmentsTag */:
+ case 328 /* SyntaxKind.JSDocAugmentsTag */:
return visitNode(cbNode, node.tagName) ||
visitNode(cbNode, node.class) ||
(typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment));
- case 342 /* JSDocTemplateTag */:
+ case 344 /* SyntaxKind.JSDocTemplateTag */:
return visitNode(cbNode, node.tagName) ||
visitNode(cbNode, node.constraint) ||
visitNodes(cbNode, cbNodes, node.typeParameters) ||
(typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment));
- case 343 /* JSDocTypedefTag */:
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
return visitNode(cbNode, node.tagName) ||
(node.typeExpression &&
- node.typeExpression.kind === 307 /* JSDocTypeExpression */
+ node.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */
? visitNode(cbNode, node.typeExpression) ||
visitNode(cbNode, node.fullName) ||
(typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))
: visitNode(cbNode, node.fullName) ||
visitNode(cbNode, node.typeExpression) ||
(typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)));
- case 336 /* JSDocCallbackTag */:
+ case 338 /* SyntaxKind.JSDocCallbackTag */:
return visitNode(cbNode, node.tagName) ||
visitNode(cbNode, node.fullName) ||
visitNode(cbNode, node.typeExpression) ||
(typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment));
- case 339 /* JSDocReturnTag */:
- case 341 /* JSDocTypeTag */:
- case 340 /* JSDocThisTag */:
- case 337 /* JSDocEnumTag */:
+ case 341 /* SyntaxKind.JSDocReturnTag */:
+ case 343 /* SyntaxKind.JSDocTypeTag */:
+ case 342 /* SyntaxKind.JSDocThisTag */:
+ case 339 /* SyntaxKind.JSDocEnumTag */:
return visitNode(cbNode, node.tagName) ||
visitNode(cbNode, node.typeExpression) ||
(typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment));
- case 321 /* JSDocSignature */:
+ case 323 /* SyntaxKind.JSDocSignature */:
return ts.forEach(node.typeParameters, cbNode) ||
ts.forEach(node.parameters, cbNode) ||
visitNode(cbNode, node.type);
- case 322 /* JSDocLink */:
- case 323 /* JSDocLinkCode */:
- case 324 /* JSDocLinkPlain */:
+ case 324 /* SyntaxKind.JSDocLink */:
+ case 325 /* SyntaxKind.JSDocLinkCode */:
+ case 326 /* SyntaxKind.JSDocLinkPlain */:
return visitNode(cbNode, node.name);
- case 320 /* JSDocTypeLiteral */:
+ case 322 /* SyntaxKind.JSDocTypeLiteral */:
return ts.forEach(node.jsDocPropertyTags, cbNode);
- case 325 /* JSDocTag */:
- case 330 /* JSDocClassTag */:
- case 331 /* JSDocPublicTag */:
- case 332 /* JSDocPrivateTag */:
- case 333 /* JSDocProtectedTag */:
- case 334 /* JSDocReadonlyTag */:
- case 329 /* JSDocDeprecatedTag */:
+ case 327 /* SyntaxKind.JSDocTag */:
+ case 332 /* SyntaxKind.JSDocClassTag */:
+ case 333 /* SyntaxKind.JSDocPublicTag */:
+ case 334 /* SyntaxKind.JSDocPrivateTag */:
+ case 335 /* SyntaxKind.JSDocProtectedTag */:
+ case 336 /* SyntaxKind.JSDocReadonlyTag */:
+ case 331 /* SyntaxKind.JSDocDeprecatedTag */:
return visitNode(cbNode, node.tagName)
|| (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment));
- case 348 /* PartiallyEmittedExpression */:
+ case 350 /* SyntaxKind.PartiallyEmittedExpression */:
return visitNode(cbNode, node.expression);
}
}
@@ -30620,7 +31269,7 @@ var ts;
continue;
return res;
}
- if (current.kind >= 160 /* FirstNode */) {
+ if (current.kind >= 161 /* SyntaxKind.FirstNode */) {
// add children in reverse order to the queue, so popping gives the first child
for (var _i = 0, _a = gatherPossibleChildren(current); _i < _a.length; _i++) {
var child = _a[_i];
@@ -30640,17 +31289,25 @@ var ts;
children.unshift(n);
}
}
- function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) {
+ function setExternalModuleIndicator(sourceFile) {
+ sourceFile.externalModuleIndicator = isFileProbablyExternalModule(sourceFile);
+ }
+ function createSourceFile(fileName, sourceText, languageVersionOrOptions, setParentNodes, scriptKind) {
if (setParentNodes === void 0) { setParentNodes = false; }
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true);
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true);
ts.performance.mark("beforeParse");
var result;
ts.perfLogger.logStartParseSourceFile(fileName);
- if (languageVersion === 100 /* JSON */) {
- result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */);
+ var _a = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions : { languageVersion: languageVersionOrOptions }, languageVersion = _a.languageVersion, overrideSetExternalModuleIndicator = _a.setExternalModuleIndicator, format = _a.impliedNodeFormat;
+ if (languageVersion === 100 /* ScriptTarget.JSON */) {
+ result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* ScriptKind.JSON */, ts.noop);
}
else {
- result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind);
+ var setIndicator = format === undefined ? overrideSetExternalModuleIndicator : function (file) {
+ file.impliedNodeFormat = format;
+ return (overrideSetExternalModuleIndicator || setExternalModuleIndicator)(file);
+ };
+ result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind, setIndicator);
}
ts.perfLogger.logStopParseSourceFile();
ts.performance.mark("afterParse");
@@ -30691,7 +31348,7 @@ var ts;
var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
// Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import.
// We will manually port the flag to the new source file.
- newSourceFile.flags |= (sourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */);
+ newSourceFile.flags |= (sourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */);
return newSourceFile;
}
ts.updateSourceFile = updateSourceFile;
@@ -30719,8 +31376,8 @@ var ts;
(function (Parser) {
// Share a single scanner across all calls to parse a source file. This helps speed things
// up by avoiding the cost of creating/compiling scanners over and over again.
- var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true);
- var disallowInAndDecoratorContext = 4096 /* DisallowInContext */ | 16384 /* DecoratorContext */;
+ var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true);
+ var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */;
// capture constructors in 'initializeState' to avoid null checks
// tslint:disable variable-name
var NodeConstructor;
@@ -30742,7 +31399,7 @@ var ts;
createBaseTokenNode: function (kind) { return countNode(new TokenConstructor(kind, /*pos*/ 0, /*end*/ 0)); },
createBaseNode: function (kind) { return countNode(new NodeConstructor(kind, /*pos*/ 0, /*end*/ 0)); }
};
- var factory = ts.createNodeFactory(1 /* NoParenthesizerRules */ | 2 /* NoNodeConverters */ | 8 /* NoOriginalNode */, baseNodeFactory);
+ var factory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */ | 2 /* NodeFactoryFlags.NoNodeConverters */ | 8 /* NodeFactoryFlags.NoOriginalNode */, baseNodeFactory);
var fileName;
var sourceFlags;
var sourceText;
@@ -30836,11 +31493,11 @@ var ts;
// Note: any errors at the end of the file that do not precede a regular node, should get
// attached to the EOF token.
var parseErrorBeforeNextFinishedNode = false;
- function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) {
+ function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind, setExternalModuleIndicatorOverride) {
var _a;
if (setParentNodes === void 0) { setParentNodes = false; }
scriptKind = ts.ensureScriptKind(fileName, scriptKind);
- if (scriptKind === 6 /* JSON */) {
+ if (scriptKind === 6 /* ScriptKind.JSON */) {
var result_3 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes);
ts.convertToObjectWorker(result_3, (_a = result_3.statements[0]) === null || _a === void 0 ? void 0 : _a.expression, result_3.parseDiagnostics, /*returnValue*/ false, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined);
result_3.referencedFiles = ts.emptyArray;
@@ -30852,32 +31509,32 @@ var ts;
return result_3;
}
initializeState(fileName, sourceText, languageVersion, syntaxCursor, scriptKind);
- var result = parseSourceFileWorker(languageVersion, setParentNodes, scriptKind);
+ var result = parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicatorOverride || setExternalModuleIndicator);
clearState();
return result;
}
Parser.parseSourceFile = parseSourceFile;
function parseIsolatedEntityName(content, languageVersion) {
// Choice of `isDeclarationFile` should be arbitrary
- initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */);
+ initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* ScriptKind.JS */);
// Prime the scanner.
nextToken();
var entityName = parseEntityName(/*allowReservedWords*/ true);
- var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length;
+ var isInvalid = token() === 1 /* SyntaxKind.EndOfFileToken */ && !parseDiagnostics.length;
clearState();
return isInvalid ? entityName : undefined;
}
Parser.parseIsolatedEntityName = parseIsolatedEntityName;
function parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) {
- if (languageVersion === void 0) { languageVersion = 2 /* ES2015 */; }
+ if (languageVersion === void 0) { languageVersion = 2 /* ScriptTarget.ES2015 */; }
if (setParentNodes === void 0) { setParentNodes = false; }
- initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* JSON */);
+ initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* ScriptKind.JSON */);
sourceFlags = contextFlags;
// Prime the scanner.
nextToken();
var pos = getNodePos();
var statements, endOfFileToken;
- if (token() === 1 /* EndOfFileToken */) {
+ if (token() === 1 /* SyntaxKind.EndOfFileToken */) {
statements = createNodeArray([], pos, pos);
endOfFileToken = parseTokenNode();
}
@@ -30885,28 +31542,28 @@ var ts;
// Loop and synthesize an ArrayLiteralExpression if there are more than
// one top-level expressions to ensure all input text is consumed.
var expressions = void 0;
- while (token() !== 1 /* EndOfFileToken */) {
+ while (token() !== 1 /* SyntaxKind.EndOfFileToken */) {
var expression_1 = void 0;
switch (token()) {
- case 22 /* OpenBracketToken */:
+ case 22 /* SyntaxKind.OpenBracketToken */:
expression_1 = parseArrayLiteralExpression();
break;
- case 110 /* TrueKeyword */:
- case 95 /* FalseKeyword */:
- case 104 /* NullKeyword */:
+ case 110 /* SyntaxKind.TrueKeyword */:
+ case 95 /* SyntaxKind.FalseKeyword */:
+ case 104 /* SyntaxKind.NullKeyword */:
expression_1 = parseTokenNode();
break;
- case 40 /* MinusToken */:
- if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) {
+ case 40 /* SyntaxKind.MinusToken */:
+ if (lookAhead(function () { return nextToken() === 8 /* SyntaxKind.NumericLiteral */ && nextToken() !== 58 /* SyntaxKind.ColonToken */; })) {
expression_1 = parsePrefixUnaryExpression();
}
else {
expression_1 = parseObjectLiteralExpression();
}
break;
- case 8 /* NumericLiteral */:
- case 10 /* StringLiteral */:
- if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) {
+ case 8 /* SyntaxKind.NumericLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ if (lookAhead(function () { return nextToken() !== 58 /* SyntaxKind.ColonToken */; })) {
expression_1 = parseLiteralNode();
break;
}
@@ -30924,7 +31581,7 @@ var ts;
}
else {
expressions = expression_1;
- if (token() !== 1 /* EndOfFileToken */) {
+ if (token() !== 1 /* SyntaxKind.EndOfFileToken */) {
parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token);
}
}
@@ -30933,10 +31590,10 @@ var ts;
var statement = factory.createExpressionStatement(expression);
finishNode(statement, pos);
statements = createNodeArray([statement], pos);
- endOfFileToken = parseExpectedToken(1 /* EndOfFileToken */, ts.Diagnostics.Unexpected_token);
+ endOfFileToken = parseExpectedToken(1 /* SyntaxKind.EndOfFileToken */, ts.Diagnostics.Unexpected_token);
}
// Set source file so that errors will be reported with this file name
- var sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags);
+ var sourceFile = createSourceFile(fileName, 2 /* ScriptTarget.ES2015 */, 6 /* ScriptKind.JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop);
if (setParentNodes) {
fixupParentReferences(sourceFile);
}
@@ -30973,15 +31630,15 @@ var ts;
sourceFlags = 0;
topLevel = true;
switch (scriptKind) {
- case 1 /* JS */:
- case 2 /* JSX */:
- contextFlags = 131072 /* JavaScriptFile */;
+ case 1 /* ScriptKind.JS */:
+ case 2 /* ScriptKind.JSX */:
+ contextFlags = 262144 /* NodeFlags.JavaScriptFile */;
break;
- case 6 /* JSON */:
- contextFlags = 131072 /* JavaScriptFile */ | 33554432 /* JsonFile */;
+ case 6 /* ScriptKind.JSON */:
+ contextFlags = 262144 /* NodeFlags.JavaScriptFile */ | 67108864 /* NodeFlags.JsonFile */;
break;
default:
- contextFlags = 0 /* None */;
+ contextFlags = 0 /* NodeFlags.None */;
break;
}
parseErrorBeforeNextFinishedNode = false;
@@ -31010,18 +31667,18 @@ var ts;
notParenthesizedArrow = undefined;
topLevel = true;
}
- function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind) {
+ function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) {
var isDeclarationFile = isDeclarationFileName(fileName);
if (isDeclarationFile) {
- contextFlags |= 8388608 /* Ambient */;
+ contextFlags |= 16777216 /* NodeFlags.Ambient */;
}
sourceFlags = contextFlags;
// Prime the scanner.
nextToken();
- var statements = parseList(0 /* SourceElements */, parseStatement);
- ts.Debug.assert(token() === 1 /* EndOfFileToken */);
+ var statements = parseList(0 /* ParsingContext.SourceElements */, parseStatement);
+ ts.Debug.assert(token() === 1 /* SyntaxKind.EndOfFileToken */);
var endOfFileToken = addJSDocComment(parseTokenNode());
- var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags);
+ var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator);
// A member of ReadonlyArray<T> isn't assignable to a member of T[] (and prevents a direct cast) - but this is where we set up those members so they can be readonly in the future
processCommentPragmas(sourceFile, sourceText);
processPragmasIntoFields(sourceFile, reportPragmaDiagnostic);
@@ -31052,7 +31709,7 @@ var ts;
node.jsDoc = jsDoc;
if (hasDeprecatedTag) {
hasDeprecatedTag = false;
- node.flags |= 134217728 /* Deprecated */;
+ node.flags |= 268435456 /* NodeFlags.Deprecated */;
}
return node;
}
@@ -31080,12 +31737,12 @@ var ts;
// reparse all statements between start and pos. We skip existing diagnostics for the same range and allow the parser to generate new ones.
speculationHelper(function () {
var savedContextFlags = contextFlags;
- contextFlags |= 32768 /* AwaitContext */;
+ contextFlags |= 32768 /* NodeFlags.AwaitContext */;
scanner.setTextPos(nextStatement.pos);
nextToken();
- while (token() !== 1 /* EndOfFileToken */) {
+ while (token() !== 1 /* SyntaxKind.EndOfFileToken */) {
var startPos = scanner.getStartPos();
- var statement = parseListElement(0 /* SourceElements */, parseStatement);
+ var statement = parseListElement(0 /* ParsingContext.SourceElements */, parseStatement);
statements.push(statement);
if (startPos === scanner.getStartPos()) {
nextToken();
@@ -31103,7 +31760,7 @@ var ts;
}
}
contextFlags = savedContextFlags;
- }, 2 /* Reparse */);
+ }, 2 /* SpeculationKind.Reparse */);
// find the next statement containing an `await`
start = pos >= 0 ? findNextStatementWithAwait(sourceFile.statements, pos) : -1;
};
@@ -31123,8 +31780,8 @@ var ts;
syntaxCursor = savedSyntaxCursor;
return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements));
function containsPossibleTopLevelAwait(node) {
- return !(node.flags & 32768 /* AwaitContext */)
- && !!(node.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */);
+ return !(node.flags & 32768 /* NodeFlags.AwaitContext */)
+ && !!(node.transformFlags & 16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */);
}
function findNextStatementWithAwait(statements, start) {
for (var i = start; i < statements.length; i++) {
@@ -31158,25 +31815,30 @@ var ts;
ts.setParentRecursive(rootNode, /*incremental*/ true);
}
Parser.fixupParentReferences = fixupParentReferences;
- function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, flags) {
+ function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, flags, setExternalModuleIndicator) {
// code from createNode is inlined here so createNode won't have to deal with special case of creating source files
// this is quite rare comparing to other nodes and createNode should be as fast as possible
var sourceFile = factory.createSourceFile(statements, endOfFileToken, flags);
ts.setTextRangePosWidth(sourceFile, 0, sourceText.length);
- setExternalModuleIndicator(sourceFile);
+ setFields(sourceFile);
// If we parsed this as an external module, it may contain top-level await
- if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */) {
+ if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* TransformFlags.ContainsPossibleTopLevelAwait */) {
sourceFile = reparseTopLevelAwait(sourceFile);
+ setFields(sourceFile);
}
- sourceFile.text = sourceText;
- sourceFile.bindDiagnostics = [];
- sourceFile.bindSuggestionDiagnostics = undefined;
- sourceFile.languageVersion = languageVersion;
- sourceFile.fileName = fileName;
- sourceFile.languageVariant = ts.getLanguageVariant(scriptKind);
- sourceFile.isDeclarationFile = isDeclarationFile;
- sourceFile.scriptKind = scriptKind;
return sourceFile;
+ function setFields(sourceFile) {
+ sourceFile.text = sourceText;
+ sourceFile.bindDiagnostics = [];
+ sourceFile.bindSuggestionDiagnostics = undefined;
+ sourceFile.languageVersion = languageVersion;
+ sourceFile.fileName = fileName;
+ sourceFile.languageVariant = ts.getLanguageVariant(scriptKind);
+ sourceFile.isDeclarationFile = isDeclarationFile;
+ sourceFile.scriptKind = scriptKind;
+ setExternalModuleIndicator(sourceFile);
+ sourceFile.setExternalModuleIndicator = setExternalModuleIndicator;
+ }
}
function setContextFlag(val, flag) {
if (val) {
@@ -31187,16 +31849,16 @@ var ts;
}
}
function setDisallowInContext(val) {
- setContextFlag(val, 4096 /* DisallowInContext */);
+ setContextFlag(val, 4096 /* NodeFlags.DisallowInContext */);
}
function setYieldContext(val) {
- setContextFlag(val, 8192 /* YieldContext */);
+ setContextFlag(val, 8192 /* NodeFlags.YieldContext */);
}
function setDecoratorContext(val) {
- setContextFlag(val, 16384 /* DecoratorContext */);
+ setContextFlag(val, 16384 /* NodeFlags.DecoratorContext */);
}
function setAwaitContext(val) {
- setContextFlag(val, 32768 /* AwaitContext */);
+ setContextFlag(val, 32768 /* NodeFlags.AwaitContext */);
}
function doOutsideOfContext(context, func) {
// contextFlagsToClear will contain only the context flags that are
@@ -31237,59 +31899,71 @@ var ts;
return func();
}
function allowInAnd(func) {
- return doOutsideOfContext(4096 /* DisallowInContext */, func);
+ return doOutsideOfContext(4096 /* NodeFlags.DisallowInContext */, func);
}
function disallowInAnd(func) {
- return doInsideOfContext(4096 /* DisallowInContext */, func);
+ return doInsideOfContext(4096 /* NodeFlags.DisallowInContext */, func);
+ }
+ function allowConditionalTypesAnd(func) {
+ return doOutsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func);
+ }
+ function disallowConditionalTypesAnd(func) {
+ return doInsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func);
}
function doInYieldContext(func) {
- return doInsideOfContext(8192 /* YieldContext */, func);
+ return doInsideOfContext(8192 /* NodeFlags.YieldContext */, func);
}
function doInDecoratorContext(func) {
- return doInsideOfContext(16384 /* DecoratorContext */, func);
+ return doInsideOfContext(16384 /* NodeFlags.DecoratorContext */, func);
}
function doInAwaitContext(func) {
- return doInsideOfContext(32768 /* AwaitContext */, func);
+ return doInsideOfContext(32768 /* NodeFlags.AwaitContext */, func);
}
function doOutsideOfAwaitContext(func) {
- return doOutsideOfContext(32768 /* AwaitContext */, func);
+ return doOutsideOfContext(32768 /* NodeFlags.AwaitContext */, func);
}
function doInYieldAndAwaitContext(func) {
- return doInsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func);
+ return doInsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func);
}
function doOutsideOfYieldAndAwaitContext(func) {
- return doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func);
+ return doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func);
}
function inContext(flags) {
return (contextFlags & flags) !== 0;
}
function inYieldContext() {
- return inContext(8192 /* YieldContext */);
+ return inContext(8192 /* NodeFlags.YieldContext */);
}
function inDisallowInContext() {
- return inContext(4096 /* DisallowInContext */);
+ return inContext(4096 /* NodeFlags.DisallowInContext */);
+ }
+ function inDisallowConditionalTypesContext() {
+ return inContext(65536 /* NodeFlags.DisallowConditionalTypesContext */);
}
function inDecoratorContext() {
- return inContext(16384 /* DecoratorContext */);
+ return inContext(16384 /* NodeFlags.DecoratorContext */);
}
function inAwaitContext() {
- return inContext(32768 /* AwaitContext */);
+ return inContext(32768 /* NodeFlags.AwaitContext */);
}
function parseErrorAtCurrentToken(message, arg0) {
- parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
+ return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
}
function parseErrorAtPosition(start, length, message, arg0) {
// Don't report another error if it would just be at the same position as the last error.
var lastError = ts.lastOrUndefined(parseDiagnostics);
+ var result;
if (!lastError || start !== lastError.start) {
- parseDiagnostics.push(ts.createDetachedDiagnostic(fileName, start, length, message, arg0));
+ result = ts.createDetachedDiagnostic(fileName, start, length, message, arg0);
+ parseDiagnostics.push(result);
}
// Mark that we've encountered an error. We'll set an appropriate bit on the next
// node we finish so that it can't be reused incrementally.
parseErrorBeforeNextFinishedNode = true;
+ return result;
}
function parseErrorAt(start, end, message, arg0) {
- parseErrorAtPosition(start, end - start, message, arg0);
+ return parseErrorAtPosition(start, end - start, message, arg0);
}
function parseErrorAtRange(range, message, arg0) {
parseErrorAt(range.pos, range.end, message, arg0);
@@ -31371,15 +32045,15 @@ var ts;
// If we're only looking ahead, then tell the scanner to only lookahead as well.
// Otherwise, if we're actually speculatively parsing, then tell the scanner to do the
// same.
- var result = speculationKind !== 0 /* TryParse */
+ var result = speculationKind !== 0 /* SpeculationKind.TryParse */
? scanner.lookAhead(callback)
: scanner.tryScan(callback);
ts.Debug.assert(saveContextFlags === contextFlags);
// If our callback returned something 'falsy' or we're just looking ahead,
// then unconditionally restore us to where we were.
- if (!result || speculationKind !== 0 /* TryParse */) {
+ if (!result || speculationKind !== 0 /* SpeculationKind.TryParse */) {
currentToken = saveToken;
- if (speculationKind !== 2 /* Reparse */) {
+ if (speculationKind !== 2 /* SpeculationKind.Reparse */) {
parseDiagnostics.length = saveParseDiagnosticsLength;
}
parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;
@@ -31391,7 +32065,7 @@ var ts;
* is returned from this function.
*/
function lookAhead(callback) {
- return speculationHelper(callback, 1 /* Lookahead */);
+ return speculationHelper(callback, 1 /* SpeculationKind.Lookahead */);
}
/** Invokes the provided callback. If the callback returns something falsy, then it restores
* the parser to the state it was in immediately prior to invoking the callback. If the
@@ -31399,31 +32073,31 @@ var ts;
* of invoking the callback is returned from this function.
*/
function tryParse(callback) {
- return speculationHelper(callback, 0 /* TryParse */);
+ return speculationHelper(callback, 0 /* SpeculationKind.TryParse */);
}
function isBindingIdentifier() {
- if (token() === 79 /* Identifier */) {
+ if (token() === 79 /* SyntaxKind.Identifier */) {
return true;
}
// `let await`/`let yield` in [Yield] or [Await] are allowed here and disallowed in the binder.
- return token() > 116 /* LastReservedWord */;
+ return token() > 116 /* SyntaxKind.LastReservedWord */;
}
// Ignore strict mode flag because we will report an error in type checker instead.
function isIdentifier() {
- if (token() === 79 /* Identifier */) {
+ if (token() === 79 /* SyntaxKind.Identifier */) {
return true;
}
// If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is
// considered a keyword and is not an identifier.
- if (token() === 125 /* YieldKeyword */ && inYieldContext()) {
+ if (token() === 125 /* SyntaxKind.YieldKeyword */ && inYieldContext()) {
return false;
}
// If we have a 'await' keyword, and we're in the [Await] context, then 'await' is
// considered a keyword and is not an identifier.
- if (token() === 132 /* AwaitKeyword */ && inAwaitContext()) {
+ if (token() === 132 /* SyntaxKind.AwaitKeyword */ && inAwaitContext()) {
return false;
}
- return token() > 116 /* LastReservedWord */;
+ return token() > 116 /* SyntaxKind.LastReservedWord */;
}
function parseExpected(kind, diagnosticMessage, shouldAdvance) {
if (shouldAdvance === void 0) { shouldAdvance = true; }
@@ -31461,7 +32135,7 @@ var ts;
// Otherwise, if this isn't a well-known keyword-like identifier, give the generic fallback message.
var expressionText = ts.isIdentifier(node) ? ts.idText(node) : undefined;
if (!expressionText || !ts.isIdentifierText(expressionText, languageVersion)) {
- parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */));
+ parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */));
return;
}
var pos = ts.skipTrivia(sourceText, node.pos);
@@ -31476,17 +32150,17 @@ var ts;
// If a declared node failed to parse, it would have emitted a diagnostic already.
return;
case "interface":
- parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* OpenBraceToken */);
+ parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */);
return;
case "is":
parseErrorAt(pos, scanner.getTextPos(), ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods);
return;
case "module":
case "namespace":
- parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* OpenBraceToken */);
+ parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */);
return;
case "type":
- parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* EqualsToken */);
+ parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* SyntaxKind.EqualsToken */);
return;
}
// The user alternatively might have misspelled or forgotten to add a space after a common keyword.
@@ -31496,7 +32170,7 @@ var ts;
return;
}
// Unknown tokens are handled with their own errors in the scanner
- if (token() === 0 /* Unknown */) {
+ if (token() === 0 /* SyntaxKind.Unknown */) {
return;
}
// Otherwise, we know this some kind of unknown word, not just a missing expected semicolon.
@@ -31527,18 +32201,18 @@ var ts;
return undefined;
}
function parseSemicolonAfterPropertyName(name, type, initializer) {
- if (token() === 59 /* AtToken */ && !scanner.hasPrecedingLineBreak()) {
+ if (token() === 59 /* SyntaxKind.AtToken */ && !scanner.hasPrecedingLineBreak()) {
parseErrorAtCurrentToken(ts.Diagnostics.Decorators_must_precede_the_name_and_all_keywords_of_property_declarations);
return;
}
- if (token() === 20 /* OpenParenToken */) {
+ if (token() === 20 /* SyntaxKind.OpenParenToken */) {
parseErrorAtCurrentToken(ts.Diagnostics.Cannot_start_a_function_call_in_a_type_annotation);
nextToken();
return;
}
if (type && !canParseSemicolon()) {
if (initializer) {
- parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */));
+ parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */));
}
else {
parseErrorAtCurrentToken(ts.Diagnostics.Expected_for_property_initializer);
@@ -31548,18 +32222,8 @@ var ts;
if (tryParseSemicolon()) {
return;
}
- // If an initializer was parsed but there is still an error in finding the next semicolon,
- // we generally know there was an error already reported in the initializer...
- // class Example { a = new Map([), ) }
- // ~
if (initializer) {
- // ...unless we've found the start of a block after a property declaration, in which
- // case we can know that regardless of the initializer we should complain on the block.
- // class Example { a = 0 {} }
- // ~
- if (token() === 18 /* OpenBraceToken */) {
- parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */));
- }
+ parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */));
return;
}
parseErrorForMissingSemicolonAfter(name);
@@ -31572,6 +32236,19 @@ var ts;
parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind));
return false;
}
+ function parseExpectedMatchingBrackets(openKind, closeKind, openParsed, openPosition) {
+ if (token() === closeKind) {
+ nextToken();
+ return;
+ }
+ var lastError = parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(closeKind));
+ if (!openParsed) {
+ return;
+ }
+ if (lastError) {
+ ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openPosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, ts.tokenToString(openKind), ts.tokenToString(closeKind)));
+ }
+ }
function parseOptional(t) {
if (token() === t) {
nextToken();
@@ -31613,24 +32290,24 @@ var ts;
}
function canParseSemicolon() {
// If there's a real semicolon, then we can always parse it out.
- if (token() === 26 /* SemicolonToken */) {
+ if (token() === 26 /* SyntaxKind.SemicolonToken */) {
return true;
}
// We can parse out an optional semicolon in ASI cases in the following cases.
- return token() === 19 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak();
+ return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 1 /* SyntaxKind.EndOfFileToken */ || scanner.hasPrecedingLineBreak();
}
function tryParseSemicolon() {
if (!canParseSemicolon()) {
return false;
}
- if (token() === 26 /* SemicolonToken */) {
+ if (token() === 26 /* SyntaxKind.SemicolonToken */) {
// consume the semicolon if it was explicitly provided.
nextToken();
}
return true;
}
function parseSemicolon() {
- return tryParseSemicolon() || parseExpected(26 /* SemicolonToken */);
+ return tryParseSemicolon() || parseExpected(26 /* SyntaxKind.SemicolonToken */);
}
function createNodeArray(elements, pos, end, hasTrailingComma) {
var array = factory.createNodeArray(elements, hasTrailingComma);
@@ -31647,7 +32324,7 @@ var ts;
// flag so that we don't mark any subsequent nodes.
if (parseErrorBeforeNextFinishedNode) {
parseErrorBeforeNextFinishedNode = false;
- node.flags |= 65536 /* ThisNodeHasError */;
+ node.flags |= 131072 /* NodeFlags.ThisNodeHasError */;
}
return node;
}
@@ -31659,11 +32336,11 @@ var ts;
parseErrorAtCurrentToken(diagnosticMessage, arg0);
}
var pos = getNodePos();
- var result = kind === 79 /* Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) :
+ var result = kind === 79 /* SyntaxKind.Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) :
ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, "", "", /*templateFlags*/ undefined) :
- kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) :
- kind === 10 /* StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) :
- kind === 275 /* MissingDeclaration */ ? factory.createMissingDeclaration() :
+ kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) :
+ kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) :
+ kind === 276 /* SyntaxKind.MissingDeclaration */ ? factory.createMissingDeclaration() :
factory.createToken(kind);
return finishNode(result, pos);
}
@@ -31687,23 +32364,23 @@ var ts;
nextTokenWithoutCheck();
return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos);
}
- if (token() === 80 /* PrivateIdentifier */) {
+ if (token() === 80 /* SyntaxKind.PrivateIdentifier */) {
parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
return createIdentifier(/*isIdentifier*/ true);
}
- if (token() === 0 /* Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* Identifier */; })) {
+ if (token() === 0 /* SyntaxKind.Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* SyntaxKind.Identifier */; })) {
// Scanner has already recorded an 'Invalid character' error, so no need to add another from the parser.
return createIdentifier(/*isIdentifier*/ true);
}
identifierCount++;
// Only for end of file because the error gets reported incorrectly on embedded script tags.
- var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */;
+ var reportAtCurrentPosition = token() === 1 /* SyntaxKind.EndOfFileToken */;
var isReservedWord = scanner.isReservedWord();
var msgArg = scanner.getTokenText();
var defaultMessage = isReservedWord ?
ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here :
ts.Diagnostics.Identifier_expected;
- return createMissingNode(79 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg);
+ return createMissingNode(79 /* SyntaxKind.Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg);
}
function parseBindingIdentifier(privateIdentifierDiagnosticMessage) {
return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage);
@@ -31716,23 +32393,23 @@ var ts;
}
function isLiteralPropertyName() {
return ts.tokenIsIdentifierOrKeyword(token()) ||
- token() === 10 /* StringLiteral */ ||
- token() === 8 /* NumericLiteral */;
+ token() === 10 /* SyntaxKind.StringLiteral */ ||
+ token() === 8 /* SyntaxKind.NumericLiteral */;
}
function isAssertionKey() {
return ts.tokenIsIdentifierOrKeyword(token()) ||
- token() === 10 /* StringLiteral */;
+ token() === 10 /* SyntaxKind.StringLiteral */;
}
function parsePropertyNameWorker(allowComputedPropertyNames) {
- if (token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */) {
+ if (token() === 10 /* SyntaxKind.StringLiteral */ || token() === 8 /* SyntaxKind.NumericLiteral */) {
var node = parseLiteralNode();
node.text = internIdentifier(node.text);
return node;
}
- if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) {
+ if (allowComputedPropertyNames && token() === 22 /* SyntaxKind.OpenBracketToken */) {
return parseComputedPropertyName();
}
- if (token() === 80 /* PrivateIdentifier */) {
+ if (token() === 80 /* SyntaxKind.PrivateIdentifier */) {
return parsePrivateIdentifier();
}
return parseIdentifierName();
@@ -31745,12 +32422,12 @@ var ts;
// LiteralPropertyName
// ComputedPropertyName[?Yield]
var pos = getNodePos();
- parseExpected(22 /* OpenBracketToken */);
+ parseExpected(22 /* SyntaxKind.OpenBracketToken */);
// We parse any expression (including a comma expression). But the grammar
// says that only an assignment expression is allowed, so the grammar checker
// will error if it sees a comma expression.
var expression = allowInAnd(parseExpression);
- parseExpected(23 /* CloseBracketToken */);
+ parseExpected(23 /* SyntaxKind.CloseBracketToken */);
return finishNode(factory.createComputedPropertyName(expression), pos);
}
function internPrivateIdentifier(text) {
@@ -31778,23 +32455,23 @@ var ts;
}
function nextTokenCanFollowModifier() {
switch (token()) {
- case 85 /* ConstKeyword */:
+ case 85 /* SyntaxKind.ConstKeyword */:
// 'const' is only a modifier if followed by 'enum'.
- return nextToken() === 92 /* EnumKeyword */;
- case 93 /* ExportKeyword */:
+ return nextToken() === 92 /* SyntaxKind.EnumKeyword */;
+ case 93 /* SyntaxKind.ExportKeyword */:
nextToken();
- if (token() === 88 /* DefaultKeyword */) {
+ if (token() === 88 /* SyntaxKind.DefaultKeyword */) {
return lookAhead(nextTokenCanFollowDefaultKeyword);
}
- if (token() === 151 /* TypeKeyword */) {
+ if (token() === 152 /* SyntaxKind.TypeKeyword */) {
return lookAhead(nextTokenCanFollowExportModifier);
}
return canFollowExportModifier();
- case 88 /* DefaultKeyword */:
+ case 88 /* SyntaxKind.DefaultKeyword */:
return nextTokenCanFollowDefaultKeyword();
- case 124 /* StaticKeyword */:
- case 136 /* GetKeyword */:
- case 148 /* SetKeyword */:
+ case 124 /* SyntaxKind.StaticKeyword */:
+ case 136 /* SyntaxKind.GetKeyword */:
+ case 149 /* SyntaxKind.SetKeyword */:
nextToken();
return canFollowModifier();
default:
@@ -31802,9 +32479,9 @@ var ts;
}
}
function canFollowExportModifier() {
- return token() !== 41 /* AsteriskToken */
- && token() !== 127 /* AsKeyword */
- && token() !== 18 /* OpenBraceToken */
+ return token() !== 41 /* SyntaxKind.AsteriskToken */
+ && token() !== 127 /* SyntaxKind.AsKeyword */
+ && token() !== 18 /* SyntaxKind.OpenBraceToken */
&& canFollowModifier();
}
function nextTokenCanFollowExportModifier() {
@@ -31815,18 +32492,18 @@ var ts;
return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier);
}
function canFollowModifier() {
- return token() === 22 /* OpenBracketToken */
- || token() === 18 /* OpenBraceToken */
- || token() === 41 /* AsteriskToken */
- || token() === 25 /* DotDotDotToken */
+ return token() === 22 /* SyntaxKind.OpenBracketToken */
+ || token() === 18 /* SyntaxKind.OpenBraceToken */
+ || token() === 41 /* SyntaxKind.AsteriskToken */
+ || token() === 25 /* SyntaxKind.DotDotDotToken */
|| isLiteralPropertyName();
}
function nextTokenCanFollowDefaultKeyword() {
nextToken();
- return token() === 84 /* ClassKeyword */ || token() === 98 /* FunctionKeyword */ ||
- token() === 118 /* InterfaceKeyword */ ||
- (token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) ||
- (token() === 131 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine));
+ return token() === 84 /* SyntaxKind.ClassKeyword */ || token() === 98 /* SyntaxKind.FunctionKeyword */ ||
+ token() === 118 /* SyntaxKind.InterfaceKeyword */ ||
+ (token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) ||
+ (token() === 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine));
}
// True if positioned at the start of a list element
function isListElement(parsingContext, inErrorRecovery) {
@@ -31835,50 +32512,50 @@ var ts;
return true;
}
switch (parsingContext) {
- case 0 /* SourceElements */:
- case 1 /* BlockStatements */:
- case 3 /* SwitchClauseStatements */:
+ case 0 /* ParsingContext.SourceElements */:
+ case 1 /* ParsingContext.BlockStatements */:
+ case 3 /* ParsingContext.SwitchClauseStatements */:
// If we're in error recovery, then we don't want to treat ';' as an empty statement.
// The problem is that ';' can show up in far too many contexts, and if we see one
// and assume it's a statement, then we may bail out inappropriately from whatever
// we're parsing. For example, if we have a semicolon in the middle of a class, then
// we really don't want to assume the class is over and we're on a statement in the
// outer module. We just want to consume and move on.
- return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement();
- case 2 /* SwitchClauses */:
- return token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */;
- case 4 /* TypeMembers */:
+ return !(token() === 26 /* SyntaxKind.SemicolonToken */ && inErrorRecovery) && isStartOfStatement();
+ case 2 /* ParsingContext.SwitchClauses */:
+ return token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */;
+ case 4 /* ParsingContext.TypeMembers */:
return lookAhead(isTypeMemberStart);
- case 5 /* ClassMembers */:
+ case 5 /* ParsingContext.ClassMembers */:
// We allow semicolons as class elements (as specified by ES6) as long as we're
// not in error recovery. If we're in error recovery, we don't want an errant
// semicolon to be treated as a class member (since they're almost always used
// for statements.
- return lookAhead(isClassMemberStart) || (token() === 26 /* SemicolonToken */ && !inErrorRecovery);
- case 6 /* EnumMembers */:
+ return lookAhead(isClassMemberStart) || (token() === 26 /* SyntaxKind.SemicolonToken */ && !inErrorRecovery);
+ case 6 /* ParsingContext.EnumMembers */:
// Include open bracket computed properties. This technically also lets in indexers,
// which would be a candidate for improved error reporting.
- return token() === 22 /* OpenBracketToken */ || isLiteralPropertyName();
- case 12 /* ObjectLiteralMembers */:
+ return token() === 22 /* SyntaxKind.OpenBracketToken */ || isLiteralPropertyName();
+ case 12 /* ParsingContext.ObjectLiteralMembers */:
switch (token()) {
- case 22 /* OpenBracketToken */:
- case 41 /* AsteriskToken */:
- case 25 /* DotDotDotToken */:
- case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`)
+ case 22 /* SyntaxKind.OpenBracketToken */:
+ case 41 /* SyntaxKind.AsteriskToken */:
+ case 25 /* SyntaxKind.DotDotDotToken */:
+ case 24 /* SyntaxKind.DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`)
return true;
default:
return isLiteralPropertyName();
}
- case 18 /* RestProperties */:
+ case 18 /* ParsingContext.RestProperties */:
return isLiteralPropertyName();
- case 9 /* ObjectBindingElements */:
- return token() === 22 /* OpenBracketToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName();
- case 24 /* AssertEntries */:
+ case 9 /* ParsingContext.ObjectBindingElements */:
+ return token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isLiteralPropertyName();
+ case 24 /* ParsingContext.AssertEntries */:
return isAssertionKey();
- case 7 /* HeritageClauseElement */:
+ case 7 /* ParsingContext.HeritageClauseElement */:
// If we see `{ ... }` then only consume it as an expression if it is followed by `,` or `{`
// That way we won't consume the body of a class in its heritage clause.
- if (token() === 18 /* OpenBraceToken */) {
+ if (token() === 18 /* SyntaxKind.OpenBraceToken */) {
return lookAhead(isValidHeritageClauseObjectLiteral);
}
if (!inErrorRecovery) {
@@ -31890,42 +32567,42 @@ var ts;
// element during recovery.
return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword();
}
- case 8 /* VariableDeclarations */:
+ case 8 /* ParsingContext.VariableDeclarations */:
return isBindingIdentifierOrPrivateIdentifierOrPattern();
- case 10 /* ArrayBindingElements */:
- return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern();
- case 19 /* TypeParameters */:
- return isIdentifier();
- case 15 /* ArrayLiteralMembers */:
+ case 10 /* ParsingContext.ArrayBindingElements */:
+ return token() === 27 /* SyntaxKind.CommaToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern();
+ case 19 /* ParsingContext.TypeParameters */:
+ return token() === 101 /* SyntaxKind.InKeyword */ || isIdentifier();
+ case 15 /* ParsingContext.ArrayLiteralMembers */:
switch (token()) {
- case 27 /* CommaToken */:
- case 24 /* DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`)
+ case 27 /* SyntaxKind.CommaToken */:
+ case 24 /* SyntaxKind.DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`)
return true;
}
// falls through
- case 11 /* ArgumentExpressions */:
- return token() === 25 /* DotDotDotToken */ || isStartOfExpression();
- case 16 /* Parameters */:
+ case 11 /* ParsingContext.ArgumentExpressions */:
+ return token() === 25 /* SyntaxKind.DotDotDotToken */ || isStartOfExpression();
+ case 16 /* ParsingContext.Parameters */:
return isStartOfParameter(/*isJSDocParameter*/ false);
- case 17 /* JSDocParameters */:
+ case 17 /* ParsingContext.JSDocParameters */:
return isStartOfParameter(/*isJSDocParameter*/ true);
- case 20 /* TypeArguments */:
- case 21 /* TupleElementTypes */:
- return token() === 27 /* CommaToken */ || isStartOfType();
- case 22 /* HeritageClauses */:
+ case 20 /* ParsingContext.TypeArguments */:
+ case 21 /* ParsingContext.TupleElementTypes */:
+ return token() === 27 /* SyntaxKind.CommaToken */ || isStartOfType();
+ case 22 /* ParsingContext.HeritageClauses */:
return isHeritageClause();
- case 23 /* ImportOrExportSpecifiers */:
+ case 23 /* ParsingContext.ImportOrExportSpecifiers */:
return ts.tokenIsIdentifierOrKeyword(token());
- case 13 /* JsxAttributes */:
- return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* OpenBraceToken */;
- case 14 /* JsxChildren */:
+ case 13 /* ParsingContext.JsxAttributes */:
+ return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* SyntaxKind.OpenBraceToken */;
+ case 14 /* ParsingContext.JsxChildren */:
return true;
}
return ts.Debug.fail("Non-exhaustive case in 'isListElement'.");
}
function isValidHeritageClauseObjectLiteral() {
- ts.Debug.assert(token() === 18 /* OpenBraceToken */);
- if (nextToken() === 19 /* CloseBraceToken */) {
+ ts.Debug.assert(token() === 18 /* SyntaxKind.OpenBraceToken */);
+ if (nextToken() === 19 /* SyntaxKind.CloseBraceToken */) {
// if we see "extends {}" then only treat the {} as what we're extending (and not
// the class body) if we have:
//
@@ -31934,7 +32611,7 @@ var ts;
// extends {} extends
// extends {} implements
var next = nextToken();
- return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 94 /* ExtendsKeyword */ || next === 117 /* ImplementsKeyword */;
+ return next === 27 /* SyntaxKind.CommaToken */ || next === 18 /* SyntaxKind.OpenBraceToken */ || next === 94 /* SyntaxKind.ExtendsKeyword */ || next === 117 /* SyntaxKind.ImplementsKeyword */;
}
return true;
}
@@ -31951,8 +32628,8 @@ var ts;
return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token());
}
function isHeritageClauseExtendsOrImplementsKeyword() {
- if (token() === 117 /* ImplementsKeyword */ ||
- token() === 94 /* ExtendsKeyword */) {
+ if (token() === 117 /* SyntaxKind.ImplementsKeyword */ ||
+ token() === 94 /* SyntaxKind.ExtendsKeyword */) {
return lookAhead(nextTokenIsStartOfExpression);
}
return false;
@@ -31967,51 +32644,51 @@ var ts;
}
// True if positioned at a list terminator
function isListTerminator(kind) {
- if (token() === 1 /* EndOfFileToken */) {
+ if (token() === 1 /* SyntaxKind.EndOfFileToken */) {
// Being at the end of the file ends all lists.
return true;
}
switch (kind) {
- case 1 /* BlockStatements */:
- case 2 /* SwitchClauses */:
- case 4 /* TypeMembers */:
- case 5 /* ClassMembers */:
- case 6 /* EnumMembers */:
- case 12 /* ObjectLiteralMembers */:
- case 9 /* ObjectBindingElements */:
- case 23 /* ImportOrExportSpecifiers */:
- case 24 /* AssertEntries */:
- return token() === 19 /* CloseBraceToken */;
- case 3 /* SwitchClauseStatements */:
- return token() === 19 /* CloseBraceToken */ || token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */;
- case 7 /* HeritageClauseElement */:
- return token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */;
- case 8 /* VariableDeclarations */:
+ case 1 /* ParsingContext.BlockStatements */:
+ case 2 /* ParsingContext.SwitchClauses */:
+ case 4 /* ParsingContext.TypeMembers */:
+ case 5 /* ParsingContext.ClassMembers */:
+ case 6 /* ParsingContext.EnumMembers */:
+ case 12 /* ParsingContext.ObjectLiteralMembers */:
+ case 9 /* ParsingContext.ObjectBindingElements */:
+ case 23 /* ParsingContext.ImportOrExportSpecifiers */:
+ case 24 /* ParsingContext.AssertEntries */:
+ return token() === 19 /* SyntaxKind.CloseBraceToken */;
+ case 3 /* ParsingContext.SwitchClauseStatements */:
+ return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */;
+ case 7 /* ParsingContext.HeritageClauseElement */:
+ return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */;
+ case 8 /* ParsingContext.VariableDeclarations */:
return isVariableDeclaratorListTerminator();
- case 19 /* TypeParameters */:
+ case 19 /* ParsingContext.TypeParameters */:
// Tokens other than '>' are here for better error recovery
- return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */;
- case 11 /* ArgumentExpressions */:
+ return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */;
+ case 11 /* ParsingContext.ArgumentExpressions */:
// Tokens other than ')' are here for better error recovery
- return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */;
- case 15 /* ArrayLiteralMembers */:
- case 21 /* TupleElementTypes */:
- case 10 /* ArrayBindingElements */:
- return token() === 23 /* CloseBracketToken */;
- case 17 /* JSDocParameters */:
- case 16 /* Parameters */:
- case 18 /* RestProperties */:
+ return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 26 /* SyntaxKind.SemicolonToken */;
+ case 15 /* ParsingContext.ArrayLiteralMembers */:
+ case 21 /* ParsingContext.TupleElementTypes */:
+ case 10 /* ParsingContext.ArrayBindingElements */:
+ return token() === 23 /* SyntaxKind.CloseBracketToken */;
+ case 17 /* ParsingContext.JSDocParameters */:
+ case 16 /* ParsingContext.Parameters */:
+ case 18 /* ParsingContext.RestProperties */:
// Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery
- return token() === 21 /* CloseParenToken */ || token() === 23 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/;
- case 20 /* TypeArguments */:
+ return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/;
+ case 20 /* ParsingContext.TypeArguments */:
// All other tokens should cause the type-argument to terminate except comma token
- return token() !== 27 /* CommaToken */;
- case 22 /* HeritageClauses */:
- return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */;
- case 13 /* JsxAttributes */:
- return token() === 31 /* GreaterThanToken */ || token() === 43 /* SlashToken */;
- case 14 /* JsxChildren */:
- return token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsSlash);
+ return token() !== 27 /* SyntaxKind.CommaToken */;
+ case 22 /* ParsingContext.HeritageClauses */:
+ return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 19 /* SyntaxKind.CloseBraceToken */;
+ case 13 /* ParsingContext.JsxAttributes */:
+ return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 43 /* SyntaxKind.SlashToken */;
+ case 14 /* ParsingContext.JsxChildren */:
+ return token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsSlash);
default:
return false;
}
@@ -32031,7 +32708,7 @@ var ts;
// For better error recovery, if we see an '=>' then we just stop immediately. We've got an
// arrow function here and it's going to be very unlikely that we'll resynchronize and get
// another variable declaration.
- if (token() === 38 /* EqualsGreaterThanToken */) {
+ if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) {
return true;
}
// Keep trying to parse out variable declarators.
@@ -32039,7 +32716,7 @@ var ts;
}
// True if positioned at element or terminator of the current list or any enclosing list
function isInSomeParsingContext() {
- for (var kind = 0; kind < 25 /* Count */; kind++) {
+ for (var kind = 0; kind < 25 /* ParsingContext.Count */; kind++) {
if (parsingContext & (1 << kind)) {
if (isListElement(kind, /*inErrorRecovery*/ true) || isListTerminator(kind)) {
return true;
@@ -32105,7 +32782,7 @@ var ts;
// differently depending on what mode it is in.
//
// This also applies to all our other context flags as well.
- var nodeContextFlags = node.flags & 25358336 /* ContextFlags */;
+ var nodeContextFlags = node.flags & 50720768 /* NodeFlags.ContextFlags */;
if (nodeContextFlags !== contextFlags) {
return undefined;
}
@@ -32128,38 +32805,38 @@ var ts;
}
function isReusableParsingContext(parsingContext) {
switch (parsingContext) {
- case 5 /* ClassMembers */:
- case 2 /* SwitchClauses */:
- case 0 /* SourceElements */:
- case 1 /* BlockStatements */:
- case 3 /* SwitchClauseStatements */:
- case 6 /* EnumMembers */:
- case 4 /* TypeMembers */:
- case 8 /* VariableDeclarations */:
- case 17 /* JSDocParameters */:
- case 16 /* Parameters */:
+ case 5 /* ParsingContext.ClassMembers */:
+ case 2 /* ParsingContext.SwitchClauses */:
+ case 0 /* ParsingContext.SourceElements */:
+ case 1 /* ParsingContext.BlockStatements */:
+ case 3 /* ParsingContext.SwitchClauseStatements */:
+ case 6 /* ParsingContext.EnumMembers */:
+ case 4 /* ParsingContext.TypeMembers */:
+ case 8 /* ParsingContext.VariableDeclarations */:
+ case 17 /* ParsingContext.JSDocParameters */:
+ case 16 /* ParsingContext.Parameters */:
return true;
}
return false;
}
function canReuseNode(node, parsingContext) {
switch (parsingContext) {
- case 5 /* ClassMembers */:
+ case 5 /* ParsingContext.ClassMembers */:
return isReusableClassMember(node);
- case 2 /* SwitchClauses */:
+ case 2 /* ParsingContext.SwitchClauses */:
return isReusableSwitchClause(node);
- case 0 /* SourceElements */:
- case 1 /* BlockStatements */:
- case 3 /* SwitchClauseStatements */:
+ case 0 /* ParsingContext.SourceElements */:
+ case 1 /* ParsingContext.BlockStatements */:
+ case 3 /* ParsingContext.SwitchClauseStatements */:
return isReusableStatement(node);
- case 6 /* EnumMembers */:
+ case 6 /* ParsingContext.EnumMembers */:
return isReusableEnumMember(node);
- case 4 /* TypeMembers */:
+ case 4 /* ParsingContext.TypeMembers */:
return isReusableTypeMember(node);
- case 8 /* VariableDeclarations */:
+ case 8 /* ParsingContext.VariableDeclarations */:
return isReusableVariableDeclaration(node);
- case 17 /* JSDocParameters */:
- case 16 /* Parameters */:
+ case 17 /* ParsingContext.JSDocParameters */:
+ case 16 /* ParsingContext.Parameters */:
return isReusableParameter(node);
// Any other lists we do not care about reusing nodes in. But feel free to add if
// you can do so safely. Danger areas involve nodes that may involve speculative
@@ -32206,20 +32883,20 @@ var ts;
function isReusableClassMember(node) {
if (node) {
switch (node.kind) {
- case 170 /* Constructor */:
- case 175 /* IndexSignature */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 166 /* PropertyDeclaration */:
- case 233 /* SemicolonClassElement */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 176 /* SyntaxKind.IndexSignature */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 234 /* SyntaxKind.SemicolonClassElement */:
return true;
- case 168 /* MethodDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
// Method declarations are not necessarily reusable. An object-literal
// may have a method calls "constructor(...)" and we must reparse that
// into an actual .ConstructorDeclaration.
var methodDeclaration = node;
- var nameIsConstructor = methodDeclaration.name.kind === 79 /* Identifier */ &&
- methodDeclaration.name.originalKeywordKind === 134 /* ConstructorKeyword */;
+ var nameIsConstructor = methodDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ &&
+ methodDeclaration.name.originalKeywordKind === 134 /* SyntaxKind.ConstructorKeyword */;
return !nameIsConstructor;
}
}
@@ -32228,8 +32905,8 @@ var ts;
function isReusableSwitchClause(node) {
if (node) {
switch (node.kind) {
- case 288 /* CaseClause */:
- case 289 /* DefaultClause */:
+ case 289 /* SyntaxKind.CaseClause */:
+ case 290 /* SyntaxKind.DefaultClause */:
return true;
}
}
@@ -32238,58 +32915,58 @@ var ts;
function isReusableStatement(node) {
if (node) {
switch (node.kind) {
- case 255 /* FunctionDeclaration */:
- case 236 /* VariableStatement */:
- case 234 /* Block */:
- case 238 /* IfStatement */:
- case 237 /* ExpressionStatement */:
- case 250 /* ThrowStatement */:
- case 246 /* ReturnStatement */:
- case 248 /* SwitchStatement */:
- case 245 /* BreakStatement */:
- case 244 /* ContinueStatement */:
- case 242 /* ForInStatement */:
- case 243 /* ForOfStatement */:
- case 241 /* ForStatement */:
- case 240 /* WhileStatement */:
- case 247 /* WithStatement */:
- case 235 /* EmptyStatement */:
- case 251 /* TryStatement */:
- case 249 /* LabeledStatement */:
- case 239 /* DoStatement */:
- case 252 /* DebuggerStatement */:
- case 265 /* ImportDeclaration */:
- case 264 /* ImportEqualsDeclaration */:
- case 271 /* ExportDeclaration */:
- case 270 /* ExportAssignment */:
- case 260 /* ModuleDeclaration */:
- case 256 /* ClassDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 259 /* EnumDeclaration */:
- case 258 /* TypeAliasDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 237 /* SyntaxKind.VariableStatement */:
+ case 235 /* SyntaxKind.Block */:
+ case 239 /* SyntaxKind.IfStatement */:
+ case 238 /* SyntaxKind.ExpressionStatement */:
+ case 251 /* SyntaxKind.ThrowStatement */:
+ case 247 /* SyntaxKind.ReturnStatement */:
+ case 249 /* SyntaxKind.SwitchStatement */:
+ case 246 /* SyntaxKind.BreakStatement */:
+ case 245 /* SyntaxKind.ContinueStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
+ case 248 /* SyntaxKind.WithStatement */:
+ case 236 /* SyntaxKind.EmptyStatement */:
+ case 252 /* SyntaxKind.TryStatement */:
+ case 250 /* SyntaxKind.LabeledStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
+ case 253 /* SyntaxKind.DebuggerStatement */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
+ case 271 /* SyntaxKind.ExportAssignment */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
return true;
}
}
return false;
}
function isReusableEnumMember(node) {
- return node.kind === 297 /* EnumMember */;
+ return node.kind === 299 /* SyntaxKind.EnumMember */;
}
function isReusableTypeMember(node) {
if (node) {
switch (node.kind) {
- case 174 /* ConstructSignature */:
- case 167 /* MethodSignature */:
- case 175 /* IndexSignature */:
- case 165 /* PropertySignature */:
- case 173 /* CallSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 176 /* SyntaxKind.IndexSignature */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 174 /* SyntaxKind.CallSignature */:
return true;
}
}
return false;
}
function isReusableVariableDeclaration(node) {
- if (node.kind !== 253 /* VariableDeclaration */) {
+ if (node.kind !== 254 /* SyntaxKind.VariableDeclaration */) {
return false;
}
// Very subtle incremental parsing bug. Consider the following code:
@@ -32310,7 +32987,7 @@ var ts;
return variableDeclarator.initializer === undefined;
}
function isReusableParameter(node) {
- if (node.kind !== 163 /* Parameter */) {
+ if (node.kind !== 164 /* SyntaxKind.Parameter */) {
return false;
}
// See the comment in isReusableVariableDeclaration for why we do this.
@@ -32328,43 +33005,42 @@ var ts;
}
function parsingContextErrors(context) {
switch (context) {
- case 0 /* SourceElements */:
- return token() === 88 /* DefaultKeyword */
- ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* ExportKeyword */))
+ case 0 /* ParsingContext.SourceElements */:
+ return token() === 88 /* SyntaxKind.DefaultKeyword */
+ ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* SyntaxKind.ExportKeyword */))
: parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected);
- case 1 /* BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected);
- case 2 /* SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected);
- case 3 /* SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected);
- case 18 /* RestProperties */: // fallthrough
- case 4 /* TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected);
- case 5 /* ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected);
- case 6 /* EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected);
- case 7 /* HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected);
- case 8 /* VariableDeclarations */:
+ case 1 /* ParsingContext.BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected);
+ case 2 /* ParsingContext.SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected);
+ case 3 /* ParsingContext.SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected);
+ case 18 /* ParsingContext.RestProperties */: // fallthrough
+ case 4 /* ParsingContext.TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected);
+ case 5 /* ParsingContext.ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected);
+ case 6 /* ParsingContext.EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected);
+ case 7 /* ParsingContext.HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected);
+ case 8 /* ParsingContext.VariableDeclarations */:
return ts.isKeyword(token())
? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_variable_declaration_name, ts.tokenToString(token()))
: parseErrorAtCurrentToken(ts.Diagnostics.Variable_declaration_expected);
- case 9 /* ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected);
- case 10 /* ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected);
- case 11 /* ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected);
- case 12 /* ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected);
- case 15 /* ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected);
- case 17 /* JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected);
- case 16 /* Parameters */:
+ case 9 /* ParsingContext.ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected);
+ case 10 /* ParsingContext.ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected);
+ case 11 /* ParsingContext.ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected);
+ case 12 /* ParsingContext.ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected);
+ case 15 /* ParsingContext.ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected);
+ case 17 /* ParsingContext.JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected);
+ case 16 /* ParsingContext.Parameters */:
return ts.isKeyword(token())
? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_parameter_name, ts.tokenToString(token()))
: parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected);
- case 19 /* TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected);
- case 20 /* TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected);
- case 21 /* TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected);
- case 22 /* HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected);
- case 23 /* ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
- case 13 /* JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
- case 14 /* JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
+ case 19 /* ParsingContext.TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected);
+ case 20 /* ParsingContext.TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected);
+ case 21 /* ParsingContext.TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected);
+ case 22 /* ParsingContext.HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected);
+ case 23 /* ParsingContext.ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
+ case 13 /* ParsingContext.JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
+ case 14 /* ParsingContext.JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
default: return [undefined]; // TODO: GH#18217 `default: Debug.assertNever(context);`
}
}
- // Parses a comma-delimited list of elements
function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
var saveParsingContext = parsingContext;
parsingContext |= 1 << kind;
@@ -32374,9 +33050,14 @@ var ts;
while (true) {
if (isListElement(kind, /*inErrorRecovery*/ false)) {
var startPos = scanner.getStartPos();
- list.push(parseListElement(kind, parseElement));
+ var result = parseListElement(kind, parseElement);
+ if (!result) {
+ parsingContext = saveParsingContext;
+ return undefined;
+ }
+ list.push(result);
commaStart = scanner.getTokenPos();
- if (parseOptional(27 /* CommaToken */)) {
+ if (parseOptional(27 /* SyntaxKind.CommaToken */)) {
// No need to check for a zero length node since we know we parsed a comma
continue;
}
@@ -32386,13 +33067,13 @@ var ts;
}
// We didn't get a comma, and the list wasn't terminated, explicitly parse
// out a comma so we give a good error message.
- parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind));
+ parseExpected(27 /* SyntaxKind.CommaToken */, getExpectedCommaDiagnostic(kind));
// If the token was a semicolon, and the caller allows that, then skip it and
// continue. This ensures we get back on track and don't result in tons of
// parse errors. For example, this can happen when people do things like use
// a semicolon to delimit object literal members. Note: we'll have already
// reported an error when we called parseExpected above.
- if (considerSemicolonAsDelimiter && token() === 26 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) {
+ if (considerSemicolonAsDelimiter && token() === 26 /* SyntaxKind.SemicolonToken */ && !scanner.hasPrecedingLineBreak()) {
nextToken();
}
if (startPos === scanner.getStartPos()) {
@@ -32421,7 +33102,7 @@ var ts;
return createNodeArray(list, listPos, /*end*/ undefined, commaStart >= 0);
}
function getExpectedCommaDiagnostic(kind) {
- return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined;
+ return kind === 6 /* ParsingContext.EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined;
}
function createMissingList() {
var list = createNodeArray([], getNodePos());
@@ -32443,8 +33124,8 @@ var ts;
var pos = getNodePos();
var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage);
var dotPos = getNodePos();
- while (parseOptional(24 /* DotToken */)) {
- if (token() === 29 /* LessThanToken */) {
+ while (parseOptional(24 /* SyntaxKind.DotToken */)) {
+ if (token() === 29 /* SyntaxKind.LessThanToken */) {
// the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting
entity.jsdocDotPos = dotPos;
break;
@@ -32483,12 +33164,12 @@ var ts;
// Report that we need an identifier. However, report it right after the dot,
// and not on the next token. This is because the next token might actually
// be an identifier and the error would be quite confusing.
- return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected);
+ return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected);
}
}
- if (token() === 80 /* PrivateIdentifier */) {
+ if (token() === 80 /* SyntaxKind.PrivateIdentifier */) {
var node = parsePrivateIdentifier();
- return allowPrivateIdentifiers ? node : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected);
+ return allowPrivateIdentifiers ? node : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected);
}
return allowIdentifierNames ? parseIdentifierName() : parseIdentifier();
}
@@ -32499,7 +33180,7 @@ var ts;
do {
node = parseTemplateSpan(isTaggedTemplate);
list.push(node);
- } while (node.literal.kind === 16 /* TemplateMiddle */);
+ } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */);
return createNodeArray(list, pos);
}
function parseTemplateExpression(isTaggedTemplate) {
@@ -32517,7 +33198,7 @@ var ts;
do {
node = parseTemplateTypeSpan();
list.push(node);
- } while (node.literal.kind === 16 /* TemplateMiddle */);
+ } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */);
return createNodeArray(list, pos);
}
function parseTemplateTypeSpan() {
@@ -32525,13 +33206,13 @@ var ts;
return finishNode(factory.createTemplateLiteralTypeSpan(parseType(), parseLiteralOfTemplateSpan(/*isTaggedTemplate*/ false)), pos);
}
function parseLiteralOfTemplateSpan(isTaggedTemplate) {
- if (token() === 19 /* CloseBraceToken */) {
+ if (token() === 19 /* SyntaxKind.CloseBraceToken */) {
reScanTemplateToken(isTaggedTemplate);
return parseTemplateMiddleOrTemplateTail();
}
else {
// TODO(rbuckton): Do we need to call `parseExpectedToken` or can we just call `createMissingNode` directly?
- return parseExpectedToken(17 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* CloseBraceToken */));
+ return parseExpectedToken(17 /* SyntaxKind.TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* SyntaxKind.CloseBraceToken */));
}
}
function parseTemplateSpan(isTaggedTemplate) {
@@ -32546,30 +33227,30 @@ var ts;
reScanTemplateHeadOrNoSubstitutionTemplate();
}
var fragment = parseLiteralLikeNode(token());
- ts.Debug.assert(fragment.kind === 15 /* TemplateHead */, "Template head has wrong token kind");
+ ts.Debug.assert(fragment.kind === 15 /* SyntaxKind.TemplateHead */, "Template head has wrong token kind");
return fragment;
}
function parseTemplateMiddleOrTemplateTail() {
var fragment = parseLiteralLikeNode(token());
- ts.Debug.assert(fragment.kind === 16 /* TemplateMiddle */ || fragment.kind === 17 /* TemplateTail */, "Template fragment has wrong token kind");
+ ts.Debug.assert(fragment.kind === 16 /* SyntaxKind.TemplateMiddle */ || fragment.kind === 17 /* SyntaxKind.TemplateTail */, "Template fragment has wrong token kind");
return fragment;
}
function getTemplateLiteralRawText(kind) {
- var isLast = kind === 14 /* NoSubstitutionTemplateLiteral */ || kind === 17 /* TemplateTail */;
+ var isLast = kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || kind === 17 /* SyntaxKind.TemplateTail */;
var tokenText = scanner.getTokenText();
return tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2));
}
function parseLiteralLikeNode(kind) {
var pos = getNodePos();
- var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TemplateLiteralLikeFlags */) :
+ var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TokenFlags.TemplateLiteralLikeFlags */) :
// Octal literals are not allowed in strict mode or ES5
// Note that theoretically the following condition would hold true literals like 009,
// which is not octal. But because of how the scanner separates the tokens, we would
// never get a token like this. Instead, we would get 00 and 9 as two separate tokens.
// We also do not need to check for negatives because any prefix operator would be part of a
// parent unary expression.
- kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) :
- kind === 10 /* StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) :
+ kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) :
+ kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) :
ts.isLiteralKind(kind) ? factory.createLiteralLikeNode(kind, scanner.getTokenValue()) :
ts.Debug.fail();
if (scanner.hasExtendedUnicodeEscape()) {
@@ -32586,8 +33267,8 @@ var ts;
return parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected);
}
function parseTypeArgumentsOfTypeReference() {
- if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) {
- return parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */);
+ if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* SyntaxKind.LessThanToken */) {
+ return parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */);
}
}
function parseTypeReference() {
@@ -32597,14 +33278,14 @@ var ts;
// If true, we should abort parsing an error function.
function typeHasArrowFunctionBlockingParseError(node) {
switch (node.kind) {
- case 177 /* TypeReference */:
+ case 178 /* SyntaxKind.TypeReference */:
return ts.nodeIsMissing(node.typeName);
- case 178 /* FunctionType */:
- case 179 /* ConstructorType */: {
+ case 179 /* SyntaxKind.FunctionType */:
+ case 180 /* SyntaxKind.ConstructorType */: {
var _a = node, parameters = _a.parameters, type = _a.type;
return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type);
}
- case 190 /* ParenthesizedType */:
+ case 191 /* SyntaxKind.ParenthesizedType */:
return typeHasArrowFunctionBlockingParseError(node.type);
default:
return false;
@@ -32627,7 +33308,7 @@ var ts;
function parseJSDocNonNullableType() {
var pos = getNodePos();
nextToken();
- return finishNode(factory.createJSDocNonNullableType(parseNonArrayType()), pos);
+ return finishNode(factory.createJSDocNonNullableType(parseNonArrayType(), /*postfix*/ false), pos);
}
function parseJSDocUnknownOrNullableType() {
var pos = getNodePos();
@@ -32642,16 +33323,16 @@ var ts;
// Foo<?>
// Foo(?=
// (?|
- if (token() === 27 /* CommaToken */ ||
- token() === 19 /* CloseBraceToken */ ||
- token() === 21 /* CloseParenToken */ ||
- token() === 31 /* GreaterThanToken */ ||
- token() === 63 /* EqualsToken */ ||
- token() === 51 /* BarToken */) {
+ if (token() === 27 /* SyntaxKind.CommaToken */ ||
+ token() === 19 /* SyntaxKind.CloseBraceToken */ ||
+ token() === 21 /* SyntaxKind.CloseParenToken */ ||
+ token() === 31 /* SyntaxKind.GreaterThanToken */ ||
+ token() === 63 /* SyntaxKind.EqualsToken */ ||
+ token() === 51 /* SyntaxKind.BarToken */) {
return finishNode(factory.createJSDocUnknownType(), pos);
}
else {
- return finishNode(factory.createJSDocNullableType(parseType()), pos);
+ return finishNode(factory.createJSDocNullableType(parseType(), /*postfix*/ false), pos);
}
}
function parseJSDocFunctionType() {
@@ -32659,8 +33340,8 @@ var ts;
var hasJSDoc = hasPrecedingJSDocComment();
if (lookAhead(nextTokenIsOpenParen)) {
nextToken();
- var parameters = parseParameters(4 /* Type */ | 32 /* JSDoc */);
- var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
+ var parameters = parseParameters(4 /* SignatureFlags.Type */ | 32 /* SignatureFlags.JSDoc */);
+ var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false);
return withJSDoc(finishNode(factory.createJSDocFunctionType(parameters, type), pos), hasJSDoc);
}
return finishNode(factory.createTypeReferenceNode(parseIdentifierName(), /*typeArguments*/ undefined), pos);
@@ -32668,9 +33349,9 @@ var ts;
function parseJSDocParameter() {
var pos = getNodePos();
var name;
- if (token() === 108 /* ThisKeyword */ || token() === 103 /* NewKeyword */) {
+ if (token() === 108 /* SyntaxKind.ThisKeyword */ || token() === 103 /* SyntaxKind.NewKeyword */) {
name = parseIdentifierName();
- parseExpected(58 /* ColonToken */);
+ parseExpected(58 /* SyntaxKind.ColonToken */);
}
return finishNode(factory.createParameterDeclaration(
/*decorators*/ undefined,
@@ -32684,15 +33365,15 @@ var ts;
function parseJSDocType() {
scanner.setInJSDocType(true);
var pos = getNodePos();
- if (parseOptional(141 /* ModuleKeyword */)) {
+ if (parseOptional(141 /* SyntaxKind.ModuleKeyword */)) {
// TODO(rbuckton): We never set the type for a JSDocNamepathType. What should we put here?
var moduleTag = factory.createJSDocNamepathType(/*type*/ undefined);
terminate: while (true) {
switch (token()) {
- case 19 /* CloseBraceToken */:
- case 1 /* EndOfFileToken */:
- case 27 /* CommaToken */:
- case 5 /* WhitespaceTrivia */:
+ case 19 /* SyntaxKind.CloseBraceToken */:
+ case 1 /* SyntaxKind.EndOfFileToken */:
+ case 27 /* SyntaxKind.CommaToken */:
+ case 5 /* SyntaxKind.WhitespaceTrivia */:
break terminate;
default:
nextTokenJSDoc();
@@ -32701,13 +33382,13 @@ var ts;
scanner.setInJSDocType(false);
return finishNode(moduleTag, pos);
}
- var hasDotDotDot = parseOptional(25 /* DotDotDotToken */);
+ var hasDotDotDot = parseOptional(25 /* SyntaxKind.DotDotDotToken */);
var type = parseTypeOrTypePredicate();
scanner.setInJSDocType(false);
if (hasDotDotDot) {
type = finishNode(factory.createJSDocVariadicType(type), pos);
}
- if (token() === 63 /* EqualsToken */) {
+ if (token() === 63 /* SyntaxKind.EqualsToken */) {
nextToken();
return finishNode(factory.createJSDocOptionalType(type), pos);
}
@@ -32715,15 +33396,19 @@ var ts;
}
function parseTypeQuery() {
var pos = getNodePos();
- parseExpected(112 /* TypeOfKeyword */);
- return finishNode(factory.createTypeQueryNode(parseEntityName(/*allowReservedWords*/ true)), pos);
+ parseExpected(112 /* SyntaxKind.TypeOfKeyword */);
+ var entityName = parseEntityName(/*allowReservedWords*/ true);
+ // Make sure we perform ASI to prevent parsing the next line's type arguments as part of an instantiation expression.
+ var typeArguments = !scanner.hasPrecedingLineBreak() ? tryParseTypeArguments() : undefined;
+ return finishNode(factory.createTypeQueryNode(entityName, typeArguments), pos);
}
function parseTypeParameter() {
var pos = getNodePos();
+ var modifiers = parseModifiers();
var name = parseIdentifier();
var constraint;
var expression;
- if (parseOptional(94 /* ExtendsKeyword */)) {
+ if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) {
// It's not uncommon for people to write improper constraints to a generic. If the
// user writes a constraint that is an expression and not an actual type, then parse
// it out as an expression (so we can recover well), but report that a type is needed
@@ -32742,21 +33427,21 @@ var ts;
expression = parseUnaryExpressionOrHigher();
}
}
- var defaultType = parseOptional(63 /* EqualsToken */) ? parseType() : undefined;
- var node = factory.createTypeParameterDeclaration(name, constraint, defaultType);
+ var defaultType = parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseType() : undefined;
+ var node = factory.createTypeParameterDeclaration(modifiers, name, constraint, defaultType);
node.expression = expression;
return finishNode(node, pos);
}
function parseTypeParameters() {
- if (token() === 29 /* LessThanToken */) {
- return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 29 /* LessThanToken */, 31 /* GreaterThanToken */);
+ if (token() === 29 /* SyntaxKind.LessThanToken */) {
+ return parseBracketedList(19 /* ParsingContext.TypeParameters */, parseTypeParameter, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */);
}
}
function isStartOfParameter(isJSDocParameter) {
- return token() === 25 /* DotDotDotToken */ ||
+ return token() === 25 /* SyntaxKind.DotDotDotToken */ ||
isBindingIdentifierOrPrivateIdentifierOrPattern() ||
ts.isModifierKind(token()) ||
- token() === 59 /* AtToken */ ||
+ token() === 59 /* SyntaxKind.AtToken */ ||
isStartOfType(/*inStartOfParameter*/ !isJSDocParameter);
}
function parseNameOfParameter(modifiers) {
@@ -32776,20 +33461,27 @@ var ts;
}
return name;
}
- function parseParameterInOuterAwaitContext() {
- return parseParameterWorker(/*inOuterAwaitContext*/ true);
+ function isParameterNameStart() {
+ // Be permissive about await and yield by calling isBindingIdentifier instead of isIdentifier; disallowing
+ // them during a speculative parse leads to many more follow-on errors than allowing the function to parse then later
+ // complaining about the use of the keywords.
+ return isBindingIdentifier() || token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */;
}
- function parseParameter() {
- return parseParameterWorker(/*inOuterAwaitContext*/ false);
+ function parseParameter(inOuterAwaitContext) {
+ return parseParameterWorker(inOuterAwaitContext);
}
- function parseParameterWorker(inOuterAwaitContext) {
+ function parseParameterForSpeculation(inOuterAwaitContext) {
+ return parseParameterWorker(inOuterAwaitContext, /*allowAmbiguity*/ false);
+ }
+ function parseParameterWorker(inOuterAwaitContext, allowAmbiguity) {
+ if (allowAmbiguity === void 0) { allowAmbiguity = true; }
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
// FormalParameter [Yield,Await]:
// BindingElement[?Yield,?Await]
// Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context.
var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators();
- if (token() === 108 /* ThisKeyword */) {
+ if (token() === 108 /* SyntaxKind.ThisKeyword */) {
var node_1 = factory.createParameterDeclaration(decorators,
/*modifiers*/ undefined,
/*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true),
@@ -32803,32 +33495,36 @@ var ts;
var savedTopLevel = topLevel;
topLevel = false;
var modifiers = parseModifiers();
- var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, parseOptionalToken(25 /* DotDotDotToken */), parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
+ var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */);
+ if (!allowAmbiguity && !isParameterNameStart()) {
+ return undefined;
+ }
+ var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* SyntaxKind.QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
topLevel = savedTopLevel;
return node;
}
function parseReturnType(returnToken, isType) {
if (shouldParseReturnType(returnToken, isType)) {
- return parseTypeOrTypePredicate();
+ return allowConditionalTypesAnd(parseTypeOrTypePredicate);
}
}
function shouldParseReturnType(returnToken, isType) {
- if (returnToken === 38 /* EqualsGreaterThanToken */) {
+ if (returnToken === 38 /* SyntaxKind.EqualsGreaterThanToken */) {
parseExpected(returnToken);
return true;
}
- else if (parseOptional(58 /* ColonToken */)) {
+ else if (parseOptional(58 /* SyntaxKind.ColonToken */)) {
return true;
}
- else if (isType && token() === 38 /* EqualsGreaterThanToken */) {
+ else if (isType && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) {
// This is easy to get backward, especially in type contexts, so parse the type anyway
- parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */));
+ parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */));
nextToken();
return true;
}
return false;
}
- function parseParametersWorker(flags) {
+ function parseParametersWorker(flags, allowAmbiguity) {
// FormalParameters [Yield,Await]: (modified)
// [empty]
// FormalParameterList[?Yield,Await]
@@ -32844,11 +33540,11 @@ var ts;
// BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt
var savedYieldContext = inYieldContext();
var savedAwaitContext = inAwaitContext();
- setYieldContext(!!(flags & 1 /* Yield */));
- setAwaitContext(!!(flags & 2 /* Await */));
- var parameters = flags & 32 /* JSDoc */ ?
- parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) :
- parseDelimitedList(16 /* Parameters */, savedAwaitContext ? parseParameterInOuterAwaitContext : parseParameter);
+ setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */));
+ setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */));
+ var parameters = flags & 32 /* SignatureFlags.JSDoc */ ?
+ parseDelimitedList(17 /* ParsingContext.JSDocParameters */, parseJSDocParameter) :
+ parseDelimitedList(16 /* ParsingContext.Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); });
setYieldContext(savedYieldContext);
setAwaitContext(savedAwaitContext);
return parameters;
@@ -32867,17 +33563,17 @@ var ts;
//
// SingleNameBinding [Yield,Await]:
// BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt
- if (!parseExpected(20 /* OpenParenToken */)) {
+ if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) {
return createMissingList();
}
- var parameters = parseParametersWorker(flags);
- parseExpected(21 /* CloseParenToken */);
+ var parameters = parseParametersWorker(flags, /*allowAmbiguity*/ true);
+ parseExpected(21 /* SyntaxKind.CloseParenToken */);
return parameters;
}
function parseTypeMemberSemicolon() {
// We allow type members to be separated by commas or (possibly ASI) semicolons.
// First check if it was a comma. If so, we're done with the member.
- if (parseOptional(27 /* CommaToken */)) {
+ if (parseOptional(27 /* SyntaxKind.CommaToken */)) {
return;
}
// Didn't have a comma. We must have a (possible ASI) semicolon.
@@ -32886,20 +33582,20 @@ var ts;
function parseSignatureMember(kind) {
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
- if (kind === 174 /* ConstructSignature */) {
- parseExpected(103 /* NewKeyword */);
+ if (kind === 175 /* SyntaxKind.ConstructSignature */) {
+ parseExpected(103 /* SyntaxKind.NewKeyword */);
}
var typeParameters = parseTypeParameters();
- var parameters = parseParameters(4 /* Type */);
- var type = parseReturnType(58 /* ColonToken */, /*isType*/ true);
+ var parameters = parseParameters(4 /* SignatureFlags.Type */);
+ var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true);
parseTypeMemberSemicolon();
- var node = kind === 173 /* CallSignature */
+ var node = kind === 174 /* SyntaxKind.CallSignature */
? factory.createCallSignature(typeParameters, parameters, type)
: factory.createConstructSignature(typeParameters, parameters, type);
return withJSDoc(finishNode(node, pos), hasJSDoc);
}
function isIndexSignature() {
- return token() === 22 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature);
+ return token() === 22 /* SyntaxKind.OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature);
}
function isUnambiguouslyIndexSignature() {
// The only allowed sequence is:
@@ -32919,7 +33615,7 @@ var ts;
// []
//
nextToken();
- if (token() === 25 /* DotDotDotToken */ || token() === 23 /* CloseBracketToken */) {
+ if (token() === 25 /* SyntaxKind.DotDotDotToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */) {
return true;
}
if (ts.isModifierKind(token())) {
@@ -32938,21 +33634,21 @@ var ts;
// A colon signifies a well formed indexer
// A comma should be a badly formed indexer because comma expressions are not allowed
// in computed properties.
- if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */) {
+ if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */) {
return true;
}
// Question mark could be an indexer with an optional property,
// or it could be a conditional expression in a computed property.
- if (token() !== 57 /* QuestionToken */) {
+ if (token() !== 57 /* SyntaxKind.QuestionToken */) {
return false;
}
// If any of the following tokens are after the question mark, it cannot
// be a conditional expression, so treat it as an indexer.
nextToken();
- return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */;
+ return token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */;
}
function parseIndexSignatureDeclaration(pos, hasJSDoc, decorators, modifiers) {
- var parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */);
+ var parameters = parseBracketedList(16 /* ParsingContext.Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */);
var type = parseTypeAnnotation();
parseTypeMemberSemicolon();
var node = factory.createIndexSignature(decorators, modifiers, parameters, type);
@@ -32960,14 +33656,14 @@ var ts;
}
function parsePropertyOrMethodSignature(pos, hasJSDoc, modifiers) {
var name = parsePropertyName();
- var questionToken = parseOptionalToken(57 /* QuestionToken */);
+ var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */);
var node;
- if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) {
+ if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) {
// Method signatures don't exist in expression contexts. So they have neither
// [Yield] nor [Await]
var typeParameters = parseTypeParameters();
- var parameters = parseParameters(4 /* Type */);
- var type = parseReturnType(58 /* ColonToken */, /*isType*/ true);
+ var parameters = parseParameters(4 /* SignatureFlags.Type */);
+ var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true);
node = factory.createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type);
}
else {
@@ -32976,7 +33672,7 @@ var ts;
// Although type literal properties cannot not have initializers, we attempt
// to parse an initializer so we can report in the checker that an interface
// property or type literal property cannot have an initializer.
- if (token() === 63 /* EqualsToken */)
+ if (token() === 63 /* SyntaxKind.EqualsToken */)
node.initializer = parseInitializer();
}
parseTypeMemberSemicolon();
@@ -32984,10 +33680,10 @@ var ts;
}
function isTypeMemberStart() {
// Return true if we have the start of a signature member
- if (token() === 20 /* OpenParenToken */ ||
- token() === 29 /* LessThanToken */ ||
- token() === 136 /* GetKeyword */ ||
- token() === 148 /* SetKeyword */) {
+ if (token() === 20 /* SyntaxKind.OpenParenToken */ ||
+ token() === 29 /* SyntaxKind.LessThanToken */ ||
+ token() === 136 /* SyntaxKind.GetKeyword */ ||
+ token() === 149 /* SyntaxKind.SetKeyword */) {
return true;
}
var idToken = false;
@@ -32997,7 +33693,7 @@ var ts;
nextToken();
}
// Index signatures and computed property names are type members
- if (token() === 22 /* OpenBracketToken */) {
+ if (token() === 22 /* SyntaxKind.OpenBracketToken */) {
return true;
}
// Try to get the first property-like token following all modifiers
@@ -33008,30 +33704,30 @@ var ts;
// If we were able to get any potential identifier, check that it is
// the start of a member declaration
if (idToken) {
- return token() === 20 /* OpenParenToken */ ||
- token() === 29 /* LessThanToken */ ||
- token() === 57 /* QuestionToken */ ||
- token() === 58 /* ColonToken */ ||
- token() === 27 /* CommaToken */ ||
+ return token() === 20 /* SyntaxKind.OpenParenToken */ ||
+ token() === 29 /* SyntaxKind.LessThanToken */ ||
+ token() === 57 /* SyntaxKind.QuestionToken */ ||
+ token() === 58 /* SyntaxKind.ColonToken */ ||
+ token() === 27 /* SyntaxKind.CommaToken */ ||
canParseSemicolon();
}
return false;
}
function parseTypeMember() {
- if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) {
- return parseSignatureMember(173 /* CallSignature */);
+ if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) {
+ return parseSignatureMember(174 /* SyntaxKind.CallSignature */);
}
- if (token() === 103 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) {
- return parseSignatureMember(174 /* ConstructSignature */);
+ if (token() === 103 /* SyntaxKind.NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) {
+ return parseSignatureMember(175 /* SyntaxKind.ConstructSignature */);
}
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
var modifiers = parseModifiers();
- if (parseContextualModifier(136 /* GetKeyword */)) {
- return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 171 /* GetAccessor */);
+ if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) {
+ return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* SyntaxKind.GetAccessor */);
}
- if (parseContextualModifier(148 /* SetKeyword */)) {
- return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* SetAccessor */);
+ if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) {
+ return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SyntaxKind.SetAccessor */);
}
if (isIndexSignature()) {
return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers);
@@ -33040,16 +33736,16 @@ var ts;
}
function nextTokenIsOpenParenOrLessThan() {
nextToken();
- return token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */;
+ return token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */;
}
function nextTokenIsDot() {
- return nextToken() === 24 /* DotToken */;
+ return nextToken() === 24 /* SyntaxKind.DotToken */;
}
function nextTokenIsOpenParenOrLessThanOrDot() {
switch (nextToken()) {
- case 20 /* OpenParenToken */:
- case 29 /* LessThanToken */:
- case 24 /* DotToken */:
+ case 20 /* SyntaxKind.OpenParenToken */:
+ case 29 /* SyntaxKind.LessThanToken */:
+ case 24 /* SyntaxKind.DotToken */:
return true;
}
return false;
@@ -33060,9 +33756,9 @@ var ts;
}
function parseObjectTypeMembers() {
var members;
- if (parseExpected(18 /* OpenBraceToken */)) {
- members = parseList(4 /* TypeMembers */, parseTypeMember);
- parseExpected(19 /* CloseBraceToken */);
+ if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) {
+ members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember);
+ parseExpected(19 /* SyntaxKind.CloseBraceToken */);
}
else {
members = createMissingList();
@@ -33071,51 +33767,51 @@ var ts;
}
function isStartOfMappedType() {
nextToken();
- if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) {
- return nextToken() === 144 /* ReadonlyKeyword */;
+ if (token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) {
+ return nextToken() === 145 /* SyntaxKind.ReadonlyKeyword */;
}
- if (token() === 144 /* ReadonlyKeyword */) {
+ if (token() === 145 /* SyntaxKind.ReadonlyKeyword */) {
nextToken();
}
- return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* InKeyword */;
+ return token() === 22 /* SyntaxKind.OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* SyntaxKind.InKeyword */;
}
function parseMappedTypeParameter() {
var pos = getNodePos();
var name = parseIdentifierName();
- parseExpected(101 /* InKeyword */);
+ parseExpected(101 /* SyntaxKind.InKeyword */);
var type = parseType();
- return finishNode(factory.createTypeParameterDeclaration(name, type, /*defaultType*/ undefined), pos);
+ return finishNode(factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, type, /*defaultType*/ undefined), pos);
}
function parseMappedType() {
var pos = getNodePos();
- parseExpected(18 /* OpenBraceToken */);
+ parseExpected(18 /* SyntaxKind.OpenBraceToken */);
var readonlyToken;
- if (token() === 144 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) {
+ if (token() === 145 /* SyntaxKind.ReadonlyKeyword */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) {
readonlyToken = parseTokenNode();
- if (readonlyToken.kind !== 144 /* ReadonlyKeyword */) {
- parseExpected(144 /* ReadonlyKeyword */);
+ if (readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) {
+ parseExpected(145 /* SyntaxKind.ReadonlyKeyword */);
}
}
- parseExpected(22 /* OpenBracketToken */);
+ parseExpected(22 /* SyntaxKind.OpenBracketToken */);
var typeParameter = parseMappedTypeParameter();
- var nameType = parseOptional(127 /* AsKeyword */) ? parseType() : undefined;
- parseExpected(23 /* CloseBracketToken */);
+ var nameType = parseOptional(127 /* SyntaxKind.AsKeyword */) ? parseType() : undefined;
+ parseExpected(23 /* SyntaxKind.CloseBracketToken */);
var questionToken;
- if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) {
+ if (token() === 57 /* SyntaxKind.QuestionToken */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) {
questionToken = parseTokenNode();
- if (questionToken.kind !== 57 /* QuestionToken */) {
- parseExpected(57 /* QuestionToken */);
+ if (questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) {
+ parseExpected(57 /* SyntaxKind.QuestionToken */);
}
}
var type = parseTypeAnnotation();
parseSemicolon();
- var members = parseList(4 /* TypeMembers */, parseTypeMember);
- parseExpected(19 /* CloseBraceToken */);
+ var members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember);
+ parseExpected(19 /* SyntaxKind.CloseBraceToken */);
return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members), pos);
}
function parseTupleElementType() {
var pos = getNodePos();
- if (parseOptional(25 /* DotDotDotToken */)) {
+ if (parseOptional(25 /* SyntaxKind.DotDotDotToken */)) {
return finishNode(factory.createRestTypeNode(parseType()), pos);
}
var type = parseType();
@@ -33128,10 +33824,10 @@ var ts;
return type;
}
function isNextTokenColonOrQuestionColon() {
- return nextToken() === 58 /* ColonToken */ || (token() === 57 /* QuestionToken */ && nextToken() === 58 /* ColonToken */);
+ return nextToken() === 58 /* SyntaxKind.ColonToken */ || (token() === 57 /* SyntaxKind.QuestionToken */ && nextToken() === 58 /* SyntaxKind.ColonToken */);
}
function isTupleElementName() {
- if (token() === 25 /* DotDotDotToken */) {
+ if (token() === 25 /* SyntaxKind.DotDotDotToken */) {
return ts.tokenIsIdentifierOrKeyword(nextToken()) && isNextTokenColonOrQuestionColon();
}
return ts.tokenIsIdentifierOrKeyword(token()) && isNextTokenColonOrQuestionColon();
@@ -33140,10 +33836,10 @@ var ts;
if (lookAhead(isTupleElementName)) {
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
- var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */);
+ var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */);
var name = parseIdentifierName();
- var questionToken = parseOptionalToken(57 /* QuestionToken */);
- parseExpected(58 /* ColonToken */);
+ var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */);
+ parseExpected(58 /* SyntaxKind.ColonToken */);
var type = parseTupleElementType();
var node = factory.createNamedTupleMember(dotDotDotToken, name, questionToken, type);
return withJSDoc(finishNode(node, pos), hasJSDoc);
@@ -33152,21 +33848,21 @@ var ts;
}
function parseTupleType() {
var pos = getNodePos();
- return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */)), pos);
+ return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* ParsingContext.TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */)), pos);
}
function parseParenthesizedType() {
var pos = getNodePos();
- parseExpected(20 /* OpenParenToken */);
+ parseExpected(20 /* SyntaxKind.OpenParenToken */);
var type = parseType();
- parseExpected(21 /* CloseParenToken */);
+ parseExpected(21 /* SyntaxKind.CloseParenToken */);
return finishNode(factory.createParenthesizedType(type), pos);
}
function parseModifiersForConstructorType() {
var modifiers;
- if (token() === 126 /* AbstractKeyword */) {
+ if (token() === 126 /* SyntaxKind.AbstractKeyword */) {
var pos = getNodePos();
nextToken();
- var modifier = finishNode(factory.createToken(126 /* AbstractKeyword */), pos);
+ var modifier = finishNode(factory.createToken(126 /* SyntaxKind.AbstractKeyword */), pos);
modifiers = createNodeArray([modifier], pos);
}
return modifiers;
@@ -33175,10 +33871,10 @@ var ts;
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
var modifiers = parseModifiersForConstructorType();
- var isConstructorType = parseOptional(103 /* NewKeyword */);
+ var isConstructorType = parseOptional(103 /* SyntaxKind.NewKeyword */);
var typeParameters = parseTypeParameters();
- var parameters = parseParameters(4 /* Type */);
- var type = parseReturnType(38 /* EqualsGreaterThanToken */, /*isType*/ false);
+ var parameters = parseParameters(4 /* SignatureFlags.Type */);
+ var type = parseReturnType(38 /* SyntaxKind.EqualsGreaterThanToken */, /*isType*/ false);
var node = isConstructorType
? factory.createConstructorTypeNode(modifiers, typeParameters, parameters, type)
: factory.createFunctionTypeNode(typeParameters, parameters, type);
@@ -33188,105 +33884,125 @@ var ts;
}
function parseKeywordAndNoDot() {
var node = parseTokenNode();
- return token() === 24 /* DotToken */ ? undefined : node;
+ return token() === 24 /* SyntaxKind.DotToken */ ? undefined : node;
}
function parseLiteralTypeNode(negative) {
var pos = getNodePos();
if (negative) {
nextToken();
}
- var expression = token() === 110 /* TrueKeyword */ || token() === 95 /* FalseKeyword */ || token() === 104 /* NullKeyword */ ?
+ var expression = token() === 110 /* SyntaxKind.TrueKeyword */ || token() === 95 /* SyntaxKind.FalseKeyword */ || token() === 104 /* SyntaxKind.NullKeyword */ ?
parseTokenNode() :
parseLiteralLikeNode(token());
if (negative) {
- expression = finishNode(factory.createPrefixUnaryExpression(40 /* MinusToken */, expression), pos);
+ expression = finishNode(factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, expression), pos);
}
return finishNode(factory.createLiteralTypeNode(expression), pos);
}
function isStartOfTypeOfImportType() {
nextToken();
- return token() === 100 /* ImportKeyword */;
+ return token() === 100 /* SyntaxKind.ImportKeyword */;
+ }
+ function parseImportTypeAssertions() {
+ var pos = getNodePos();
+ var openBracePosition = scanner.getTokenPos();
+ parseExpected(18 /* SyntaxKind.OpenBraceToken */);
+ var multiLine = scanner.hasPrecedingLineBreak();
+ parseExpected(129 /* SyntaxKind.AssertKeyword */);
+ parseExpected(58 /* SyntaxKind.ColonToken */);
+ var clause = parseAssertClause(/*skipAssertKeyword*/ true);
+ if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) {
+ var lastError = ts.lastOrUndefined(parseDiagnostics);
+ if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
+ ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}"));
+ }
+ }
+ return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos);
}
function parseImportType() {
- sourceFlags |= 1048576 /* PossiblyContainsDynamicImport */;
+ sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */;
var pos = getNodePos();
- var isTypeOf = parseOptional(112 /* TypeOfKeyword */);
- parseExpected(100 /* ImportKeyword */);
- parseExpected(20 /* OpenParenToken */);
+ var isTypeOf = parseOptional(112 /* SyntaxKind.TypeOfKeyword */);
+ parseExpected(100 /* SyntaxKind.ImportKeyword */);
+ parseExpected(20 /* SyntaxKind.OpenParenToken */);
var type = parseType();
- parseExpected(21 /* CloseParenToken */);
- var qualifier = parseOptional(24 /* DotToken */) ? parseEntityNameOfTypeReference() : undefined;
+ var assertions;
+ if (parseOptional(27 /* SyntaxKind.CommaToken */)) {
+ assertions = parseImportTypeAssertions();
+ }
+ parseExpected(21 /* SyntaxKind.CloseParenToken */);
+ var qualifier = parseOptional(24 /* SyntaxKind.DotToken */) ? parseEntityNameOfTypeReference() : undefined;
var typeArguments = parseTypeArgumentsOfTypeReference();
- return finishNode(factory.createImportTypeNode(type, qualifier, typeArguments, isTypeOf), pos);
+ return finishNode(factory.createImportTypeNode(type, assertions, qualifier, typeArguments, isTypeOf), pos);
}
function nextTokenIsNumericOrBigIntLiteral() {
nextToken();
- return token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */;
+ return token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */;
}
function parseNonArrayType() {
switch (token()) {
- case 130 /* AnyKeyword */:
- case 154 /* UnknownKeyword */:
- case 149 /* StringKeyword */:
- case 146 /* NumberKeyword */:
- case 157 /* BigIntKeyword */:
- case 150 /* SymbolKeyword */:
- case 133 /* BooleanKeyword */:
- case 152 /* UndefinedKeyword */:
- case 143 /* NeverKeyword */:
- case 147 /* ObjectKeyword */:
+ case 130 /* SyntaxKind.AnyKeyword */:
+ case 155 /* SyntaxKind.UnknownKeyword */:
+ case 150 /* SyntaxKind.StringKeyword */:
+ case 147 /* SyntaxKind.NumberKeyword */:
+ case 158 /* SyntaxKind.BigIntKeyword */:
+ case 151 /* SyntaxKind.SymbolKeyword */:
+ case 133 /* SyntaxKind.BooleanKeyword */:
+ case 153 /* SyntaxKind.UndefinedKeyword */:
+ case 143 /* SyntaxKind.NeverKeyword */:
+ case 148 /* SyntaxKind.ObjectKeyword */:
// If these are followed by a dot, then parse these out as a dotted type reference instead.
return tryParse(parseKeywordAndNoDot) || parseTypeReference();
- case 66 /* AsteriskEqualsToken */:
+ case 66 /* SyntaxKind.AsteriskEqualsToken */:
// If there is '*=', treat it as * followed by postfix =
scanner.reScanAsteriskEqualsToken();
// falls through
- case 41 /* AsteriskToken */:
+ case 41 /* SyntaxKind.AsteriskToken */:
return parseJSDocAllType();
- case 60 /* QuestionQuestionToken */:
+ case 60 /* SyntaxKind.QuestionQuestionToken */:
// If there is '??', treat it as prefix-'?' in JSDoc type.
scanner.reScanQuestionToken();
// falls through
- case 57 /* QuestionToken */:
+ case 57 /* SyntaxKind.QuestionToken */:
return parseJSDocUnknownOrNullableType();
- case 98 /* FunctionKeyword */:
+ case 98 /* SyntaxKind.FunctionKeyword */:
return parseJSDocFunctionType();
- case 53 /* ExclamationToken */:
+ case 53 /* SyntaxKind.ExclamationToken */:
return parseJSDocNonNullableType();
- case 14 /* NoSubstitutionTemplateLiteral */:
- case 10 /* StringLiteral */:
- case 8 /* NumericLiteral */:
- case 9 /* BigIntLiteral */:
- case 110 /* TrueKeyword */:
- case 95 /* FalseKeyword */:
- case 104 /* NullKeyword */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
+ case 9 /* SyntaxKind.BigIntLiteral */:
+ case 110 /* SyntaxKind.TrueKeyword */:
+ case 95 /* SyntaxKind.FalseKeyword */:
+ case 104 /* SyntaxKind.NullKeyword */:
return parseLiteralTypeNode();
- case 40 /* MinusToken */:
+ case 40 /* SyntaxKind.MinusToken */:
return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference();
- case 114 /* VoidKeyword */:
+ case 114 /* SyntaxKind.VoidKeyword */:
return parseTokenNode();
- case 108 /* ThisKeyword */: {
+ case 108 /* SyntaxKind.ThisKeyword */: {
var thisKeyword = parseThisTypeNode();
- if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) {
+ if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) {
return parseThisTypePredicate(thisKeyword);
}
else {
return thisKeyword;
}
}
- case 112 /* TypeOfKeyword */:
+ case 112 /* SyntaxKind.TypeOfKeyword */:
return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery();
- case 18 /* OpenBraceToken */:
+ case 18 /* SyntaxKind.OpenBraceToken */:
return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral();
- case 22 /* OpenBracketToken */:
+ case 22 /* SyntaxKind.OpenBracketToken */:
return parseTupleType();
- case 20 /* OpenParenToken */:
+ case 20 /* SyntaxKind.OpenParenToken */:
return parseParenthesizedType();
- case 100 /* ImportKeyword */:
+ case 100 /* SyntaxKind.ImportKeyword */:
return parseImportType();
- case 128 /* AssertsKeyword */:
+ case 128 /* SyntaxKind.AssertsKeyword */:
return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference();
- case 15 /* TemplateHead */:
+ case 15 /* SyntaxKind.TemplateHead */:
return parseTemplateType();
default:
return parseTypeReference();
@@ -33294,48 +34010,48 @@ var ts;
}
function isStartOfType(inStartOfParameter) {
switch (token()) {
- case 130 /* AnyKeyword */:
- case 154 /* UnknownKeyword */:
- case 149 /* StringKeyword */:
- case 146 /* NumberKeyword */:
- case 157 /* BigIntKeyword */:
- case 133 /* BooleanKeyword */:
- case 144 /* ReadonlyKeyword */:
- case 150 /* SymbolKeyword */:
- case 153 /* UniqueKeyword */:
- case 114 /* VoidKeyword */:
- case 152 /* UndefinedKeyword */:
- case 104 /* NullKeyword */:
- case 108 /* ThisKeyword */:
- case 112 /* TypeOfKeyword */:
- case 143 /* NeverKeyword */:
- case 18 /* OpenBraceToken */:
- case 22 /* OpenBracketToken */:
- case 29 /* LessThanToken */:
- case 51 /* BarToken */:
- case 50 /* AmpersandToken */:
- case 103 /* NewKeyword */:
- case 10 /* StringLiteral */:
- case 8 /* NumericLiteral */:
- case 9 /* BigIntLiteral */:
- case 110 /* TrueKeyword */:
- case 95 /* FalseKeyword */:
- case 147 /* ObjectKeyword */:
- case 41 /* AsteriskToken */:
- case 57 /* QuestionToken */:
- case 53 /* ExclamationToken */:
- case 25 /* DotDotDotToken */:
- case 137 /* InferKeyword */:
- case 100 /* ImportKeyword */:
- case 128 /* AssertsKeyword */:
- case 14 /* NoSubstitutionTemplateLiteral */:
- case 15 /* TemplateHead */:
+ case 130 /* SyntaxKind.AnyKeyword */:
+ case 155 /* SyntaxKind.UnknownKeyword */:
+ case 150 /* SyntaxKind.StringKeyword */:
+ case 147 /* SyntaxKind.NumberKeyword */:
+ case 158 /* SyntaxKind.BigIntKeyword */:
+ case 133 /* SyntaxKind.BooleanKeyword */:
+ case 145 /* SyntaxKind.ReadonlyKeyword */:
+ case 151 /* SyntaxKind.SymbolKeyword */:
+ case 154 /* SyntaxKind.UniqueKeyword */:
+ case 114 /* SyntaxKind.VoidKeyword */:
+ case 153 /* SyntaxKind.UndefinedKeyword */:
+ case 104 /* SyntaxKind.NullKeyword */:
+ case 108 /* SyntaxKind.ThisKeyword */:
+ case 112 /* SyntaxKind.TypeOfKeyword */:
+ case 143 /* SyntaxKind.NeverKeyword */:
+ case 18 /* SyntaxKind.OpenBraceToken */:
+ case 22 /* SyntaxKind.OpenBracketToken */:
+ case 29 /* SyntaxKind.LessThanToken */:
+ case 51 /* SyntaxKind.BarToken */:
+ case 50 /* SyntaxKind.AmpersandToken */:
+ case 103 /* SyntaxKind.NewKeyword */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
+ case 9 /* SyntaxKind.BigIntLiteral */:
+ case 110 /* SyntaxKind.TrueKeyword */:
+ case 95 /* SyntaxKind.FalseKeyword */:
+ case 148 /* SyntaxKind.ObjectKeyword */:
+ case 41 /* SyntaxKind.AsteriskToken */:
+ case 57 /* SyntaxKind.QuestionToken */:
+ case 53 /* SyntaxKind.ExclamationToken */:
+ case 25 /* SyntaxKind.DotDotDotToken */:
+ case 137 /* SyntaxKind.InferKeyword */:
+ case 100 /* SyntaxKind.ImportKeyword */:
+ case 128 /* SyntaxKind.AssertsKeyword */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
+ case 15 /* SyntaxKind.TemplateHead */:
return true;
- case 98 /* FunctionKeyword */:
+ case 98 /* SyntaxKind.FunctionKeyword */:
return !inStartOfParameter;
- case 40 /* MinusToken */:
+ case 40 /* SyntaxKind.MinusToken */:
return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral);
- case 20 /* OpenParenToken */:
+ case 20 /* SyntaxKind.OpenParenToken */:
// Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier,
// or something that starts a type. We don't want to consider things like '(1)' a type.
return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType);
@@ -33345,34 +34061,34 @@ var ts;
}
function isStartOfParenthesizedOrFunctionType() {
nextToken();
- return token() === 21 /* CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType();
+ return token() === 21 /* SyntaxKind.CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType();
}
function parsePostfixTypeOrHigher() {
var pos = getNodePos();
var type = parseNonArrayType();
while (!scanner.hasPrecedingLineBreak()) {
switch (token()) {
- case 53 /* ExclamationToken */:
+ case 53 /* SyntaxKind.ExclamationToken */:
nextToken();
- type = finishNode(factory.createJSDocNonNullableType(type), pos);
+ type = finishNode(factory.createJSDocNonNullableType(type, /*postfix*/ true), pos);
break;
- case 57 /* QuestionToken */:
+ case 57 /* SyntaxKind.QuestionToken */:
// If next token is start of a type we have a conditional type
if (lookAhead(nextTokenIsStartOfType)) {
return type;
}
nextToken();
- type = finishNode(factory.createJSDocNullableType(type), pos);
+ type = finishNode(factory.createJSDocNullableType(type, /*postfix*/ true), pos);
break;
- case 22 /* OpenBracketToken */:
- parseExpected(22 /* OpenBracketToken */);
+ case 22 /* SyntaxKind.OpenBracketToken */:
+ parseExpected(22 /* SyntaxKind.OpenBracketToken */);
if (isStartOfType()) {
var indexType = parseType();
- parseExpected(23 /* CloseBracketToken */);
+ parseExpected(23 /* SyntaxKind.CloseBracketToken */);
type = finishNode(factory.createIndexedAccessTypeNode(type, indexType), pos);
}
else {
- parseExpected(23 /* CloseBracketToken */);
+ parseExpected(23 /* SyntaxKind.CloseBracketToken */);
type = finishNode(factory.createArrayTypeNode(type), pos);
}
break;
@@ -33387,28 +34103,37 @@ var ts;
parseExpected(operator);
return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos);
}
+ function tryParseConstraintOfInferType() {
+ if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) {
+ var constraint = disallowConditionalTypesAnd(parseType);
+ if (inDisallowConditionalTypesContext() || token() !== 57 /* SyntaxKind.QuestionToken */) {
+ return constraint;
+ }
+ }
+ }
function parseTypeParameterOfInferType() {
var pos = getNodePos();
- return finishNode(factory.createTypeParameterDeclaration(parseIdentifier(),
- /*constraint*/ undefined,
- /*defaultType*/ undefined), pos);
+ var name = parseIdentifier();
+ var constraint = tryParse(tryParseConstraintOfInferType);
+ var node = factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, constraint);
+ return finishNode(node, pos);
}
function parseInferType() {
var pos = getNodePos();
- parseExpected(137 /* InferKeyword */);
+ parseExpected(137 /* SyntaxKind.InferKeyword */);
return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos);
}
function parseTypeOperatorOrHigher() {
var operator = token();
switch (operator) {
- case 140 /* KeyOfKeyword */:
- case 153 /* UniqueKeyword */:
- case 144 /* ReadonlyKeyword */:
+ case 140 /* SyntaxKind.KeyOfKeyword */:
+ case 154 /* SyntaxKind.UniqueKeyword */:
+ case 145 /* SyntaxKind.ReadonlyKeyword */:
return parseTypeOperator(operator);
- case 137 /* InferKeyword */:
+ case 137 /* SyntaxKind.InferKeyword */:
return parseInferType();
}
- return parsePostfixTypeOrHigher();
+ return allowConditionalTypesAnd(parsePostfixTypeOrHigher);
}
function parseFunctionOrConstructorTypeToError(isInUnionType) {
// the function type and constructor type shorthand notation
@@ -33434,7 +34159,7 @@ var ts;
}
function parseUnionOrIntersectionType(operator, parseConstituentType, createTypeNode) {
var pos = getNodePos();
- var isUnionType = operator === 51 /* BarToken */;
+ var isUnionType = operator === 51 /* SyntaxKind.BarToken */;
var hasLeadingOperator = parseOptional(operator);
var type = hasLeadingOperator && parseFunctionOrConstructorTypeToError(isUnionType)
|| parseConstituentType();
@@ -33448,35 +34173,35 @@ var ts;
return type;
}
function parseIntersectionTypeOrHigher() {
- return parseUnionOrIntersectionType(50 /* AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode);
+ return parseUnionOrIntersectionType(50 /* SyntaxKind.AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode);
}
function parseUnionTypeOrHigher() {
- return parseUnionOrIntersectionType(51 /* BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode);
+ return parseUnionOrIntersectionType(51 /* SyntaxKind.BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode);
}
function nextTokenIsNewKeyword() {
nextToken();
- return token() === 103 /* NewKeyword */;
+ return token() === 103 /* SyntaxKind.NewKeyword */;
}
function isStartOfFunctionTypeOrConstructorType() {
- if (token() === 29 /* LessThanToken */) {
+ if (token() === 29 /* SyntaxKind.LessThanToken */) {
return true;
}
- if (token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) {
+ if (token() === 20 /* SyntaxKind.OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) {
return true;
}
- return token() === 103 /* NewKeyword */ ||
- token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword);
+ return token() === 103 /* SyntaxKind.NewKeyword */ ||
+ token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword);
}
function skipParameterStart() {
if (ts.isModifierKind(token())) {
// Skip modifiers
parseModifiers();
}
- if (isIdentifier() || token() === 108 /* ThisKeyword */) {
+ if (isIdentifier() || token() === 108 /* SyntaxKind.ThisKeyword */) {
nextToken();
return true;
}
- if (token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */) {
+ if (token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */) {
// Return true if we can parse an array or object binding pattern with no errors
var previousErrorCount = parseDiagnostics.length;
parseIdentifierOrPattern();
@@ -33486,7 +34211,7 @@ var ts;
}
function isUnambiguouslyStartOfFunctionType() {
nextToken();
- if (token() === 21 /* CloseParenToken */ || token() === 25 /* DotDotDotToken */) {
+ if (token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */) {
// ( )
// ( ...
return true;
@@ -33494,17 +34219,17 @@ var ts;
if (skipParameterStart()) {
// We successfully skipped modifiers (if any) and an identifier or binding pattern,
// now see if we have something that indicates a parameter declaration
- if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ ||
- token() === 57 /* QuestionToken */ || token() === 63 /* EqualsToken */) {
+ if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ ||
+ token() === 57 /* SyntaxKind.QuestionToken */ || token() === 63 /* SyntaxKind.EqualsToken */) {
// ( xxx :
// ( xxx ,
// ( xxx ?
// ( xxx =
return true;
}
- if (token() === 21 /* CloseParenToken */) {
+ if (token() === 21 /* SyntaxKind.CloseParenToken */) {
nextToken();
- if (token() === 38 /* EqualsGreaterThanToken */) {
+ if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) {
// ( xxx ) =>
return true;
}
@@ -33525,67 +34250,65 @@ var ts;
}
function parseTypePredicatePrefix() {
var id = parseIdentifier();
- if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) {
+ if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) {
nextToken();
return id;
}
}
function parseAssertsTypePredicate() {
var pos = getNodePos();
- var assertsModifier = parseExpectedToken(128 /* AssertsKeyword */);
- var parameterName = token() === 108 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier();
- var type = parseOptional(139 /* IsKeyword */) ? parseType() : undefined;
+ var assertsModifier = parseExpectedToken(128 /* SyntaxKind.AssertsKeyword */);
+ var parameterName = token() === 108 /* SyntaxKind.ThisKeyword */ ? parseThisTypeNode() : parseIdentifier();
+ var type = parseOptional(139 /* SyntaxKind.IsKeyword */) ? parseType() : undefined;
return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos);
}
function parseType() {
- // The rules about 'yield' only apply to actual code/expression contexts. They don't
- // apply to 'type' contexts. So we disable these parameters here before moving on.
- return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseTypeWorker);
- }
- function parseTypeWorker(noConditionalTypes) {
+ if (contextFlags & 40960 /* NodeFlags.TypeExcludesFlags */) {
+ return doOutsideOfContext(40960 /* NodeFlags.TypeExcludesFlags */, parseType);
+ }
if (isStartOfFunctionTypeOrConstructorType()) {
return parseFunctionOrConstructorType();
}
var pos = getNodePos();
var type = parseUnionTypeOrHigher();
- if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) {
+ if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) {
// The type following 'extends' is not permitted to be another conditional type
- var extendsType = parseTypeWorker(/*noConditionalTypes*/ true);
- parseExpected(57 /* QuestionToken */);
- var trueType = parseTypeWorker();
- parseExpected(58 /* ColonToken */);
- var falseType = parseTypeWorker();
+ var extendsType = disallowConditionalTypesAnd(parseType);
+ parseExpected(57 /* SyntaxKind.QuestionToken */);
+ var trueType = allowConditionalTypesAnd(parseType);
+ parseExpected(58 /* SyntaxKind.ColonToken */);
+ var falseType = allowConditionalTypesAnd(parseType);
return finishNode(factory.createConditionalTypeNode(type, extendsType, trueType, falseType), pos);
}
return type;
}
function parseTypeAnnotation() {
- return parseOptional(58 /* ColonToken */) ? parseType() : undefined;
+ return parseOptional(58 /* SyntaxKind.ColonToken */) ? parseType() : undefined;
}
// EXPRESSIONS
function isStartOfLeftHandSideExpression() {
switch (token()) {
- case 108 /* ThisKeyword */:
- case 106 /* SuperKeyword */:
- case 104 /* NullKeyword */:
- case 110 /* TrueKeyword */:
- case 95 /* FalseKeyword */:
- case 8 /* NumericLiteral */:
- case 9 /* BigIntLiteral */:
- case 10 /* StringLiteral */:
- case 14 /* NoSubstitutionTemplateLiteral */:
- case 15 /* TemplateHead */:
- case 20 /* OpenParenToken */:
- case 22 /* OpenBracketToken */:
- case 18 /* OpenBraceToken */:
- case 98 /* FunctionKeyword */:
- case 84 /* ClassKeyword */:
- case 103 /* NewKeyword */:
- case 43 /* SlashToken */:
- case 68 /* SlashEqualsToken */:
- case 79 /* Identifier */:
+ case 108 /* SyntaxKind.ThisKeyword */:
+ case 106 /* SyntaxKind.SuperKeyword */:
+ case 104 /* SyntaxKind.NullKeyword */:
+ case 110 /* SyntaxKind.TrueKeyword */:
+ case 95 /* SyntaxKind.FalseKeyword */:
+ case 8 /* SyntaxKind.NumericLiteral */:
+ case 9 /* SyntaxKind.BigIntLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
+ case 15 /* SyntaxKind.TemplateHead */:
+ case 20 /* SyntaxKind.OpenParenToken */:
+ case 22 /* SyntaxKind.OpenBracketToken */:
+ case 18 /* SyntaxKind.OpenBraceToken */:
+ case 98 /* SyntaxKind.FunctionKeyword */:
+ case 84 /* SyntaxKind.ClassKeyword */:
+ case 103 /* SyntaxKind.NewKeyword */:
+ case 43 /* SyntaxKind.SlashToken */:
+ case 68 /* SyntaxKind.SlashEqualsToken */:
+ case 79 /* SyntaxKind.Identifier */:
return true;
- case 100 /* ImportKeyword */:
+ case 100 /* SyntaxKind.ImportKeyword */:
return lookAhead(nextTokenIsOpenParenOrLessThanOrDot);
default:
return isIdentifier();
@@ -33596,19 +34319,19 @@ var ts;
return true;
}
switch (token()) {
- case 39 /* PlusToken */:
- case 40 /* MinusToken */:
- case 54 /* TildeToken */:
- case 53 /* ExclamationToken */:
- case 89 /* DeleteKeyword */:
- case 112 /* TypeOfKeyword */:
- case 114 /* VoidKeyword */:
- case 45 /* PlusPlusToken */:
- case 46 /* MinusMinusToken */:
- case 29 /* LessThanToken */:
- case 132 /* AwaitKeyword */:
- case 125 /* YieldKeyword */:
- case 80 /* PrivateIdentifier */:
+ case 39 /* SyntaxKind.PlusToken */:
+ case 40 /* SyntaxKind.MinusToken */:
+ case 54 /* SyntaxKind.TildeToken */:
+ case 53 /* SyntaxKind.ExclamationToken */:
+ case 89 /* SyntaxKind.DeleteKeyword */:
+ case 112 /* SyntaxKind.TypeOfKeyword */:
+ case 114 /* SyntaxKind.VoidKeyword */:
+ case 45 /* SyntaxKind.PlusPlusToken */:
+ case 46 /* SyntaxKind.MinusMinusToken */:
+ case 29 /* SyntaxKind.LessThanToken */:
+ case 132 /* SyntaxKind.AwaitKeyword */:
+ case 125 /* SyntaxKind.YieldKeyword */:
+ case 80 /* SyntaxKind.PrivateIdentifier */:
// Yield/await always starts an expression. Either it is an identifier (in which case
// it is definitely an expression). Or it's a keyword (either because we're in
// a generator or async function, or in strict mode (or both)) and it started a yield or await expression.
@@ -33626,10 +34349,10 @@ var ts;
}
function isStartOfExpressionStatement() {
// As per the grammar, none of '{' or 'function' or 'class' can start an expression statement.
- return token() !== 18 /* OpenBraceToken */ &&
- token() !== 98 /* FunctionKeyword */ &&
- token() !== 84 /* ClassKeyword */ &&
- token() !== 59 /* AtToken */ &&
+ return token() !== 18 /* SyntaxKind.OpenBraceToken */ &&
+ token() !== 98 /* SyntaxKind.FunctionKeyword */ &&
+ token() !== 84 /* SyntaxKind.ClassKeyword */ &&
+ token() !== 59 /* SyntaxKind.AtToken */ &&
isStartOfExpression();
}
function parseExpression() {
@@ -33644,7 +34367,7 @@ var ts;
var pos = getNodePos();
var expr = parseAssignmentExpressionOrHigher();
var operatorToken;
- while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) {
+ while ((operatorToken = parseOptionalToken(27 /* SyntaxKind.CommaToken */))) {
expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(), pos);
}
if (saveDecoratorContext) {
@@ -33653,7 +34376,7 @@ var ts;
return expr;
}
function parseInitializer() {
- return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined;
+ return parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined;
}
function parseAssignmentExpressionOrHigher() {
// AssignmentExpression[in,yield]:
@@ -33695,11 +34418,11 @@ var ts;
// binary expression here, so we pass in the 'lowest' precedence here so that it matches
// and consumes anything.
var pos = getNodePos();
- var expr = parseBinaryExpressionOrHigher(0 /* Lowest */);
+ var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */);
// To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized
// parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single
// identifier and the current token is an arrow.
- if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) {
+ if (expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) {
return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined);
}
// Now see if we might be in cases '2' or '3'.
@@ -33715,7 +34438,7 @@ var ts;
return parseConditionalExpressionRest(expr, pos);
}
function isYieldExpression() {
- if (token() === 125 /* YieldKeyword */) {
+ if (token() === 125 /* SyntaxKind.YieldKeyword */) {
// If we have a 'yield' keyword, and this is a context where yield expressions are
// allowed, then definitely parse out a yield expression.
if (inYieldContext()) {
@@ -33751,8 +34474,8 @@ var ts;
// yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield]
nextToken();
if (!scanner.hasPrecedingLineBreak() &&
- (token() === 41 /* AsteriskToken */ || isStartOfExpression())) {
- return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher()), pos);
+ (token() === 41 /* SyntaxKind.AsteriskToken */ || isStartOfExpression())) {
+ return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* SyntaxKind.AsteriskToken */), parseAssignmentExpressionOrHigher()), pos);
}
else {
// if the next token is not on the same line as yield. or we don't have an '*' or
@@ -33761,7 +34484,7 @@ var ts;
}
}
function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) {
- ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
+ ts.Debug.assert(token() === 38 /* SyntaxKind.EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
var parameter = factory.createParameterDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined,
@@ -33771,14 +34494,14 @@ var ts;
/*initializer*/ undefined);
finishNode(parameter, identifier.pos);
var parameters = createNodeArray([parameter], parameter.pos, parameter.end);
- var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
+ var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */);
var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier);
var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body);
return addJSDocComment(finishNode(node, pos));
}
function tryParseParenthesizedArrowFunctionExpression() {
var triState = isParenthesizedArrowFunctionExpression();
- if (triState === 0 /* False */) {
+ if (triState === 0 /* Tristate.False */) {
// It's definitely not a parenthesized arrow function expression.
return undefined;
}
@@ -33786,7 +34509,7 @@ var ts;
// following => or { token. Otherwise, we *might* have an arrow function. Try to parse
// it out, but don't allow any ambiguity, and return 'undefined' if this could be an
// expression instead.
- return triState === 1 /* True */ ?
+ return triState === 1 /* Tristate.True */ ?
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) :
tryParse(parsePossibleParenthesizedArrowFunctionExpression);
}
@@ -33795,44 +34518,44 @@ var ts;
// Unknown -> There *might* be a parenthesized arrow function here.
// Speculatively look ahead to be sure, and rollback if not.
function isParenthesizedArrowFunctionExpression() {
- if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 131 /* AsyncKeyword */) {
+ if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */ || token() === 131 /* SyntaxKind.AsyncKeyword */) {
return lookAhead(isParenthesizedArrowFunctionExpressionWorker);
}
- if (token() === 38 /* EqualsGreaterThanToken */) {
+ if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) {
// ERROR RECOVERY TWEAK:
// If we see a standalone => try to parse it as an arrow function expression as that's
// likely what the user intended to write.
- return 1 /* True */;
+ return 1 /* Tristate.True */;
}
// Definitely not a parenthesized arrow function.
- return 0 /* False */;
+ return 0 /* Tristate.False */;
}
function isParenthesizedArrowFunctionExpressionWorker() {
- if (token() === 131 /* AsyncKeyword */) {
+ if (token() === 131 /* SyntaxKind.AsyncKeyword */) {
nextToken();
if (scanner.hasPrecedingLineBreak()) {
- return 0 /* False */;
+ return 0 /* Tristate.False */;
}
- if (token() !== 20 /* OpenParenToken */ && token() !== 29 /* LessThanToken */) {
- return 0 /* False */;
+ if (token() !== 20 /* SyntaxKind.OpenParenToken */ && token() !== 29 /* SyntaxKind.LessThanToken */) {
+ return 0 /* Tristate.False */;
}
}
var first = token();
var second = nextToken();
- if (first === 20 /* OpenParenToken */) {
- if (second === 21 /* CloseParenToken */) {
+ if (first === 20 /* SyntaxKind.OpenParenToken */) {
+ if (second === 21 /* SyntaxKind.CloseParenToken */) {
// Simple cases: "() =>", "(): ", and "() {".
// This is an arrow function with no parameters.
// The last one is not actually an arrow function,
// but this is probably what the user intended.
var third = nextToken();
switch (third) {
- case 38 /* EqualsGreaterThanToken */:
- case 58 /* ColonToken */:
- case 18 /* OpenBraceToken */:
- return 1 /* True */;
+ case 38 /* SyntaxKind.EqualsGreaterThanToken */:
+ case 58 /* SyntaxKind.ColonToken */:
+ case 18 /* SyntaxKind.OpenBraceToken */:
+ return 1 /* Tristate.True */;
default:
- return 0 /* False */;
+ return 0 /* Tristate.False */;
}
}
// If encounter "([" or "({", this could be the start of a binding pattern.
@@ -33841,81 +34564,85 @@ var ts;
// ({ x }) => { }
// ([ x ])
// ({ x })
- if (second === 22 /* OpenBracketToken */ || second === 18 /* OpenBraceToken */) {
- return 2 /* Unknown */;
+ if (second === 22 /* SyntaxKind.OpenBracketToken */ || second === 18 /* SyntaxKind.OpenBraceToken */) {
+ return 2 /* Tristate.Unknown */;
}
// Simple case: "(..."
// This is an arrow function with a rest parameter.
- if (second === 25 /* DotDotDotToken */) {
- return 1 /* True */;
+ if (second === 25 /* SyntaxKind.DotDotDotToken */) {
+ return 1 /* Tristate.True */;
}
// Check for "(xxx yyy", where xxx is a modifier and yyy is an identifier. This
// isn't actually allowed, but we want to treat it as a lambda so we can provide
// a good error message.
- if (ts.isModifierKind(second) && second !== 131 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) {
- return 1 /* True */;
+ if (ts.isModifierKind(second) && second !== 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) {
+ if (lookAhead(function () { return nextToken() === 127 /* SyntaxKind.AsKeyword */; })) {
+ // https://github.com/microsoft/TypeScript/issues/44466
+ return 0 /* Tristate.False */;
+ }
+ return 1 /* Tristate.True */;
}
// If we had "(" followed by something that's not an identifier,
// then this definitely doesn't look like a lambda. "this" is not
// valid, but we want to parse it and then give a semantic error.
- if (!isIdentifier() && second !== 108 /* ThisKeyword */) {
- return 0 /* False */;
+ if (!isIdentifier() && second !== 108 /* SyntaxKind.ThisKeyword */) {
+ return 0 /* Tristate.False */;
}
switch (nextToken()) {
- case 58 /* ColonToken */:
+ case 58 /* SyntaxKind.ColonToken */:
// If we have something like "(a:", then we must have a
// type-annotated parameter in an arrow function expression.
- return 1 /* True */;
- case 57 /* QuestionToken */:
+ return 1 /* Tristate.True */;
+ case 57 /* SyntaxKind.QuestionToken */:
nextToken();
// If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda.
- if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 63 /* EqualsToken */ || token() === 21 /* CloseParenToken */) {
- return 1 /* True */;
+ if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 63 /* SyntaxKind.EqualsToken */ || token() === 21 /* SyntaxKind.CloseParenToken */) {
+ return 1 /* Tristate.True */;
}
// Otherwise it is definitely not a lambda.
- return 0 /* False */;
- case 27 /* CommaToken */:
- case 63 /* EqualsToken */:
- case 21 /* CloseParenToken */:
+ return 0 /* Tristate.False */;
+ case 27 /* SyntaxKind.CommaToken */:
+ case 63 /* SyntaxKind.EqualsToken */:
+ case 21 /* SyntaxKind.CloseParenToken */:
// If we have "(a," or "(a=" or "(a)" this *could* be an arrow function
- return 2 /* Unknown */;
+ return 2 /* Tristate.Unknown */;
}
// It is definitely not an arrow function
- return 0 /* False */;
+ return 0 /* Tristate.False */;
}
else {
- ts.Debug.assert(first === 29 /* LessThanToken */);
+ ts.Debug.assert(first === 29 /* SyntaxKind.LessThanToken */);
// If we have "<" not followed by an identifier,
// then this definitely is not an arrow function.
if (!isIdentifier()) {
- return 0 /* False */;
+ return 0 /* Tristate.False */;
}
// JSX overrides
- if (languageVariant === 1 /* JSX */) {
+ if (languageVariant === 1 /* LanguageVariant.JSX */) {
var isArrowFunctionInJsx = lookAhead(function () {
var third = nextToken();
- if (third === 94 /* ExtendsKeyword */) {
+ if (third === 94 /* SyntaxKind.ExtendsKeyword */) {
var fourth = nextToken();
switch (fourth) {
- case 63 /* EqualsToken */:
- case 31 /* GreaterThanToken */:
+ case 63 /* SyntaxKind.EqualsToken */:
+ case 31 /* SyntaxKind.GreaterThanToken */:
return false;
default:
return true;
}
}
- else if (third === 27 /* CommaToken */ || third === 63 /* EqualsToken */) {
+ else if (third === 27 /* SyntaxKind.CommaToken */ || third === 63 /* SyntaxKind.EqualsToken */) {
return true;
}
return false;
});
if (isArrowFunctionInJsx) {
- return 1 /* True */;
+ return 1 /* Tristate.True */;
}
- return 0 /* False */;
+ return 0 /* Tristate.False */;
}
// This *could* be a parenthesized arrow function.
- return 2 /* Unknown */;
+ return 2 /* Tristate.Unknown */;
}
}
function parsePossibleParenthesizedArrowFunctionExpression() {
@@ -33931,11 +34658,11 @@ var ts;
}
function tryParseAsyncSimpleArrowFunctionExpression() {
// We do a check here so that we won't be doing unnecessarily call to "lookAhead"
- if (token() === 131 /* AsyncKeyword */) {
- if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) {
+ if (token() === 131 /* SyntaxKind.AsyncKeyword */) {
+ if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* Tristate.True */) {
var pos = getNodePos();
var asyncModifier = parseModifiersForArrowFunction();
- var expr = parseBinaryExpressionOrHigher(0 /* Lowest */);
+ var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */);
return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier);
}
}
@@ -33945,26 +34672,26 @@ var ts;
// AsyncArrowFunctionExpression:
// 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In]
// 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In]
- if (token() === 131 /* AsyncKeyword */) {
+ if (token() === 131 /* SyntaxKind.AsyncKeyword */) {
nextToken();
// If the "async" is followed by "=>" token then it is not a beginning of an async arrow-function
// but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher"
- if (scanner.hasPrecedingLineBreak() || token() === 38 /* EqualsGreaterThanToken */) {
- return 0 /* False */;
+ if (scanner.hasPrecedingLineBreak() || token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) {
+ return 0 /* Tristate.False */;
}
// Check for un-parenthesized AsyncArrowFunction
- var expr = parseBinaryExpressionOrHigher(0 /* Lowest */);
- if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) {
- return 1 /* True */;
+ var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */);
+ if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) {
+ return 1 /* Tristate.True */;
}
}
- return 0 /* False */;
+ return 0 /* Tristate.False */;
}
function parseParenthesizedArrowFunctionExpression(allowAmbiguity) {
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
var modifiers = parseModifiersForArrowFunction();
- var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */;
+ var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */;
// Arrow functions are never generators.
//
// If we're speculatively parsing a signature for a parenthesized arrow function, then
@@ -33974,19 +34701,28 @@ var ts;
// close paren.
var typeParameters = parseTypeParameters();
var parameters;
- if (!parseExpected(20 /* OpenParenToken */)) {
+ if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) {
if (!allowAmbiguity) {
return undefined;
}
parameters = createMissingList();
}
else {
- parameters = parseParametersWorker(isAsync);
- if (!parseExpected(21 /* CloseParenToken */) && !allowAmbiguity) {
+ if (!allowAmbiguity) {
+ var maybeParameters = parseParametersWorker(isAsync, allowAmbiguity);
+ if (!maybeParameters) {
+ return undefined;
+ }
+ parameters = maybeParameters;
+ }
+ else {
+ parameters = parseParametersWorker(isAsync, allowAmbiguity);
+ }
+ if (!parseExpected(21 /* SyntaxKind.CloseParenToken */) && !allowAmbiguity) {
return undefined;
}
}
- var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
+ var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false);
if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
return undefined;
}
@@ -34001,31 +34737,31 @@ var ts;
//
// So we need just a bit of lookahead to ensure that it can only be a signature.
var unwrappedType = type;
- while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 190 /* ParenthesizedType */) {
+ while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 191 /* SyntaxKind.ParenthesizedType */) {
unwrappedType = unwrappedType.type; // Skip parens if need be
}
var hasJSDocFunctionType = unwrappedType && ts.isJSDocFunctionType(unwrappedType);
- if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) {
+ if (!allowAmbiguity && token() !== 38 /* SyntaxKind.EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* SyntaxKind.OpenBraceToken */)) {
// Returning undefined here will cause our caller to rewind to where we started from.
return undefined;
}
// If we have an arrow, then try to parse the body. Even if not, try to parse if we
// have an opening brace, just in case we're in an error state.
var lastToken = token();
- var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
- var body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */)
+ var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */);
+ var body = (lastToken === 38 /* SyntaxKind.EqualsGreaterThanToken */ || lastToken === 18 /* SyntaxKind.OpenBraceToken */)
? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier))
: parseIdentifier();
var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
return withJSDoc(finishNode(node, pos), hasJSDoc);
}
function parseArrowFunctionExpressionBody(isAsync) {
- if (token() === 18 /* OpenBraceToken */) {
- return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */);
+ if (token() === 18 /* SyntaxKind.OpenBraceToken */) {
+ return parseFunctionBlock(isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */);
}
- if (token() !== 26 /* SemicolonToken */ &&
- token() !== 98 /* FunctionKeyword */ &&
- token() !== 84 /* ClassKeyword */ &&
+ if (token() !== 26 /* SyntaxKind.SemicolonToken */ &&
+ token() !== 98 /* SyntaxKind.FunctionKeyword */ &&
+ token() !== 84 /* SyntaxKind.ClassKeyword */ &&
isStartOfStatement() &&
!isStartOfExpressionStatement()) {
// Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations)
@@ -34042,7 +34778,7 @@ var ts;
// up preemptively closing the containing construct.
//
// Note: even when 'IgnoreMissingOpenBrace' is passed, parseBody will still error.
- return parseFunctionBlock(16 /* IgnoreMissingOpenBrace */ | (isAsync ? 2 /* Await */ : 0 /* None */));
+ return parseFunctionBlock(16 /* SignatureFlags.IgnoreMissingOpenBrace */ | (isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */));
}
var savedTopLevel = topLevel;
topLevel = false;
@@ -34054,16 +34790,16 @@ var ts;
}
function parseConditionalExpressionRest(leftOperand, pos) {
// Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher.
- var questionToken = parseOptionalToken(57 /* QuestionToken */);
+ var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */);
if (!questionToken) {
return leftOperand;
}
// Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and
// we do not that for the 'whenFalse' part.
var colonToken;
- return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
+ return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* SyntaxKind.ColonToken */), ts.nodeIsPresent(colonToken)
? parseAssignmentExpressionOrHigher()
- : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos);
+ : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */))), pos);
}
function parseBinaryExpressionOrHigher(precedence) {
var pos = getNodePos();
@@ -34071,7 +34807,7 @@ var ts;
return parseBinaryExpressionRest(precedence, leftOperand, pos);
}
function isInOrOfKeyword(t) {
- return t === 101 /* InKeyword */ || t === 159 /* OfKeyword */;
+ return t === 101 /* SyntaxKind.InKeyword */ || t === 160 /* SyntaxKind.OfKeyword */;
}
function parseBinaryExpressionRest(precedence, leftOperand, pos) {
while (true) {
@@ -34100,16 +34836,16 @@ var ts;
// ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand
// a ** b - c
// ^token; leftOperand = b. Return b to the caller as a rightOperand
- var consumeCurrentOperator = token() === 42 /* AsteriskAsteriskToken */ ?
+ var consumeCurrentOperator = token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ?
newPrecedence >= precedence :
newPrecedence > precedence;
if (!consumeCurrentOperator) {
break;
}
- if (token() === 101 /* InKeyword */ && inDisallowInContext()) {
+ if (token() === 101 /* SyntaxKind.InKeyword */ && inDisallowInContext()) {
break;
}
- if (token() === 127 /* AsKeyword */) {
+ if (token() === 127 /* SyntaxKind.AsKeyword */) {
// Make sure we *do* perform ASI for constructs like this:
// var x = foo
// as (Bar)
@@ -34130,7 +34866,7 @@ var ts;
return leftOperand;
}
function isBinaryOperator() {
- if (inDisallowInContext() && token() === 101 /* InKeyword */) {
+ if (inDisallowInContext() && token() === 101 /* SyntaxKind.InKeyword */) {
return false;
}
return ts.getBinaryOperatorPrecedence(token()) > 0;
@@ -34158,7 +34894,7 @@ var ts;
return finishNode(factory.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos);
}
function isAwaitExpression() {
- if (token() === 132 /* AwaitKeyword */) {
+ if (token() === 132 /* SyntaxKind.AwaitKeyword */) {
if (inAwaitContext()) {
return true;
}
@@ -34191,7 +34927,7 @@ var ts;
if (isUpdateExpression()) {
var pos = getNodePos();
var updateExpression = parseUpdateExpression();
- return token() === 42 /* AsteriskAsteriskToken */ ?
+ return token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ?
parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression, pos) :
updateExpression;
}
@@ -34208,10 +34944,10 @@ var ts;
*/
var unaryOperator = token();
var simpleUnaryExpression = parseSimpleUnaryExpression();
- if (token() === 42 /* AsteriskAsteriskToken */) {
+ if (token() === 42 /* SyntaxKind.AsteriskAsteriskToken */) {
var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos);
var end = simpleUnaryExpression.end;
- if (simpleUnaryExpression.kind === 210 /* TypeAssertionExpression */) {
+ if (simpleUnaryExpression.kind === 211 /* SyntaxKind.TypeAssertionExpression */) {
parseErrorAt(pos, end, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses);
}
else {
@@ -34236,23 +34972,23 @@ var ts;
*/
function parseSimpleUnaryExpression() {
switch (token()) {
- case 39 /* PlusToken */:
- case 40 /* MinusToken */:
- case 54 /* TildeToken */:
- case 53 /* ExclamationToken */:
+ case 39 /* SyntaxKind.PlusToken */:
+ case 40 /* SyntaxKind.MinusToken */:
+ case 54 /* SyntaxKind.TildeToken */:
+ case 53 /* SyntaxKind.ExclamationToken */:
return parsePrefixUnaryExpression();
- case 89 /* DeleteKeyword */:
+ case 89 /* SyntaxKind.DeleteKeyword */:
return parseDeleteExpression();
- case 112 /* TypeOfKeyword */:
+ case 112 /* SyntaxKind.TypeOfKeyword */:
return parseTypeOfExpression();
- case 114 /* VoidKeyword */:
+ case 114 /* SyntaxKind.VoidKeyword */:
return parseVoidExpression();
- case 29 /* LessThanToken */:
+ case 29 /* SyntaxKind.LessThanToken */:
// This is modified UnaryExpression grammar in TypeScript
// UnaryExpression (modified):
// < type > UnaryExpression
return parseTypeAssertion();
- case 132 /* AwaitKeyword */:
+ case 132 /* SyntaxKind.AwaitKeyword */:
if (isAwaitExpression()) {
return parseAwaitExpression();
}
@@ -34275,18 +35011,18 @@ var ts;
// This function is called inside parseUnaryExpression to decide
// whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly
switch (token()) {
- case 39 /* PlusToken */:
- case 40 /* MinusToken */:
- case 54 /* TildeToken */:
- case 53 /* ExclamationToken */:
- case 89 /* DeleteKeyword */:
- case 112 /* TypeOfKeyword */:
- case 114 /* VoidKeyword */:
- case 132 /* AwaitKeyword */:
+ case 39 /* SyntaxKind.PlusToken */:
+ case 40 /* SyntaxKind.MinusToken */:
+ case 54 /* SyntaxKind.TildeToken */:
+ case 53 /* SyntaxKind.ExclamationToken */:
+ case 89 /* SyntaxKind.DeleteKeyword */:
+ case 112 /* SyntaxKind.TypeOfKeyword */:
+ case 114 /* SyntaxKind.VoidKeyword */:
+ case 132 /* SyntaxKind.AwaitKeyword */:
return false;
- case 29 /* LessThanToken */:
+ case 29 /* SyntaxKind.LessThanToken */:
// If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression
- if (languageVariant !== 1 /* JSX */) {
+ if (languageVariant !== 1 /* LanguageVariant.JSX */) {
return false;
}
// We are in JSX context and the token is part of JSXElement.
@@ -34307,17 +35043,17 @@ var ts;
* In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression
*/
function parseUpdateExpression() {
- if (token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) {
+ if (token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) {
var pos = getNodePos();
return finishNode(factory.createPrefixUnaryExpression(token(), nextTokenAnd(parseLeftHandSideExpressionOrHigher)), pos);
}
- else if (languageVariant === 1 /* JSX */ && token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) {
+ else if (languageVariant === 1 /* LanguageVariant.JSX */ && token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) {
// JSXElement is part of primaryExpression
return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true);
}
var expression = parseLeftHandSideExpressionOrHigher();
ts.Debug.assert(ts.isLeftHandSideExpression(expression));
- if ((token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) {
+ if ((token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) {
var operator = token();
nextToken();
return finishNode(factory.createPostfixUnaryExpression(expression, operator), expression.pos);
@@ -34358,29 +35094,29 @@ var ts;
// or starts the beginning of the first four CallExpression productions.
var pos = getNodePos();
var expression;
- if (token() === 100 /* ImportKeyword */) {
+ if (token() === 100 /* SyntaxKind.ImportKeyword */) {
if (lookAhead(nextTokenIsOpenParenOrLessThan)) {
// We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "("
// For example:
// var foo3 = require("subfolder
// import * as foo1 from "module-from-node
// We want this import to be a statement rather than import call expression
- sourceFlags |= 1048576 /* PossiblyContainsDynamicImport */;
+ sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */;
expression = parseTokenNode();
}
else if (lookAhead(nextTokenIsDot)) {
// This is an 'import.*' metaproperty (i.e. 'import.meta')
nextToken(); // advance past the 'import'
nextToken(); // advance past the dot
- expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos);
- sourceFlags |= 2097152 /* PossiblyContainsImportMeta */;
+ expression = finishNode(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, parseIdentifierName()), pos);
+ sourceFlags |= 4194304 /* NodeFlags.PossiblyContainsImportMeta */;
}
else {
expression = parseMemberExpressionOrHigher();
}
}
else {
- expression = token() === 106 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher();
+ expression = token() === 106 /* SyntaxKind.SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher();
}
// Now, we *may* be complete. However, we might have consumed the start of a
// CallExpression or OptionalExpression. As such, we need to consume the rest
@@ -34442,19 +35178,19 @@ var ts;
function parseSuperExpression() {
var pos = getNodePos();
var expression = parseTokenNode();
- if (token() === 29 /* LessThanToken */) {
+ if (token() === 29 /* SyntaxKind.LessThanToken */) {
var startPos = getNodePos();
var typeArguments = tryParse(parseTypeArgumentsInExpression);
if (typeArguments !== undefined) {
parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments);
}
}
- if (token() === 20 /* OpenParenToken */ || token() === 24 /* DotToken */ || token() === 22 /* OpenBracketToken */) {
+ if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 24 /* SyntaxKind.DotToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */) {
return expression;
}
// If we have seen "super" it must be followed by '(' or '.'.
// If it wasn't then just try to parse out a '.' and report an error.
- parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access);
+ parseExpectedToken(24 /* SyntaxKind.DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access);
// private names will never work with `super` (`super.#foo`), but that's a semantic error, not syntactic
return finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ true)), pos);
}
@@ -34462,11 +35198,11 @@ var ts;
var pos = getNodePos();
var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext);
var result;
- if (opening.kind === 279 /* JsxOpeningElement */) {
+ if (opening.kind === 280 /* SyntaxKind.JsxOpeningElement */) {
var children = parseJsxChildren(opening);
var closingElement = void 0;
var lastChild = children[children.length - 1];
- if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 277 /* JsxElement */
+ if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 278 /* SyntaxKind.JsxElement */
&& !tagNamesAreEquivalent(lastChild.openingElement.tagName, lastChild.closingElement.tagName)
&& tagNamesAreEquivalent(opening.tagName, lastChild.closingElement.tagName)) {
// when an unclosed JsxOpeningElement incorrectly parses its parent's JsxClosingElement,
@@ -34492,11 +35228,11 @@ var ts;
}
result = finishNode(factory.createJsxElement(opening, children, closingElement), pos);
}
- else if (opening.kind === 282 /* JsxOpeningFragment */) {
+ else if (opening.kind === 283 /* SyntaxKind.JsxOpeningFragment */) {
result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos);
}
else {
- ts.Debug.assert(opening.kind === 278 /* JsxSelfClosingElement */);
+ ts.Debug.assert(opening.kind === 279 /* SyntaxKind.JsxSelfClosingElement */);
// Nothing else to do for self-closing elements
result = opening;
}
@@ -34507,11 +35243,11 @@ var ts;
// does less damage and we can report a better error.
// Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios
// of one sort or another.
- if (inExpressionContext && token() === 29 /* LessThanToken */) {
+ if (inExpressionContext && token() === 29 /* SyntaxKind.LessThanToken */) {
var topBadPos_1 = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition;
var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true, topBadPos_1); });
if (invalidElement) {
- var operatorToken = createMissingNode(27 /* CommaToken */, /*reportAtCurrentPosition*/ false);
+ var operatorToken = createMissingNode(27 /* SyntaxKind.CommaToken */, /*reportAtCurrentPosition*/ false);
ts.setTextRangePosWidth(operatorToken, invalidElement.pos, 0);
parseErrorAt(ts.skipTrivia(sourceText, topBadPos_1), invalidElement.end, ts.Diagnostics.JSX_expressions_must_have_one_parent_element);
return finishNode(factory.createBinaryExpression(result, operatorToken, invalidElement), pos);
@@ -34521,13 +35257,13 @@ var ts;
}
function parseJsxText() {
var pos = getNodePos();
- var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* JsxTextAllWhiteSpaces */);
+ var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* SyntaxKind.JsxTextAllWhiteSpaces */);
currentToken = scanner.scanJsxToken();
return finishNode(node, pos);
}
function parseJsxChild(openingTag, token) {
switch (token) {
- case 1 /* EndOfFileToken */:
+ case 1 /* SyntaxKind.EndOfFileToken */:
// If we hit EOF, issue the error at the tag that lacks the closing element
// rather than at the end of the file (which is useless)
if (ts.isJsxOpeningFragment(openingTag)) {
@@ -34541,15 +35277,15 @@ var ts;
parseErrorAt(start, tag.end, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName));
}
return undefined;
- case 30 /* LessThanSlashToken */:
- case 7 /* ConflictMarkerTrivia */:
+ case 30 /* SyntaxKind.LessThanSlashToken */:
+ case 7 /* SyntaxKind.ConflictMarkerTrivia */:
return undefined;
- case 11 /* JsxText */:
- case 12 /* JsxTextAllWhiteSpaces */:
+ case 11 /* SyntaxKind.JsxText */:
+ case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */:
return parseJsxText();
- case 18 /* OpenBraceToken */:
+ case 18 /* SyntaxKind.OpenBraceToken */:
return parseJsxExpression(/*inExpressionContext*/ false);
- case 29 /* LessThanToken */:
+ case 29 /* SyntaxKind.LessThanToken */:
return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false, /*topInvalidNodePosition*/ undefined, openingTag);
default:
return ts.Debug.assertNever(token);
@@ -34559,14 +35295,14 @@ var ts;
var list = [];
var listPos = getNodePos();
var saveParsingContext = parsingContext;
- parsingContext |= 1 << 14 /* JsxChildren */;
+ parsingContext |= 1 << 14 /* ParsingContext.JsxChildren */;
while (true) {
var child = parseJsxChild(openingTag, currentToken = scanner.reScanJsxToken());
if (!child)
break;
list.push(child);
if (ts.isJsxOpeningElement(openingTag)
- && (child === null || child === void 0 ? void 0 : child.kind) === 277 /* JsxElement */
+ && (child === null || child === void 0 ? void 0 : child.kind) === 278 /* SyntaxKind.JsxElement */
&& !tagNamesAreEquivalent(child.openingElement.tagName, child.closingElement.tagName)
&& tagNamesAreEquivalent(openingTag.tagName, child.closingElement.tagName)) {
// stop after parsing a mismatched child like <div>...(<span></div>) in order to reattach the </div> higher
@@ -34578,21 +35314,21 @@ var ts;
}
function parseJsxAttributes() {
var pos = getNodePos();
- return finishNode(factory.createJsxAttributes(parseList(13 /* JsxAttributes */, parseJsxAttribute)), pos);
+ return finishNode(factory.createJsxAttributes(parseList(13 /* ParsingContext.JsxAttributes */, parseJsxAttribute)), pos);
}
function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) {
var pos = getNodePos();
- parseExpected(29 /* LessThanToken */);
- if (token() === 31 /* GreaterThanToken */) {
+ parseExpected(29 /* SyntaxKind.LessThanToken */);
+ if (token() === 31 /* SyntaxKind.GreaterThanToken */) {
// See below for explanation of scanJsxText
scanJsxText();
return finishNode(factory.createJsxOpeningFragment(), pos);
}
var tagName = parseJsxElementName();
- var typeArguments = (contextFlags & 131072 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined;
+ var typeArguments = (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined;
var attributes = parseJsxAttributes();
var node;
- if (token() === 31 /* GreaterThanToken */) {
+ if (token() === 31 /* SyntaxKind.GreaterThanToken */) {
// Closing tag, so scan the immediately-following text with the JSX scanning instead
// of regular scanning to avoid treating illegal characters (e.g. '#') as immediate
// scanning errors
@@ -34600,8 +35336,8 @@ var ts;
node = factory.createJsxOpeningElement(tagName, typeArguments, attributes);
}
else {
- parseExpected(43 /* SlashToken */);
- if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) {
+ parseExpected(43 /* SyntaxKind.SlashToken */);
+ if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) {
// manually advance the scanner in order to look for jsx text inside jsx
if (inExpressionContext) {
nextToken();
@@ -34622,60 +35358,60 @@ var ts;
// primaryExpression in the form of an identifier and "this" keyword
// We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword
// We only want to consider "this" as a primaryExpression
- var expression = token() === 108 /* ThisKeyword */ ?
+ var expression = token() === 108 /* SyntaxKind.ThisKeyword */ ?
parseTokenNode() : parseIdentifierName();
- while (parseOptional(24 /* DotToken */)) {
+ while (parseOptional(24 /* SyntaxKind.DotToken */)) {
expression = finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ false)), pos);
}
return expression;
}
function parseJsxExpression(inExpressionContext) {
var pos = getNodePos();
- if (!parseExpected(18 /* OpenBraceToken */)) {
+ if (!parseExpected(18 /* SyntaxKind.OpenBraceToken */)) {
return undefined;
}
var dotDotDotToken;
var expression;
- if (token() !== 19 /* CloseBraceToken */) {
- dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */);
+ if (token() !== 19 /* SyntaxKind.CloseBraceToken */) {
+ dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */);
// Only an AssignmentExpression is valid here per the JSX spec,
// but we can unambiguously parse a comma sequence and provide
// a better error message in grammar checking.
expression = parseExpression();
}
if (inExpressionContext) {
- parseExpected(19 /* CloseBraceToken */);
+ parseExpected(19 /* SyntaxKind.CloseBraceToken */);
}
else {
- if (parseExpected(19 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) {
+ if (parseExpected(19 /* SyntaxKind.CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) {
scanJsxText();
}
}
return finishNode(factory.createJsxExpression(dotDotDotToken, expression), pos);
}
function parseJsxAttribute() {
- if (token() === 18 /* OpenBraceToken */) {
+ if (token() === 18 /* SyntaxKind.OpenBraceToken */) {
return parseJsxSpreadAttribute();
}
scanJsxIdentifier();
var pos = getNodePos();
- return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 /* EqualsToken */ ? undefined :
- scanJsxAttributeValue() === 10 /* StringLiteral */ ? parseLiteralNode() :
+ return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 /* SyntaxKind.EqualsToken */ ? undefined :
+ scanJsxAttributeValue() === 10 /* SyntaxKind.StringLiteral */ ? parseLiteralNode() :
parseJsxExpression(/*inExpressionContext*/ true)), pos);
}
function parseJsxSpreadAttribute() {
var pos = getNodePos();
- parseExpected(18 /* OpenBraceToken */);
- parseExpected(25 /* DotDotDotToken */);
+ parseExpected(18 /* SyntaxKind.OpenBraceToken */);
+ parseExpected(25 /* SyntaxKind.DotDotDotToken */);
var expression = parseExpression();
- parseExpected(19 /* CloseBraceToken */);
+ parseExpected(19 /* SyntaxKind.CloseBraceToken */);
return finishNode(factory.createJsxSpreadAttribute(expression), pos);
}
function parseJsxClosingElement(open, inExpressionContext) {
var pos = getNodePos();
- parseExpected(30 /* LessThanSlashToken */);
+ parseExpected(30 /* SyntaxKind.LessThanSlashToken */);
var tagName = parseJsxElementName();
- if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) {
+ if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) {
// manually advance the scanner in order to look for jsx text inside jsx
if (inExpressionContext || !tagNamesAreEquivalent(open.tagName, tagName)) {
nextToken();
@@ -34688,11 +35424,11 @@ var ts;
}
function parseJsxClosingFragment(inExpressionContext) {
var pos = getNodePos();
- parseExpected(30 /* LessThanSlashToken */);
+ parseExpected(30 /* SyntaxKind.LessThanSlashToken */);
if (ts.tokenIsIdentifierOrKeyword(token())) {
parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment);
}
- if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) {
+ if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) {
// manually advance the scanner in order to look for jsx text inside jsx
if (inExpressionContext) {
nextToken();
@@ -34705,36 +35441,36 @@ var ts;
}
function parseTypeAssertion() {
var pos = getNodePos();
- parseExpected(29 /* LessThanToken */);
+ parseExpected(29 /* SyntaxKind.LessThanToken */);
var type = parseType();
- parseExpected(31 /* GreaterThanToken */);
+ parseExpected(31 /* SyntaxKind.GreaterThanToken */);
var expression = parseSimpleUnaryExpression();
return finishNode(factory.createTypeAssertion(type, expression), pos);
}
function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() {
nextToken();
return ts.tokenIsIdentifierOrKeyword(token())
- || token() === 22 /* OpenBracketToken */
+ || token() === 22 /* SyntaxKind.OpenBracketToken */
|| isTemplateStartOfTaggedTemplate();
}
function isStartOfOptionalPropertyOrElementAccessChain() {
- return token() === 28 /* QuestionDotToken */
+ return token() === 28 /* SyntaxKind.QuestionDotToken */
&& lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate);
}
function tryReparseOptionalChain(node) {
- if (node.flags & 32 /* OptionalChain */) {
+ if (node.flags & 32 /* NodeFlags.OptionalChain */) {
return true;
}
// check for an optional chain in a non-null expression
if (ts.isNonNullExpression(node)) {
var expr = node.expression;
- while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* OptionalChain */)) {
+ while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* NodeFlags.OptionalChain */)) {
expr = expr.expression;
}
- if (expr.flags & 32 /* OptionalChain */) {
+ if (expr.flags & 32 /* NodeFlags.OptionalChain */) {
// this is part of an optional chain. Walk down from `node` to `expression` and set the flag.
while (ts.isNonNullExpression(node)) {
- node.flags |= 32 /* OptionalChain */;
+ node.flags |= 32 /* NodeFlags.OptionalChain */;
node = node.expression;
}
return true;
@@ -34755,8 +35491,8 @@ var ts;
}
function parseElementAccessExpressionRest(pos, expression, questionDotToken) {
var argumentExpression;
- if (token() === 23 /* CloseBracketToken */) {
- argumentExpression = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument);
+ if (token() === 23 /* SyntaxKind.CloseBracketToken */) {
+ argumentExpression = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument);
}
else {
var argument = allowInAnd(parseExpression);
@@ -34765,7 +35501,7 @@ var ts;
}
argumentExpression = argument;
}
- parseExpected(23 /* CloseBracketToken */);
+ parseExpected(23 /* SyntaxKind.CloseBracketToken */);
var indexedAccess = questionDotToken || tryReparseOptionalChain(expression) ?
factory.createElementAccessChain(expression, questionDotToken, argumentExpression) :
factory.createElementAccessExpression(expression, argumentExpression);
@@ -34776,42 +35512,52 @@ var ts;
var questionDotToken = void 0;
var isPropertyAccess = false;
if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) {
- questionDotToken = parseExpectedToken(28 /* QuestionDotToken */);
+ questionDotToken = parseExpectedToken(28 /* SyntaxKind.QuestionDotToken */);
isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token());
}
else {
- isPropertyAccess = parseOptional(24 /* DotToken */);
+ isPropertyAccess = parseOptional(24 /* SyntaxKind.DotToken */);
}
if (isPropertyAccess) {
expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken);
continue;
}
- if (!questionDotToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) {
- nextToken();
- expression = finishNode(factory.createNonNullExpression(expression), pos);
- continue;
- }
// when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName
- if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) {
+ if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* SyntaxKind.OpenBracketToken */)) {
expression = parseElementAccessExpressionRest(pos, expression, questionDotToken);
continue;
}
if (isTemplateStartOfTaggedTemplate()) {
- expression = parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined);
+ // Absorb type arguments into TemplateExpression when preceding expression is ExpressionWithTypeArguments
+ expression = !questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ?
+ parseTaggedTemplateRest(pos, expression.expression, questionDotToken, expression.typeArguments) :
+ parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined);
continue;
}
+ if (!questionDotToken) {
+ if (token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) {
+ nextToken();
+ expression = finishNode(factory.createNonNullExpression(expression), pos);
+ continue;
+ }
+ var typeArguments = tryParse(parseTypeArgumentsInExpression);
+ if (typeArguments) {
+ expression = finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
+ continue;
+ }
+ }
return expression;
}
}
function isTemplateStartOfTaggedTemplate() {
- return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */;
+ return token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || token() === 15 /* SyntaxKind.TemplateHead */;
}
function parseTaggedTemplateRest(pos, tag, questionDotToken, typeArguments) {
- var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* NoSubstitutionTemplateLiteral */ ?
+ var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ ?
(reScanTemplateHeadOrNoSubstitutionTemplate(), parseLiteralNode()) :
parseTemplateExpression(/*isTaggedTemplate*/ true));
- if (questionDotToken || tag.flags & 32 /* OptionalChain */) {
- tagExpression.flags |= 32 /* OptionalChain */;
+ if (questionDotToken || tag.flags & 32 /* NodeFlags.OptionalChain */) {
+ tagExpression.flags |= 32 /* NodeFlags.OptionalChain */;
}
tagExpression.questionDotToken = questionDotToken;
return finishNode(tagExpression, pos);
@@ -34819,39 +35565,31 @@ var ts;
function parseCallExpressionRest(pos, expression) {
while (true) {
expression = parseMemberExpressionRest(pos, expression, /*allowOptionalChain*/ true);
- var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */);
- // handle 'foo<<T>()'
- // parse template arguments only in TypeScript files (not in JavaScript files).
- if ((contextFlags & 131072 /* JavaScriptFile */) === 0 && (token() === 29 /* LessThanToken */ || token() === 47 /* LessThanLessThanToken */)) {
- // See if this is the start of a generic invocation. If so, consume it and
- // keep checking for postfix expressions. Otherwise, it's just a '<' that's
- // part of an arithmetic expression. Break out so we consume it higher in the
- // stack.
- var typeArguments = tryParse(parseTypeArgumentsInExpression);
- if (typeArguments) {
- if (isTemplateStartOfTaggedTemplate()) {
- expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
- continue;
- }
- var argumentList = parseArgumentList();
- var callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
- factory.createCallChain(expression, questionDotToken, typeArguments, argumentList) :
- factory.createCallExpression(expression, typeArguments, argumentList);
- expression = finishNode(callExpr, pos);
+ var typeArguments = void 0;
+ var questionDotToken = parseOptionalToken(28 /* SyntaxKind.QuestionDotToken */);
+ if (questionDotToken) {
+ typeArguments = tryParse(parseTypeArgumentsInExpression);
+ if (isTemplateStartOfTaggedTemplate()) {
+ expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
continue;
}
}
- else if (token() === 20 /* OpenParenToken */) {
+ if (typeArguments || token() === 20 /* SyntaxKind.OpenParenToken */) {
+ // Absorb type arguments into CallExpression when preceding expression is ExpressionWithTypeArguments
+ if (!questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) {
+ typeArguments = expression.typeArguments;
+ expression = expression.expression;
+ }
var argumentList = parseArgumentList();
var callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
- factory.createCallChain(expression, questionDotToken, /*typeArguments*/ undefined, argumentList) :
- factory.createCallExpression(expression, /*typeArguments*/ undefined, argumentList);
+ factory.createCallChain(expression, questionDotToken, typeArguments, argumentList) :
+ factory.createCallExpression(expression, typeArguments, argumentList);
expression = finishNode(callExpr, pos);
continue;
}
if (questionDotToken) {
- // We failed to parse anything, so report a missing identifier here.
- var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected);
+ // We parsed `?.` but then failed to parse anything, so report a missing identifier here.
+ var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected);
expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos);
}
break;
@@ -34859,92 +35597,62 @@ var ts;
return expression;
}
function parseArgumentList() {
- parseExpected(20 /* OpenParenToken */);
- var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression);
- parseExpected(21 /* CloseParenToken */);
+ parseExpected(20 /* SyntaxKind.OpenParenToken */);
+ var result = parseDelimitedList(11 /* ParsingContext.ArgumentExpressions */, parseArgumentExpression);
+ parseExpected(21 /* SyntaxKind.CloseParenToken */);
return result;
}
function parseTypeArgumentsInExpression() {
- if ((contextFlags & 131072 /* JavaScriptFile */) !== 0) {
+ if ((contextFlags & 262144 /* NodeFlags.JavaScriptFile */) !== 0) {
// TypeArguments must not be parsed in JavaScript files to avoid ambiguity with binary operators.
return undefined;
}
- if (reScanLessThanToken() !== 29 /* LessThanToken */) {
+ if (reScanLessThanToken() !== 29 /* SyntaxKind.LessThanToken */) {
return undefined;
}
nextToken();
- var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType);
- if (!parseExpected(31 /* GreaterThanToken */)) {
+ var typeArguments = parseDelimitedList(20 /* ParsingContext.TypeArguments */, parseType);
+ if (!parseExpected(31 /* SyntaxKind.GreaterThanToken */)) {
// If it doesn't have the closing `>` then it's definitely not an type argument list.
return undefined;
}
- // If we have a '<', then only parse this as a argument list if the type arguments
- // are complete and we have an open paren. if we don't, rewind and return nothing.
- return typeArguments && canFollowTypeArgumentsInExpression()
- ? typeArguments
- : undefined;
+ // We successfully parsed a type argument list. The next token determines whether we want to
+ // treat it as such. If the type argument list is followed by `(` or a template literal, as in
+ // `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
+ // it as a relational expression.
+ return typeArguments && canFollowTypeArgumentsInExpression() ? typeArguments : undefined;
}
function canFollowTypeArgumentsInExpression() {
switch (token()) {
- case 20 /* OpenParenToken */: // foo<x>(
- case 14 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
- case 15 /* TemplateHead */: // foo<T> `...${100}...`
- // these are the only tokens can legally follow a type argument
- // list. So we definitely want to treat them as type arg lists.
- // falls through
- case 24 /* DotToken */: // foo<x>.
- case 21 /* CloseParenToken */: // foo<x>)
- case 23 /* CloseBracketToken */: // foo<x>]
- case 58 /* ColonToken */: // foo<x>:
- case 26 /* SemicolonToken */: // foo<x>;
- case 57 /* QuestionToken */: // foo<x>?
- case 34 /* EqualsEqualsToken */: // foo<x> ==
- case 36 /* EqualsEqualsEqualsToken */: // foo<x> ===
- case 35 /* ExclamationEqualsToken */: // foo<x> !=
- case 37 /* ExclamationEqualsEqualsToken */: // foo<x> !==
- case 55 /* AmpersandAmpersandToken */: // foo<x> &&
- case 56 /* BarBarToken */: // foo<x> ||
- case 60 /* QuestionQuestionToken */: // foo<x> ??
- case 52 /* CaretToken */: // foo<x> ^
- case 50 /* AmpersandToken */: // foo<x> &
- case 51 /* BarToken */: // foo<x> |
- case 19 /* CloseBraceToken */: // foo<x> }
- case 1 /* EndOfFileToken */: // foo<x>
- // these cases can't legally follow a type arg list. However, they're not legal
- // expressions either. The user is probably in the middle of a generic type. So
- // treat it as such.
+ // These tokens can follow a type argument list in a call expression.
+ case 20 /* SyntaxKind.OpenParenToken */: // foo<x>(
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: // foo<T> `...`
+ case 15 /* SyntaxKind.TemplateHead */: // foo<T> `...${100}...`
return true;
- case 27 /* CommaToken */: // foo<x>,
- case 18 /* OpenBraceToken */: // foo<x> {
- // We don't want to treat these as type arguments. Otherwise we'll parse this
- // as an invocation expression. Instead, we want to parse out the expression
- // in isolation from the type arguments.
- // falls through
- default:
- // Anything else treat as an expression.
- return false;
}
+ // Consider something a type argument list only if the following token can't start an expression.
+ return !isStartOfExpression();
}
function parsePrimaryExpression() {
switch (token()) {
- case 8 /* NumericLiteral */:
- case 9 /* BigIntLiteral */:
- case 10 /* StringLiteral */:
- case 14 /* NoSubstitutionTemplateLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
+ case 9 /* SyntaxKind.BigIntLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
return parseLiteralNode();
- case 108 /* ThisKeyword */:
- case 106 /* SuperKeyword */:
- case 104 /* NullKeyword */:
- case 110 /* TrueKeyword */:
- case 95 /* FalseKeyword */:
+ case 108 /* SyntaxKind.ThisKeyword */:
+ case 106 /* SyntaxKind.SuperKeyword */:
+ case 104 /* SyntaxKind.NullKeyword */:
+ case 110 /* SyntaxKind.TrueKeyword */:
+ case 95 /* SyntaxKind.FalseKeyword */:
return parseTokenNode();
- case 20 /* OpenParenToken */:
+ case 20 /* SyntaxKind.OpenParenToken */:
return parseParenthesizedExpression();
- case 22 /* OpenBracketToken */:
+ case 22 /* SyntaxKind.OpenBracketToken */:
return parseArrayLiteralExpression();
- case 18 /* OpenBraceToken */:
+ case 18 /* SyntaxKind.OpenBraceToken */:
return parseObjectLiteralExpression();
- case 131 /* AsyncKeyword */:
+ case 131 /* SyntaxKind.AsyncKeyword */:
// Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher.
// If we encounter `async [no LineTerminator here] function` then this is an async
// function; otherwise, its an identifier.
@@ -34952,21 +35660,21 @@ var ts;
break;
}
return parseFunctionExpression();
- case 84 /* ClassKeyword */:
+ case 84 /* SyntaxKind.ClassKeyword */:
return parseClassExpression();
- case 98 /* FunctionKeyword */:
+ case 98 /* SyntaxKind.FunctionKeyword */:
return parseFunctionExpression();
- case 103 /* NewKeyword */:
+ case 103 /* SyntaxKind.NewKeyword */:
return parseNewExpressionOrNewDotTarget();
- case 43 /* SlashToken */:
- case 68 /* SlashEqualsToken */:
- if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) {
+ case 43 /* SyntaxKind.SlashToken */:
+ case 68 /* SyntaxKind.SlashEqualsToken */:
+ if (reScanSlashToken() === 13 /* SyntaxKind.RegularExpressionLiteral */) {
return parseLiteralNode();
}
break;
- case 15 /* TemplateHead */:
+ case 15 /* SyntaxKind.TemplateHead */:
return parseTemplateExpression(/* isTaggedTemplate */ false);
- case 80 /* PrivateIdentifier */:
+ case 80 /* SyntaxKind.PrivateIdentifier */:
return parsePrivateIdentifier();
}
return parseIdentifier(ts.Diagnostics.Expression_expected);
@@ -34974,20 +35682,20 @@ var ts;
function parseParenthesizedExpression() {
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
- parseExpected(20 /* OpenParenToken */);
+ parseExpected(20 /* SyntaxKind.OpenParenToken */);
var expression = allowInAnd(parseExpression);
- parseExpected(21 /* CloseParenToken */);
+ parseExpected(21 /* SyntaxKind.CloseParenToken */);
return withJSDoc(finishNode(factory.createParenthesizedExpression(expression), pos), hasJSDoc);
}
function parseSpreadElement() {
var pos = getNodePos();
- parseExpected(25 /* DotDotDotToken */);
+ parseExpected(25 /* SyntaxKind.DotDotDotToken */);
var expression = parseAssignmentExpressionOrHigher();
return finishNode(factory.createSpreadElement(expression), pos);
}
function parseArgumentOrArrayLiteralElement() {
- return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() :
- token() === 27 /* CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) :
+ return token() === 25 /* SyntaxKind.DotDotDotToken */ ? parseSpreadElement() :
+ token() === 27 /* SyntaxKind.CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) :
parseAssignmentExpressionOrHigher();
}
function parseArgumentExpression() {
@@ -34995,34 +35703,35 @@ var ts;
}
function parseArrayLiteralExpression() {
var pos = getNodePos();
- parseExpected(22 /* OpenBracketToken */);
+ var openBracketPosition = scanner.getTokenPos();
+ var openBracketParsed = parseExpected(22 /* SyntaxKind.OpenBracketToken */);
var multiLine = scanner.hasPrecedingLineBreak();
- var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement);
- parseExpected(23 /* CloseBracketToken */);
+ var elements = parseDelimitedList(15 /* ParsingContext.ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement);
+ parseExpectedMatchingBrackets(22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */, openBracketParsed, openBracketPosition);
return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos);
}
function parseObjectLiteralElement() {
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
- if (parseOptionalToken(25 /* DotDotDotToken */)) {
+ if (parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */)) {
var expression = parseAssignmentExpressionOrHigher();
return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc);
}
var decorators = parseDecorators();
var modifiers = parseModifiers();
- if (parseContextualModifier(136 /* GetKeyword */)) {
- return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 171 /* GetAccessor */);
+ if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) {
+ return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */);
}
- if (parseContextualModifier(148 /* SetKeyword */)) {
- return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SetAccessor */);
+ if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) {
+ return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */);
}
- var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
+ var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */);
var tokenIsIdentifier = isIdentifier();
var name = parsePropertyName();
// Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker.
- var questionToken = parseOptionalToken(57 /* QuestionToken */);
- var exclamationToken = parseOptionalToken(53 /* ExclamationToken */);
- if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) {
+ var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */);
+ var exclamationToken = parseOptionalToken(53 /* SyntaxKind.ExclamationToken */);
+ if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) {
return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken);
}
// check if it is short-hand property assignment or normal property assignment
@@ -35031,9 +35740,9 @@ var ts;
// IdentifierReference[?Yield] Initializer[In, ?Yield]
// this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern
var node;
- var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */);
+ var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* SyntaxKind.ColonToken */);
if (isShorthandPropertyAssignment) {
- var equalsToken = parseOptionalToken(63 /* EqualsToken */);
+ var equalsToken = parseOptionalToken(63 /* SyntaxKind.EqualsToken */);
var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined;
node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer);
// Save equals token for error reporting.
@@ -35041,7 +35750,7 @@ var ts;
node.equalsToken = equalsToken;
}
else {
- parseExpected(58 /* ColonToken */);
+ parseExpected(58 /* SyntaxKind.ColonToken */);
var initializer = allowInAnd(parseAssignmentExpressionOrHigher);
node = factory.createPropertyAssignment(name, initializer);
}
@@ -35055,15 +35764,10 @@ var ts;
function parseObjectLiteralExpression() {
var pos = getNodePos();
var openBracePosition = scanner.getTokenPos();
- parseExpected(18 /* OpenBraceToken */);
+ var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */);
var multiLine = scanner.hasPrecedingLineBreak();
- var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true);
- if (!parseExpected(19 /* CloseBraceToken */)) {
- var lastError = ts.lastOrUndefined(parseDiagnostics);
- if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
- ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
- }
- }
+ var properties = parseDelimitedList(12 /* ParsingContext.ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true);
+ parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition);
return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos);
}
function parseFunctionExpression() {
@@ -35077,17 +35781,17 @@ var ts;
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
var modifiers = parseModifiers();
- parseExpected(98 /* FunctionKeyword */);
- var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
- var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */;
- var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */;
+ parseExpected(98 /* SyntaxKind.FunctionKeyword */);
+ var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */);
+ var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */;
+ var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */;
var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) :
isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) :
isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) :
parseOptionalBindingIdentifier();
var typeParameters = parseTypeParameters();
var parameters = parseParameters(isGenerator | isAsync);
- var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
+ var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false);
var body = parseFunctionBlock(isGenerator | isAsync);
setDecoratorContext(savedDecoratorContext);
var node = factory.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body);
@@ -35098,49 +35802,34 @@ var ts;
}
function parseNewExpressionOrNewDotTarget() {
var pos = getNodePos();
- parseExpected(103 /* NewKeyword */);
- if (parseOptional(24 /* DotToken */)) {
+ parseExpected(103 /* SyntaxKind.NewKeyword */);
+ if (parseOptional(24 /* SyntaxKind.DotToken */)) {
var name = parseIdentifierName();
- return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos);
+ return finishNode(factory.createMetaProperty(103 /* SyntaxKind.NewKeyword */, name), pos);
}
var expressionPos = getNodePos();
- var expression = parsePrimaryExpression();
+ var expression = parseMemberExpressionRest(expressionPos, parsePrimaryExpression(), /*allowOptionalChain*/ false);
var typeArguments;
- while (true) {
- expression = parseMemberExpressionRest(expressionPos, expression, /*allowOptionalChain*/ false);
- typeArguments = tryParse(parseTypeArgumentsInExpression);
- if (isTemplateStartOfTaggedTemplate()) {
- ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'");
- expression = parseTaggedTemplateRest(expressionPos, expression, /*optionalChain*/ undefined, typeArguments);
- typeArguments = undefined;
- }
- break;
- }
- var argumentsArray;
- if (token() === 20 /* OpenParenToken */) {
- argumentsArray = parseArgumentList();
+ // Absorb type arguments into NewExpression when preceding expression is ExpressionWithTypeArguments
+ if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) {
+ typeArguments = expression.typeArguments;
+ expression = expression.expression;
}
- else if (typeArguments) {
- parseErrorAt(pos, scanner.getStartPos(), ts.Diagnostics.A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list);
- }
- return finishNode(factory.createNewExpression(expression, typeArguments, argumentsArray), pos);
+ var argumentList = token() === 20 /* SyntaxKind.OpenParenToken */ ? parseArgumentList() : undefined;
+ return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos);
}
// STATEMENTS
function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) {
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
var openBracePosition = scanner.getTokenPos();
- if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) {
+ var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */, diagnosticMessage);
+ if (openBraceParsed || ignoreMissingOpenBrace) {
var multiLine = scanner.hasPrecedingLineBreak();
- var statements = parseList(1 /* BlockStatements */, parseStatement);
- if (!parseExpected(19 /* CloseBraceToken */)) {
- var lastError = ts.lastOrUndefined(parseDiagnostics);
- if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
- ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
- }
- }
+ var statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement);
+ parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition);
var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc);
- if (token() === 63 /* EqualsToken */) {
+ if (token() === 63 /* SyntaxKind.EqualsToken */) {
parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses);
nextToken();
}
@@ -35153,9 +35842,9 @@ var ts;
}
function parseFunctionBlock(flags, diagnosticMessage) {
var savedYieldContext = inYieldContext();
- setYieldContext(!!(flags & 1 /* Yield */));
+ setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */));
var savedAwaitContext = inAwaitContext();
- setAwaitContext(!!(flags & 2 /* Await */));
+ setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */));
var savedTopLevel = topLevel;
topLevel = false;
// We may be in a [Decorator] context when parsing a function expression or
@@ -35164,7 +35853,7 @@ var ts;
if (saveDecoratorContext) {
setDecoratorContext(/*val*/ false);
}
- var block = parseBlock(!!(flags & 16 /* IgnoreMissingOpenBrace */), diagnosticMessage);
+ var block = parseBlock(!!(flags & 16 /* SignatureFlags.IgnoreMissingOpenBrace */), diagnosticMessage);
if (saveDecoratorContext) {
setDecoratorContext(/*val*/ true);
}
@@ -35176,55 +35865,58 @@ var ts;
function parseEmptyStatement() {
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
- parseExpected(26 /* SemicolonToken */);
+ parseExpected(26 /* SyntaxKind.SemicolonToken */);
return withJSDoc(finishNode(factory.createEmptyStatement(), pos), hasJSDoc);
}
function parseIfStatement() {
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
- parseExpected(99 /* IfKeyword */);
- parseExpected(20 /* OpenParenToken */);
+ parseExpected(99 /* SyntaxKind.IfKeyword */);
+ var openParenPosition = scanner.getTokenPos();
+ var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */);
var expression = allowInAnd(parseExpression);
- parseExpected(21 /* CloseParenToken */);
+ parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition);
var thenStatement = parseStatement();
- var elseStatement = parseOptional(91 /* ElseKeyword */) ? parseStatement() : undefined;
+ var elseStatement = parseOptional(91 /* SyntaxKind.ElseKeyword */) ? parseStatement() : undefined;
return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc);
}
function parseDoStatement() {
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
- parseExpected(90 /* DoKeyword */);
+ parseExpected(90 /* SyntaxKind.DoKeyword */);
var statement = parseStatement();
- parseExpected(115 /* WhileKeyword */);
- parseExpected(20 /* OpenParenToken */);
+ parseExpected(115 /* SyntaxKind.WhileKeyword */);
+ var openParenPosition = scanner.getTokenPos();
+ var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */);
var expression = allowInAnd(parseExpression);
- parseExpected(21 /* CloseParenToken */);
+ parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition);
// From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html
// 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in
// spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby
// do;while(0)x will have a semicolon inserted before x.
- parseOptional(26 /* SemicolonToken */);
+ parseOptional(26 /* SyntaxKind.SemicolonToken */);
return withJSDoc(finishNode(factory.createDoStatement(statement, expression), pos), hasJSDoc);
}
function parseWhileStatement() {
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
- parseExpected(115 /* WhileKeyword */);
- parseExpected(20 /* OpenParenToken */);
+ parseExpected(115 /* SyntaxKind.WhileKeyword */);
+ var openParenPosition = scanner.getTokenPos();
+ var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */);
var expression = allowInAnd(parseExpression);
- parseExpected(21 /* CloseParenToken */);
+ parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition);
var statement = parseStatement();
return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc);
}
function parseForOrForInOrForOfStatement() {
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
- parseExpected(97 /* ForKeyword */);
- var awaitToken = parseOptionalToken(132 /* AwaitKeyword */);
- parseExpected(20 /* OpenParenToken */);
+ parseExpected(97 /* SyntaxKind.ForKeyword */);
+ var awaitToken = parseOptionalToken(132 /* SyntaxKind.AwaitKeyword */);
+ parseExpected(20 /* SyntaxKind.OpenParenToken */);
var initializer;
- if (token() !== 26 /* SemicolonToken */) {
- if (token() === 113 /* VarKeyword */ || token() === 119 /* LetKeyword */ || token() === 85 /* ConstKeyword */) {
+ if (token() !== 26 /* SyntaxKind.SemicolonToken */) {
+ if (token() === 113 /* SyntaxKind.VarKeyword */ || token() === 119 /* SyntaxKind.LetKeyword */ || token() === 85 /* SyntaxKind.ConstKeyword */) {
initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true);
}
else {
@@ -35232,26 +35924,26 @@ var ts;
}
}
var node;
- if (awaitToken ? parseExpected(159 /* OfKeyword */) : parseOptional(159 /* OfKeyword */)) {
+ if (awaitToken ? parseExpected(160 /* SyntaxKind.OfKeyword */) : parseOptional(160 /* SyntaxKind.OfKeyword */)) {
var expression = allowInAnd(parseAssignmentExpressionOrHigher);
- parseExpected(21 /* CloseParenToken */);
+ parseExpected(21 /* SyntaxKind.CloseParenToken */);
node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement());
}
- else if (parseOptional(101 /* InKeyword */)) {
+ else if (parseOptional(101 /* SyntaxKind.InKeyword */)) {
var expression = allowInAnd(parseExpression);
- parseExpected(21 /* CloseParenToken */);
+ parseExpected(21 /* SyntaxKind.CloseParenToken */);
node = factory.createForInStatement(initializer, expression, parseStatement());
}
else {
- parseExpected(26 /* SemicolonToken */);
- var condition = token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */
+ parseExpected(26 /* SyntaxKind.SemicolonToken */);
+ var condition = token() !== 26 /* SyntaxKind.SemicolonToken */ && token() !== 21 /* SyntaxKind.CloseParenToken */
? allowInAnd(parseExpression)
: undefined;
- parseExpected(26 /* SemicolonToken */);
- var incrementor = token() !== 21 /* CloseParenToken */
+ parseExpected(26 /* SyntaxKind.SemicolonToken */);
+ var incrementor = token() !== 21 /* SyntaxKind.CloseParenToken */
? allowInAnd(parseExpression)
: undefined;
- parseExpected(21 /* CloseParenToken */);
+ parseExpected(21 /* SyntaxKind.CloseParenToken */);
node = factory.createForStatement(initializer, condition, incrementor, parseStatement());
}
return withJSDoc(finishNode(node, pos), hasJSDoc);
@@ -35259,10 +35951,10 @@ var ts;
function parseBreakOrContinueStatement(kind) {
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
- parseExpected(kind === 245 /* BreakStatement */ ? 81 /* BreakKeyword */ : 86 /* ContinueKeyword */);
+ parseExpected(kind === 246 /* SyntaxKind.BreakStatement */ ? 81 /* SyntaxKind.BreakKeyword */ : 86 /* SyntaxKind.ContinueKeyword */);
var label = canParseSemicolon() ? undefined : parseIdentifier();
parseSemicolon();
- var node = kind === 245 /* BreakStatement */
+ var node = kind === 246 /* SyntaxKind.BreakStatement */
? factory.createBreakStatement(label)
: factory.createContinueStatement(label);
return withJSDoc(finishNode(node, pos), hasJSDoc);
@@ -35270,7 +35962,7 @@ var ts;
function parseReturnStatement() {
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
- parseExpected(105 /* ReturnKeyword */);
+ parseExpected(105 /* SyntaxKind.ReturnKeyword */);
var expression = canParseSemicolon() ? undefined : allowInAnd(parseExpression);
parseSemicolon();
return withJSDoc(finishNode(factory.createReturnStatement(expression), pos), hasJSDoc);
@@ -35278,45 +35970,47 @@ var ts;
function parseWithStatement() {
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
- parseExpected(116 /* WithKeyword */);
- parseExpected(20 /* OpenParenToken */);
+ parseExpected(116 /* SyntaxKind.WithKeyword */);
+ var openParenPosition = scanner.getTokenPos();
+ var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */);
var expression = allowInAnd(parseExpression);
- parseExpected(21 /* CloseParenToken */);
- var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement);
+ parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition);
+ var statement = doInsideOfContext(33554432 /* NodeFlags.InWithStatement */, parseStatement);
return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc);
}
function parseCaseClause() {
var pos = getNodePos();
- parseExpected(82 /* CaseKeyword */);
+ var hasJSDoc = hasPrecedingJSDocComment();
+ parseExpected(82 /* SyntaxKind.CaseKeyword */);
var expression = allowInAnd(parseExpression);
- parseExpected(58 /* ColonToken */);
- var statements = parseList(3 /* SwitchClauseStatements */, parseStatement);
- return finishNode(factory.createCaseClause(expression, statements), pos);
+ parseExpected(58 /* SyntaxKind.ColonToken */);
+ var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement);
+ return withJSDoc(finishNode(factory.createCaseClause(expression, statements), pos), hasJSDoc);
}
function parseDefaultClause() {
var pos = getNodePos();
- parseExpected(88 /* DefaultKeyword */);
- parseExpected(58 /* ColonToken */);
- var statements = parseList(3 /* SwitchClauseStatements */, parseStatement);
+ parseExpected(88 /* SyntaxKind.DefaultKeyword */);
+ parseExpected(58 /* SyntaxKind.ColonToken */);
+ var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement);
return finishNode(factory.createDefaultClause(statements), pos);
}
function parseCaseOrDefaultClause() {
- return token() === 82 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause();
+ return token() === 82 /* SyntaxKind.CaseKeyword */ ? parseCaseClause() : parseDefaultClause();
}
function parseCaseBlock() {
var pos = getNodePos();
- parseExpected(18 /* OpenBraceToken */);
- var clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause);
- parseExpected(19 /* CloseBraceToken */);
+ parseExpected(18 /* SyntaxKind.OpenBraceToken */);
+ var clauses = parseList(2 /* ParsingContext.SwitchClauses */, parseCaseOrDefaultClause);
+ parseExpected(19 /* SyntaxKind.CloseBraceToken */);
return finishNode(factory.createCaseBlock(clauses), pos);
}
function parseSwitchStatement() {
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
- parseExpected(107 /* SwitchKeyword */);
- parseExpected(20 /* OpenParenToken */);
+ parseExpected(107 /* SyntaxKind.SwitchKeyword */);
+ parseExpected(20 /* SyntaxKind.OpenParenToken */);
var expression = allowInAnd(parseExpression);
- parseExpected(21 /* CloseParenToken */);
+ parseExpected(21 /* SyntaxKind.CloseParenToken */);
var caseBlock = parseCaseBlock();
return withJSDoc(finishNode(factory.createSwitchStatement(expression, caseBlock), pos), hasJSDoc);
}
@@ -35325,7 +36019,7 @@ var ts;
// throw [no LineTerminator here]Expression[In, ?Yield];
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
- parseExpected(109 /* ThrowKeyword */);
+ parseExpected(109 /* SyntaxKind.ThrowKeyword */);
// Because of automatic semicolon insertion, we need to report error if this
// throw could be terminated with a semicolon. Note: we can't call 'parseExpression'
// directly as that might consume an expression on the following line.
@@ -35345,25 +36039,25 @@ var ts;
function parseTryStatement() {
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
- parseExpected(111 /* TryKeyword */);
+ parseExpected(111 /* SyntaxKind.TryKeyword */);
var tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false);
- var catchClause = token() === 83 /* CatchKeyword */ ? parseCatchClause() : undefined;
+ var catchClause = token() === 83 /* SyntaxKind.CatchKeyword */ ? parseCatchClause() : undefined;
// If we don't have a catch clause, then we must have a finally clause. Try to parse
// one out no matter what.
var finallyBlock;
- if (!catchClause || token() === 96 /* FinallyKeyword */) {
- parseExpected(96 /* FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected);
+ if (!catchClause || token() === 96 /* SyntaxKind.FinallyKeyword */) {
+ parseExpected(96 /* SyntaxKind.FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected);
finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false);
}
return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc);
}
function parseCatchClause() {
var pos = getNodePos();
- parseExpected(83 /* CatchKeyword */);
+ parseExpected(83 /* SyntaxKind.CatchKeyword */);
var variableDeclaration;
- if (parseOptional(20 /* OpenParenToken */)) {
+ if (parseOptional(20 /* SyntaxKind.OpenParenToken */)) {
variableDeclaration = parseVariableDeclaration();
- parseExpected(21 /* CloseParenToken */);
+ parseExpected(21 /* SyntaxKind.CloseParenToken */);
}
else {
// Keep shape of node to avoid degrading performance.
@@ -35375,7 +36069,7 @@ var ts;
function parseDebuggerStatement() {
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
- parseExpected(87 /* DebuggerKeyword */);
+ parseExpected(87 /* SyntaxKind.DebuggerKeyword */);
parseSemicolon();
return withJSDoc(finishNode(factory.createDebuggerStatement(), pos), hasJSDoc);
}
@@ -35386,9 +36080,9 @@ var ts;
var pos = getNodePos();
var hasJSDoc = hasPrecedingJSDocComment();
var node;
- var hasParen = token() === 20 /* OpenParenToken */;
+ var hasParen = token() === 20 /* SyntaxKind.OpenParenToken */;
var expression = allowInAnd(parseExpression);
- if (ts.isIdentifier(expression) && parseOptional(58 /* ColonToken */)) {
+ if (ts.isIdentifier(expression) && parseOptional(58 /* SyntaxKind.ColonToken */)) {
node = factory.createLabeledStatement(expression, parseStatement());
}
else {
@@ -35409,25 +36103,25 @@ var ts;
}
function nextTokenIsClassKeywordOnSameLine() {
nextToken();
- return token() === 84 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak();
+ return token() === 84 /* SyntaxKind.ClassKeyword */ && !scanner.hasPrecedingLineBreak();
}
function nextTokenIsFunctionKeywordOnSameLine() {
nextToken();
- return token() === 98 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak();
+ return token() === 98 /* SyntaxKind.FunctionKeyword */ && !scanner.hasPrecedingLineBreak();
}
function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() {
nextToken();
- return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */ || token() === 10 /* StringLiteral */) && !scanner.hasPrecedingLineBreak();
+ return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */ || token() === 10 /* SyntaxKind.StringLiteral */) && !scanner.hasPrecedingLineBreak();
}
function isDeclaration() {
while (true) {
switch (token()) {
- case 113 /* VarKeyword */:
- case 119 /* LetKeyword */:
- case 85 /* ConstKeyword */:
- case 98 /* FunctionKeyword */:
- case 84 /* ClassKeyword */:
- case 92 /* EnumKeyword */:
+ case 113 /* SyntaxKind.VarKeyword */:
+ case 119 /* SyntaxKind.LetKeyword */:
+ case 85 /* SyntaxKind.ConstKeyword */:
+ case 98 /* SyntaxKind.FunctionKeyword */:
+ case 84 /* SyntaxKind.ClassKeyword */:
+ case 92 /* SyntaxKind.EnumKeyword */:
return true;
// 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers;
// however, an identifier cannot be followed by another identifier on the same line. This is what we
@@ -35450,44 +36144,44 @@ var ts;
// I {}
//
// could be legal, it would add complexity for very little gain.
- case 118 /* InterfaceKeyword */:
- case 151 /* TypeKeyword */:
+ case 118 /* SyntaxKind.InterfaceKeyword */:
+ case 152 /* SyntaxKind.TypeKeyword */:
return nextTokenIsIdentifierOnSameLine();
- case 141 /* ModuleKeyword */:
- case 142 /* NamespaceKeyword */:
+ case 141 /* SyntaxKind.ModuleKeyword */:
+ case 142 /* SyntaxKind.NamespaceKeyword */:
return nextTokenIsIdentifierOrStringLiteralOnSameLine();
- case 126 /* AbstractKeyword */:
- case 131 /* AsyncKeyword */:
- case 135 /* DeclareKeyword */:
- case 121 /* PrivateKeyword */:
- case 122 /* ProtectedKeyword */:
- case 123 /* PublicKeyword */:
- case 144 /* ReadonlyKeyword */:
+ case 126 /* SyntaxKind.AbstractKeyword */:
+ case 131 /* SyntaxKind.AsyncKeyword */:
+ case 135 /* SyntaxKind.DeclareKeyword */:
+ case 121 /* SyntaxKind.PrivateKeyword */:
+ case 122 /* SyntaxKind.ProtectedKeyword */:
+ case 123 /* SyntaxKind.PublicKeyword */:
+ case 145 /* SyntaxKind.ReadonlyKeyword */:
nextToken();
// ASI takes effect for this modifier.
if (scanner.hasPrecedingLineBreak()) {
return false;
}
continue;
- case 156 /* GlobalKeyword */:
+ case 157 /* SyntaxKind.GlobalKeyword */:
nextToken();
- return token() === 18 /* OpenBraceToken */ || token() === 79 /* Identifier */ || token() === 93 /* ExportKeyword */;
- case 100 /* ImportKeyword */:
+ return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 79 /* SyntaxKind.Identifier */ || token() === 93 /* SyntaxKind.ExportKeyword */;
+ case 100 /* SyntaxKind.ImportKeyword */:
nextToken();
- return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ ||
- token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token());
- case 93 /* ExportKeyword */:
+ return token() === 10 /* SyntaxKind.StringLiteral */ || token() === 41 /* SyntaxKind.AsteriskToken */ ||
+ token() === 18 /* SyntaxKind.OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token());
+ case 93 /* SyntaxKind.ExportKeyword */:
var currentToken_1 = nextToken();
- if (currentToken_1 === 151 /* TypeKeyword */) {
+ if (currentToken_1 === 152 /* SyntaxKind.TypeKeyword */) {
currentToken_1 = lookAhead(nextToken);
}
- if (currentToken_1 === 63 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ ||
- currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 88 /* DefaultKeyword */ ||
- currentToken_1 === 127 /* AsKeyword */) {
+ if (currentToken_1 === 63 /* SyntaxKind.EqualsToken */ || currentToken_1 === 41 /* SyntaxKind.AsteriskToken */ ||
+ currentToken_1 === 18 /* SyntaxKind.OpenBraceToken */ || currentToken_1 === 88 /* SyntaxKind.DefaultKeyword */ ||
+ currentToken_1 === 127 /* SyntaxKind.AsKeyword */) {
return true;
}
continue;
- case 124 /* StaticKeyword */:
+ case 124 /* SyntaxKind.StaticKeyword */:
nextToken();
continue;
default:
@@ -35500,51 +36194,51 @@ var ts;
}
function isStartOfStatement() {
switch (token()) {
- case 59 /* AtToken */:
- case 26 /* SemicolonToken */:
- case 18 /* OpenBraceToken */:
- case 113 /* VarKeyword */:
- case 119 /* LetKeyword */:
- case 98 /* FunctionKeyword */:
- case 84 /* ClassKeyword */:
- case 92 /* EnumKeyword */:
- case 99 /* IfKeyword */:
- case 90 /* DoKeyword */:
- case 115 /* WhileKeyword */:
- case 97 /* ForKeyword */:
- case 86 /* ContinueKeyword */:
- case 81 /* BreakKeyword */:
- case 105 /* ReturnKeyword */:
- case 116 /* WithKeyword */:
- case 107 /* SwitchKeyword */:
- case 109 /* ThrowKeyword */:
- case 111 /* TryKeyword */:
- case 87 /* DebuggerKeyword */:
+ case 59 /* SyntaxKind.AtToken */:
+ case 26 /* SyntaxKind.SemicolonToken */:
+ case 18 /* SyntaxKind.OpenBraceToken */:
+ case 113 /* SyntaxKind.VarKeyword */:
+ case 119 /* SyntaxKind.LetKeyword */:
+ case 98 /* SyntaxKind.FunctionKeyword */:
+ case 84 /* SyntaxKind.ClassKeyword */:
+ case 92 /* SyntaxKind.EnumKeyword */:
+ case 99 /* SyntaxKind.IfKeyword */:
+ case 90 /* SyntaxKind.DoKeyword */:
+ case 115 /* SyntaxKind.WhileKeyword */:
+ case 97 /* SyntaxKind.ForKeyword */:
+ case 86 /* SyntaxKind.ContinueKeyword */:
+ case 81 /* SyntaxKind.BreakKeyword */:
+ case 105 /* SyntaxKind.ReturnKeyword */:
+ case 116 /* SyntaxKind.WithKeyword */:
+ case 107 /* SyntaxKind.SwitchKeyword */:
+ case 109 /* SyntaxKind.ThrowKeyword */:
+ case 111 /* SyntaxKind.TryKeyword */:
+ case 87 /* SyntaxKind.DebuggerKeyword */:
// 'catch' and 'finally' do not actually indicate that the code is part of a statement,
// however, we say they are here so that we may gracefully parse them and error later.
// falls through
- case 83 /* CatchKeyword */:
- case 96 /* FinallyKeyword */:
+ case 83 /* SyntaxKind.CatchKeyword */:
+ case 96 /* SyntaxKind.FinallyKeyword */:
return true;
- case 100 /* ImportKeyword */:
+ case 100 /* SyntaxKind.ImportKeyword */:
return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot);
- case 85 /* ConstKeyword */:
- case 93 /* ExportKeyword */:
+ case 85 /* SyntaxKind.ConstKeyword */:
+ case 93 /* SyntaxKind.ExportKeyword */:
return isStartOfDeclaration();
- case 131 /* AsyncKeyword */:
- case 135 /* DeclareKeyword */:
- case 118 /* InterfaceKeyword */:
- case 141 /* ModuleKeyword */:
- case 142 /* NamespaceKeyword */:
- case 151 /* TypeKeyword */:
- case 156 /* GlobalKeyword */:
+ case 131 /* SyntaxKind.AsyncKeyword */:
+ case 135 /* SyntaxKind.DeclareKeyword */:
+ case 118 /* SyntaxKind.InterfaceKeyword */:
+ case 141 /* SyntaxKind.ModuleKeyword */:
+ case 142 /* SyntaxKind.NamespaceKeyword */:
+ case 152 /* SyntaxKind.TypeKeyword */:
+ case 157 /* SyntaxKind.GlobalKeyword */:
// When these don't start a declaration, they're an identifier in an expression statement
return true;
- case 123 /* PublicKeyword */:
- case 121 /* PrivateKeyword */:
- case 122 /* ProtectedKeyword */:
- case 124 /* StaticKeyword */:
- case 144 /* ReadonlyKeyword */:
+ case 123 /* SyntaxKind.PublicKeyword */:
+ case 121 /* SyntaxKind.PrivateKeyword */:
+ case 122 /* SyntaxKind.ProtectedKeyword */:
+ case 124 /* SyntaxKind.StaticKeyword */:
+ case 145 /* SyntaxKind.ReadonlyKeyword */:
// When these don't start a declaration, they may be the start of a class member if an identifier
// immediately follows. Otherwise they're an identifier in an expression statement.
return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
@@ -35554,7 +36248,7 @@ var ts;
}
function nextTokenIsBindingIdentifierOrStartOfDestructuring() {
nextToken();
- return isBindingIdentifier() || token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */;
+ return isBindingIdentifier() || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */;
}
function isLetDeclaration() {
// In ES6 'let' always starts a lexical declaration if followed by an identifier or {
@@ -35563,68 +36257,68 @@ var ts;
}
function parseStatement() {
switch (token()) {
- case 26 /* SemicolonToken */:
+ case 26 /* SyntaxKind.SemicolonToken */:
return parseEmptyStatement();
- case 18 /* OpenBraceToken */:
+ case 18 /* SyntaxKind.OpenBraceToken */:
return parseBlock(/*ignoreMissingOpenBrace*/ false);
- case 113 /* VarKeyword */:
+ case 113 /* SyntaxKind.VarKeyword */:
return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined);
- case 119 /* LetKeyword */:
+ case 119 /* SyntaxKind.LetKeyword */:
if (isLetDeclaration()) {
return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined);
}
break;
- case 98 /* FunctionKeyword */:
+ case 98 /* SyntaxKind.FunctionKeyword */:
return parseFunctionDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined);
- case 84 /* ClassKeyword */:
+ case 84 /* SyntaxKind.ClassKeyword */:
return parseClassDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined);
- case 99 /* IfKeyword */:
+ case 99 /* SyntaxKind.IfKeyword */:
return parseIfStatement();
- case 90 /* DoKeyword */:
+ case 90 /* SyntaxKind.DoKeyword */:
return parseDoStatement();
- case 115 /* WhileKeyword */:
+ case 115 /* SyntaxKind.WhileKeyword */:
return parseWhileStatement();
- case 97 /* ForKeyword */:
+ case 97 /* SyntaxKind.ForKeyword */:
return parseForOrForInOrForOfStatement();
- case 86 /* ContinueKeyword */:
- return parseBreakOrContinueStatement(244 /* ContinueStatement */);
- case 81 /* BreakKeyword */:
- return parseBreakOrContinueStatement(245 /* BreakStatement */);
- case 105 /* ReturnKeyword */:
+ case 86 /* SyntaxKind.ContinueKeyword */:
+ return parseBreakOrContinueStatement(245 /* SyntaxKind.ContinueStatement */);
+ case 81 /* SyntaxKind.BreakKeyword */:
+ return parseBreakOrContinueStatement(246 /* SyntaxKind.BreakStatement */);
+ case 105 /* SyntaxKind.ReturnKeyword */:
return parseReturnStatement();
- case 116 /* WithKeyword */:
+ case 116 /* SyntaxKind.WithKeyword */:
return parseWithStatement();
- case 107 /* SwitchKeyword */:
+ case 107 /* SyntaxKind.SwitchKeyword */:
return parseSwitchStatement();
- case 109 /* ThrowKeyword */:
+ case 109 /* SyntaxKind.ThrowKeyword */:
return parseThrowStatement();
- case 111 /* TryKeyword */:
+ case 111 /* SyntaxKind.TryKeyword */:
// Include 'catch' and 'finally' for error recovery.
// falls through
- case 83 /* CatchKeyword */:
- case 96 /* FinallyKeyword */:
+ case 83 /* SyntaxKind.CatchKeyword */:
+ case 96 /* SyntaxKind.FinallyKeyword */:
return parseTryStatement();
- case 87 /* DebuggerKeyword */:
+ case 87 /* SyntaxKind.DebuggerKeyword */:
return parseDebuggerStatement();
- case 59 /* AtToken */:
+ case 59 /* SyntaxKind.AtToken */:
return parseDeclaration();
- case 131 /* AsyncKeyword */:
- case 118 /* InterfaceKeyword */:
- case 151 /* TypeKeyword */:
- case 141 /* ModuleKeyword */:
- case 142 /* NamespaceKeyword */:
- case 135 /* DeclareKeyword */:
- case 85 /* ConstKeyword */:
- case 92 /* EnumKeyword */:
- case 93 /* ExportKeyword */:
- case 100 /* ImportKeyword */:
- case 121 /* PrivateKeyword */:
- case 122 /* ProtectedKeyword */:
- case 123 /* PublicKeyword */:
- case 126 /* AbstractKeyword */:
- case 124 /* StaticKeyword */:
- case 144 /* ReadonlyKeyword */:
- case 156 /* GlobalKeyword */:
+ case 131 /* SyntaxKind.AsyncKeyword */:
+ case 118 /* SyntaxKind.InterfaceKeyword */:
+ case 152 /* SyntaxKind.TypeKeyword */:
+ case 141 /* SyntaxKind.ModuleKeyword */:
+ case 142 /* SyntaxKind.NamespaceKeyword */:
+ case 135 /* SyntaxKind.DeclareKeyword */:
+ case 85 /* SyntaxKind.ConstKeyword */:
+ case 92 /* SyntaxKind.EnumKeyword */:
+ case 93 /* SyntaxKind.ExportKeyword */:
+ case 100 /* SyntaxKind.ImportKeyword */:
+ case 121 /* SyntaxKind.PrivateKeyword */:
+ case 122 /* SyntaxKind.ProtectedKeyword */:
+ case 123 /* SyntaxKind.PublicKeyword */:
+ case 126 /* SyntaxKind.AbstractKeyword */:
+ case 124 /* SyntaxKind.StaticKeyword */:
+ case 145 /* SyntaxKind.ReadonlyKeyword */:
+ case 157 /* SyntaxKind.GlobalKeyword */:
if (isStartOfDeclaration()) {
return parseDeclaration();
}
@@ -35633,7 +36327,7 @@ var ts;
return parseExpressionOrLabeledStatement();
}
function isDeclareModifier(modifier) {
- return modifier.kind === 135 /* DeclareKeyword */;
+ return modifier.kind === 135 /* SyntaxKind.DeclareKeyword */;
}
function parseDeclaration() {
// TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner
@@ -35656,16 +36350,16 @@ var ts;
if (isAmbient) {
for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
var m = _a[_i];
- m.flags |= 8388608 /* Ambient */;
+ m.flags |= 16777216 /* NodeFlags.Ambient */;
}
- return doInsideOfContext(8388608 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); });
+ return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); });
}
else {
return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers);
}
}
function tryReuseAmbientDeclaration() {
- return doInsideOfContext(8388608 /* Ambient */, function () {
+ return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () {
var node = currentNode(parsingContext);
if (node) {
return consumeNode(node);
@@ -35674,33 +36368,33 @@ var ts;
}
function parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers) {
switch (token()) {
- case 113 /* VarKeyword */:
- case 119 /* LetKeyword */:
- case 85 /* ConstKeyword */:
+ case 113 /* SyntaxKind.VarKeyword */:
+ case 119 /* SyntaxKind.LetKeyword */:
+ case 85 /* SyntaxKind.ConstKeyword */:
return parseVariableStatement(pos, hasJSDoc, decorators, modifiers);
- case 98 /* FunctionKeyword */:
+ case 98 /* SyntaxKind.FunctionKeyword */:
return parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers);
- case 84 /* ClassKeyword */:
+ case 84 /* SyntaxKind.ClassKeyword */:
return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers);
- case 118 /* InterfaceKeyword */:
+ case 118 /* SyntaxKind.InterfaceKeyword */:
return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers);
- case 151 /* TypeKeyword */:
+ case 152 /* SyntaxKind.TypeKeyword */:
return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers);
- case 92 /* EnumKeyword */:
+ case 92 /* SyntaxKind.EnumKeyword */:
return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers);
- case 156 /* GlobalKeyword */:
- case 141 /* ModuleKeyword */:
- case 142 /* NamespaceKeyword */:
+ case 157 /* SyntaxKind.GlobalKeyword */:
+ case 141 /* SyntaxKind.ModuleKeyword */:
+ case 142 /* SyntaxKind.NamespaceKeyword */:
return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers);
- case 100 /* ImportKeyword */:
+ case 100 /* SyntaxKind.ImportKeyword */:
return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers);
- case 93 /* ExportKeyword */:
+ case 93 /* SyntaxKind.ExportKeyword */:
nextToken();
switch (token()) {
- case 88 /* DefaultKeyword */:
- case 63 /* EqualsToken */:
+ case 88 /* SyntaxKind.DefaultKeyword */:
+ case 63 /* SyntaxKind.EqualsToken */:
return parseExportAssignment(pos, hasJSDoc, decorators, modifiers);
- case 127 /* AsKeyword */:
+ case 127 /* SyntaxKind.AsKeyword */:
return parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers);
default:
return parseExportDeclaration(pos, hasJSDoc, decorators, modifiers);
@@ -35709,7 +36403,7 @@ var ts;
if (decorators || modifiers) {
// We reached this point because we encountered decorators and/or modifiers and assumed a declaration
// would follow. For recovery and error reporting purposes, return an incomplete declaration.
- var missing = createMissingNode(275 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected);
+ var missing = createMissingNode(276 /* SyntaxKind.MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected);
ts.setTextRangePos(missing, pos);
missing.decorators = decorators;
missing.modifiers = modifiers;
@@ -35720,10 +36414,10 @@ var ts;
}
function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
nextToken();
- return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */);
+ return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* SyntaxKind.StringLiteral */);
}
function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) {
- if (token() !== 18 /* OpenBraceToken */ && canParseSemicolon()) {
+ if (token() !== 18 /* SyntaxKind.OpenBraceToken */ && canParseSemicolon()) {
parseSemicolon();
return;
}
@@ -35732,26 +36426,26 @@ var ts;
// DECLARATIONS
function parseArrayBindingElement() {
var pos = getNodePos();
- if (token() === 27 /* CommaToken */) {
+ if (token() === 27 /* SyntaxKind.CommaToken */) {
return finishNode(factory.createOmittedExpression(), pos);
}
- var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */);
+ var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */);
var name = parseIdentifierOrPattern();
var initializer = parseInitializer();
return finishNode(factory.createBindingElement(dotDotDotToken, /*propertyName*/ undefined, name, initializer), pos);
}
function parseObjectBindingElement() {
var pos = getNodePos();
- var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */);
+ var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */);
var tokenIsIdentifier = isBindingIdentifier();
var propertyName = parsePropertyName();
var name;
- if (tokenIsIdentifier && token() !== 58 /* ColonToken */) {
+ if (tokenIsIdentifier && token() !== 58 /* SyntaxKind.ColonToken */) {
name = propertyName;
propertyName = undefined;
}
else {
- parseExpected(58 /* ColonToken */);
+ parseExpected(58 /* SyntaxKind.ColonToken */);
name = parseIdentifierOrPattern();
}
var initializer = parseInitializer();
@@ -35759,29 +36453,29 @@ var ts;
}
function parseObjectBindingPattern() {
var pos = getNodePos();
- parseExpected(18 /* OpenBraceToken */);
- var elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement);
- parseExpected(19 /* CloseBraceToken */);
+ parseExpected(18 /* SyntaxKind.OpenBraceToken */);
+ var elements = parseDelimitedList(9 /* ParsingContext.ObjectBindingElements */, parseObjectBindingElement);
+ parseExpected(19 /* SyntaxKind.CloseBraceToken */);
return finishNode(factory.createObjectBindingPattern(elements), pos);
}
function parseArrayBindingPattern() {
var pos = getNodePos();
- parseExpected(22 /* OpenBracketToken */);
- var elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement);
- parseExpected(23 /* CloseBracketToken */);
+ parseExpected(22 /* SyntaxKind.OpenBracketToken */);
+ var elements = parseDelimitedList(10 /* ParsingContext.ArrayBindingElements */, parseArrayBindingElement);
+ parseExpected(23 /* SyntaxKind.CloseBracketToken */);
return finishNode(factory.createArrayBindingPattern(elements), pos);
}
function isBindingIdentifierOrPrivateIdentifierOrPattern() {
- return token() === 18 /* OpenBraceToken */
- || token() === 22 /* OpenBracketToken */
- || token() === 80 /* PrivateIdentifier */
+ return token() === 18 /* SyntaxKind.OpenBraceToken */
+ || token() === 22 /* SyntaxKind.OpenBracketToken */
+ || token() === 80 /* SyntaxKind.PrivateIdentifier */
|| isBindingIdentifier();
}
function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) {
- if (token() === 22 /* OpenBracketToken */) {
+ if (token() === 22 /* SyntaxKind.OpenBracketToken */) {
return parseArrayBindingPattern();
}
- if (token() === 18 /* OpenBraceToken */) {
+ if (token() === 18 /* SyntaxKind.OpenBraceToken */) {
return parseObjectBindingPattern();
}
return parseBindingIdentifier(privateIdentifierDiagnosticMessage);
@@ -35794,8 +36488,8 @@ var ts;
var hasJSDoc = hasPrecedingJSDocComment();
var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations);
var exclamationToken;
- if (allowExclamation && name.kind === 79 /* Identifier */ &&
- token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) {
+ if (allowExclamation && name.kind === 79 /* SyntaxKind.Identifier */ &&
+ token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) {
exclamationToken = parseTokenNode();
}
var type = parseTypeAnnotation();
@@ -35807,13 +36501,13 @@ var ts;
var pos = getNodePos();
var flags = 0;
switch (token()) {
- case 113 /* VarKeyword */:
+ case 113 /* SyntaxKind.VarKeyword */:
break;
- case 119 /* LetKeyword */:
- flags |= 1 /* Let */;
+ case 119 /* SyntaxKind.LetKeyword */:
+ flags |= 1 /* NodeFlags.Let */;
break;
- case 85 /* ConstKeyword */:
- flags |= 2 /* Const */;
+ case 85 /* SyntaxKind.ConstKeyword */:
+ flags |= 2 /* NodeFlags.Const */;
break;
default:
ts.Debug.fail();
@@ -35829,19 +36523,19 @@ var ts;
// this context.
// The checker will then give an error that there is an empty declaration list.
var declarations;
- if (token() === 159 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) {
+ if (token() === 160 /* SyntaxKind.OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) {
declarations = createMissingList();
}
else {
var savedDisallowIn = inDisallowInContext();
setDisallowInContext(inForStatementInitializer);
- declarations = parseDelimitedList(8 /* VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation);
+ declarations = parseDelimitedList(8 /* ParsingContext.VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation);
setDisallowInContext(savedDisallowIn);
}
return finishNode(factory.createVariableDeclarationList(declarations, flags), pos);
}
function canFollowContextualOfKeyword() {
- return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */;
+ return nextTokenIsIdentifier() && nextToken() === 21 /* SyntaxKind.CloseParenToken */;
}
function parseVariableStatement(pos, hasJSDoc, decorators, modifiers) {
var declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false);
@@ -35854,27 +36548,27 @@ var ts;
function parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers) {
var savedAwaitContext = inAwaitContext();
var modifierFlags = ts.modifiersToFlags(modifiers);
- parseExpected(98 /* FunctionKeyword */);
- var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
+ parseExpected(98 /* SyntaxKind.FunctionKeyword */);
+ var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */);
// We don't parse the name here in await context, instead we will report a grammar error in the checker.
- var name = modifierFlags & 512 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier();
- var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */;
- var isAsync = modifierFlags & 256 /* Async */ ? 2 /* Await */ : 0 /* None */;
+ var name = modifierFlags & 512 /* ModifierFlags.Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier();
+ var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */;
+ var isAsync = modifierFlags & 256 /* ModifierFlags.Async */ ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */;
var typeParameters = parseTypeParameters();
- if (modifierFlags & 1 /* Export */)
+ if (modifierFlags & 1 /* ModifierFlags.Export */)
setAwaitContext(/*value*/ true);
var parameters = parseParameters(isGenerator | isAsync);
- var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
+ var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false);
var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected);
setAwaitContext(savedAwaitContext);
var node = factory.createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body);
return withJSDoc(finishNode(node, pos), hasJSDoc);
}
function parseConstructorName() {
- if (token() === 134 /* ConstructorKeyword */) {
- return parseExpected(134 /* ConstructorKeyword */);
+ if (token() === 134 /* SyntaxKind.ConstructorKeyword */) {
+ return parseExpected(134 /* SyntaxKind.ConstructorKeyword */);
}
- if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) {
+ if (token() === 10 /* SyntaxKind.StringLiteral */ && lookAhead(nextToken) === 20 /* SyntaxKind.OpenParenToken */) {
return tryParse(function () {
var literalNode = parseLiteralNode();
return literalNode.text === "constructor" ? literalNode : undefined;
@@ -35885,9 +36579,9 @@ var ts;
return tryParse(function () {
if (parseConstructorName()) {
var typeParameters = parseTypeParameters();
- var parameters = parseParameters(0 /* None */);
- var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
- var body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected);
+ var parameters = parseParameters(0 /* SignatureFlags.None */);
+ var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false);
+ var body = parseFunctionBlockOrSemicolon(0 /* SignatureFlags.None */, ts.Diagnostics.or_expected);
var node = factory.createConstructorDeclaration(decorators, modifiers, parameters, body);
// Attach `typeParameters` and `type` if they exist so that we can report them in the grammar checker.
node.typeParameters = typeParameters;
@@ -35897,11 +36591,11 @@ var ts;
});
}
function parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken, diagnosticMessage) {
- var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */;
- var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */;
+ var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */;
+ var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */;
var typeParameters = parseTypeParameters();
var parameters = parseParameters(isGenerator | isAsync);
- var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
+ var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false);
var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage);
var node = factory.createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body);
// An exclamation token on a method is invalid syntax and will be handled by the grammar checker
@@ -35909,20 +36603,20 @@ var ts;
return withJSDoc(finishNode(node, pos), hasJSDoc);
}
function parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken) {
- var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* ExclamationToken */) : undefined;
+ var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* SyntaxKind.ExclamationToken */) : undefined;
var type = parseTypeAnnotation();
- var initializer = doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */ | 4096 /* DisallowInContext */, parseInitializer);
+ var initializer = doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */ | 4096 /* NodeFlags.DisallowInContext */, parseInitializer);
parseSemicolonAfterPropertyName(name, type, initializer);
var node = factory.createPropertyDeclaration(decorators, modifiers, name, questionToken || exclamationToken, type, initializer);
return withJSDoc(finishNode(node, pos), hasJSDoc);
}
function parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers) {
- var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
+ var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */);
var name = parsePropertyName();
// Note: this is not legal as per the grammar. But we allow it in the parser and
// report an error in the grammar checker.
- var questionToken = parseOptionalToken(57 /* QuestionToken */);
- if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) {
+ var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */);
+ if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) {
return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, /*exclamationToken*/ undefined, ts.Diagnostics.or_expected);
}
return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken);
@@ -35930,21 +36624,21 @@ var ts;
function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) {
var name = parsePropertyName();
var typeParameters = parseTypeParameters();
- var parameters = parseParameters(0 /* None */);
- var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
- var body = parseFunctionBlockOrSemicolon(0 /* None */);
- var node = kind === 171 /* GetAccessor */
+ var parameters = parseParameters(0 /* SignatureFlags.None */);
+ var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false);
+ var body = parseFunctionBlockOrSemicolon(0 /* SignatureFlags.None */);
+ var node = kind === 172 /* SyntaxKind.GetAccessor */
? factory.createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body)
: factory.createSetAccessorDeclaration(decorators, modifiers, name, parameters, body);
// Keep track of `typeParameters` (for both) and `type` (for setters) if they were parsed those indicate grammar errors
node.typeParameters = typeParameters;
- if (type && node.kind === 172 /* SetAccessor */)
+ if (type && node.kind === 173 /* SyntaxKind.SetAccessor */)
node.type = type;
return withJSDoc(finishNode(node, pos), hasJSDoc);
}
function isClassMemberStart() {
var idToken;
- if (token() === 59 /* AtToken */) {
+ if (token() === 59 /* SyntaxKind.AtToken */) {
return true;
}
// Eat up all modifiers, but hold on to the last one in case it is actually an identifier.
@@ -35961,7 +36655,7 @@ var ts;
}
nextToken();
}
- if (token() === 41 /* AsteriskToken */) {
+ if (token() === 41 /* SyntaxKind.AsteriskToken */) {
return true;
}
// Try to get the first property-like token following all modifiers.
@@ -35971,24 +36665,24 @@ var ts;
nextToken();
}
// Index signatures and computed properties are class members; we can parse.
- if (token() === 22 /* OpenBracketToken */) {
+ if (token() === 22 /* SyntaxKind.OpenBracketToken */) {
return true;
}
// If we were able to get any potential identifier...
if (idToken !== undefined) {
// If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse.
- if (!ts.isKeyword(idToken) || idToken === 148 /* SetKeyword */ || idToken === 136 /* GetKeyword */) {
+ if (!ts.isKeyword(idToken) || idToken === 149 /* SyntaxKind.SetKeyword */ || idToken === 136 /* SyntaxKind.GetKeyword */) {
return true;
}
// If it *is* a keyword, but not an accessor, check a little farther along
// to see if it should actually be parsed as a class member.
switch (token()) {
- case 20 /* OpenParenToken */: // Method declaration
- case 29 /* LessThanToken */: // Generic Method declaration
- case 53 /* ExclamationToken */: // Non-null assertion on property name
- case 58 /* ColonToken */: // Type Annotation for declaration
- case 63 /* EqualsToken */: // Initializer for declaration
- case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on.
+ case 20 /* SyntaxKind.OpenParenToken */: // Method declaration
+ case 29 /* SyntaxKind.LessThanToken */: // Generic Method declaration
+ case 53 /* SyntaxKind.ExclamationToken */: // Non-null assertion on property name
+ case 58 /* SyntaxKind.ColonToken */: // Type Annotation for declaration
+ case 63 /* SyntaxKind.EqualsToken */: // Initializer for declaration
+ case 57 /* SyntaxKind.QuestionToken */: // Not valid, but permitted so that it gets caught later on.
return true;
default:
// Covers
@@ -36002,7 +36696,7 @@ var ts;
return false;
}
function parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers) {
- parseExpectedToken(124 /* StaticKeyword */);
+ parseExpectedToken(124 /* SyntaxKind.StaticKeyword */);
var body = parseClassStaticBlockBody();
return withJSDoc(finishNode(factory.createClassStaticBlockDeclaration(decorators, modifiers, body), pos), hasJSDoc);
}
@@ -36017,7 +36711,7 @@ var ts;
return body;
}
function parseDecoratorExpression() {
- if (inAwaitContext() && token() === 132 /* AwaitKeyword */) {
+ if (inAwaitContext() && token() === 132 /* SyntaxKind.AwaitKeyword */) {
// `@await` is is disallowed in an [Await] context, but can cause parsing to go off the rails
// This simply parses the missing identifier and moves on.
var pos = getNodePos();
@@ -36030,7 +36724,7 @@ var ts;
}
function tryParseDecorator() {
var pos = getNodePos();
- if (!parseOptional(59 /* AtToken */)) {
+ if (!parseOptional(59 /* SyntaxKind.AtToken */)) {
return undefined;
}
var expression = doInDecoratorContext(parseDecoratorExpression);
@@ -36047,17 +36741,17 @@ var ts;
function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStaticModifier) {
var pos = getNodePos();
var kind = token();
- if (token() === 85 /* ConstKeyword */ && permitInvalidConstAsModifier) {
+ if (token() === 85 /* SyntaxKind.ConstKeyword */ && permitInvalidConstAsModifier) {
// We need to ensure that any subsequent modifiers appear on the same line
// so that when 'const' is a standalone declaration, we don't issue an error.
if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) {
return undefined;
}
}
- else if (stopOnStartOfClassStaticBlock && token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) {
+ else if (stopOnStartOfClassStaticBlock && token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) {
return undefined;
}
- else if (hasSeenStaticModifier && token() === 124 /* StaticKeyword */) {
+ else if (hasSeenStaticModifier && token() === 124 /* SyntaxKind.StaticKeyword */) {
return undefined;
}
else {
@@ -36078,7 +36772,7 @@ var ts;
var pos = getNodePos();
var list, modifier, hasSeenStatic = false;
while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStatic)) {
- if (modifier.kind === 124 /* StaticKeyword */)
+ if (modifier.kind === 124 /* SyntaxKind.StaticKeyword */)
hasSeenStatic = true;
list = ts.append(list, modifier);
}
@@ -36086,33 +36780,33 @@ var ts;
}
function parseModifiersForArrowFunction() {
var modifiers;
- if (token() === 131 /* AsyncKeyword */) {
+ if (token() === 131 /* SyntaxKind.AsyncKeyword */) {
var pos = getNodePos();
nextToken();
- var modifier = finishNode(factory.createToken(131 /* AsyncKeyword */), pos);
+ var modifier = finishNode(factory.createToken(131 /* SyntaxKind.AsyncKeyword */), pos);
modifiers = createNodeArray([modifier], pos);
}
return modifiers;
}
function parseClassElement() {
var pos = getNodePos();
- if (token() === 26 /* SemicolonToken */) {
+ if (token() === 26 /* SyntaxKind.SemicolonToken */) {
nextToken();
return finishNode(factory.createSemicolonClassElement(), pos);
}
var hasJSDoc = hasPrecedingJSDocComment();
var decorators = parseDecorators();
var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true, /*stopOnStartOfClassStaticBlock*/ true);
- if (token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) {
+ if (token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) {
return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers);
}
- if (parseContextualModifier(136 /* GetKeyword */)) {
- return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 171 /* GetAccessor */);
+ if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) {
+ return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */);
}
- if (parseContextualModifier(148 /* SetKeyword */)) {
- return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SetAccessor */);
+ if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) {
+ return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */);
}
- if (token() === 134 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) {
+ if (token() === 134 /* SyntaxKind.ConstructorKeyword */ || token() === 10 /* SyntaxKind.StringLiteral */) {
var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers);
if (constructorDeclaration) {
return constructorDeclaration;
@@ -36124,17 +36818,17 @@ var ts;
// It is very important that we check this *after* checking indexers because
// the [ token can start an index signature or a computed property name
if (ts.tokenIsIdentifierOrKeyword(token()) ||
- token() === 10 /* StringLiteral */ ||
- token() === 8 /* NumericLiteral */ ||
- token() === 41 /* AsteriskToken */ ||
- token() === 22 /* OpenBracketToken */) {
+ token() === 10 /* SyntaxKind.StringLiteral */ ||
+ token() === 8 /* SyntaxKind.NumericLiteral */ ||
+ token() === 41 /* SyntaxKind.AsteriskToken */ ||
+ token() === 22 /* SyntaxKind.OpenBracketToken */) {
var isAmbient = ts.some(modifiers, isDeclareModifier);
if (isAmbient) {
for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
var m = _a[_i];
- m.flags |= 8388608 /* Ambient */;
+ m.flags |= 16777216 /* NodeFlags.Ambient */;
}
- return doInsideOfContext(8388608 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); });
+ return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); });
}
else {
return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers);
@@ -36142,21 +36836,21 @@ var ts;
}
if (decorators || modifiers) {
// treat this as a property declaration with a missing name.
- var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected);
+ var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected);
return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, /*questionToken*/ undefined);
}
// 'isClassMemberStart' should have hinted not to attempt parsing.
return ts.Debug.fail("Should not have attempted to parse class member declaration.");
}
function parseClassExpression() {
- return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 225 /* ClassExpression */);
+ return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* SyntaxKind.ClassExpression */);
}
function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) {
- return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 256 /* ClassDeclaration */);
+ return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 257 /* SyntaxKind.ClassDeclaration */);
}
function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) {
var savedAwaitContext = inAwaitContext();
- parseExpected(84 /* ClassKeyword */);
+ parseExpected(84 /* SyntaxKind.ClassKeyword */);
// We don't parse the name here in await context, instead we will report a grammar error in the checker.
var name = parseNameOfClassDeclarationOrExpression();
var typeParameters = parseTypeParameters();
@@ -36164,17 +36858,17 @@ var ts;
setAwaitContext(/*value*/ true);
var heritageClauses = parseHeritageClauses();
var members;
- if (parseExpected(18 /* OpenBraceToken */)) {
+ if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) {
// ClassTail[Yield,Await] : (Modified) See 14.5
// ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt }
members = parseClassMembers();
- parseExpected(19 /* CloseBraceToken */);
+ parseExpected(19 /* SyntaxKind.CloseBraceToken */);
}
else {
members = createMissingList();
}
setAwaitContext(savedAwaitContext);
- var node = kind === 256 /* ClassDeclaration */
+ var node = kind === 257 /* SyntaxKind.ClassDeclaration */
? factory.createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members)
: factory.createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members);
return withJSDoc(finishNode(node, pos), hasJSDoc);
@@ -36190,42 +36884,45 @@ var ts;
: undefined;
}
function isImplementsClause() {
- return token() === 117 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword);
+ return token() === 117 /* SyntaxKind.ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword);
}
function parseHeritageClauses() {
// ClassTail[Yield,Await] : (Modified) See 14.5
// ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt }
if (isHeritageClause()) {
- return parseList(22 /* HeritageClauses */, parseHeritageClause);
+ return parseList(22 /* ParsingContext.HeritageClauses */, parseHeritageClause);
}
return undefined;
}
function parseHeritageClause() {
var pos = getNodePos();
var tok = token();
- ts.Debug.assert(tok === 94 /* ExtendsKeyword */ || tok === 117 /* ImplementsKeyword */); // isListElement() should ensure this.
+ ts.Debug.assert(tok === 94 /* SyntaxKind.ExtendsKeyword */ || tok === 117 /* SyntaxKind.ImplementsKeyword */); // isListElement() should ensure this.
nextToken();
- var types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments);
+ var types = parseDelimitedList(7 /* ParsingContext.HeritageClauseElement */, parseExpressionWithTypeArguments);
return finishNode(factory.createHeritageClause(tok, types), pos);
}
function parseExpressionWithTypeArguments() {
var pos = getNodePos();
var expression = parseLeftHandSideExpressionOrHigher();
+ if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) {
+ return expression;
+ }
var typeArguments = tryParseTypeArguments();
return finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
}
function tryParseTypeArguments() {
- return token() === 29 /* LessThanToken */ ?
- parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined;
+ return token() === 29 /* SyntaxKind.LessThanToken */ ?
+ parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */) : undefined;
}
function isHeritageClause() {
- return token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */;
+ return token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */;
}
function parseClassMembers() {
- return parseList(5 /* ClassMembers */, parseClassElement);
+ return parseList(5 /* ParsingContext.ClassMembers */, parseClassElement);
}
function parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers) {
- parseExpected(118 /* InterfaceKeyword */);
+ parseExpected(118 /* SyntaxKind.InterfaceKeyword */);
var name = parseIdentifier();
var typeParameters = parseTypeParameters();
var heritageClauses = parseHeritageClauses();
@@ -36234,11 +36931,11 @@ var ts;
return withJSDoc(finishNode(node, pos), hasJSDoc);
}
function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) {
- parseExpected(151 /* TypeKeyword */);
+ parseExpected(152 /* SyntaxKind.TypeKeyword */);
var name = parseIdentifier();
var typeParameters = parseTypeParameters();
- parseExpected(63 /* EqualsToken */);
- var type = token() === 138 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType();
+ parseExpected(63 /* SyntaxKind.EqualsToken */);
+ var type = token() === 138 /* SyntaxKind.IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType();
parseSemicolon();
var node = factory.createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type);
return withJSDoc(finishNode(node, pos), hasJSDoc);
@@ -36255,12 +36952,12 @@ var ts;
return withJSDoc(finishNode(factory.createEnumMember(name, initializer), pos), hasJSDoc);
}
function parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers) {
- parseExpected(92 /* EnumKeyword */);
+ parseExpected(92 /* SyntaxKind.EnumKeyword */);
var name = parseIdentifier();
var members;
- if (parseExpected(18 /* OpenBraceToken */)) {
- members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* EnumMembers */, parseEnumMember); });
- parseExpected(19 /* CloseBraceToken */);
+ if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) {
+ members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* ParsingContext.EnumMembers */, parseEnumMember); });
+ parseExpected(19 /* SyntaxKind.CloseBraceToken */);
}
else {
members = createMissingList();
@@ -36271,9 +36968,9 @@ var ts;
function parseModuleBlock() {
var pos = getNodePos();
var statements;
- if (parseExpected(18 /* OpenBraceToken */)) {
- statements = parseList(1 /* BlockStatements */, parseStatement);
- parseExpected(19 /* CloseBraceToken */);
+ if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) {
+ statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement);
+ parseExpected(19 /* SyntaxKind.CloseBraceToken */);
}
else {
statements = createMissingList();
@@ -36283,10 +36980,10 @@ var ts;
function parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags) {
// If we are parsing a dotted namespace name, we want to
// propagate the 'Namespace' flag across the names if set.
- var namespaceFlag = flags & 16 /* Namespace */;
+ var namespaceFlag = flags & 16 /* NodeFlags.Namespace */;
var name = parseIdentifier();
- var body = parseOptional(24 /* DotToken */)
- ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NestedNamespace */ | namespaceFlag)
+ var body = parseOptional(24 /* SyntaxKind.DotToken */)
+ ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NodeFlags.NestedNamespace */ | namespaceFlag)
: parseModuleBlock();
var node = factory.createModuleDeclaration(decorators, modifiers, name, body, flags);
return withJSDoc(finishNode(node, pos), hasJSDoc);
@@ -36294,17 +36991,17 @@ var ts;
function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) {
var flags = 0;
var name;
- if (token() === 156 /* GlobalKeyword */) {
+ if (token() === 157 /* SyntaxKind.GlobalKeyword */) {
// parse 'global' as name of global scope augmentation
name = parseIdentifier();
- flags |= 1024 /* GlobalAugmentation */;
+ flags |= 1024 /* NodeFlags.GlobalAugmentation */;
}
else {
name = parseLiteralNode();
name.text = internIdentifier(name.text);
}
var body;
- if (token() === 18 /* OpenBraceToken */) {
+ if (token() === 18 /* SyntaxKind.OpenBraceToken */) {
body = parseModuleBlock();
}
else {
@@ -36315,37 +37012,37 @@ var ts;
}
function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) {
var flags = 0;
- if (token() === 156 /* GlobalKeyword */) {
+ if (token() === 157 /* SyntaxKind.GlobalKeyword */) {
// global augmentation
return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers);
}
- else if (parseOptional(142 /* NamespaceKeyword */)) {
- flags |= 16 /* Namespace */;
+ else if (parseOptional(142 /* SyntaxKind.NamespaceKeyword */)) {
+ flags |= 16 /* NodeFlags.Namespace */;
}
else {
- parseExpected(141 /* ModuleKeyword */);
- if (token() === 10 /* StringLiteral */) {
+ parseExpected(141 /* SyntaxKind.ModuleKeyword */);
+ if (token() === 10 /* SyntaxKind.StringLiteral */) {
return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers);
}
}
return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags);
}
function isExternalModuleReference() {
- return token() === 145 /* RequireKeyword */ &&
+ return token() === 146 /* SyntaxKind.RequireKeyword */ &&
lookAhead(nextTokenIsOpenParen);
}
function nextTokenIsOpenParen() {
- return nextToken() === 20 /* OpenParenToken */;
+ return nextToken() === 20 /* SyntaxKind.OpenParenToken */;
}
function nextTokenIsOpenBrace() {
- return nextToken() === 18 /* OpenBraceToken */;
+ return nextToken() === 18 /* SyntaxKind.OpenBraceToken */;
}
function nextTokenIsSlash() {
- return nextToken() === 43 /* SlashToken */;
+ return nextToken() === 43 /* SyntaxKind.SlashToken */;
}
function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) {
- parseExpected(127 /* AsKeyword */);
- parseExpected(142 /* NamespaceKeyword */);
+ parseExpected(127 /* SyntaxKind.AsKeyword */);
+ parseExpected(142 /* SyntaxKind.NamespaceKeyword */);
var name = parseIdentifier();
parseSemicolon();
var node = factory.createNamespaceExportDeclaration(name);
@@ -36355,7 +37052,7 @@ var ts;
return withJSDoc(finishNode(node, pos), hasJSDoc);
}
function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers) {
- parseExpected(100 /* ImportKeyword */);
+ parseExpected(100 /* SyntaxKind.ImportKeyword */);
var afterImportPos = scanner.getStartPos();
// We don't parse the identifier here in await context, instead we will report a grammar error in the checker.
var identifier;
@@ -36363,7 +37060,7 @@ var ts;
identifier = parseIdentifier();
}
var isTypeOnly = false;
- if (token() !== 155 /* FromKeyword */ &&
+ if (token() !== 156 /* SyntaxKind.FromKeyword */ &&
(identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" &&
(isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
isTypeOnly = true;
@@ -36377,15 +37074,15 @@ var ts;
// import ModuleSpecifier;
var importClause;
if (identifier || // import id
- token() === 41 /* AsteriskToken */ || // import *
- token() === 18 /* OpenBraceToken */ // import {
+ token() === 41 /* SyntaxKind.AsteriskToken */ || // import *
+ token() === 18 /* SyntaxKind.OpenBraceToken */ // import {
) {
importClause = parseImportClause(identifier, afterImportPos, isTypeOnly);
- parseExpected(155 /* FromKeyword */);
+ parseExpected(156 /* SyntaxKind.FromKeyword */);
}
var moduleSpecifier = parseModuleSpecifier();
var assertClause;
- if (token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) {
+ if (token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) {
assertClause = parseAssertClause();
}
parseSemicolon();
@@ -36394,22 +37091,24 @@ var ts;
}
function parseAssertEntry() {
var pos = getNodePos();
- var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */);
- parseExpected(58 /* ColonToken */);
+ var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* SyntaxKind.StringLiteral */);
+ parseExpected(58 /* SyntaxKind.ColonToken */);
var value = parseAssignmentExpressionOrHigher();
return finishNode(factory.createAssertEntry(name, value), pos);
}
- function parseAssertClause() {
+ function parseAssertClause(skipAssertKeyword) {
var pos = getNodePos();
- parseExpected(129 /* AssertKeyword */);
+ if (!skipAssertKeyword) {
+ parseExpected(129 /* SyntaxKind.AssertKeyword */);
+ }
var openBracePosition = scanner.getTokenPos();
- if (parseExpected(18 /* OpenBraceToken */)) {
+ if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) {
var multiLine = scanner.hasPrecedingLineBreak();
- var elements = parseDelimitedList(24 /* AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true);
- if (!parseExpected(19 /* CloseBraceToken */)) {
+ var elements = parseDelimitedList(24 /* ParsingContext.AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true);
+ if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) {
var lastError = ts.lastOrUndefined(parseDiagnostics);
if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
- ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
+ ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}"));
}
}
return finishNode(factory.createAssertClause(elements, multiLine), pos);
@@ -36420,15 +37119,15 @@ var ts;
}
}
function tokenAfterImportDefinitelyProducesImportDeclaration() {
- return token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */;
+ return token() === 41 /* SyntaxKind.AsteriskToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */;
}
function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() {
// In `import id ___`, the current token decides whether to produce
// an ImportDeclaration or ImportEqualsDeclaration.
- return token() === 27 /* CommaToken */ || token() === 155 /* FromKeyword */;
+ return token() === 27 /* SyntaxKind.CommaToken */ || token() === 156 /* SyntaxKind.FromKeyword */;
}
function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) {
- parseExpected(63 /* EqualsToken */);
+ parseExpected(63 /* SyntaxKind.EqualsToken */);
var moduleReference = parseModuleReference();
parseSemicolon();
var node = factory.createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, identifier, moduleReference);
@@ -36446,8 +37145,8 @@ var ts;
// parse namespace or named imports
var namedBindings;
if (!identifier ||
- parseOptional(27 /* CommaToken */)) {
- namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(268 /* NamedImports */);
+ parseOptional(27 /* SyntaxKind.CommaToken */)) {
+ namedBindings = token() === 41 /* SyntaxKind.AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(269 /* SyntaxKind.NamedImports */);
}
return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos);
}
@@ -36458,14 +37157,14 @@ var ts;
}
function parseExternalModuleReference() {
var pos = getNodePos();
- parseExpected(145 /* RequireKeyword */);
- parseExpected(20 /* OpenParenToken */);
+ parseExpected(146 /* SyntaxKind.RequireKeyword */);
+ parseExpected(20 /* SyntaxKind.OpenParenToken */);
var expression = parseModuleSpecifier();
- parseExpected(21 /* CloseParenToken */);
+ parseExpected(21 /* SyntaxKind.CloseParenToken */);
return finishNode(factory.createExternalModuleReference(expression), pos);
}
function parseModuleSpecifier() {
- if (token() === 10 /* StringLiteral */) {
+ if (token() === 10 /* SyntaxKind.StringLiteral */) {
var result = parseLiteralNode();
result.text = internIdentifier(result.text);
return result;
@@ -36481,8 +37180,8 @@ var ts;
// NameSpaceImport:
// * as ImportedBinding
var pos = getNodePos();
- parseExpected(41 /* AsteriskToken */);
- parseExpected(127 /* AsKeyword */);
+ parseExpected(41 /* SyntaxKind.AsteriskToken */);
+ parseExpected(127 /* SyntaxKind.AsKeyword */);
var name = parseIdentifier();
return finishNode(factory.createNamespaceImport(name), pos);
}
@@ -36495,17 +37194,17 @@ var ts;
// ImportsList:
// ImportSpecifier
// ImportsList, ImportSpecifier
- var node = kind === 268 /* NamedImports */
- ? factory.createNamedImports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */))
- : factory.createNamedExports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */));
+ var node = kind === 269 /* SyntaxKind.NamedImports */
+ ? factory.createNamedImports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */))
+ : factory.createNamedExports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */));
return finishNode(node, pos);
}
function parseExportSpecifier() {
var hasJSDoc = hasPrecedingJSDocComment();
- return withJSDoc(parseImportOrExportSpecifier(274 /* ExportSpecifier */), hasJSDoc);
+ return withJSDoc(parseImportOrExportSpecifier(275 /* SyntaxKind.ExportSpecifier */), hasJSDoc);
}
function parseImportSpecifier() {
- return parseImportOrExportSpecifier(269 /* ImportSpecifier */);
+ return parseImportOrExportSpecifier(270 /* SyntaxKind.ImportSpecifier */);
}
function parseImportOrExportSpecifier(kind) {
var pos = getNodePos();
@@ -36530,10 +37229,10 @@ var ts;
// import { type as } from "mod"; - isTypeOnly: true, name: as
// import { type as as } from "mod"; - isTypeOnly: false, name: as, propertyName: type
// import { type as as as } from "mod"; - isTypeOnly: true, name: as, propertyName: as
- if (token() === 127 /* AsKeyword */) {
+ if (token() === 127 /* SyntaxKind.AsKeyword */) {
// { type as ...? }
var firstAs = parseIdentifierName();
- if (token() === 127 /* AsKeyword */) {
+ if (token() === 127 /* SyntaxKind.AsKeyword */) {
// { type as as ...? }
var secondAs = parseIdentifierName();
if (ts.tokenIsIdentifierOrKeyword(token())) {
@@ -36568,15 +37267,15 @@ var ts;
name = parseNameWithKeywordCheck();
}
}
- if (canParseAsKeyword && token() === 127 /* AsKeyword */) {
+ if (canParseAsKeyword && token() === 127 /* SyntaxKind.AsKeyword */) {
propertyName = name;
- parseExpected(127 /* AsKeyword */);
+ parseExpected(127 /* SyntaxKind.AsKeyword */);
name = parseNameWithKeywordCheck();
}
- if (kind === 269 /* ImportSpecifier */ && checkIdentifierIsKeyword) {
+ if (kind === 270 /* SyntaxKind.ImportSpecifier */ && checkIdentifierIsKeyword) {
parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected);
}
- var node = kind === 269 /* ImportSpecifier */
+ var node = kind === 270 /* SyntaxKind.ImportSpecifier */
? factory.createImportSpecifier(isTypeOnly, propertyName, name)
: factory.createExportSpecifier(isTypeOnly, propertyName, name);
return finishNode(node, pos);
@@ -36596,26 +37295,26 @@ var ts;
var exportClause;
var moduleSpecifier;
var assertClause;
- var isTypeOnly = parseOptional(151 /* TypeKeyword */);
+ var isTypeOnly = parseOptional(152 /* SyntaxKind.TypeKeyword */);
var namespaceExportPos = getNodePos();
- if (parseOptional(41 /* AsteriskToken */)) {
- if (parseOptional(127 /* AsKeyword */)) {
+ if (parseOptional(41 /* SyntaxKind.AsteriskToken */)) {
+ if (parseOptional(127 /* SyntaxKind.AsKeyword */)) {
exportClause = parseNamespaceExport(namespaceExportPos);
}
- parseExpected(155 /* FromKeyword */);
+ parseExpected(156 /* SyntaxKind.FromKeyword */);
moduleSpecifier = parseModuleSpecifier();
}
else {
- exportClause = parseNamedImportsOrExports(272 /* NamedExports */);
+ exportClause = parseNamedImportsOrExports(273 /* SyntaxKind.NamedExports */);
// It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios,
// the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`)
// If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect.
- if (token() === 155 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) {
- parseExpected(155 /* FromKeyword */);
+ if (token() === 156 /* SyntaxKind.FromKeyword */ || (token() === 10 /* SyntaxKind.StringLiteral */ && !scanner.hasPrecedingLineBreak())) {
+ parseExpected(156 /* SyntaxKind.FromKeyword */);
moduleSpecifier = parseModuleSpecifier();
}
}
- if (moduleSpecifier && token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) {
+ if (moduleSpecifier && token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) {
assertClause = parseAssertClause();
}
parseSemicolon();
@@ -36627,11 +37326,11 @@ var ts;
var savedAwaitContext = inAwaitContext();
setAwaitContext(/*value*/ true);
var isExportEquals;
- if (parseOptional(63 /* EqualsToken */)) {
+ if (parseOptional(63 /* SyntaxKind.EqualsToken */)) {
isExportEquals = true;
}
else {
- parseExpected(88 /* DefaultKeyword */);
+ parseExpected(88 /* SyntaxKind.DefaultKeyword */);
}
var expression = parseAssignmentExpressionOrHigher();
parseSemicolon();
@@ -36639,35 +37338,6 @@ var ts;
var node = factory.createExportAssignment(decorators, modifiers, isExportEquals, expression);
return withJSDoc(finishNode(node, pos), hasJSDoc);
}
- function setExternalModuleIndicator(sourceFile) {
- // Try to use the first top-level import/export when available, then
- // fall back to looking for an 'import.meta' somewhere in the tree if necessary.
- sourceFile.externalModuleIndicator =
- ts.forEach(sourceFile.statements, isAnExternalModuleIndicatorNode) ||
- getImportMetaIfNecessary(sourceFile);
- }
- function isAnExternalModuleIndicatorNode(node) {
- return hasModifierOfKind(node, 93 /* ExportKeyword */)
- || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference)
- || ts.isImportDeclaration(node)
- || ts.isExportAssignment(node)
- || ts.isExportDeclaration(node) ? node : undefined;
- }
- function getImportMetaIfNecessary(sourceFile) {
- return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ?
- walkTreeForExternalModuleIndicators(sourceFile) :
- undefined;
- }
- function walkTreeForExternalModuleIndicators(node) {
- return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators);
- }
- /** Do not use hasModifier inside the parser; it relies on parent pointers. Use this instead. */
- function hasModifierOfKind(node, kind) {
- return ts.some(node.modifiers, function (m) { return m.kind === kind; });
- }
- function isImportMeta(node) {
- return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta";
- }
var ParsingContext;
(function (ParsingContext) {
ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements";
@@ -36706,11 +37376,11 @@ var ts;
var JSDocParser;
(function (JSDocParser) {
function parseJSDocTypeExpressionForTests(content, start, length) {
- initializeState("file.js", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */);
+ initializeState("file.js", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */);
scanner.setText(content, start, length);
currentToken = scanner.scan();
var jsDocTypeExpression = parseJSDocTypeExpression();
- var sourceFile = createSourceFile("file.js", 99 /* Latest */, 1 /* JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* EndOfFileToken */), 0 /* None */);
+ var sourceFile = createSourceFile("file.js", 99 /* ScriptTarget.Latest */, 1 /* ScriptKind.JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* SyntaxKind.EndOfFileToken */), 0 /* NodeFlags.None */, ts.noop);
var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
if (jsDocDiagnostics) {
sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile);
@@ -36722,10 +37392,10 @@ var ts;
// Parses out a JSDoc type expression.
function parseJSDocTypeExpression(mayOmitBraces) {
var pos = getNodePos();
- var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */);
- var type = doInsideOfContext(4194304 /* JSDoc */, parseJSDocType);
+ var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* SyntaxKind.OpenBraceToken */);
+ var type = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType);
if (!mayOmitBraces || hasBrace) {
- parseExpectedJSDoc(19 /* CloseBraceToken */);
+ parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */);
}
var result = factory.createJSDocTypeExpression(type);
fixupParentReferences(result);
@@ -36734,16 +37404,16 @@ var ts;
JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression;
function parseJSDocNameReference() {
var pos = getNodePos();
- var hasBrace = parseOptional(18 /* OpenBraceToken */);
+ var hasBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */);
var p2 = getNodePos();
var entityName = parseEntityName(/* allowReservedWords*/ false);
- while (token() === 80 /* PrivateIdentifier */) {
+ while (token() === 80 /* SyntaxKind.PrivateIdentifier */) {
reScanHashToken(); // rescan #id as # id
nextTokenJSDoc(); // then skip the #
entityName = finishNode(factory.createJSDocMemberName(entityName, parseIdentifier()), p2);
}
if (hasBrace) {
- parseExpectedJSDoc(19 /* CloseBraceToken */);
+ parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */);
}
var result = factory.createJSDocNameReference(entityName);
fixupParentReferences(result);
@@ -36751,9 +37421,9 @@ var ts;
}
JSDocParser.parseJSDocNameReference = parseJSDocNameReference;
function parseIsolatedJSDocComment(content, start, length) {
- initializeState("", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */);
- var jsDoc = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
- var sourceFile = { languageVariant: 0 /* Standard */, text: content };
+ initializeState("", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */);
+ var jsDoc = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
+ var sourceFile = { languageVariant: 0 /* LanguageVariant.Standard */, text: content };
var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
clearState();
return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined;
@@ -36763,9 +37433,9 @@ var ts;
var saveToken = currentToken;
var saveParseDiagnosticsLength = parseDiagnostics.length;
var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
- var comment = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
+ var comment = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
ts.setParent(comment, parent);
- if (contextFlags & 131072 /* JavaScriptFile */) {
+ if (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) {
if (!jsDocDiagnostics) {
jsDocDiagnostics = [];
}
@@ -36813,7 +37483,7 @@ var ts;
return scanner.scanRange(start + 3, length - 5, function () {
// Initially we can parse out a tag. We also have seen a starting asterisk.
// This is so that /** * @type */ doesn't parse.
- var state = 1 /* SawAsterisk */;
+ var state = 1 /* JSDocState.SawAsterisk */;
var margin;
// + 4 for leading '/** '
// + 1 because the last index of \n is always one index before the first character in the line and coincidentally, if there is no \n before start, it is -1, which is also one index before the first character
@@ -36826,16 +37496,16 @@ var ts;
indent += text.length;
}
nextTokenJSDoc();
- while (parseOptionalJsdoc(5 /* WhitespaceTrivia */))
+ while (parseOptionalJsdoc(5 /* SyntaxKind.WhitespaceTrivia */))
;
- if (parseOptionalJsdoc(4 /* NewLineTrivia */)) {
- state = 0 /* BeginningOfLine */;
+ if (parseOptionalJsdoc(4 /* SyntaxKind.NewLineTrivia */)) {
+ state = 0 /* JSDocState.BeginningOfLine */;
indent = 0;
}
loop: while (true) {
switch (token()) {
- case 59 /* AtToken */:
- if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) {
+ case 59 /* SyntaxKind.AtToken */:
+ if (state === 0 /* JSDocState.BeginningOfLine */ || state === 1 /* JSDocState.SawAsterisk */) {
removeTrailingWhitespace(comments);
if (!commentsPos)
commentsPos = getNodePos();
@@ -36843,35 +37513,35 @@ var ts;
// NOTE: According to usejsdoc.org, a tag goes to end of line, except the last tag.
// Real-world comments may break this rule, so "BeginningOfLine" will not be a real line beginning
// for malformed examples like `/** @param {string} x @returns {number} the length */`
- state = 0 /* BeginningOfLine */;
+ state = 0 /* JSDocState.BeginningOfLine */;
margin = undefined;
}
else {
pushComment(scanner.getTokenText());
}
break;
- case 4 /* NewLineTrivia */:
+ case 4 /* SyntaxKind.NewLineTrivia */:
comments.push(scanner.getTokenText());
- state = 0 /* BeginningOfLine */;
+ state = 0 /* JSDocState.BeginningOfLine */;
indent = 0;
break;
- case 41 /* AsteriskToken */:
+ case 41 /* SyntaxKind.AsteriskToken */:
var asterisk = scanner.getTokenText();
- if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) {
+ if (state === 1 /* JSDocState.SawAsterisk */ || state === 2 /* JSDocState.SavingComments */) {
// If we've already seen an asterisk, then we can no longer parse a tag on this line
- state = 2 /* SavingComments */;
+ state = 2 /* JSDocState.SavingComments */;
pushComment(asterisk);
}
else {
// Ignore the first asterisk on a line
- state = 1 /* SawAsterisk */;
+ state = 1 /* JSDocState.SawAsterisk */;
indent += asterisk.length;
}
break;
- case 5 /* WhitespaceTrivia */:
+ case 5 /* SyntaxKind.WhitespaceTrivia */:
// only collect whitespace if we're already saving comments or have just crossed the comment indent margin
var whitespace = scanner.getTokenText();
- if (state === 2 /* SavingComments */) {
+ if (state === 2 /* JSDocState.SavingComments */) {
comments.push(whitespace);
}
else if (margin !== undefined && indent + whitespace.length > margin) {
@@ -36879,10 +37549,10 @@ var ts;
}
indent += whitespace.length;
break;
- case 1 /* EndOfFileToken */:
+ case 1 /* SyntaxKind.EndOfFileToken */:
break loop;
- case 18 /* OpenBraceToken */:
- state = 2 /* SavingComments */;
+ case 18 /* SyntaxKind.OpenBraceToken */:
+ state = 2 /* JSDocState.SavingComments */;
var commentEnd = scanner.getStartPos();
var linkStart = scanner.getTextPos() - 1;
var link = parseJSDocLink(linkStart);
@@ -36901,7 +37571,7 @@ var ts;
// Anything else is doc comment text. We just save it. Because it
// wasn't a tag, we can no longer parse a tag on this line until we hit the next
// line break.
- state = 2 /* SavingComments */;
+ state = 2 /* JSDocState.SavingComments */;
pushComment(scanner.getTokenText());
break;
}
@@ -36930,26 +37600,26 @@ var ts;
// We must use infinite lookahead, as there could be any number of newlines :(
while (true) {
nextTokenJSDoc();
- if (token() === 1 /* EndOfFileToken */) {
+ if (token() === 1 /* SyntaxKind.EndOfFileToken */) {
return true;
}
- if (!(token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */)) {
+ if (!(token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */)) {
return false;
}
}
}
function skipWhitespace() {
- if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) {
+ if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) {
if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range
}
}
- while (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) {
+ while (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) {
nextTokenJSDoc();
}
}
function skipWhitespaceOrAsterisk() {
- if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) {
+ if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) {
if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
return ""; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range
}
@@ -36957,14 +37627,14 @@ var ts;
var precedingLineBreak = scanner.hasPrecedingLineBreak();
var seenLineBreak = false;
var indentText = "";
- while ((precedingLineBreak && token() === 41 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) {
+ while ((precedingLineBreak && token() === 41 /* SyntaxKind.AsteriskToken */) || token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) {
indentText += scanner.getTokenText();
- if (token() === 4 /* NewLineTrivia */) {
+ if (token() === 4 /* SyntaxKind.NewLineTrivia */) {
precedingLineBreak = true;
seenLineBreak = true;
indentText = "";
}
- else if (token() === 41 /* AsteriskToken */) {
+ else if (token() === 41 /* SyntaxKind.AsteriskToken */) {
precedingLineBreak = false;
}
nextTokenJSDoc();
@@ -36972,7 +37642,7 @@ var ts;
return seenLineBreak ? indentText : "";
}
function parseTag(margin) {
- ts.Debug.assert(token() === 59 /* AtToken */);
+ ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */);
var start = scanner.getTokenPos();
nextTokenJSDoc();
var tagName = parseJSDocIdentifierName(/*message*/ undefined);
@@ -37021,7 +37691,7 @@ var ts;
case "arg":
case "argument":
case "param":
- return parseParameterOrPropertyTag(start, tagName, 2 /* Parameter */, margin);
+ return parseParameterOrPropertyTag(start, tagName, 2 /* PropertyLikeParse.Parameter */, margin);
case "return":
case "returns":
tag = parseReturnTag(start, tagName, margin, indentText);
@@ -37059,7 +37729,7 @@ var ts;
var comments = [];
var parts = [];
var linkEnd;
- var state = 0 /* BeginningOfLine */;
+ var state = 0 /* JSDocState.BeginningOfLine */;
var previousWhitespace = true;
var margin;
function pushComment(text) {
@@ -37074,31 +37744,31 @@ var ts;
if (initialMargin !== "") {
pushComment(initialMargin);
}
- state = 1 /* SawAsterisk */;
+ state = 1 /* JSDocState.SawAsterisk */;
}
var tok = token();
loop: while (true) {
switch (tok) {
- case 4 /* NewLineTrivia */:
- state = 0 /* BeginningOfLine */;
+ case 4 /* SyntaxKind.NewLineTrivia */:
+ state = 0 /* JSDocState.BeginningOfLine */;
// don't use pushComment here because we want to keep the margin unchanged
comments.push(scanner.getTokenText());
indent = 0;
break;
- case 59 /* AtToken */:
- if (state === 3 /* SavingBackticks */
- || state === 2 /* SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) {
+ case 59 /* SyntaxKind.AtToken */:
+ if (state === 3 /* JSDocState.SavingBackticks */
+ || state === 2 /* JSDocState.SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) {
// @ doesn't start a new tag inside ``, and inside a comment, only after whitespace or not before whitespace
comments.push(scanner.getTokenText());
break;
}
scanner.setTextPos(scanner.getTextPos() - 1);
// falls through
- case 1 /* EndOfFileToken */:
+ case 1 /* SyntaxKind.EndOfFileToken */:
// Done
break loop;
- case 5 /* WhitespaceTrivia */:
- if (state === 2 /* SavingComments */ || state === 3 /* SavingBackticks */) {
+ case 5 /* SyntaxKind.WhitespaceTrivia */:
+ if (state === 2 /* JSDocState.SavingComments */ || state === 3 /* JSDocState.SavingBackticks */) {
pushComment(scanner.getTokenText());
}
else {
@@ -37110,8 +37780,8 @@ var ts;
indent += whitespace.length;
}
break;
- case 18 /* OpenBraceToken */:
- state = 2 /* SavingComments */;
+ case 18 /* SyntaxKind.OpenBraceToken */:
+ state = 2 /* JSDocState.SavingComments */;
var commentEnd = scanner.getStartPos();
var linkStart = scanner.getTextPos() - 1;
var link = parseJSDocLink(linkStart);
@@ -37125,32 +37795,32 @@ var ts;
pushComment(scanner.getTokenText());
}
break;
- case 61 /* BacktickToken */:
- if (state === 3 /* SavingBackticks */) {
- state = 2 /* SavingComments */;
+ case 61 /* SyntaxKind.BacktickToken */:
+ if (state === 3 /* JSDocState.SavingBackticks */) {
+ state = 2 /* JSDocState.SavingComments */;
}
else {
- state = 3 /* SavingBackticks */;
+ state = 3 /* JSDocState.SavingBackticks */;
}
pushComment(scanner.getTokenText());
break;
- case 41 /* AsteriskToken */:
- if (state === 0 /* BeginningOfLine */) {
+ case 41 /* SyntaxKind.AsteriskToken */:
+ if (state === 0 /* JSDocState.BeginningOfLine */) {
// leading asterisks start recording on the *next* (non-whitespace) token
- state = 1 /* SawAsterisk */;
+ state = 1 /* JSDocState.SawAsterisk */;
indent += 1;
break;
}
// record the * as a comment
// falls through
default:
- if (state !== 3 /* SavingBackticks */) {
- state = 2 /* SavingComments */; // leading identifiers start recording as well
+ if (state !== 3 /* JSDocState.SavingBackticks */) {
+ state = 2 /* JSDocState.SavingComments */; // leading identifiers start recording as well
}
pushComment(scanner.getTokenText());
break;
}
- previousWhitespace = token() === 5 /* WhitespaceTrivia */;
+ previousWhitespace = token() === 5 /* SyntaxKind.WhitespaceTrivia */;
tok = nextTokenJSDoc();
}
removeLeadingNewlines(comments);
@@ -37167,7 +37837,7 @@ var ts;
}
function isNextJSDocTokenWhitespace() {
var next = nextTokenJSDoc();
- return next === 5 /* WhitespaceTrivia */ || next === 4 /* NewLineTrivia */;
+ return next === 5 /* SyntaxKind.WhitespaceTrivia */ || next === 4 /* SyntaxKind.NewLineTrivia */;
}
function parseJSDocLink(start) {
var linkType = tryParse(parseJSDocLinkPrefix);
@@ -37182,14 +37852,14 @@ var ts;
? parseEntityName(/*allowReservedWords*/ true)
: undefined;
if (name) {
- while (token() === 80 /* PrivateIdentifier */) {
+ while (token() === 80 /* SyntaxKind.PrivateIdentifier */) {
reScanHashToken(); // rescan #id as # id
nextTokenJSDoc(); // then skip the #
name = finishNode(factory.createJSDocMemberName(name, parseIdentifier()), p2);
}
}
var text = [];
- while (token() !== 19 /* CloseBraceToken */ && token() !== 4 /* NewLineTrivia */ && token() !== 1 /* EndOfFileToken */) {
+ while (token() !== 19 /* SyntaxKind.CloseBraceToken */ && token() !== 4 /* SyntaxKind.NewLineTrivia */ && token() !== 1 /* SyntaxKind.EndOfFileToken */) {
text.push(scanner.getTokenText());
nextTokenJSDoc();
}
@@ -37200,15 +37870,17 @@ var ts;
}
function parseJSDocLinkPrefix() {
skipWhitespaceOrAsterisk();
- if (token() === 18 /* OpenBraceToken */
- && nextTokenJSDoc() === 59 /* AtToken */
+ if (token() === 18 /* SyntaxKind.OpenBraceToken */
+ && nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */
&& ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) {
var kind = scanner.getTokenValue();
- if (kind === "link" || kind === "linkcode" || kind === "linkplain") {
+ if (isJSDocLinkTag(kind))
return kind;
- }
}
}
+ function isJSDocLinkTag(kind) {
+ return kind === "link" || kind === "linkcode" || kind === "linkplain";
+ }
function parseUnknownTag(start, tagName, indent, indentText) {
return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start);
}
@@ -37227,35 +37899,35 @@ var ts;
}
function tryParseTypeExpression() {
skipWhitespaceOrAsterisk();
- return token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined;
+ return token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined;
}
function parseBracketNameInPropertyAndParamTag() {
// Looking for something like '[foo]', 'foo', '[foo.bar]' or 'foo.bar'
- var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */);
+ var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */);
if (isBracketed) {
skipWhitespace();
}
// a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild
- var isBackquoted = parseOptionalJsdoc(61 /* BacktickToken */);
+ var isBackquoted = parseOptionalJsdoc(61 /* SyntaxKind.BacktickToken */);
var name = parseJSDocEntityName();
if (isBackquoted) {
- parseExpectedTokenJSDoc(61 /* BacktickToken */);
+ parseExpectedTokenJSDoc(61 /* SyntaxKind.BacktickToken */);
}
if (isBracketed) {
skipWhitespace();
// May have an optional default, e.g. '[foo = 42]'
- if (parseOptionalToken(63 /* EqualsToken */)) {
+ if (parseOptionalToken(63 /* SyntaxKind.EqualsToken */)) {
parseExpression();
}
- parseExpected(23 /* CloseBracketToken */);
+ parseExpected(23 /* SyntaxKind.CloseBracketToken */);
}
return { name: name, isBracketed: isBracketed };
}
function isObjectOrObjectArrayTypeReference(node) {
switch (node.kind) {
- case 147 /* ObjectKeyword */:
+ case 148 /* SyntaxKind.ObjectKeyword */:
return true;
- case 182 /* ArrayType */:
+ case 183 /* SyntaxKind.ArrayType */:
return isObjectOrObjectArrayTypeReference(node.elementType);
default:
return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments;
@@ -37271,12 +37943,12 @@ var ts;
typeExpression = tryParseTypeExpression();
}
var comment = parseTrailingTagComments(start, getNodePos(), indent, indentText);
- var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent);
+ var nestedTypeLiteral = target !== 4 /* PropertyLikeParse.CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent);
if (nestedTypeLiteral) {
typeExpression = nestedTypeLiteral;
isNameFirst = true;
}
- var result = target === 1 /* Property */
+ var result = target === 1 /* PropertyLikeParse.Property */
? factory.createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment)
: factory.createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment);
return finishNode(result, start);
@@ -37287,12 +37959,12 @@ var ts;
var child = void 0;
var children = void 0;
while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) {
- if (child.kind === 338 /* JSDocParameterTag */ || child.kind === 345 /* JSDocPropertyTag */) {
+ if (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) {
children = ts.append(children, child);
}
}
if (children) {
- var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 182 /* ArrayType */), pos);
+ var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */), pos);
return finishNode(factory.createJSDocTypeExpression(literal), pos);
}
}
@@ -37313,8 +37985,8 @@ var ts;
return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start);
}
function parseSeeTag(start, tagName, indent, indentText) {
- var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */
- || lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link"; });
+ var isMarkdownOrJSDocLink = token() === 22 /* SyntaxKind.OpenBracketToken */
+ || lookAhead(function () { return nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); });
var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference();
var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined;
return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start);
@@ -37336,14 +38008,14 @@ var ts;
var comments = [];
var inEmail = false;
var token = scanner.getToken();
- while (token !== 1 /* EndOfFileToken */ && token !== 4 /* NewLineTrivia */) {
- if (token === 29 /* LessThanToken */) {
+ while (token !== 1 /* SyntaxKind.EndOfFileToken */ && token !== 4 /* SyntaxKind.NewLineTrivia */) {
+ if (token === 29 /* SyntaxKind.LessThanToken */) {
inEmail = true;
}
- else if (token === 59 /* AtToken */ && !inEmail) {
+ else if (token === 59 /* SyntaxKind.AtToken */ && !inEmail) {
break;
}
- else if (token === 31 /* GreaterThanToken */ && inEmail) {
+ else if (token === 31 /* SyntaxKind.GreaterThanToken */ && inEmail) {
comments.push(scanner.getTokenText());
scanner.setTextPos(scanner.getTokenPos() + 1);
break;
@@ -37362,21 +38034,21 @@ var ts;
return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start);
}
function parseExpressionWithTypeArgumentsForAugments() {
- var usedBrace = parseOptional(18 /* OpenBraceToken */);
+ var usedBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */);
var pos = getNodePos();
var expression = parsePropertyAccessEntityNameExpression();
var typeArguments = tryParseTypeArguments();
var node = factory.createExpressionWithTypeArguments(expression, typeArguments);
var res = finishNode(node, pos);
if (usedBrace) {
- parseExpected(19 /* CloseBraceToken */);
+ parseExpected(19 /* SyntaxKind.CloseBraceToken */);
}
return res;
}
function parsePropertyAccessEntityNameExpression() {
var pos = getNodePos();
var node = parseJSDocIdentifierName();
- while (parseOptional(24 /* DotToken */)) {
+ while (parseOptional(24 /* SyntaxKind.DotToken */)) {
var name = parseJSDocIdentifierName();
node = finishNode(factory.createPropertyAccessExpression(node, name), pos);
}
@@ -37410,10 +38082,9 @@ var ts;
var hasChildren = false;
while (child = tryParse(function () { return parseChildPropertyTag(indent); })) {
hasChildren = true;
- if (child.kind === 341 /* JSDocTypeTag */) {
+ if (child.kind === 343 /* SyntaxKind.JSDocTypeTag */) {
if (childTypeTag) {
- parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
- var lastError = ts.lastOrUndefined(parseDiagnostics);
+ var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
if (lastError) {
ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, 0, 0, ts.Diagnostics.The_tag_was_first_specified_here));
}
@@ -37428,7 +38099,7 @@ var ts;
}
}
if (hasChildren) {
- var isArrayType = typeExpression && typeExpression.type.kind === 182 /* ArrayType */;
+ var isArrayType = typeExpression && typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */;
var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType);
typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ?
childTypeTag.typeExpression :
@@ -37452,11 +38123,11 @@ var ts;
return undefined;
}
var typeNameOrNamespaceName = parseJSDocIdentifierName();
- if (parseOptional(24 /* DotToken */)) {
+ if (parseOptional(24 /* SyntaxKind.DotToken */)) {
var body = parseJSDocTypeNameWithNamespace(/*nested*/ true);
var jsDocNamespaceNode = factory.createModuleDeclaration(
/*decorators*/ undefined,
- /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NestedNamespace */ : undefined);
+ /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NodeFlags.NestedNamespace */ : undefined);
return finishNode(jsDocNamespaceNode, pos);
}
if (nested) {
@@ -37468,7 +38139,7 @@ var ts;
var pos = getNodePos();
var child;
var parameters;
- while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) {
+ while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* PropertyLikeParse.CallbackParameter */, indent); })) {
parameters = ts.append(parameters, child);
}
return createNodeArray(parameters || [], pos);
@@ -37479,9 +38150,9 @@ var ts;
var comment = parseTagComments(indent);
var parameters = parseCallbackTagParameters(indent);
var returnTag = tryParse(function () {
- if (parseOptionalJsdoc(59 /* AtToken */)) {
+ if (parseOptionalJsdoc(59 /* SyntaxKind.AtToken */)) {
var tag = parseTag(indent);
- if (tag && tag.kind === 339 /* JSDocReturnTag */) {
+ if (tag && tag.kind === 341 /* SyntaxKind.JSDocReturnTag */) {
return tag;
}
}
@@ -37490,7 +38161,8 @@ var ts;
if (!comment) {
comment = parseTrailingTagComments(start, getNodePos(), indent, indentText);
}
- return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start);
+ var end = comment !== undefined ? getNodePos() : typeExpression.end;
+ return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end);
}
function escapedTextsEqual(a, b) {
while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) {
@@ -37505,18 +38177,18 @@ var ts;
return a.escapedText === b.escapedText;
}
function parseChildPropertyTag(indent) {
- return parseChildParameterOrPropertyTag(1 /* Property */, indent);
+ return parseChildParameterOrPropertyTag(1 /* PropertyLikeParse.Property */, indent);
}
function parseChildParameterOrPropertyTag(target, indent, name) {
var canParseTag = true;
var seenAsterisk = false;
while (true) {
switch (nextTokenJSDoc()) {
- case 59 /* AtToken */:
+ case 59 /* SyntaxKind.AtToken */:
if (canParseTag) {
var child = tryParseChildTag(target, indent);
- if (child && (child.kind === 338 /* JSDocParameterTag */ || child.kind === 345 /* JSDocPropertyTag */) &&
- target !== 4 /* CallbackParameter */ &&
+ if (child && (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) &&
+ target !== 4 /* PropertyLikeParse.CallbackParameter */ &&
name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) {
return false;
}
@@ -37524,26 +38196,26 @@ var ts;
}
seenAsterisk = false;
break;
- case 4 /* NewLineTrivia */:
+ case 4 /* SyntaxKind.NewLineTrivia */:
canParseTag = true;
seenAsterisk = false;
break;
- case 41 /* AsteriskToken */:
+ case 41 /* SyntaxKind.AsteriskToken */:
if (seenAsterisk) {
canParseTag = false;
}
seenAsterisk = true;
break;
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
canParseTag = false;
break;
- case 1 /* EndOfFileToken */:
+ case 1 /* SyntaxKind.EndOfFileToken */:
return false;
}
}
}
function tryParseChildTag(target, indent) {
- ts.Debug.assert(token() === 59 /* AtToken */);
+ ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */);
var start = scanner.getStartPos();
nextTokenJSDoc();
var tagName = parseJSDocIdentifierName();
@@ -37551,15 +38223,15 @@ var ts;
var t;
switch (tagName.escapedText) {
case "type":
- return target === 1 /* Property */ && parseTypeTag(start, tagName);
+ return target === 1 /* PropertyLikeParse.Property */ && parseTypeTag(start, tagName);
case "prop":
case "property":
- t = 1 /* Property */;
+ t = 1 /* PropertyLikeParse.Property */;
break;
case "arg":
case "argument":
case "param":
- t = 2 /* Parameter */ | 4 /* CallbackParameter */;
+ t = 2 /* PropertyLikeParse.Parameter */ | 4 /* PropertyLikeParse.CallbackParameter */;
break;
default:
return false;
@@ -37571,7 +38243,7 @@ var ts;
}
function parseTemplateTagTypeParameter() {
var typeParameterPos = getNodePos();
- var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */);
+ var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */);
if (isBracketed) {
skipWhitespace();
}
@@ -37579,14 +38251,14 @@ var ts;
var defaultType;
if (isBracketed) {
skipWhitespace();
- parseExpected(63 /* EqualsToken */);
- defaultType = doInsideOfContext(4194304 /* JSDoc */, parseJSDocType);
- parseExpected(23 /* CloseBracketToken */);
+ parseExpected(63 /* SyntaxKind.EqualsToken */);
+ defaultType = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType);
+ parseExpected(23 /* SyntaxKind.CloseBracketToken */);
}
if (ts.nodeIsMissing(name)) {
return undefined;
}
- return finishNode(factory.createTypeParameterDeclaration(name, /*constraint*/ undefined, defaultType), typeParameterPos);
+ return finishNode(factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, /*constraint*/ undefined, defaultType), typeParameterPos);
}
function parseTemplateTagTypeParameters() {
var pos = getNodePos();
@@ -37598,7 +38270,7 @@ var ts;
typeParameters.push(node);
}
skipWhitespaceOrAsterisk();
- } while (parseOptionalJsdoc(27 /* CommaToken */));
+ } while (parseOptionalJsdoc(27 /* SyntaxKind.CommaToken */));
return createNodeArray(typeParameters, pos);
}
function parseTemplateTag(start, tagName, indent, indentText) {
@@ -37613,7 +38285,7 @@ var ts;
// TODO: Determine whether we should enforce this in the checker.
// TODO: Consider moving the `constraint` to the first type parameter as we could then remove `getEffectiveConstraintOfTypeParameter`.
// TODO: Consider only parsing a single type parameter if there is a constraint.
- var constraint = token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined;
+ var constraint = token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined;
var typeParameters = parseTemplateTagTypeParameters();
return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start);
}
@@ -37626,16 +38298,16 @@ var ts;
}
function parseJSDocEntityName() {
var entity = parseJSDocIdentifierName();
- if (parseOptional(22 /* OpenBracketToken */)) {
- parseExpected(23 /* CloseBracketToken */);
+ if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) {
+ parseExpected(23 /* SyntaxKind.CloseBracketToken */);
// Note that y[] is accepted as an entity name, but the postfix brackets are not saved for checking.
// Technically usejsdoc.org requires them for specifying a property of a type equivalent to Array<{ x: ...}>
// but it's not worth it to enforce that restriction.
}
- while (parseOptional(24 /* DotToken */)) {
+ while (parseOptional(24 /* SyntaxKind.DotToken */)) {
var name = parseJSDocIdentifierName();
- if (parseOptional(22 /* OpenBracketToken */)) {
- parseExpected(23 /* CloseBracketToken */);
+ if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) {
+ parseExpected(23 /* SyntaxKind.CloseBracketToken */);
}
entity = createQualifiedName(entity, name);
}
@@ -37643,7 +38315,7 @@ var ts;
}
function parseJSDocIdentifierName(message) {
if (!ts.tokenIsIdentifierOrKeyword(token())) {
- return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected);
+ return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected);
}
identifierCount++;
var pos = scanner.getTokenPos();
@@ -37660,7 +38332,7 @@ var ts;
var IncrementalParser;
(function (IncrementalParser) {
function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) {
- aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* Aggressive */);
+ aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */);
checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks);
if (ts.textChangeRangeIsUnchanged(textChangeRange)) {
// if the text didn't change, then we can just return our current source file as-is.
@@ -37669,7 +38341,7 @@ var ts;
if (sourceFile.statements.length === 0) {
// If we don't have any statements in the current source file, then there's no real
// way to incrementally parse. So just do a full parse instead.
- return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setParentNodes*/ true, sourceFile.scriptKind);
+ return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setParentNodes*/ true, sourceFile.scriptKind, sourceFile.setExternalModuleIndicator);
}
// Make sure we're not trying to incrementally update a source file more than once. Once
// we do an update the original source file is considered unusable from that point onwards.
@@ -37726,7 +38398,7 @@ var ts;
// inconsistent tree. Setting the parents on the new tree should be very fast. We
// will immediately bail out of walking any subtrees when we can see that their parents
// are already correct.
- var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /*setParentNodes*/ true, sourceFile.scriptKind);
+ var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /*setParentNodes*/ true, sourceFile.scriptKind, sourceFile.setExternalModuleIndicator);
result.commentDirectives = getNewCommentDirectives(sourceFile.commentDirectives, result.commentDirectives, changeRange.span.start, ts.textSpanEnd(changeRange.span), delta, oldText, newText, aggressiveChecks);
result.impliedNodeFormat = sourceFile.impliedNodeFormat;
return result;
@@ -37815,9 +38487,9 @@ var ts;
}
function shouldCheckNode(node) {
switch (node.kind) {
- case 10 /* StringLiteral */:
- case 8 /* NumericLiteral */:
- case 79 /* Identifier */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
+ case 79 /* SyntaxKind.Identifier */:
return true;
}
return false;
@@ -38072,7 +38744,7 @@ var ts;
var oldText = sourceFile.text;
if (textChangeRange) {
ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length);
- if (aggressiveChecks || ts.Debug.shouldAssert(3 /* VeryAggressive */)) {
+ if (aggressiveChecks || ts.Debug.shouldAssert(3 /* AssertionLevel.VeryAggressive */)) {
var oldTextPrefix = oldText.substr(0, textChangeRange.span.start);
var newTextPrefix = newText.substr(0, textChangeRange.span.start);
ts.Debug.assert(oldTextPrefix === newTextPrefix);
@@ -38087,7 +38759,7 @@ var ts;
var currentArrayIndex = 0;
ts.Debug.assert(currentArrayIndex < currentArray.length);
var current = currentArray[currentArrayIndex];
- var lastQueriedPosition = -1 /* Value */;
+ var lastQueriedPosition = -1 /* InvalidPosition.Value */;
return {
currentNode: function (position) {
// Only compute the current node if the position is different than the last time
@@ -38125,7 +38797,7 @@ var ts;
function findHighestListElementThatStartsAtPosition(position) {
// Clear out any cached state about the last node we found.
currentArray = undefined;
- currentArrayIndex = -1 /* Value */;
+ currentArrayIndex = -1 /* InvalidPosition.Value */;
current = undefined;
// Recurse into the source file to find the highest node at this position.
forEachChild(sourceFile, visitNode, visitArray);
@@ -38178,9 +38850,22 @@ var ts;
})(IncrementalParser || (IncrementalParser = {}));
/** @internal */
function isDeclarationFileName(fileName) {
- return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]);
+ return ts.fileExtensionIsOneOf(fileName, ts.supportedDeclarationExtensions);
}
ts.isDeclarationFileName = isDeclarationFileName;
+ function parseResolutionMode(mode, pos, end, reportDiagnostic) {
+ if (!mode) {
+ return undefined;
+ }
+ if (mode === "import") {
+ return ts.ModuleKind.ESNext;
+ }
+ if (mode === "require") {
+ return ts.ModuleKind.CommonJS;
+ }
+ reportDiagnostic(pos, end - pos, ts.Diagnostics.resolution_mode_should_be_either_require_or_import);
+ return undefined;
+ }
/*@internal*/
function processCommentPragmas(context, sourceText) {
var pragmas = [];
@@ -38223,12 +38908,13 @@ var ts;
var typeReferenceDirectives_1 = context.typeReferenceDirectives;
var libReferenceDirectives_1 = context.libReferenceDirectives;
ts.forEach(ts.toArray(entryOrList), function (arg) {
- var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path;
+ var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path, res = _a["resolution-mode"];
if (arg.arguments["no-default-lib"]) {
context.hasNoDefaultLib = true;
}
else if (types) {
- typeReferenceDirectives_1.push({ pos: types.pos, end: types.end, fileName: types.value });
+ var parsed = parseResolutionMode(res, types.pos, types.end, reportDiagnostic);
+ typeReferenceDirectives_1.push(__assign({ pos: types.pos, end: types.end, fileName: types.value }, (parsed ? { resolutionMode: parsed } : {})));
}
else if (lib) {
libReferenceDirectives_1.push({ pos: lib.pos, end: lib.end, fileName: lib.value });
@@ -38298,11 +38984,11 @@ var ts;
var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im;
var singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im;
function extractPragmas(pragmas, range, text) {
- var tripleSlash = range.kind === 2 /* SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text);
+ var tripleSlash = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text);
if (tripleSlash) {
var name = tripleSlash[1].toLowerCase(); // Technically unsafe cast, but we do it so the below check to make it safe typechecks
var pragma = ts.commentPragmas[name];
- if (!pragma || !(pragma.kind & 1 /* TripleSlashXML */)) {
+ if (!pragma || !(pragma.kind & 1 /* PragmaKindFlags.TripleSlashXML */)) {
return;
}
if (pragma.args) {
@@ -38336,15 +39022,15 @@ var ts;
}
return;
}
- var singleLine = range.kind === 2 /* SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text);
+ var singleLine = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text);
if (singleLine) {
- return addPragmaForMatch(pragmas, range, 2 /* SingleLine */, singleLine);
+ return addPragmaForMatch(pragmas, range, 2 /* PragmaKindFlags.SingleLine */, singleLine);
}
- if (range.kind === 3 /* MultiLineCommentTrivia */) {
+ if (range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) {
var multiLinePragmaRegEx = /@(\S+)(\s+.*)?$/gim; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating)
var multiLineMatch = void 0;
while (multiLineMatch = multiLinePragmaRegEx.exec(text)) {
- addPragmaForMatch(pragmas, range, 4 /* MultiLine */, multiLineMatch);
+ addPragmaForMatch(pragmas, range, 4 /* PragmaKindFlags.MultiLine */, multiLineMatch);
}
}
}
@@ -38387,10 +39073,10 @@ var ts;
if (lhs.kind !== rhs.kind) {
return false;
}
- if (lhs.kind === 79 /* Identifier */) {
+ if (lhs.kind === 79 /* SyntaxKind.Identifier */) {
return lhs.escapedText === rhs.escapedText;
}
- if (lhs.kind === 108 /* ThisKeyword */) {
+ if (lhs.kind === 108 /* SyntaxKind.ThisKeyword */) {
return true;
}
// If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only
@@ -38410,11 +39096,11 @@ var ts;
defaultValueDescription: false,
};
var jsxOptionMap = new ts.Map(ts.getEntries({
- "preserve": 1 /* Preserve */,
- "react-native": 3 /* ReactNative */,
- "react": 2 /* React */,
- "react-jsx": 4 /* ReactJSX */,
- "react-jsxdev": 5 /* ReactJSXDev */,
+ "preserve": 1 /* JsxEmit.Preserve */,
+ "react-native": 3 /* JsxEmit.ReactNative */,
+ "react": 2 /* JsxEmit.React */,
+ "react-jsx": 4 /* JsxEmit.ReactJSX */,
+ "react-jsxdev": 5 /* JsxEmit.ReactJSXDev */,
}));
/* @internal */
ts.inverseJsxOptionMap = new ts.Map(ts.arrayFrom(ts.mapIterator(jsxOptionMap.entries(), function (_a) {
@@ -38474,21 +39160,25 @@ var ts;
["es2019.string", "lib.es2019.string.d.ts"],
["es2019.symbol", "lib.es2019.symbol.d.ts"],
["es2020.bigint", "lib.es2020.bigint.d.ts"],
+ ["es2020.date", "lib.es2020.date.d.ts"],
["es2020.promise", "lib.es2020.promise.d.ts"],
["es2020.sharedmemory", "lib.es2020.sharedmemory.d.ts"],
["es2020.string", "lib.es2020.string.d.ts"],
["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"],
["es2020.intl", "lib.es2020.intl.d.ts"],
+ ["es2020.number", "lib.es2020.number.d.ts"],
["es2021.promise", "lib.es2021.promise.d.ts"],
["es2021.string", "lib.es2021.string.d.ts"],
["es2021.weakref", "lib.es2021.weakref.d.ts"],
["es2021.intl", "lib.es2021.intl.d.ts"],
["es2022.array", "lib.es2022.array.d.ts"],
["es2022.error", "lib.es2022.error.d.ts"],
+ ["es2022.intl", "lib.es2022.intl.d.ts"],
["es2022.object", "lib.es2022.object.d.ts"],
["es2022.string", "lib.es2022.string.d.ts"],
- ["esnext.array", "lib.esnext.array.d.ts"],
+ ["esnext.array", "lib.es2022.array.d.ts"],
["esnext.symbol", "lib.es2019.symbol.d.ts"],
+ ["esnext.array", "lib.esnext.array.d.ts"],
["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"],
["esnext.intl", "lib.esnext.intl.d.ts"],
["esnext.bigint", "lib.es2020.bigint.d.ts"],
@@ -38690,7 +39380,7 @@ var ts;
shortName: "i",
type: "boolean",
category: ts.Diagnostics.Projects,
- description: ts.Diagnostics.Enable_incremental_compilation,
+ description: ts.Diagnostics.Save_tsbuildinfo_files_to_allow_for_incremental_compilation_of_projects,
transpileOptionValue: undefined,
defaultValueDescription: ts.Diagnostics.false_unless_composite_is_set
},
@@ -38717,18 +39407,18 @@ var ts;
name: "target",
shortName: "t",
type: new ts.Map(ts.getEntries({
- es3: 0 /* ES3 */,
- es5: 1 /* ES5 */,
- es6: 2 /* ES2015 */,
- es2015: 2 /* ES2015 */,
- es2016: 3 /* ES2016 */,
- es2017: 4 /* ES2017 */,
- es2018: 5 /* ES2018 */,
- es2019: 6 /* ES2019 */,
- es2020: 7 /* ES2020 */,
- es2021: 8 /* ES2021 */,
- es2022: 9 /* ES2022 */,
- esnext: 99 /* ESNext */,
+ es3: 0 /* ScriptTarget.ES3 */,
+ es5: 1 /* ScriptTarget.ES5 */,
+ es6: 2 /* ScriptTarget.ES2015 */,
+ es2015: 2 /* ScriptTarget.ES2015 */,
+ es2016: 3 /* ScriptTarget.ES2016 */,
+ es2017: 4 /* ScriptTarget.ES2017 */,
+ es2018: 5 /* ScriptTarget.ES2018 */,
+ es2019: 6 /* ScriptTarget.ES2019 */,
+ es2020: 7 /* ScriptTarget.ES2020 */,
+ es2021: 8 /* ScriptTarget.ES2021 */,
+ es2022: 9 /* ScriptTarget.ES2022 */,
+ esnext: 99 /* ScriptTarget.ESNext */,
})),
affectsSourceFile: true,
affectsModuleResolution: true,
@@ -38737,7 +39427,7 @@ var ts;
showInSimplifiedHelpView: true,
category: ts.Diagnostics.Language_and_Environment,
description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations,
- defaultValueDescription: 0 /* ES3 */,
+ defaultValueDescription: 0 /* ScriptTarget.ES3 */,
};
var commandOptionsWithoutBuild = [
// CommandLine only options
@@ -38820,7 +39510,7 @@ var ts;
es2020: ts.ModuleKind.ES2020,
es2022: ts.ModuleKind.ES2022,
esnext: ts.ModuleKind.ESNext,
- node12: ts.ModuleKind.Node12,
+ node16: ts.ModuleKind.Node16,
nodenext: ts.ModuleKind.NodeNext,
})),
affectsModuleResolution: true,
@@ -38964,7 +39654,7 @@ var ts;
category: ts.Diagnostics.Projects,
transpileOptionValue: undefined,
defaultValueDescription: ".tsbuildinfo",
- description: ts.Diagnostics.Specify_the_folder_for_tsbuildinfo_incremental_compilation_files,
+ description: ts.Diagnostics.Specify_the_path_to_tsbuildinfo_incremental_compilation_file,
},
{
name: "removeComments",
@@ -38995,15 +39685,15 @@ var ts;
{
name: "importsNotUsedAsValues",
type: new ts.Map(ts.getEntries({
- remove: 0 /* Remove */,
- preserve: 1 /* Preserve */,
- error: 2 /* Error */,
+ remove: 0 /* ImportsNotUsedAsValues.Remove */,
+ preserve: 1 /* ImportsNotUsedAsValues.Preserve */,
+ error: 2 /* ImportsNotUsedAsValues.Error */,
})),
affectsEmit: true,
affectsSemanticDiagnostics: true,
category: ts.Diagnostics.Emit,
description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types,
- defaultValueDescription: 0 /* Remove */,
+ defaultValueDescription: 0 /* ImportsNotUsedAsValues.Remove */,
},
{
name: "downlevelIteration",
@@ -39090,7 +39780,7 @@ var ts;
affectsSemanticDiagnostics: true,
strictFlag: true,
category: ts.Diagnostics.Type_Checking,
- description: ts.Diagnostics.Type_catch_clause_variables_as_unknown_instead_of_any,
+ description: ts.Diagnostics.Default_catch_clause_variables_as_unknown_instead_of_any,
defaultValueDescription: false,
},
{
@@ -39108,7 +39798,7 @@ var ts;
type: "boolean",
affectsSemanticDiagnostics: true,
category: ts.Diagnostics.Type_Checking,
- description: ts.Diagnostics.Enable_error_reporting_when_a_local_variables_aren_t_read,
+ description: ts.Diagnostics.Enable_error_reporting_when_local_variables_aren_t_read,
defaultValueDescription: false,
},
{
@@ -39149,7 +39839,7 @@ var ts;
type: "boolean",
affectsSemanticDiagnostics: true,
category: ts.Diagnostics.Type_Checking,
- description: ts.Diagnostics.Include_undefined_in_index_signature_results,
+ description: ts.Diagnostics.Add_undefined_to_a_type_when_accessed_using_an_index,
defaultValueDescription: false,
},
{
@@ -39174,7 +39864,7 @@ var ts;
type: new ts.Map(ts.getEntries({
node: ts.ModuleResolutionKind.NodeJs,
classic: ts.ModuleResolutionKind.Classic,
- node12: ts.ModuleResolutionKind.Node12,
+ node16: ts.ModuleResolutionKind.Node16,
nodenext: ts.ModuleResolutionKind.NodeNext,
})),
affectsModuleResolution: true,
@@ -39277,6 +39967,18 @@ var ts;
description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
defaultValueDescription: false,
},
+ {
+ name: "moduleSuffixes",
+ type: "list",
+ element: {
+ name: "suffix",
+ type: "string",
+ },
+ listPreserveFalsyValues: true,
+ affectsModuleResolution: true,
+ category: ts.Diagnostics.Modules,
+ description: ts.Diagnostics.List_of_file_name_suffixes_to_search_when_resolving_a_module,
+ },
// Source Maps
{
name: "sourceRoot",
@@ -39340,7 +40042,8 @@ var ts;
name: "jsxFragmentFactory",
type: "string",
category: ts.Diagnostics.Language_and_Environment,
- description: ts.Diagnostics.Specify_the_JSX_Fragment_reference_used_for_fragments_when_targeting_React_JSX_emit_e_g_React_Fragment_or_Fragment
+ description: ts.Diagnostics.Specify_the_JSX_Fragment_reference_used_for_fragments_when_targeting_React_JSX_emit_e_g_React_Fragment_or_Fragment,
+ defaultValueDescription: "React.Fragment",
},
{
name: "jsxImportSource",
@@ -39404,8 +40107,8 @@ var ts;
{
name: "newLine",
type: new ts.Map(ts.getEntries({
- crlf: 0 /* CarriageReturnLineFeed */,
- lf: 1 /* LineFeed */
+ crlf: 0 /* NewLineKind.CarriageReturnLineFeed */,
+ lf: 1 /* NewLineKind.LineFeed */
})),
affectsEmit: true,
paramType: ts.Diagnostics.NEWLINE,
@@ -39624,9 +40327,21 @@ var ts;
name: "plugin",
type: "object"
},
- description: ts.Diagnostics.List_of_language_service_plugins,
+ description: ts.Diagnostics.Specify_a_list_of_language_service_plugins_to_include,
category: ts.Diagnostics.Editor_Support,
},
+ {
+ name: "moduleDetection",
+ type: new ts.Map(ts.getEntries({
+ auto: ts.ModuleDetectionKind.Auto,
+ legacy: ts.ModuleDetectionKind.Legacy,
+ force: ts.ModuleDetectionKind.Force,
+ })),
+ affectsModuleResolution: true,
+ description: ts.Diagnostics.Control_what_method_is_used_to_detect_module_format_JS_files,
+ category: ts.Diagnostics.Language_and_Environment,
+ defaultValueDescription: ts.Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules,
+ }
];
/* @internal */
ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild, true), commandOptionsWithoutBuild, true);
@@ -39746,7 +40461,7 @@ var ts;
/* @internal */
ts.defaultInitCompilerOptions = {
module: ts.ModuleKind.CommonJS,
- target: 3 /* ES2016 */,
+ target: 3 /* ScriptTarget.ES2016 */,
strict: true,
esModuleInterop: true,
forceConsistentCasingInFileNames: true,
@@ -39831,11 +40546,11 @@ var ts;
while (i < args.length) {
var s = args[i];
i++;
- if (s.charCodeAt(0) === 64 /* at */) {
+ if (s.charCodeAt(0) === 64 /* CharacterCodes.at */) {
parseResponseFile(s.slice(1));
}
- else if (s.charCodeAt(0) === 45 /* minus */) {
- var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* minus */ ? 2 : 1);
+ else if (s.charCodeAt(0) === 45 /* CharacterCodes.minus */) {
+ var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* CharacterCodes.minus */ ? 2 : 1);
var opt = getOptionDeclarationFromName(diagnostics.getOptionsNameMap, inputOptionName, /*allowShort*/ true);
if (opt) {
i = parseOptionValue(args, i, diagnostics, opt, options, errors);
@@ -39864,14 +40579,14 @@ var ts;
var args = [];
var pos = 0;
while (true) {
- while (pos < text.length && text.charCodeAt(pos) <= 32 /* space */)
+ while (pos < text.length && text.charCodeAt(pos) <= 32 /* CharacterCodes.space */)
pos++;
if (pos >= text.length)
break;
var start = pos;
- if (text.charCodeAt(start) === 34 /* doubleQuote */) {
+ if (text.charCodeAt(start) === 34 /* CharacterCodes.doubleQuote */) {
pos++;
- while (pos < text.length && text.charCodeAt(pos) !== 34 /* doubleQuote */)
+ while (pos < text.length && text.charCodeAt(pos) !== 34 /* CharacterCodes.doubleQuote */)
pos++;
if (pos < text.length) {
args.push(text.substring(start + 1, pos));
@@ -39882,7 +40597,7 @@ var ts;
}
}
else {
- while (text.charCodeAt(pos) > 32 /* space */)
+ while (text.charCodeAt(pos) > 32 /* CharacterCodes.space */)
pos++;
args.push(text.substring(start, pos));
}
@@ -40217,7 +40932,7 @@ var ts;
var _a;
var rootExpression = (_a = sourceFile.statements[0]) === null || _a === void 0 ? void 0 : _a.expression;
var knownRootOptions = reportOptionsErrors ? getTsconfigRootOptionsMap() : undefined;
- if (rootExpression && rootExpression.kind !== 204 /* ObjectLiteralExpression */) {
+ if (rootExpression && rootExpression.kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) {
errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, rootExpression, ts.Diagnostics.The_root_value_of_a_0_file_must_be_an_object, ts.getBaseFileName(sourceFile.fileName) === "jsconfig.json" ? "jsconfig.json" : "tsconfig.json"));
// Last-ditch error recovery. Somewhat useful because the JSON parser will recover from some parse errors by
// synthesizing a top-level array literal expression. There's a reasonable chance the first element of that
@@ -40257,7 +40972,7 @@ var ts;
function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) {
var result = returnValue ? {} : undefined;
var _loop_4 = function (element) {
- if (element.kind !== 294 /* PropertyAssignment */) {
+ if (element.kind !== 296 /* SyntaxKind.PropertyAssignment */) {
errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected));
return "continue";
}
@@ -40324,16 +41039,16 @@ var ts;
function convertPropertyValueToJson(valueExpression, option) {
var invalidReported;
switch (valueExpression.kind) {
- case 110 /* TrueKeyword */:
+ case 110 /* SyntaxKind.TrueKeyword */:
reportInvalidOptionValue(option && option.type !== "boolean");
return validateValue(/*value*/ true);
- case 95 /* FalseKeyword */:
+ case 95 /* SyntaxKind.FalseKeyword */:
reportInvalidOptionValue(option && option.type !== "boolean");
return validateValue(/*value*/ false);
- case 104 /* NullKeyword */:
+ case 104 /* SyntaxKind.NullKeyword */:
reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for
return validateValue(/*value*/ null); // eslint-disable-line no-null/no-null
- case 10 /* StringLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
if (!isDoubleQuotedString(valueExpression)) {
errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected));
}
@@ -40348,16 +41063,16 @@ var ts;
}
}
return validateValue(text);
- case 8 /* NumericLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
reportInvalidOptionValue(option && option.type !== "number");
return validateValue(Number(valueExpression.text));
- case 218 /* PrefixUnaryExpression */:
- if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) {
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
+ if (valueExpression.operator !== 40 /* SyntaxKind.MinusToken */ || valueExpression.operand.kind !== 8 /* SyntaxKind.NumericLiteral */) {
break; // not valid JSON syntax
}
reportInvalidOptionValue(option && option.type !== "number");
return validateValue(-Number(valueExpression.operand.text));
- case 204 /* ObjectLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
reportInvalidOptionValue(option && option.type !== "object");
var objectLiteralExpression = valueExpression;
// Currently having element option declaration in the tsconfig with type "object"
@@ -40374,7 +41089,7 @@ var ts;
return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined,
/*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined));
}
- case 203 /* ArrayLiteralExpression */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
reportInvalidOptionValue(option && option.type !== "list");
return validateValue(convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element));
}
@@ -40642,7 +41357,7 @@ var ts;
var result = [];
result.push("{");
result.push("".concat(tab, "\"compilerOptions\": {"));
- result.push("".concat(tab).concat(tab, "/* ").concat(ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file), " */"));
+ result.push("".concat(tab).concat(tab, "/* ").concat(ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file), " */"));
result.push("");
// Print out each row, aligning all the descriptions on the same column.
for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) {
@@ -40714,7 +41429,10 @@ var ts;
* file to. e.g. outDir
*/
function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
- return parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName });
+ var result = parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
+ return result;
}
ts.parseJsonSourceFileConfigFileContent = parseJsonSourceFileConfigFileContent;
/*@internal*/
@@ -41056,7 +41774,7 @@ var ts;
extendedConfig = ts.normalizeSlashes(extendedConfig);
if (ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../")) {
var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath);
- if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) {
+ if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Extension.Json */)) {
extendedConfigPath = "".concat(extendedConfigPath, ".json");
if (!host.fileExists(extendedConfigPath)) {
errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
@@ -41187,7 +41905,7 @@ var ts;
if (option.type === "list") {
var listOption_1 = option;
if (listOption_1.element.isFilePath || !ts.isString(listOption_1.element.type)) {
- return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return !!v; });
+ return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return listOption_1.listPreserveFalsyValues ? true : !!v; });
}
return value;
}
@@ -41228,7 +41946,7 @@ var ts;
}
}
function convertJsonOptionOfListType(option, values, basePath, errors) {
- return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; });
+ return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return option.listPreserveFalsyValues ? true : !!v; });
}
/**
* Tests for a path that ends in a recursive directory wildcard.
@@ -41298,10 +42016,10 @@ var ts;
var jsonOnlyIncludeRegexes;
if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
var _loop_6 = function (file) {
- if (ts.fileExtensionIs(file, ".json" /* Json */)) {
+ if (ts.fileExtensionIs(file, ".json" /* Extension.Json */)) {
// Valid only if *.json specified
if (!jsonOnlyIncludeRegexes) {
- var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Json */); });
+ var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Extension.Json */); });
var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^".concat(pattern, "$"); });
jsonOnlyIncludeRegexes = includeFilePatterns ? includeFilePatterns.map(function (pattern) { return ts.getRegexFromPattern(pattern, host.useCaseSensitiveFileNames); }) : ts.emptyArray;
}
@@ -41446,7 +42164,7 @@ var ts;
var existingFlags = wildcardDirectories[key];
if (existingFlags === undefined || existingFlags < flags) {
wildcardDirectories[key] = flags;
- if (flags === 1 /* Recursive */) {
+ if (flags === 1 /* WatchDirectoryFlags.Recursive */) {
recursiveKeys.push(key);
}
}
@@ -41480,13 +42198,13 @@ var ts;
key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]),
flags: (questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex)
|| (starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex)
- ? 1 /* Recursive */ : 0 /* None */
+ ? 1 /* WatchDirectoryFlags.Recursive */ : 0 /* WatchDirectoryFlags.None */
};
}
if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
return {
key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
- flags: 1 /* Recursive */
+ flags: 1 /* WatchDirectoryFlags.Recursive */
};
}
return undefined;
@@ -41509,7 +42227,7 @@ var ts;
}
var higherPriorityPath = keyMapper(ts.changeExtension(file, ext));
if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) {
- if (ext === ".d.ts" /* Dts */ && (ts.fileExtensionIs(file, ".js" /* Js */) || ts.fileExtensionIs(file, ".jsx" /* Jsx */))) {
+ if (ext === ".d.ts" /* Extension.Dts */ && (ts.fileExtensionIs(file, ".js" /* Extension.Js */) || ts.fileExtensionIs(file, ".jsx" /* Extension.Jsx */))) {
// LEGACY BEHAVIOR: An off-by-one bug somewhere in the extension priority system for wildcard module loading allowed declaration
// files to be loaded alongside their js(x) counterparts. We regard this as generally undesirable, but retain the behavior to
// prevent breakage.
@@ -41586,7 +42304,8 @@ var ts;
case "boolean":
return true;
case "string":
- return option.isFilePath ? "./" : "";
+ var defaultValue = option.defaultValueDescription;
+ return option.isFilePath ? "./".concat(defaultValue && typeof defaultValue === "string" ? defaultValue : "") : "";
case "list":
return [];
case "object":
@@ -41643,7 +42362,8 @@ var ts;
Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
Extensions[Extensions["Json"] = 2] = "Json";
Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
- Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; /** Only '.d.ts' */
+ Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
+ Extensions[Extensions["TsOnly"] = 5] = "TsOnly";
})(Extensions || (Extensions = {}));
/** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */
function resolvedTypeScriptOnly(resolved) {
@@ -41653,7 +42373,7 @@ var ts;
ts.Debug.assert(ts.extensionIsTS(resolved.extension));
return { fileName: resolved.path, packageId: resolved.packageId };
}
- function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, resultFromCache) {
+ function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, diagnostics, resultFromCache) {
var _a;
if (resultFromCache) {
(_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
@@ -41661,7 +42381,8 @@ var ts;
}
return {
resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
- failedLookupLocations: failedLookupLocations
+ failedLookupLocations: failedLookupLocations,
+ resolutionDiagnostics: diagnostics
};
}
function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
@@ -41801,21 +42522,22 @@ var ts;
var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types");
function arePathsEqual(path1, path2, host) {
var useCaseSensitiveFileNames = typeof host.useCaseSensitiveFileNames === "function" ? host.useCaseSensitiveFileNames() : host.useCaseSensitiveFileNames;
- return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* EqualTo */;
+ return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* Comparison.EqualTo */;
}
/**
* @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown.
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
* is assumed to be the same as root directory of the project.
*/
- function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache) {
+ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache, resolutionMode) {
+ ts.Debug.assert(typeof typeReferenceDirectiveName === "string", "Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.");
var traceEnabled = isTraceEnabled(options, host);
if (redirectedReference) {
options = redirectedReference.commandLine.options;
}
var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
- var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/ undefined);
+ var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/ resolutionMode);
if (result) {
if (traceEnabled) {
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
@@ -41850,7 +42572,29 @@ var ts;
}
var failedLookupLocations = [];
var features = getDefaultNodeResolutionFeatures(options);
- var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: ["node", "require", "types"] };
+ // Unlike `import` statements, whose mode-calculating APIs are all guaranteed to return `undefined` if we're in an un-mode-ed module resolution
+ // setting, type references will return their target mode regardless of options because of how the parser works, so we guard against the mode being
+ // set in a non-modal module resolution setting here. Do note that our behavior is not particularly well defined when these mode-overriding imports
+ // are present in a non-modal project; while in theory we'd like to either ignore the mode or provide faithful modern resolution, depending on what we feel is best,
+ // in practice, not every cache has the options available to intelligently make the choice to ignore the mode request, and it's unclear how modern "faithful modern
+ // resolution" should be (`node16`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution
+ // context should _probably_ be an error - and that should likely be handled by the `Program` (which is what we do).
+ if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) {
+ features |= NodeResolutionFeatures.EsmMode;
+ }
+ var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : [];
+ var diagnostics = [];
+ var moduleResolutionState = {
+ compilerOptions: options,
+ host: host,
+ traceEnabled: traceEnabled,
+ failedLookupLocations: failedLookupLocations,
+ packageJsonInfoCache: cache,
+ features: features,
+ conditions: conditions,
+ requestContainingDirectory: containingDirectory,
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
+ };
var resolved = primaryLookup();
var primary = true;
if (!resolved) {
@@ -41869,8 +42613,8 @@ var ts;
isExternalLibraryImport: pathContainsNodeModules(fileName),
};
}
- result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
- perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ undefined, result);
+ result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, resolutionDiagnostics: diagnostics };
+ perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
if (traceEnabled)
traceResult(result);
return result;
@@ -41921,7 +42665,7 @@ var ts;
result_4 = searchResult && searchResult.value;
}
else {
- var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path;
+ var candidate = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName).path;
result_4 = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true);
}
return resolvedTypeScriptOnly(result_4);
@@ -41935,7 +42679,7 @@ var ts;
}
ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective;
function getDefaultNodeResolutionFeatures(options) {
- return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default :
+ return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 ? NodeResolutionFeatures.Node16Default :
ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault :
NodeResolutionFeatures.None;
}
@@ -41952,6 +42696,8 @@ var ts;
packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
conditions: ts.emptyArray,
features: NodeResolutionFeatures.None,
+ requestContainingDirectory: containingDirectory,
+ reportDiagnostic: ts.noop
};
return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) {
if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
@@ -41994,7 +42740,7 @@ var ts;
if (!isNotNeededPackage) {
var baseFileName = ts.getBaseFileName(normalized);
// At this stage, skip results with leading dot.
- if (baseFileName.charCodeAt(0) !== 46 /* dot */) {
+ if (baseFileName.charCodeAt(0) !== 46 /* CharacterCodes.dot */) {
// Return just the type directive names
result.push(baseFileName);
}
@@ -42156,7 +42902,11 @@ var ts;
ts.Debug.assert(keys.length === values.length);
var map = createModeAwareCache();
for (var i = 0; i < keys.length; ++i) {
- map.set(keys[i], ts.getModeForResolutionAtIndex(file, i), values[i]);
+ var entry = keys[i];
+ // We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
+ var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
+ var mode = !ts.isString(entry) ? entry.resolutionMode || file.impliedNodeFormat : ts.getModeForResolutionAtIndex(file, i);
+ map.set(name, mode, values[i]);
}
return map;
}
@@ -42289,8 +43039,8 @@ var ts;
case ts.ModuleKind.CommonJS:
moduleResolution = ts.ModuleResolutionKind.NodeJs;
break;
- case ts.ModuleKind.Node12:
- moduleResolution = ts.ModuleResolutionKind.Node12;
+ case ts.ModuleKind.Node16:
+ moduleResolution = ts.ModuleResolutionKind.Node16;
break;
case ts.ModuleKind.NodeNext:
moduleResolution = ts.ModuleResolutionKind.NodeNext;
@@ -42310,8 +43060,8 @@ var ts;
}
ts.perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/);
switch (moduleResolution) {
- case ts.ModuleResolutionKind.Node12:
- result = node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
+ case ts.ModuleResolutionKind.Node16:
+ result = node16ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
break;
case ts.ModuleResolutionKind.NodeNext:
result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
@@ -42545,15 +43295,15 @@ var ts;
// respecting the `.exports` member of packages' package.json files and its (conditional) mappings of export names
NodeResolutionFeatures[NodeResolutionFeatures["Exports"] = 8] = "Exports";
// allowing `*` in the LHS of an export to be followed by more content, eg `"./whatever/*.js"`
- // not currently backported to node 12 - https://github.com/nodejs/Release/issues/690
+ // not supported in node 12 - https://github.com/nodejs/Release/issues/690
NodeResolutionFeatures[NodeResolutionFeatures["ExportsPatternTrailers"] = 16] = "ExportsPatternTrailers";
NodeResolutionFeatures[NodeResolutionFeatures["AllFeatures"] = 30] = "AllFeatures";
- NodeResolutionFeatures[NodeResolutionFeatures["Node12Default"] = 14] = "Node12Default";
+ NodeResolutionFeatures[NodeResolutionFeatures["Node16Default"] = 30] = "Node16Default";
NodeResolutionFeatures[NodeResolutionFeatures["NodeNextDefault"] = 30] = "NodeNextDefault";
NodeResolutionFeatures[NodeResolutionFeatures["EsmMode"] = 32] = "EsmMode";
})(NodeResolutionFeatures || (NodeResolutionFeatures = {}));
- function node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
- return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Node12Default, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
+ function node16ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
+ return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Node16Default, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
}
function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
@@ -42572,15 +43322,34 @@ var ts;
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
}
function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
- return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
+ var extensions;
+ if (lookupConfig) {
+ extensions = tsconfigExtensions;
+ }
+ else if (compilerOptions.noDtsResolution) {
+ extensions = [Extensions.TsOnly];
+ if (compilerOptions.allowJs)
+ extensions.push(Extensions.JavaScript);
+ if (compilerOptions.resolveJsonModule)
+ extensions.push(Extensions.Json);
+ }
+ else {
+ extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions;
+ }
+ return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference);
}
ts.nodeModuleNameResolver = nodeModuleNameResolver;
function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
var _a, _b;
var traceEnabled = isTraceEnabled(compilerOptions, host);
var failedLookupLocations = [];
- // conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
+ // conditions are only used by the node16/nodenext resolver - there's no priority order in the list,
//it's essentially a set (priority is determined by object insertion order in the object we look at).
+ var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
+ if (compilerOptions.noDtsResolution) {
+ conditions.pop();
+ }
+ var diagnostics = [];
var state = {
compilerOptions: compilerOptions,
host: host,
@@ -42588,10 +43357,12 @@ var ts;
failedLookupLocations: failedLookupLocations,
packageJsonInfoCache: cache,
features: features,
- conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]
+ conditions: conditions,
+ requestContainingDirectory: containingDirectory,
+ 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, 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, diagnostics, state.resultFromCache);
function tryResolve(extensions) {
var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); };
var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
@@ -42624,13 +43395,25 @@ var ts;
return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } };
}
else {
- var _a = ts.normalizePathAndParts(ts.combinePaths(containingDirectory, moduleName)), candidate = _a.path, parts = _a.parts;
+ var _a = normalizePathForCJSResolution(containingDirectory, moduleName), candidate = _a.path, parts = _a.parts;
var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, /*onlyRecordFailures*/ false, state, /*considerPackageJson*/ true);
// Treat explicit "node_modules" import as an external library import.
return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") });
}
}
}
+ // If you import from "." inside a containing directory "/foo", the result of `normalizePath`
+ // would be "/foo", but this loses the information that `foo` is a directory and we intended
+ // to look inside of it. The Node CommonJS resolution algorithm doesn't call this out
+ // (https://nodejs.org/api/modules.html#all-together), but it seems that module paths ending
+ // in `.` are actually normalized to `./` before proceeding with the resolution algorithm.
+ function normalizePathForCJSResolution(containingDirectory, moduleName) {
+ var combined = ts.combinePaths(containingDirectory, moduleName);
+ var parts = ts.getPathComponents(combined);
+ var lastPart = ts.lastOrUndefined(parts);
+ var path = lastPart === "." || lastPart === ".." ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(combined)) : ts.normalizePath(combined);
+ return { path: path, parts: parts };
+ }
function realPath(path, host, traceEnabled) {
if (!host.realpath) {
return path;
@@ -42672,7 +43455,13 @@ var ts;
onlyRecordFailures = true;
}
}
- return loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson);
+ // esm mode relative imports shouldn't do any directory lookups (either inside `package.json`
+ // files or implicit `index.js`es). This is a notable depature from cjs norms, where `./foo/pkg`
+ // could have been redirected by `./foo/pkg/package.json` to an arbitrary location!
+ if (!(state.features & NodeResolutionFeatures.EsmMode)) {
+ return loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson);
+ }
+ return undefined;
}
/*@internal*/
ts.nodeModulesPathPart = "/node_modules/";
@@ -42700,7 +43489,7 @@ var ts;
}
var indexAfterNodeModules = idx + ts.nodeModulesPathPart.length;
var indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules);
- if (path.charCodeAt(indexAfterNodeModules) === 64 /* at */) {
+ if (path.charCodeAt(indexAfterNodeModules) === 64 /* CharacterCodes.at */) {
indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName);
}
return path.slice(0, indexAfterPackageName);
@@ -42719,7 +43508,7 @@ var ts;
*/
function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) {
if (extensions === Extensions.Json || extensions === Extensions.TSConfig) {
- var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */);
+ var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Extension.Json */);
var extension = extensionLess ? candidate.substring(extensionLess.length) : "";
return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, extension, onlyRecordFailures, state);
}
@@ -42736,7 +43525,7 @@ var ts;
function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state) {
// If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one;
// e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts"
- if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Json */) && state.compilerOptions.resolveJsonModule)) {
+ if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Extension.Json */) && state.compilerOptions.resolveJsonModule)) {
var extensionless = ts.removeFileExtension(candidate);
var extension = candidate.substring(extensionless.length);
if (state.traceEnabled) {
@@ -42746,9 +43535,9 @@ var ts;
}
}
function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
- if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */])) {
+ if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, ts.supportedTSExtensionsFlat)) {
var result = tryFile(candidate, onlyRecordFailures, state);
- return result !== undefined ? { path: candidate, ext: ts.forEach([".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */], function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined;
+ return result !== undefined ? { path: candidate, ext: ts.tryExtractTSExtension(candidate) } : undefined;
}
return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
}
@@ -42764,53 +43553,55 @@ var ts;
switch (extensions) {
case Extensions.DtsOnly:
switch (originalExtension) {
- case ".mjs" /* Mjs */:
- case ".mts" /* Mts */:
- case ".d.mts" /* Dmts */:
- return tryExtension(".d.mts" /* Dmts */);
- case ".cjs" /* Cjs */:
- case ".cts" /* Cts */:
- case ".d.cts" /* Dcts */:
- return tryExtension(".d.cts" /* Dcts */);
- case ".json" /* Json */:
- candidate += ".json" /* Json */;
- return tryExtension(".d.ts" /* Dts */);
- default: return tryExtension(".d.ts" /* Dts */);
+ case ".mjs" /* Extension.Mjs */:
+ case ".mts" /* Extension.Mts */:
+ case ".d.mts" /* Extension.Dmts */:
+ return tryExtension(".d.mts" /* Extension.Dmts */);
+ case ".cjs" /* Extension.Cjs */:
+ case ".cts" /* Extension.Cts */:
+ case ".d.cts" /* Extension.Dcts */:
+ return tryExtension(".d.cts" /* Extension.Dcts */);
+ case ".json" /* Extension.Json */:
+ candidate += ".json" /* Extension.Json */;
+ return tryExtension(".d.ts" /* Extension.Dts */);
+ default: return tryExtension(".d.ts" /* Extension.Dts */);
}
case Extensions.TypeScript:
+ case Extensions.TsOnly:
+ var useDts = extensions === Extensions.TypeScript;
switch (originalExtension) {
- case ".mjs" /* Mjs */:
- case ".mts" /* Mts */:
- case ".d.mts" /* Dmts */:
- return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
- case ".cjs" /* Cjs */:
- case ".cts" /* Cts */:
- case ".d.cts" /* Dcts */:
- return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
- case ".json" /* Json */:
- candidate += ".json" /* Json */;
- return tryExtension(".d.ts" /* Dts */);
+ case ".mjs" /* Extension.Mjs */:
+ case ".mts" /* Extension.Mts */:
+ case ".d.mts" /* Extension.Dmts */:
+ return tryExtension(".mts" /* Extension.Mts */) || (useDts ? tryExtension(".d.mts" /* Extension.Dmts */) : undefined);
+ case ".cjs" /* Extension.Cjs */:
+ case ".cts" /* Extension.Cts */:
+ case ".d.cts" /* Extension.Dcts */:
+ return tryExtension(".cts" /* Extension.Cts */) || (useDts ? tryExtension(".d.cts" /* Extension.Dcts */) : undefined);
+ case ".json" /* Extension.Json */:
+ candidate += ".json" /* Extension.Json */;
+ return useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined;
default:
- return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
+ return tryExtension(".ts" /* Extension.Ts */) || tryExtension(".tsx" /* Extension.Tsx */) || (useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined);
}
case Extensions.JavaScript:
switch (originalExtension) {
- case ".mjs" /* Mjs */:
- case ".mts" /* Mts */:
- case ".d.mts" /* Dmts */:
- return tryExtension(".mjs" /* Mjs */);
- case ".cjs" /* Cjs */:
- case ".cts" /* Cts */:
- case ".d.cts" /* Dcts */:
- return tryExtension(".cjs" /* Cjs */);
- case ".json" /* Json */:
- return tryExtension(".json" /* Json */);
+ case ".mjs" /* Extension.Mjs */:
+ case ".mts" /* Extension.Mts */:
+ case ".d.mts" /* Extension.Dmts */:
+ return tryExtension(".mjs" /* Extension.Mjs */);
+ case ".cjs" /* Extension.Cjs */:
+ case ".cts" /* Extension.Cts */:
+ case ".d.cts" /* Extension.Dcts */:
+ return tryExtension(".cjs" /* Extension.Cjs */);
+ case ".json" /* Extension.Json */:
+ return tryExtension(".json" /* Extension.Json */);
default:
- return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */);
+ return tryExtension(".js" /* Extension.Js */) || tryExtension(".jsx" /* Extension.Jsx */);
}
case Extensions.TSConfig:
case Extensions.Json:
- return tryExtension(".json" /* Json */);
+ return tryExtension(".json" /* Extension.Json */);
}
function tryExtension(ext) {
var path = tryFile(candidate + ext, onlyRecordFailures, state);
@@ -42819,6 +43610,15 @@ var ts;
}
/** Return the file if it exists. */
function tryFile(fileName, onlyRecordFailures, state) {
+ var _a, _b;
+ if (!((_a = state.compilerOptions.moduleSuffixes) === null || _a === void 0 ? void 0 : _a.length)) {
+ return tryFileLookup(fileName, onlyRecordFailures, state);
+ }
+ var ext = (_b = ts.tryGetExtensionFromPath(fileName)) !== null && _b !== void 0 ? _b : "";
+ var fileNameNoExtension = ext ? ts.removeExtension(fileName, ext) : fileName;
+ return ts.forEach(state.compilerOptions.moduleSuffixes, function (suffix) { return tryFileLookup(fileNameNoExtension + suffix + ext, onlyRecordFailures, state); });
+ }
+ function tryFileLookup(fileName, onlyRecordFailures, state) {
if (!onlyRecordFailures) {
if (state.host.fileExists(fileName)) {
if (state.traceEnabled) {
@@ -42860,6 +43660,8 @@ var ts;
packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
conditions: ["node", "require", "types"],
features: features,
+ requestContainingDirectory: packageJsonInfo.packageDirectory,
+ reportDiagnostic: ts.noop
};
var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory,
/*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths);
@@ -42946,6 +43748,8 @@ var ts;
packageJsonInfoCache: packageJsonInfoCache,
features: 0,
conditions: [],
+ requestContainingDirectory: undefined,
+ reportDiagnostic: ts.noop
};
var parts = ts.getPathComponents(fileName);
parts.pop();
@@ -43009,6 +43813,7 @@ var ts;
switch (extensions) {
case Extensions.JavaScript:
case Extensions.Json:
+ case Extensions.TsOnly:
packageFile = readPackageJsonMainField(jsonContent, candidate, state);
break;
case Extensions.TypeScript:
@@ -43039,7 +43844,16 @@ var ts;
// Even if extensions is DtsOnly, we can still look up a .ts file as a result of package.json "types"
var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions;
// Don't do package.json lookup recursively, because Node.js' package lookup doesn't.
- return nodeLoadModuleByRelativeName(nextExtensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ false);
+ // Disable `EsmMode` for the resolution of the package path for cjs-mode packages (so the `main` field can omit extensions)
+ // (technically it only emits a deprecation warning in esm packages right now, but that's probably
+ // enough to mean we don't need to support it)
+ var features = state.features;
+ if ((jsonContent === null || jsonContent === void 0 ? void 0 : jsonContent.type) !== "module") {
+ state.features &= ~NodeResolutionFeatures.EsmMode;
+ }
+ var result = nodeLoadModuleByRelativeName(nextExtensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ false);
+ state.features = features;
+ return result;
};
var onlyRecordFailuresForPackageFile = packageFile ? !ts.directoryProbablyExists(ts.getDirectoryPath(packageFile), state.host) : undefined;
var onlyRecordFailuresForIndex = onlyRecordFailures || !ts.directoryProbablyExists(candidate, state.host);
@@ -43072,14 +43886,16 @@ var ts;
function extensionIsOk(extensions, extension) {
switch (extensions) {
case Extensions.JavaScript:
- return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */;
+ return extension === ".js" /* Extension.Js */ || extension === ".jsx" /* Extension.Jsx */ || extension === ".mjs" /* Extension.Mjs */ || extension === ".cjs" /* Extension.Cjs */;
case Extensions.TSConfig:
case Extensions.Json:
- return extension === ".json" /* Json */;
+ return extension === ".json" /* Extension.Json */;
case Extensions.TypeScript:
- return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */;
+ return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */ || extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */;
+ case Extensions.TsOnly:
+ return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */;
case Extensions.DtsOnly:
- return extension === ".d.ts" /* Dts */;
+ return extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */;
}
}
/* @internal */
@@ -43225,7 +44041,6 @@ var ts;
function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
return loadModuleFromTargetImportOrExport;
function loadModuleFromTargetImportOrExport(target, subpath, pattern) {
- var _a, _b;
if (typeof target === "string") {
if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) {
if (state.traceEnabled) {
@@ -43262,13 +44077,16 @@ var ts;
}
return toSearchResult(/*value*/ undefined);
}
- var finalPath = ts.getNormalizedAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a));
+ var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath);
+ var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports);
+ if (inputLink)
+ return inputLink;
return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, finalPath, /*onlyRecordFailures*/ false, state)));
}
else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null
if (!Array.isArray(target)) {
- for (var _i = 0, _c = ts.getOwnKeys(target); _i < _c.length; _i++) {
- var key = _c[_i];
+ for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) {
+ var key = _a[_i];
if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) {
var subTarget = target[key];
var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern);
@@ -43286,8 +44104,8 @@ var ts;
}
return toSearchResult(/*value*/ undefined);
}
- for (var _d = 0, target_2 = target; _d < target_2.length; _d++) {
- var elem = target_2[_d];
+ for (var _b = 0, target_2 = target; _b < target_2.length; _b++) {
+ var elem = target_2[_b];
var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
if (result) {
return result;
@@ -43305,6 +44123,128 @@ var ts;
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
}
return toSearchResult(/*value*/ undefined);
+ function toAbsolutePath(path) {
+ var _a, _b;
+ if (path === undefined)
+ return path;
+ return ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames })(ts.getNormalizedAbsolutePath(path, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)));
+ }
+ function combineDirectoryPath(root, dir) {
+ return ts.ensureTrailingDirectorySeparator(ts.combinePaths(root, dir));
+ }
+ function useCaseSensitiveFileNames() {
+ return !state.host.useCaseSensitiveFileNames ? true :
+ typeof state.host.useCaseSensitiveFileNames === "boolean" ? state.host.useCaseSensitiveFileNames :
+ state.host.useCaseSensitiveFileNames();
+ }
+ function tryLoadInputFileForPath(finalPath, entry, packagePath, isImports) {
+ var _a, _b, _c, _d;
+ // Replace any references to outputs for files in the program with the input files to support package self-names used with outDir
+ // PROBLEM: We don't know how to calculate the output paths yet, because the "common source directory" we use as the base of the file structure
+ // we reproduce into the output directory is based on the set of input files, which we're still in the process of traversing and resolving!
+ // _Given that_, we have to guess what the base of the output directory is (obviously the user wrote the export map, so has some idea what it is!).
+ // We are going to probe _so many_ possible paths. We limit where we'll do this to try to reduce the possibilities of false positive lookups.
+ if ((extensions === Extensions.TypeScript || extensions === Extensions.JavaScript || extensions === Extensions.Json)
+ && (state.compilerOptions.declarationDir || state.compilerOptions.outDir)
+ && finalPath.indexOf("/node_modules/") === -1
+ && (state.compilerOptions.configFile ? ts.startsWith(toAbsolutePath(state.compilerOptions.configFile.fileName), scope.packageDirectory) : true)) {
+ // So that all means we'll only try these guesses for files outside `node_modules` in a directory where the `package.json` and `tsconfig.json` are siblings.
+ // Even with all that, we still don't know if the root of the output file structure will be (relative to the package file)
+ // `.`, `./src` or any other deeper directory structure. (If project references are used, it's definitely `.` by fiat, so that should be pretty common.)
+ var getCanonicalFileName = ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames });
+ var commonSourceDirGuesses = [];
+ // A `rootDir` compiler option strongly indicates the root location
+ // A `composite` project is using project references and has it's common src dir set to `.`, so it shouldn't need to check any other locations
+ if (state.compilerOptions.rootDir || (state.compilerOptions.composite && state.compilerOptions.configFilePath)) {
+ var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return []; }, ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "", getCanonicalFileName));
+ commonSourceDirGuesses.push(commonDir);
+ }
+ else if (state.requestContainingDirectory) {
+ // However without either of those set we're in the dark. Let's say you have
+ //
+ // ./tools/index.ts
+ // ./src/index.ts
+ // ./dist/index.js
+ // ./package.json <-- references ./dist/index.js
+ // ./tsconfig.json <-- loads ./src/index.ts
+ //
+ // How do we know `./src` is the common src dir, and not `./tools`, given only the `./dist` out dir and `./dist/index.js` filename?
+ // Answer: We... don't. We know we're looking for an `index.ts` input file, but we have _no clue_ which subfolder it's supposed to be loaded from
+ // without more context.
+ // But we do have more context! Just a tiny bit more! We're resolving an import _for some other input file_! And that input file, too
+ // must be inside the common source directory! So we propagate that tidbit of info all the way to here via state.requestContainingDirectory
+ var requestingFile_1 = toAbsolutePath(ts.combinePaths(state.requestContainingDirectory, "index.ts"));
+ // And we can try every folder above the common folder for the request folder and the config/package base directory
+ // This technically can be wrong - we may load ./src/index.ts when ./src/sub/index.ts was right because we don't
+ // know if only `./src/sub` files were loaded by the program; but this has the best chance to be right of just about anything
+ // else we have. And, given that we're about to load `./src/index.ts` because we choose it as likely correct, there will then
+ // be a file outside of `./src/sub` in the program (the file we resolved to), making us de-facto right. So this fallback lookup
+ // logic may influence what files are pulled in by self-names, which in turn influences the output path shape, but it's all
+ // internally consistent so the paths should be stable so long as we prefer the "most general" (meaning: top-most-level directory) possible results first.
+ var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return [requestingFile_1, toAbsolutePath(packagePath)]; }, ((_d = (_c = state.host).getCurrentDirectory) === null || _d === void 0 ? void 0 : _d.call(_c)) || "", getCanonicalFileName));
+ commonSourceDirGuesses.push(commonDir);
+ var fragment = ts.ensureTrailingDirectorySeparator(commonDir);
+ while (fragment && fragment.length > 1) {
+ var parts = ts.getPathComponents(fragment);
+ parts.pop(); // remove a directory
+ var commonDir_1 = ts.getPathFromPathComponents(parts);
+ commonSourceDirGuesses.unshift(commonDir_1);
+ fragment = ts.ensureTrailingDirectorySeparator(commonDir_1);
+ }
+ }
+ if (commonSourceDirGuesses.length > 1) {
+ state.reportDiagnostic(ts.createCompilerDiagnostic(isImports
+ ? ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate
+ : ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate, entry === "" ? "." : entry, // replace empty string with `.` - the reverse of the operation done when entries are built - so main entrypoint errors don't look weird
+ packagePath));
+ }
+ for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) {
+ var commonSourceDirGuess = commonSourceDirGuesses_1[_i];
+ var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess);
+ for (var _e = 0, candidateDirectories_1 = candidateDirectories; _e < candidateDirectories_1.length; _e++) {
+ var candidateDir = candidateDirectories_1[_e];
+ if (ts.startsWith(finalPath, candidateDir)) {
+ // The matched export is looking up something in either the out declaration or js dir, now map the written path back into the source dir and source extension
+ var pathFragment = finalPath.slice(candidateDir.length + 1); // +1 to also remove directory seperator
+ var possibleInputBase = ts.combinePaths(commonSourceDirGuess, pathFragment);
+ var jsAndDtsExtensions = [".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */, ".js" /* Extension.Js */, ".json" /* Extension.Json */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".d.ts" /* Extension.Dts */];
+ for (var _f = 0, jsAndDtsExtensions_1 = jsAndDtsExtensions; _f < jsAndDtsExtensions_1.length; _f++) {
+ var ext = jsAndDtsExtensions_1[_f];
+ if (ts.fileExtensionIs(possibleInputBase, ext)) {
+ var inputExts = ts.getPossibleOriginalInputExtensionForExtension(possibleInputBase);
+ for (var _g = 0, inputExts_1 = inputExts; _g < inputExts_1.length; _g++) {
+ var possibleExt = inputExts_1[_g];
+ var possibleInputWithInputExtension = ts.changeAnyExtension(possibleInputBase, possibleExt, ext, !useCaseSensitiveFileNames());
+ if ((extensions === Extensions.TypeScript && ts.hasJSFileExtension(possibleInputWithInputExtension)) ||
+ (extensions === Extensions.JavaScript && ts.hasTSFileExtension(possibleInputWithInputExtension))) {
+ continue;
+ }
+ if (state.host.fileExists(possibleInputWithInputExtension)) {
+ return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, possibleInputWithInputExtension, /*onlyRecordFailures*/ false, state)));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return undefined;
+ function getOutputDirectoriesForBaseDirectory(commonSourceDirGuess) {
+ var _a, _b;
+ // Config file ouput paths are processed to be relative to the host's current directory, while
+ // otherwise the paths are resolved relative to the common source dir the compiler puts together
+ var currentDir = state.compilerOptions.configFile ? ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "" : commonSourceDirGuess;
+ var candidateDirectories = [];
+ if (state.compilerOptions.declarationDir) {
+ candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.declarationDir)));
+ }
+ if (state.compilerOptions.outDir && state.compilerOptions.outDir !== state.compilerOptions.declarationDir) {
+ candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.outDir)));
+ }
+ return candidateDirectories;
+ }
+ }
}
}
/* @internal */
@@ -43384,6 +44324,14 @@ var ts;
}
var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
+ if (!pathAndExtension && packageInfo
+ && packageInfo.packageJsonContent.exports === undefined
+ && packageInfo.packageJsonContent.main === undefined
+ && state.features & NodeResolutionFeatures.EsmMode) {
+ // EsmMode disables index lookup in `loadNodeModuleFromDirectoryWorker` generally, however non-relative package resolutions still assume
+ // a default `index.js` entrypoint if no `main` or `exports` are present
+ pathAndExtension = loadModuleFromFile(extensions, ts.combinePaths(candidate, "index.js"), onlyRecordFailures, state);
+ }
return withPackageId(packageInfo, pathAndExtension);
};
if (rest !== "") { // If "rest" is empty, we just did this search above.
@@ -43487,11 +44435,12 @@ var ts;
function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
var traceEnabled = isTraceEnabled(compilerOptions, host);
var failedLookupLocations = [];
- var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] };
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 resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
// No originalPath because classic resolution doesn't resolve realPath
- return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, state.resultFromCache);
+ return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, diagnostics, state.resultFromCache);
function tryResolve(extensions) {
var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
if (resolvedUsingSettings) {
@@ -43534,9 +44483,10 @@ 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 state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [] };
+ 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 resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
- return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache);
+ return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, diagnostics, state.resultFromCache);
}
ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
/**
@@ -43562,14 +44512,14 @@ var ts;
ts.setParent(node.body, node);
ts.setParentRecursive(node.body, /*incremental*/ false);
}
- return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */;
+ return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* ModuleInstanceState.Instantiated */;
}
ts.getModuleInstanceState = getModuleInstanceState;
function getModuleInstanceStateCached(node, visited) {
if (visited === void 0) { visited = new ts.Map(); }
var nodeId = ts.getNodeId(node);
if (visited.has(nodeId)) {
- return visited.get(nodeId) || 0 /* NonInstantiated */;
+ return visited.get(nodeId) || 0 /* ModuleInstanceState.NonInstantiated */;
}
visited.set(nodeId, undefined);
var result = getModuleInstanceStateWorker(node, visited);
@@ -43580,34 +44530,34 @@ var ts;
// A module is uninstantiated if it contains only
switch (node.kind) {
// 1. interface declarations, type alias declarations
- case 257 /* InterfaceDeclaration */:
- case 258 /* TypeAliasDeclaration */:
- return 0 /* NonInstantiated */;
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ return 0 /* ModuleInstanceState.NonInstantiated */;
// 2. const enum declarations
- case 259 /* EnumDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
if (ts.isEnumConst(node)) {
- return 2 /* ConstEnumOnly */;
+ return 2 /* ModuleInstanceState.ConstEnumOnly */;
}
break;
// 3. non-exported import declarations
- case 265 /* ImportDeclaration */:
- case 264 /* ImportEqualsDeclaration */:
- if (!(ts.hasSyntacticModifier(node, 1 /* Export */))) {
- return 0 /* NonInstantiated */;
+ case 266 /* SyntaxKind.ImportDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ if (!(ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) {
+ return 0 /* ModuleInstanceState.NonInstantiated */;
}
break;
// 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain
- case 271 /* ExportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
var exportDeclaration = node;
- if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 272 /* NamedExports */) {
- var state = 0 /* NonInstantiated */;
+ if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 273 /* SyntaxKind.NamedExports */) {
+ var state = 0 /* ModuleInstanceState.NonInstantiated */;
for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) {
var specifier = _a[_i];
var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited);
if (specifierState > state) {
state = specifierState;
}
- if (state === 1 /* Instantiated */) {
+ if (state === 1 /* ModuleInstanceState.Instantiated */) {
return state;
}
}
@@ -43615,21 +44565,21 @@ var ts;
}
break;
// 5. other uninstantiated module declarations.
- case 261 /* ModuleBlock */: {
- var state_1 = 0 /* NonInstantiated */;
+ case 262 /* SyntaxKind.ModuleBlock */: {
+ var state_1 = 0 /* ModuleInstanceState.NonInstantiated */;
ts.forEachChild(node, function (n) {
var childState = getModuleInstanceStateCached(n, visited);
switch (childState) {
- case 0 /* NonInstantiated */:
+ case 0 /* ModuleInstanceState.NonInstantiated */:
// child is non-instantiated - continue searching
return;
- case 2 /* ConstEnumOnly */:
+ case 2 /* ModuleInstanceState.ConstEnumOnly */:
// child is const enum only - record state and continue searching
- state_1 = 2 /* ConstEnumOnly */;
+ state_1 = 2 /* ModuleInstanceState.ConstEnumOnly */;
return;
- case 1 /* Instantiated */:
+ case 1 /* ModuleInstanceState.Instantiated */:
// child is instantiated - record state and stop
- state_1 = 1 /* Instantiated */;
+ state_1 = 1 /* ModuleInstanceState.Instantiated */;
return true;
default:
ts.Debug.assertNever(childState);
@@ -43637,16 +44587,16 @@ var ts;
});
return state_1;
}
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
return getModuleInstanceState(node, visited);
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
// Only jsdoc typedef definition can exist in jsdoc namespace, and it should
// be considered the same as type alias
if (node.isInJSDocNamespace) {
- return 0 /* NonInstantiated */;
+ return 0 /* ModuleInstanceState.NonInstantiated */;
}
}
- return 1 /* Instantiated */;
+ return 1 /* ModuleInstanceState.Instantiated */;
}
function getModuleInstanceStateForAliasTarget(specifier, visited) {
var name = specifier.propertyName || specifier.name;
@@ -43666,7 +44616,7 @@ var ts;
if (found === undefined || state > found) {
found = state;
}
- if (found === 1 /* Instantiated */) {
+ if (found === 1 /* ModuleInstanceState.Instantiated */) {
return found;
}
}
@@ -43677,7 +44627,7 @@ var ts;
}
p = p.parent;
}
- return 1 /* Instantiated */; // Couldn't locate, assume could refer to a value
+ return 1 /* ModuleInstanceState.Instantiated */; // Couldn't locate, assume could refer to a value
}
var ContainerFlags;
(function (ContainerFlags) {
@@ -43751,8 +44701,8 @@ var ts;
var symbolCount = 0;
var Symbol;
var classifiableNames;
- var unreachableFlow = { flags: 1 /* Unreachable */ };
- var reportedUnreachableFlow = { flags: 1 /* Unreachable */ };
+ var unreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ };
+ var reportedUnreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ };
var bindBinaryExpressionFlow = createBindBinaryExpressionFlow();
/**
* Inside the binder, we may create a diagnostic for an as-yet unbound node (with potentially no parent pointers, implying no accessible source file)
@@ -43774,7 +44724,7 @@ var ts;
ts.Debug.attachFlowNodeDebugInfo(unreachableFlow);
ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow);
if (!file.locals) {
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true);
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* tracing.Phase.Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true);
bind(file);
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
file.symbolCount = symbolCount;
@@ -43801,7 +44751,7 @@ var ts;
activeLabelList = undefined;
hasExplicitReturn = false;
inAssignmentPattern = false;
- emitFlags = 0 /* None */;
+ emitFlags = 0 /* NodeFlags.None */;
}
return bindSourceFile;
function bindInStrictMode(file, opts) {
@@ -43821,25 +44771,25 @@ var ts;
symbol.flags |= symbolFlags;
node.symbol = symbol;
symbol.declarations = ts.appendIfUnique(symbol.declarations, node);
- if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) {
+ if (symbolFlags & (32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */) && !symbol.exports) {
symbol.exports = ts.createSymbolTable();
}
- if (symbolFlags & (32 /* Class */ | 64 /* Interface */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && !symbol.members) {
+ if (symbolFlags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && !symbol.members) {
symbol.members = ts.createSymbolTable();
}
// On merge of const enum module with class or function, reset const enum only flag (namespaces will already recalculate)
- if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) {
+ if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */))) {
symbol.constEnumOnlyModule = false;
}
- if (symbolFlags & 111551 /* Value */) {
+ if (symbolFlags & 111551 /* SymbolFlags.Value */) {
ts.setValueDeclaration(symbol, node);
}
}
// Should not be called on a declaration with a computed property name,
// unless it is a well known Symbol.
function getDeclarationName(node) {
- if (node.kind === 270 /* ExportAssignment */) {
- return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */;
+ if (node.kind === 271 /* SyntaxKind.ExportAssignment */) {
+ return node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */;
}
var name = ts.getNameOfDeclaration(node);
if (name) {
@@ -43847,7 +44797,7 @@ var ts;
var moduleName = ts.getTextOfIdentifierOrLiteral(name);
return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"".concat(moduleName, "\""));
}
- if (name.kind === 161 /* ComputedPropertyName */) {
+ if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) {
var nameExpression = name.expression;
// treat computed property names where expression is string/numeric literal as just string/numeric literal
if (ts.isStringOrNumericLiteralLike(nameExpression)) {
@@ -43873,36 +44823,36 @@ var ts;
return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined;
}
switch (node.kind) {
- case 170 /* Constructor */:
- return "__constructor" /* Constructor */;
- case 178 /* FunctionType */:
- case 173 /* CallSignature */:
- case 321 /* JSDocSignature */:
- return "__call" /* Call */;
- case 179 /* ConstructorType */:
- case 174 /* ConstructSignature */:
- return "__new" /* New */;
- case 175 /* IndexSignature */:
- return "__index" /* Index */;
- case 271 /* ExportDeclaration */:
- return "__export" /* ExportStar */;
- case 303 /* SourceFile */:
+ case 171 /* SyntaxKind.Constructor */:
+ return "__constructor" /* InternalSymbolName.Constructor */;
+ case 179 /* SyntaxKind.FunctionType */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 323 /* SyntaxKind.JSDocSignature */:
+ return "__call" /* InternalSymbolName.Call */;
+ case 180 /* SyntaxKind.ConstructorType */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ return "__new" /* InternalSymbolName.New */;
+ case 176 /* SyntaxKind.IndexSignature */:
+ return "__index" /* InternalSymbolName.Index */;
+ case 272 /* SyntaxKind.ExportDeclaration */:
+ return "__export" /* InternalSymbolName.ExportStar */;
+ case 305 /* SyntaxKind.SourceFile */:
// json file should behave as
// module.exports = ...
- return "export=" /* ExportEquals */;
- case 220 /* BinaryExpression */:
- if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) {
+ return "export=" /* InternalSymbolName.ExportEquals */;
+ case 221 /* SyntaxKind.BinaryExpression */:
+ if (ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */) {
// module.exports = ...
- return "export=" /* ExportEquals */;
+ return "export=" /* InternalSymbolName.ExportEquals */;
}
ts.Debug.fail("Unknown binary declaration kind");
break;
- case 315 /* JSDocFunctionType */:
- return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */);
- case 163 /* Parameter */:
+ case 317 /* SyntaxKind.JSDocFunctionType */:
+ return (ts.isJSDocConstructSignature(node) ? "__new" /* InternalSymbolName.New */ : "__call" /* InternalSymbolName.Call */);
+ case 164 /* SyntaxKind.Parameter */:
// Parameters with names are handled at the top of this function. Parameters
// without names can only come from JSDocFunctionTypes.
- ts.Debug.assert(node.parent.kind === 315 /* JSDocFunctionType */, "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 /* SyntaxKind.JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: ".concat(ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind, ", expected JSDocFunctionType"); });
var functionType = node.parent;
var index = functionType.parameters.indexOf(node);
return "arg" + index;
@@ -43921,14 +44871,14 @@ var ts;
*/
function declareSymbol(symbolTable, parent, node, includes, excludes, isReplaceableByMethod, isComputedName) {
ts.Debug.assert(isComputedName || !ts.hasDynamicName(node));
- var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default";
+ var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default";
// The exported symbol for an export default function/class node is always named "default"
- var name = isComputedName ? "__computed" /* Computed */
- : isDefaultExport && parent ? "default" /* Default */
+ var name = isComputedName ? "__computed" /* InternalSymbolName.Computed */
+ : isDefaultExport && parent ? "default" /* InternalSymbolName.Default */
: getDeclarationName(node);
var symbol;
if (name === undefined) {
- symbol = createSymbol(0 /* None */, "__missing" /* Missing */);
+ symbol = createSymbol(0 /* SymbolFlags.None */, "__missing" /* InternalSymbolName.Missing */);
}
else {
// Check and see if the symbol table already has a symbol with this name. If not,
@@ -43955,11 +44905,11 @@ var ts;
// you have multiple 'vars' with the same name in the same container). In this case
// just add this node into the declarations list of the symbol.
symbol = symbolTable.get(name);
- if (includes & 2885600 /* Classifiable */) {
+ if (includes & 2885600 /* SymbolFlags.Classifiable */) {
classifiableNames.add(name);
}
if (!symbol) {
- symbolTable.set(name, symbol = createSymbol(0 /* None */, name));
+ symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name));
if (isReplaceableByMethod)
symbol.isReplaceableByMethod = true;
}
@@ -43971,20 +44921,20 @@ var ts;
if (symbol.isReplaceableByMethod) {
// Javascript constructor-declared symbols can be discarded in favor of
// prototype symbols like methods.
- symbolTable.set(name, symbol = createSymbol(0 /* None */, name));
+ symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name));
}
- else if (!(includes & 3 /* Variable */ && symbol.flags & 67108864 /* Assignment */)) {
+ else if (!(includes & 3 /* SymbolFlags.Variable */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */)) {
// Assignment declarations are allowed to merge with variables, no matter what other flags they have.
if (ts.isNamedDeclaration(node)) {
ts.setParent(node.name, node);
}
// Report errors every position with duplicate declaration
// Report errors on previous encountered declarations
- var message_1 = symbol.flags & 2 /* BlockScopedVariable */
+ var message_1 = symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */
? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
: ts.Diagnostics.Duplicate_identifier_0;
var messageNeedsName_1 = true;
- if (symbol.flags & 384 /* Enum */ || includes & 384 /* Enum */) {
+ if (symbol.flags & 384 /* SymbolFlags.Enum */ || includes & 384 /* SymbolFlags.Enum */) {
message_1 = ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations;
messageNeedsName_1 = false;
}
@@ -44004,7 +44954,7 @@ var ts;
// 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default
// 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers)
if (symbol.declarations && symbol.declarations.length &&
- (node.kind === 270 /* ExportAssignment */ && !node.isExportEquals)) {
+ (node.kind === 271 /* SyntaxKind.ExportAssignment */ && !node.isExportEquals)) {
message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports;
messageNeedsName_1 = false;
multipleDefaultExports_1 = true;
@@ -44012,7 +44962,7 @@ var ts;
}
}
var relatedInformation_1 = [];
- if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* Export */) && symbol.flags & (2097152 /* Alias */ | 788968 /* Type */ | 1920 /* Namespace */)) {
+ if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) && symbol.flags & (2097152 /* SymbolFlags.Alias */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) {
// export type T; - may have meant export type { T }?
relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { ".concat(ts.unescapeLeadingUnderscores(node.name.escapedText), " }")));
}
@@ -44027,7 +44977,7 @@ var ts;
});
var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined);
file.bindDiagnostics.push(ts.addRelatedInfo.apply(void 0, __spreadArray([diag], relatedInformation_1, false)));
- symbol = createSymbol(0 /* None */, name);
+ symbol = createSymbol(0 /* SymbolFlags.None */, name);
}
}
}
@@ -44041,9 +44991,9 @@ var ts;
return symbol;
}
function declareModuleMember(node, symbolFlags, symbolExcludes) {
- var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node);
- if (symbolFlags & 2097152 /* Alias */) {
- if (node.kind === 274 /* ExportSpecifier */ || (node.kind === 264 /* ImportEqualsDeclaration */ && hasExportModifier)) {
+ var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) || jsdocTreatAsExported(node);
+ if (symbolFlags & 2097152 /* SymbolFlags.Alias */) {
+ if (node.kind === 275 /* SyntaxKind.ExportSpecifier */ || (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && hasExportModifier)) {
return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
}
else {
@@ -44067,11 +45017,11 @@ var ts;
// and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed.
if (ts.isJSDocTypeAlias(node))
ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file.
- if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) {
- if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* Default */) && !getDeclarationName(node))) {
+ if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* NodeFlags.ExportContext */)) {
+ if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) && !getDeclarationName(node))) {
return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default!
}
- var exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0;
+ var exportKind = symbolFlags & 111551 /* SymbolFlags.Value */ ? 1048576 /* SymbolFlags.ExportValue */ : 0;
var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes);
local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
node.localSymbol = local;
@@ -44098,7 +45048,7 @@ var ts;
return false;
if (ts.isPropertyAccessEntityNameExpression(declName.parent) && isTopLevelNamespaceAssignment(declName.parent))
return true;
- if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* Export */)
+ if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* ModifierFlags.Export */)
return true;
// This could potentially be simplified by having `delayedBindJSDocTypedefTag` pass in an override for `hasExportModifier`, since it should
// already have calculated and branched on most of this.
@@ -44131,21 +45081,21 @@ var ts;
// reusing a node from a previous compilation, that node may have had 'locals' created
// for it. We must clear this so we don't accidentally move any stale data forward from
// a previous compilation.
- if (containerFlags & 1 /* IsContainer */) {
- if (node.kind !== 213 /* ArrowFunction */) {
+ if (containerFlags & 1 /* ContainerFlags.IsContainer */) {
+ if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) {
thisParentContainer = container;
}
container = blockScopeContainer = node;
- if (containerFlags & 32 /* HasLocals */) {
+ if (containerFlags & 32 /* ContainerFlags.HasLocals */) {
container.locals = ts.createSymbolTable();
}
addToContainerChain(container);
}
- else if (containerFlags & 2 /* IsBlockScopedContainer */) {
+ else if (containerFlags & 2 /* ContainerFlags.IsBlockScopedContainer */) {
blockScopeContainer = node;
blockScopeContainer.locals = undefined;
}
- if (containerFlags & 4 /* IsControlFlowContainer */) {
+ if (containerFlags & 4 /* ContainerFlags.IsControlFlowContainer */) {
var saveCurrentFlow = currentFlow;
var saveBreakTarget = currentBreakTarget;
var saveContinueTarget = currentContinueTarget;
@@ -44153,19 +45103,22 @@ var ts;
var saveExceptionTarget = currentExceptionTarget;
var saveActiveLabelList = activeLabelList;
var saveHasExplicitReturn = hasExplicitReturn;
- var isIIFE = containerFlags & 16 /* IsFunctionExpression */ && !ts.hasSyntacticModifier(node, 256 /* Async */) &&
- !node.asteriskToken && !!ts.getImmediatelyInvokedFunctionExpression(node);
+ var isImmediatelyInvoked = (containerFlags & 16 /* ContainerFlags.IsFunctionExpression */ &&
+ !ts.hasSyntacticModifier(node, 256 /* ModifierFlags.Async */) &&
+ !node.asteriskToken &&
+ !!ts.getImmediatelyInvokedFunctionExpression(node)) ||
+ node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */;
// A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave
// similarly to break statements that exit to a label just past the statement body.
- if (!isIIFE) {
- currentFlow = initFlowNode({ flags: 2 /* Start */ });
- if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */)) {
+ if (!isImmediatelyInvoked) {
+ currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ });
+ if (containerFlags & (16 /* ContainerFlags.IsFunctionExpression */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */)) {
currentFlow.node = node;
}
}
// We create a return control flow graph for IIFEs and constructors. For constructors
// we use the return control flow graph in strict property initialization checks.
- currentReturnTarget = isIIFE || node.kind === 170 /* Constructor */ || node.kind === 169 /* ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 255 /* FunctionDeclaration */ || node.kind === 212 /* FunctionExpression */)) ? createBranchLabel() : undefined;
+ currentReturnTarget = isImmediatelyInvoked || node.kind === 171 /* SyntaxKind.Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) ? createBranchLabel() : undefined;
currentExceptionTarget = undefined;
currentBreakTarget = undefined;
currentContinueTarget = undefined;
@@ -44173,25 +45126,25 @@ var ts;
hasExplicitReturn = false;
bindChildren(node);
// Reset all reachability check related flags on node (for incremental scenarios)
- node.flags &= ~2816 /* ReachabilityAndEmitFlags */;
- if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) {
- node.flags |= 256 /* HasImplicitReturn */;
+ node.flags &= ~2816 /* NodeFlags.ReachabilityAndEmitFlags */;
+ if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && containerFlags & 8 /* ContainerFlags.IsFunctionLike */ && ts.nodeIsPresent(node.body)) {
+ node.flags |= 256 /* NodeFlags.HasImplicitReturn */;
if (hasExplicitReturn)
- node.flags |= 512 /* HasExplicitReturn */;
+ node.flags |= 512 /* NodeFlags.HasExplicitReturn */;
node.endFlowNode = currentFlow;
}
- if (node.kind === 303 /* SourceFile */) {
+ if (node.kind === 305 /* SyntaxKind.SourceFile */) {
node.flags |= emitFlags;
node.endFlowNode = currentFlow;
}
if (currentReturnTarget) {
addAntecedent(currentReturnTarget, currentFlow);
currentFlow = finishFlowLabel(currentReturnTarget);
- if (node.kind === 170 /* Constructor */ || node.kind === 169 /* ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 255 /* FunctionDeclaration */ || node.kind === 212 /* FunctionExpression */))) {
+ if (node.kind === 171 /* SyntaxKind.Constructor */ || node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */))) {
node.returnFlowNode = currentFlow;
}
}
- if (!isIIFE) {
+ if (!isImmediatelyInvoked) {
currentFlow = saveCurrentFlow;
}
currentBreakTarget = saveBreakTarget;
@@ -44201,10 +45154,10 @@ var ts;
activeLabelList = saveActiveLabelList;
hasExplicitReturn = saveHasExplicitReturn;
}
- else if (containerFlags & 64 /* IsInterface */) {
+ else if (containerFlags & 64 /* ContainerFlags.IsInterface */) {
seenThisKeyword = false;
bindChildren(node);
- node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */;
+ node.flags = seenThisKeyword ? node.flags | 128 /* NodeFlags.ContainsThis */ : node.flags & ~128 /* NodeFlags.ContainsThis */;
}
else {
bindChildren(node);
@@ -44214,8 +45167,8 @@ var ts;
blockScopeContainer = savedBlockScopeContainer;
}
function bindEachFunctionsFirst(nodes) {
- bindEach(nodes, function (n) { return n.kind === 255 /* FunctionDeclaration */ ? bind(n) : undefined; });
- bindEach(nodes, function (n) { return n.kind !== 255 /* FunctionDeclaration */ ? bind(n) : undefined; });
+ bindEach(nodes, function (n) { return n.kind === 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; });
+ bindEach(nodes, function (n) { return n.kind !== 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; });
}
function bindEach(nodes, bindFunction) {
if (bindFunction === void 0) { bindFunction = bind; }
@@ -44238,59 +45191,59 @@ var ts;
inAssignmentPattern = saveInAssignmentPattern;
return;
}
- if (node.kind >= 236 /* FirstStatement */ && node.kind <= 252 /* LastStatement */ && !options.allowUnreachableCode) {
+ if (node.kind >= 237 /* SyntaxKind.FirstStatement */ && node.kind <= 253 /* SyntaxKind.LastStatement */ && !options.allowUnreachableCode) {
node.flowNode = currentFlow;
}
switch (node.kind) {
- case 240 /* WhileStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
bindWhileStatement(node);
break;
- case 239 /* DoStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
bindDoStatement(node);
break;
- case 241 /* ForStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
bindForStatement(node);
break;
- case 242 /* ForInStatement */:
- case 243 /* ForOfStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
bindForInOrForOfStatement(node);
break;
- case 238 /* IfStatement */:
+ case 239 /* SyntaxKind.IfStatement */:
bindIfStatement(node);
break;
- case 246 /* ReturnStatement */:
- case 250 /* ThrowStatement */:
+ case 247 /* SyntaxKind.ReturnStatement */:
+ case 251 /* SyntaxKind.ThrowStatement */:
bindReturnOrThrow(node);
break;
- case 245 /* BreakStatement */:
- case 244 /* ContinueStatement */:
+ case 246 /* SyntaxKind.BreakStatement */:
+ case 245 /* SyntaxKind.ContinueStatement */:
bindBreakOrContinueStatement(node);
break;
- case 251 /* TryStatement */:
+ case 252 /* SyntaxKind.TryStatement */:
bindTryStatement(node);
break;
- case 248 /* SwitchStatement */:
+ case 249 /* SyntaxKind.SwitchStatement */:
bindSwitchStatement(node);
break;
- case 262 /* CaseBlock */:
+ case 263 /* SyntaxKind.CaseBlock */:
bindCaseBlock(node);
break;
- case 288 /* CaseClause */:
+ case 289 /* SyntaxKind.CaseClause */:
bindCaseClause(node);
break;
- case 237 /* ExpressionStatement */:
+ case 238 /* SyntaxKind.ExpressionStatement */:
bindExpressionStatement(node);
break;
- case 249 /* LabeledStatement */:
+ case 250 /* SyntaxKind.LabeledStatement */:
bindLabeledStatement(node);
break;
- case 218 /* PrefixUnaryExpression */:
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
bindPrefixUnaryExpressionFlow(node);
break;
- case 219 /* PostfixUnaryExpression */:
+ case 220 /* SyntaxKind.PostfixUnaryExpression */:
bindPostfixUnaryExpressionFlow(node);
break;
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
if (ts.isDestructuringAssignment(node)) {
// Carry over whether we are in an assignment pattern to
// binary expressions that could actually be an initializer
@@ -44300,47 +45253,47 @@ var ts;
}
bindBinaryExpressionFlow(node);
break;
- case 214 /* DeleteExpression */:
+ case 215 /* SyntaxKind.DeleteExpression */:
bindDeleteExpressionFlow(node);
break;
- case 221 /* ConditionalExpression */:
+ case 222 /* SyntaxKind.ConditionalExpression */:
bindConditionalExpressionFlow(node);
break;
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
bindVariableDeclarationFlow(node);
break;
- case 205 /* PropertyAccessExpression */:
- case 206 /* ElementAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
bindAccessExpressionFlow(node);
break;
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
bindCallExpressionFlow(node);
break;
- case 229 /* NonNullExpression */:
+ case 230 /* SyntaxKind.NonNullExpression */:
bindNonNullExpressionFlow(node);
break;
- case 343 /* JSDocTypedefTag */:
- case 336 /* JSDocCallbackTag */:
- case 337 /* JSDocEnumTag */:
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
+ case 338 /* SyntaxKind.JSDocCallbackTag */:
+ case 339 /* SyntaxKind.JSDocEnumTag */:
bindJSDocTypeAlias(node);
break;
// In source files and blocks, bind functions first to match hoisting that occurs at runtime
- case 303 /* SourceFile */: {
+ case 305 /* SyntaxKind.SourceFile */: {
bindEachFunctionsFirst(node.statements);
bind(node.endOfFileToken);
break;
}
- case 234 /* Block */:
- case 261 /* ModuleBlock */:
+ case 235 /* SyntaxKind.Block */:
+ case 262 /* SyntaxKind.ModuleBlock */:
bindEachFunctionsFirst(node.statements);
break;
- case 202 /* BindingElement */:
+ case 203 /* SyntaxKind.BindingElement */:
bindBindingElementFlow(node);
break;
- case 204 /* ObjectLiteralExpression */:
- case 203 /* ArrayLiteralExpression */:
- case 294 /* PropertyAssignment */:
- case 224 /* SpreadElement */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
+ case 225 /* SyntaxKind.SpreadElement */:
// Carry over whether we are in an assignment pattern of Object and Array literals
// as well as their children that are valid assignment targets.
inAssignmentPattern = saveInAssignmentPattern;
@@ -44354,22 +45307,22 @@ var ts;
}
function isNarrowingExpression(expr) {
switch (expr.kind) {
- case 79 /* Identifier */:
- case 80 /* PrivateIdentifier */:
- case 108 /* ThisKeyword */:
- case 205 /* PropertyAccessExpression */:
- case 206 /* ElementAccessExpression */:
+ case 79 /* SyntaxKind.Identifier */:
+ case 80 /* SyntaxKind.PrivateIdentifier */:
+ case 108 /* SyntaxKind.ThisKeyword */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
return containsNarrowableReference(expr);
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
return hasNarrowableArgument(expr);
- case 211 /* ParenthesizedExpression */:
- case 229 /* NonNullExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
+ case 230 /* SyntaxKind.NonNullExpression */:
return isNarrowingExpression(expr.expression);
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return isNarrowingBinaryExpression(expr);
- case 218 /* PrefixUnaryExpression */:
- return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand);
- case 215 /* TypeOfExpression */:
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
+ return expr.operator === 53 /* SyntaxKind.ExclamationToken */ && isNarrowingExpression(expr.operand);
+ case 216 /* SyntaxKind.TypeOfExpression */:
return isNarrowingExpression(expr.expression);
}
return false;
@@ -44377,8 +45330,8 @@ var ts;
function isNarrowableReference(expr) {
return ts.isDottedName(expr)
|| (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression)
- || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right)
- || ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression)
+ || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isNarrowableReference(expr.right)
+ || ts.isElementAccessExpression(expr) && (ts.isStringOrNumericLiteralLike(expr.argumentExpression) || ts.isEntityNameExpression(expr.argumentExpression)) && isNarrowableReference(expr.expression)
|| ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left);
}
function containsNarrowableReference(expr) {
@@ -44393,7 +45346,7 @@ var ts;
}
}
}
- if (expr.expression.kind === 205 /* PropertyAccessExpression */ &&
+ if (expr.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ &&
containsNarrowableReference(expr.expression.expression)) {
return true;
}
@@ -44404,68 +45357,68 @@ var ts;
}
function isNarrowingBinaryExpression(expr) {
switch (expr.operatorToken.kind) {
- case 63 /* EqualsToken */:
- case 75 /* BarBarEqualsToken */:
- case 76 /* AmpersandAmpersandEqualsToken */:
- case 77 /* QuestionQuestionEqualsToken */:
+ case 63 /* SyntaxKind.EqualsToken */:
+ case 75 /* SyntaxKind.BarBarEqualsToken */:
+ case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */:
+ case 77 /* SyntaxKind.QuestionQuestionEqualsToken */:
return containsNarrowableReference(expr.left);
- case 34 /* EqualsEqualsToken */:
- case 35 /* ExclamationEqualsToken */:
- case 36 /* EqualsEqualsEqualsToken */:
- case 37 /* ExclamationEqualsEqualsToken */:
+ case 34 /* SyntaxKind.EqualsEqualsToken */:
+ case 35 /* SyntaxKind.ExclamationEqualsToken */:
+ case 36 /* SyntaxKind.EqualsEqualsEqualsToken */:
+ case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */:
return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) ||
isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right);
- case 102 /* InstanceOfKeyword */:
+ case 102 /* SyntaxKind.InstanceOfKeyword */:
return isNarrowableOperand(expr.left);
- case 101 /* InKeyword */:
+ case 101 /* SyntaxKind.InKeyword */:
return isNarrowingExpression(expr.right);
- case 27 /* CommaToken */:
+ case 27 /* SyntaxKind.CommaToken */:
return isNarrowingExpression(expr.right);
}
return false;
}
function isNarrowableOperand(expr) {
switch (expr.kind) {
- case 211 /* ParenthesizedExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
return isNarrowableOperand(expr.expression);
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
switch (expr.operatorToken.kind) {
- case 63 /* EqualsToken */:
+ case 63 /* SyntaxKind.EqualsToken */:
return isNarrowableOperand(expr.left);
- case 27 /* CommaToken */:
+ case 27 /* SyntaxKind.CommaToken */:
return isNarrowableOperand(expr.right);
}
}
return containsNarrowableReference(expr);
}
function createBranchLabel() {
- return initFlowNode({ flags: 4 /* BranchLabel */, antecedents: undefined });
+ return initFlowNode({ flags: 4 /* FlowFlags.BranchLabel */, antecedents: undefined });
}
function createLoopLabel() {
- return initFlowNode({ flags: 8 /* LoopLabel */, antecedents: undefined });
+ return initFlowNode({ flags: 8 /* FlowFlags.LoopLabel */, antecedents: undefined });
}
function createReduceLabel(target, antecedents, antecedent) {
- return initFlowNode({ flags: 1024 /* ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent });
+ return initFlowNode({ flags: 1024 /* FlowFlags.ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent });
}
function setFlowNodeReferenced(flow) {
// On first reference we set the Referenced flag, thereafter we set the Shared flag
- flow.flags |= flow.flags & 2048 /* Referenced */ ? 4096 /* Shared */ : 2048 /* Referenced */;
+ flow.flags |= flow.flags & 2048 /* FlowFlags.Referenced */ ? 4096 /* FlowFlags.Shared */ : 2048 /* FlowFlags.Referenced */;
}
function addAntecedent(label, antecedent) {
- if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) {
+ if (!(antecedent.flags & 1 /* FlowFlags.Unreachable */) && !ts.contains(label.antecedents, antecedent)) {
(label.antecedents || (label.antecedents = [])).push(antecedent);
setFlowNodeReferenced(antecedent);
}
}
function createFlowCondition(flags, antecedent, expression) {
- if (antecedent.flags & 1 /* Unreachable */) {
+ if (antecedent.flags & 1 /* FlowFlags.Unreachable */) {
return antecedent;
}
if (!expression) {
- return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow;
+ return flags & 32 /* FlowFlags.TrueCondition */ ? antecedent : unreachableFlow;
}
- if ((expression.kind === 110 /* TrueKeyword */ && flags & 64 /* FalseCondition */ ||
- expression.kind === 95 /* FalseKeyword */ && flags & 32 /* TrueCondition */) &&
+ if ((expression.kind === 110 /* SyntaxKind.TrueKeyword */ && flags & 64 /* FlowFlags.FalseCondition */ ||
+ expression.kind === 95 /* SyntaxKind.FalseKeyword */ && flags & 32 /* FlowFlags.TrueCondition */) &&
!ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) {
return unreachableFlow;
}
@@ -44477,7 +45430,7 @@ var ts;
}
function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) {
setFlowNodeReferenced(antecedent);
- return initFlowNode({ flags: 128 /* SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd });
+ return initFlowNode({ flags: 128 /* FlowFlags.SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd });
}
function createFlowMutation(flags, antecedent, node) {
setFlowNodeReferenced(antecedent);
@@ -44489,7 +45442,7 @@ var ts;
}
function createFlowCall(antecedent, node) {
setFlowNodeReferenced(antecedent);
- return initFlowNode({ flags: 512 /* Call */, antecedent: antecedent, node: node });
+ return initFlowNode({ flags: 512 /* FlowFlags.Call */, antecedent: antecedent, node: node });
}
function finishFlowLabel(flow) {
var antecedents = flow.antecedents;
@@ -44504,28 +45457,28 @@ var ts;
function isStatementCondition(node) {
var parent = node.parent;
switch (parent.kind) {
- case 238 /* IfStatement */:
- case 240 /* WhileStatement */:
- case 239 /* DoStatement */:
+ case 239 /* SyntaxKind.IfStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
return parent.expression === node;
- case 241 /* ForStatement */:
- case 221 /* ConditionalExpression */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 222 /* SyntaxKind.ConditionalExpression */:
return parent.condition === node;
}
return false;
}
function isLogicalExpression(node) {
while (true) {
- if (node.kind === 211 /* ParenthesizedExpression */) {
+ if (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */) {
node = node.expression;
}
- else if (node.kind === 218 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) {
+ else if (node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && node.operator === 53 /* SyntaxKind.ExclamationToken */) {
node = node.operand;
}
else {
- return node.kind === 220 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ ||
- node.operatorToken.kind === 56 /* BarBarToken */ ||
- node.operatorToken.kind === 60 /* QuestionQuestionToken */);
+ return node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ ||
+ node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ ||
+ node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */);
}
}
}
@@ -44535,11 +45488,10 @@ var ts;
}
function isTopLevelLogicalExpression(node) {
while (ts.isParenthesizedExpression(node.parent) ||
- ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) {
+ ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* SyntaxKind.ExclamationToken */) {
node = node.parent;
}
return !isStatementCondition(node) &&
- !isLogicalAssignmentExpression(node.parent) &&
!isLogicalExpression(node.parent) &&
!(ts.isOptionalChain(node.parent) && node.parent.expression === node);
}
@@ -44555,8 +45507,8 @@ var ts;
function bindCondition(node, trueTarget, falseTarget) {
doWithConditionalBranches(bind, node, trueTarget, falseTarget);
if (!node || !isLogicalAssignmentExpression(node) && !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) {
- addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
- addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
+ addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node));
+ addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node));
}
}
function bindIterativeStatement(node, breakTarget, continueTarget) {
@@ -44570,7 +45522,7 @@ var ts;
}
function setContinueTarget(node, target) {
var label = activeLabelList;
- while (label && node.parent.kind === 249 /* LabeledStatement */) {
+ while (label && node.parent.kind === 250 /* SyntaxKind.LabeledStatement */) {
label.continueTarget = target;
label = label.next;
node = node.parent;
@@ -44621,12 +45573,12 @@ var ts;
bind(node.expression);
addAntecedent(preLoopLabel, currentFlow);
currentFlow = preLoopLabel;
- if (node.kind === 243 /* ForOfStatement */) {
+ if (node.kind === 244 /* SyntaxKind.ForOfStatement */) {
bind(node.awaitModifier);
}
addAntecedent(postLoopLabel, currentFlow);
bind(node.initializer);
- if (node.initializer.kind !== 254 /* VariableDeclarationList */) {
+ if (node.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) {
bindAssignmentTargetFlow(node.initializer);
}
bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel);
@@ -44648,7 +45600,7 @@ var ts;
}
function bindReturnOrThrow(node) {
bind(node.expression);
- if (node.kind === 246 /* ReturnStatement */) {
+ if (node.kind === 247 /* SyntaxKind.ReturnStatement */) {
hasExplicitReturn = true;
if (currentReturnTarget) {
addAntecedent(currentReturnTarget, currentFlow);
@@ -44665,7 +45617,7 @@ var ts;
return undefined;
}
function bindBreakOrContinueFlow(node, breakTarget, continueTarget) {
- var flowLabel = node.kind === 245 /* BreakStatement */ ? breakTarget : continueTarget;
+ var flowLabel = node.kind === 246 /* SyntaxKind.BreakStatement */ ? breakTarget : continueTarget;
if (flowLabel) {
addAntecedent(flowLabel, currentFlow);
currentFlow = unreachableFlow;
@@ -44736,7 +45688,7 @@ var ts;
finallyLabel.antecedents = ts.concatenate(ts.concatenate(normalExitLabel.antecedents, exceptionLabel.antecedents), returnLabel.antecedents);
currentFlow = finallyLabel;
bind(node.finallyBlock);
- if (currentFlow.flags & 1 /* Unreachable */) {
+ if (currentFlow.flags & 1 /* FlowFlags.Unreachable */) {
// If the end of the finally block is unreachable, the end of the entire try statement is unreachable.
currentFlow = unreachableFlow;
}
@@ -44770,7 +45722,7 @@ var ts;
preSwitchCaseFlow = currentFlow;
bind(node.caseBlock);
addAntecedent(postSwitchLabel, currentFlow);
- var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 289 /* DefaultClause */; });
+ var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 290 /* SyntaxKind.DefaultClause */; });
// We mark a switch statement as possibly exhaustive if it has no default clause and if all
// case clauses have unreachable end points (e.g. they all return). Note, we no longer need
// this property in control flow analysis, it's there only for backwards compatibility.
@@ -44799,7 +45751,7 @@ var ts;
var clause = clauses[i];
bind(clause);
fallthroughFlow = currentFlow;
- if (!(currentFlow.flags & 1 /* Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) {
+ if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) {
clause.fallthroughFlowNode = currentFlow;
}
}
@@ -44818,9 +45770,9 @@ var ts;
function maybeBindExpressionFlowIfCall(node) {
// A top level or comma expression call expression with a dotted function name and at least one argument
// is potentially an assertion and is therefore included in the control flow.
- if (node.kind === 207 /* CallExpression */) {
+ if (node.kind === 208 /* SyntaxKind.CallExpression */) {
var call = node;
- if (call.expression.kind !== 106 /* SuperKeyword */ && ts.isDottedName(call.expression)) {
+ if (call.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && ts.isDottedName(call.expression)) {
currentFlow = createFlowCall(currentFlow, call);
}
}
@@ -44844,7 +45796,7 @@ var ts;
currentFlow = finishFlowLabel(postStatementLabel);
}
function bindDestructuringTargetFlow(node) {
- if (node.kind === 220 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */) {
+ if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) {
bindAssignmentTargetFlow(node.left);
}
else {
@@ -44853,12 +45805,12 @@ var ts;
}
function bindAssignmentTargetFlow(node) {
if (isNarrowableReference(node)) {
- currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node);
+ currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node);
}
- else if (node.kind === 203 /* ArrayLiteralExpression */) {
+ else if (node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) {
for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
var e = _a[_i];
- if (e.kind === 224 /* SpreadElement */) {
+ if (e.kind === 225 /* SyntaxKind.SpreadElement */) {
bindAssignmentTargetFlow(e.expression);
}
else {
@@ -44866,16 +45818,16 @@ var ts;
}
}
}
- else if (node.kind === 204 /* ObjectLiteralExpression */) {
+ else if (node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) {
for (var _b = 0, _c = node.properties; _b < _c.length; _b++) {
var p = _c[_b];
- if (p.kind === 294 /* PropertyAssignment */) {
+ if (p.kind === 296 /* SyntaxKind.PropertyAssignment */) {
bindDestructuringTargetFlow(p.initializer);
}
- else if (p.kind === 295 /* ShorthandPropertyAssignment */) {
+ else if (p.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) {
bindAssignmentTargetFlow(p.name);
}
- else if (p.kind === 296 /* SpreadAssignment */) {
+ else if (p.kind === 298 /* SyntaxKind.SpreadAssignment */) {
bindAssignmentTargetFlow(p.expression);
}
}
@@ -44883,7 +45835,7 @@ var ts;
}
function bindLogicalLikeExpression(node, trueTarget, falseTarget) {
var preRightLabel = createBranchLabel();
- if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* AmpersandAmpersandEqualsToken */) {
+ if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) {
bindCondition(node.left, preRightLabel, falseTarget);
}
else {
@@ -44894,15 +45846,15 @@ var ts;
if (ts.isLogicalOrCoalescingAssignmentOperator(node.operatorToken.kind)) {
doWithConditionalBranches(bind, node.right, trueTarget, falseTarget);
bindAssignmentTargetFlow(node.left);
- addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
- addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
+ addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node));
+ addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node));
}
else {
bindCondition(node.right, trueTarget, falseTarget);
}
}
function bindPrefixUnaryExpressionFlow(node) {
- if (node.operator === 53 /* ExclamationToken */) {
+ if (node.operator === 53 /* SyntaxKind.ExclamationToken */) {
var saveTrueTarget = currentTrueTarget;
currentTrueTarget = currentFalseTarget;
currentFalseTarget = saveTrueTarget;
@@ -44912,14 +45864,14 @@ var ts;
}
else {
bindEachChild(node);
- if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) {
+ if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) {
bindAssignmentTargetFlow(node.operand);
}
}
}
function bindPostfixUnaryExpressionFlow(node) {
bindEachChild(node);
- if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) {
+ if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) {
bindAssignmentTargetFlow(node.operand);
}
}
@@ -44968,9 +45920,9 @@ var ts;
// we'll need to handle the `bindLogicalExpression` scenarios in this state machine, too
// For now, though, since the common cases are chained `+`, leaving it recursive is fine
var operator = node.operatorToken.kind;
- if (operator === 55 /* AmpersandAmpersandToken */ ||
- operator === 56 /* BarBarToken */ ||
- operator === 60 /* QuestionQuestionToken */ ||
+ if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ ||
+ operator === 56 /* SyntaxKind.BarBarToken */ ||
+ operator === 60 /* SyntaxKind.QuestionQuestionToken */ ||
ts.isLogicalOrCoalescingAssignmentOperator(operator)) {
if (isTopLevelLogicalExpression(node)) {
var postExpressionLabel = createBranchLabel();
@@ -44987,7 +45939,7 @@ var ts;
function onLeft(left, state, node) {
if (!state.skip) {
var maybeBound = maybeBind(left);
- if (node.operatorToken.kind === 27 /* CommaToken */) {
+ if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) {
maybeBindExpressionFlowIfCall(left);
}
return maybeBound;
@@ -45001,7 +45953,7 @@ var ts;
function onRight(right, state, node) {
if (!state.skip) {
var maybeBound = maybeBind(right);
- if (node.operatorToken.kind === 27 /* CommaToken */) {
+ if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) {
maybeBindExpressionFlowIfCall(right);
}
return maybeBound;
@@ -45012,10 +45964,10 @@ var ts;
var operator = node.operatorToken.kind;
if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) {
bindAssignmentTargetFlow(node.left);
- if (operator === 63 /* EqualsToken */ && node.left.kind === 206 /* ElementAccessExpression */) {
+ if (operator === 63 /* SyntaxKind.EqualsToken */ && node.left.kind === 207 /* SyntaxKind.ElementAccessExpression */) {
var elementAccess = node.left;
if (isNarrowableOperand(elementAccess.expression)) {
- currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node);
+ currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node);
}
}
}
@@ -45040,7 +45992,7 @@ var ts;
}
function bindDeleteExpressionFlow(node) {
bindEachChild(node);
- if (node.expression.kind === 205 /* PropertyAccessExpression */) {
+ if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) {
bindAssignmentTargetFlow(node.expression);
}
}
@@ -45068,7 +46020,7 @@ var ts;
}
}
else {
- currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node);
+ currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node);
}
}
function bindVariableDeclarationFlow(node) {
@@ -45097,7 +46049,7 @@ var ts;
}
function bindJSDocTypeAlias(node) {
bind(node.tagName);
- if (node.kind !== 337 /* JSDocEnumTag */ && node.fullName) {
+ if (node.kind !== 339 /* SyntaxKind.JSDocEnumTag */ && node.fullName) {
// don't bind the type name yet; that's delayed until delayedBindJSDocTypedefTag
ts.setParent(node.fullName, node);
ts.setParentRecursive(node.fullName, /*incremental*/ false);
@@ -45109,28 +46061,28 @@ var ts;
function bindJSDocClassTag(node) {
bindEachChild(node);
var host = ts.getHostSignatureFromJSDoc(node);
- if (host && host.kind !== 168 /* MethodDeclaration */) {
- addDeclarationToSymbol(host.symbol, host, 32 /* Class */);
+ if (host && host.kind !== 169 /* SyntaxKind.MethodDeclaration */) {
+ addDeclarationToSymbol(host.symbol, host, 32 /* SymbolFlags.Class */);
}
}
function bindOptionalExpression(node, trueTarget, falseTarget) {
doWithConditionalBranches(bind, node, trueTarget, falseTarget);
if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) {
- addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
- addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
+ addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node));
+ addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node));
}
}
function bindOptionalChainRest(node) {
switch (node.kind) {
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
bind(node.questionDotToken);
bind(node.name);
break;
- case 206 /* ElementAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
bind(node.questionDotToken);
bind(node.argumentExpression);
break;
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
bind(node.questionDotToken);
bindEach(node.typeArguments);
bindEach(node.arguments);
@@ -45156,8 +46108,8 @@ var ts;
}
doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget);
if (ts.isOutermostOptionalChain(node)) {
- addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
- addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
+ addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node));
+ addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node));
}
}
function bindOptionalChainFlow(node) {
@@ -45195,76 +46147,76 @@ var ts;
// an immediately invoked function expression (IIFE). Initialize the flowNode property to
// the current control flow (which includes evaluation of the IIFE arguments).
var expr = ts.skipParentheses(node.expression);
- if (expr.kind === 212 /* FunctionExpression */ || expr.kind === 213 /* ArrowFunction */) {
+ if (expr.kind === 213 /* SyntaxKind.FunctionExpression */ || expr.kind === 214 /* SyntaxKind.ArrowFunction */) {
bindEach(node.typeArguments);
bindEach(node.arguments);
bind(node.expression);
}
else {
bindEachChild(node);
- if (node.expression.kind === 106 /* SuperKeyword */) {
+ if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) {
currentFlow = createFlowCall(currentFlow, node);
}
}
}
- if (node.expression.kind === 205 /* PropertyAccessExpression */) {
+ if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) {
var propertyAccess = node.expression;
if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) {
- currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node);
+ currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node);
}
}
}
function getContainerFlags(node) {
switch (node.kind) {
- case 225 /* ClassExpression */:
- case 256 /* ClassDeclaration */:
- case 259 /* EnumDeclaration */:
- case 204 /* ObjectLiteralExpression */:
- case 181 /* TypeLiteral */:
- case 320 /* JSDocTypeLiteral */:
- case 285 /* JsxAttributes */:
- return 1 /* IsContainer */;
- case 257 /* InterfaceDeclaration */:
- return 1 /* IsContainer */ | 64 /* IsInterface */;
- case 260 /* ModuleDeclaration */:
- case 258 /* TypeAliasDeclaration */:
- case 194 /* MappedType */:
- return 1 /* IsContainer */ | 32 /* HasLocals */;
- case 303 /* SourceFile */:
- return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */;
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 168 /* MethodDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
+ case 182 /* SyntaxKind.TypeLiteral */:
+ case 322 /* SyntaxKind.JSDocTypeLiteral */:
+ case 286 /* SyntaxKind.JsxAttributes */:
+ return 1 /* ContainerFlags.IsContainer */;
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ return 1 /* ContainerFlags.IsContainer */ | 64 /* ContainerFlags.IsInterface */;
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 195 /* SyntaxKind.MappedType */:
+ case 176 /* SyntaxKind.IndexSignature */:
+ return 1 /* ContainerFlags.IsContainer */ | 32 /* ContainerFlags.HasLocals */;
+ case 305 /* SyntaxKind.SourceFile */:
+ return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */;
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
if (ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) {
- return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */;
+ return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */;
}
// falls through
- case 170 /* Constructor */:
- case 255 /* FunctionDeclaration */:
- case 167 /* MethodSignature */:
- case 173 /* CallSignature */:
- case 321 /* JSDocSignature */:
- case 315 /* JSDocFunctionType */:
- case 178 /* FunctionType */:
- case 174 /* ConstructSignature */:
- case 175 /* IndexSignature */:
- case 179 /* ConstructorType */:
- case 169 /* ClassStaticBlockDeclaration */:
- return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */;
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
- return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */;
- case 261 /* ModuleBlock */:
- return 4 /* IsControlFlowContainer */;
- case 166 /* PropertyDeclaration */:
- return node.initializer ? 4 /* IsControlFlowContainer */ : 0;
- case 291 /* CatchClause */:
- case 241 /* ForStatement */:
- case 242 /* ForInStatement */:
- case 243 /* ForOfStatement */:
- case 262 /* CaseBlock */:
- return 2 /* IsBlockScopedContainer */;
- case 234 /* Block */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 323 /* SyntaxKind.JSDocSignature */:
+ case 317 /* SyntaxKind.JSDocFunctionType */:
+ case 179 /* SyntaxKind.FunctionType */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 180 /* SyntaxKind.ConstructorType */:
+ case 170 /* SyntaxKind.ClassStaticBlockDeclaration */:
+ return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */;
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 16 /* ContainerFlags.IsFunctionExpression */;
+ case 262 /* SyntaxKind.ModuleBlock */:
+ return 4 /* ContainerFlags.IsControlFlowContainer */;
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ return node.initializer ? 4 /* ContainerFlags.IsControlFlowContainer */ : 0;
+ case 292 /* SyntaxKind.CatchClause */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
+ case 263 /* SyntaxKind.CaseBlock */:
+ return 2 /* ContainerFlags.IsBlockScopedContainer */;
+ case 235 /* SyntaxKind.Block */:
// do not treat blocks directly inside a function as a block-scoped-container.
// Locals that reside in this block should go to the function locals. Otherwise 'x'
// would not appear to be a redeclaration of a block scoped local in the following
@@ -45281,9 +46233,9 @@ var ts;
// By not creating a new block-scoped-container here, we ensure that both 'var x'
// and 'let x' go into the Function-container's locals, and we do get a collision
// conflict.
- return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* None */ : 2 /* IsBlockScopedContainer */;
+ return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* ContainerFlags.None */ : 2 /* ContainerFlags.IsBlockScopedContainer */;
}
- return 0 /* None */;
+ return 0 /* ContainerFlags.None */;
}
function addToContainerChain(next) {
if (lastContainer) {
@@ -45297,46 +46249,46 @@ var ts;
// members are declared (for example, a member of a class will go into a specific
// symbol table depending on if it is static or not). We defer to specialized
// handlers to take care of declaring these child members.
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
return declareModuleMember(node, symbolFlags, symbolExcludes);
- case 303 /* SourceFile */:
+ case 305 /* SyntaxKind.SourceFile */:
return declareSourceFileMember(node, symbolFlags, symbolExcludes);
- case 225 /* ClassExpression */:
- case 256 /* ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
return declareClassMember(node, symbolFlags, symbolExcludes);
- case 259 /* EnumDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
- case 181 /* TypeLiteral */:
- case 320 /* JSDocTypeLiteral */:
- case 204 /* ObjectLiteralExpression */:
- case 257 /* InterfaceDeclaration */:
- case 285 /* JsxAttributes */:
+ case 182 /* SyntaxKind.TypeLiteral */:
+ case 322 /* SyntaxKind.JSDocTypeLiteral */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 286 /* SyntaxKind.JsxAttributes */:
// Interface/Object-types always have their children added to the 'members' of
// their container. They are only accessible through an instance of their
// container, and are never in scope otherwise (even inside the body of the
// object / type / interface declaring them). An exception is type parameters,
// which are in scope without qualification (similar to 'locals').
return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes);
- case 178 /* FunctionType */:
- case 179 /* ConstructorType */:
- case 173 /* CallSignature */:
- case 174 /* ConstructSignature */:
- case 321 /* JSDocSignature */:
- case 175 /* IndexSignature */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 170 /* Constructor */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
- case 315 /* JSDocFunctionType */:
- case 343 /* JSDocTypedefTag */:
- case 336 /* JSDocCallbackTag */:
- case 169 /* ClassStaticBlockDeclaration */:
- case 258 /* TypeAliasDeclaration */:
- case 194 /* MappedType */:
+ case 179 /* SyntaxKind.FunctionType */:
+ case 180 /* SyntaxKind.ConstructorType */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 323 /* SyntaxKind.JSDocSignature */:
+ case 176 /* SyntaxKind.IndexSignature */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 317 /* SyntaxKind.JSDocFunctionType */:
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
+ case 338 /* SyntaxKind.JSDocCallbackTag */:
+ case 170 /* SyntaxKind.ClassStaticBlockDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 195 /* SyntaxKind.MappedType */:
// All the children of these container types are never visible through another
// symbol (i.e. through another symbol's 'exports' or 'members'). Instead,
// they're only accessed 'lexically' (i.e. from code that exists underneath
@@ -45363,17 +46315,17 @@ var ts;
function setExportContextFlag(node) {
// A declaration source file or ambient module declaration that contains no export declarations (but possibly regular
// declarations with export modifiers) is an export context in which declarations are implicitly exported.
- if (node.flags & 8388608 /* Ambient */ && !hasExportDeclarations(node)) {
- node.flags |= 64 /* ExportContext */;
+ if (node.flags & 16777216 /* NodeFlags.Ambient */ && !hasExportDeclarations(node)) {
+ node.flags |= 64 /* NodeFlags.ExportContext */;
}
else {
- node.flags &= ~64 /* ExportContext */;
+ node.flags &= ~64 /* NodeFlags.ExportContext */;
}
}
function bindModuleDeclaration(node) {
setExportContextFlag(node);
if (ts.isAmbientModule(node)) {
- if (ts.hasSyntacticModifier(node, 1 /* Export */)) {
+ if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) {
errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible);
}
if (ts.isModuleAugmentationExternal(node)) {
@@ -45381,25 +46333,25 @@ var ts;
}
else {
var pattern = void 0;
- if (node.name.kind === 10 /* StringLiteral */) {
+ if (node.name.kind === 10 /* SyntaxKind.StringLiteral */) {
var text = node.name.text;
pattern = ts.tryParsePattern(text);
if (pattern === undefined) {
errorOnFirstToken(node.name, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, text);
}
}
- var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 110735 /* ValueModuleExcludes */);
+ var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* SymbolFlags.ValueModule */, 110735 /* SymbolFlags.ValueModuleExcludes */);
file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && !ts.isString(pattern) ? { pattern: pattern, symbol: symbol } : undefined);
}
}
else {
var state = declareModuleSymbol(node);
- if (state !== 0 /* NonInstantiated */) {
+ if (state !== 0 /* ModuleInstanceState.NonInstantiated */) {
var symbol = node.symbol;
// if module was already merged with some function, class or non-const enum, treat it as non-const-enum-only
- symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */)))
+ symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */)))
// Current must be `const enum` only
- && state === 2 /* ConstEnumOnly */
+ && state === 2 /* ModuleInstanceState.ConstEnumOnly */
// Can't have been set to 'false' in a previous merged symbol. ('undefined' OK)
&& symbol.constEnumOnlyModule !== false;
}
@@ -45407,8 +46359,8 @@ var ts;
}
function declareModuleSymbol(node) {
var state = getModuleInstanceState(node);
- var instantiated = state !== 0 /* NonInstantiated */;
- declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* ValueModule */ : 1024 /* NamespaceModule */, instantiated ? 110735 /* ValueModuleExcludes */ : 0 /* NamespaceModuleExcludes */);
+ var instantiated = state !== 0 /* ModuleInstanceState.NonInstantiated */;
+ declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* SymbolFlags.ValueModule */ : 1024 /* SymbolFlags.NamespaceModule */, instantiated ? 110735 /* SymbolFlags.ValueModuleExcludes */ : 0 /* SymbolFlags.NamespaceModuleExcludes */);
return state;
}
function bindFunctionOrConstructorType(node) {
@@ -45418,10 +46370,10 @@ var ts;
// We do that by making an anonymous type literal symbol, and then setting the function
// symbol as its sole member. To the rest of the system, this symbol will be indistinguishable
// from an actual type literal symbol you would have gotten had you used the long form.
- var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); // TODO: GH#18217
- addDeclarationToSymbol(symbol, node, 131072 /* Signature */);
- var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
- addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */);
+ var symbol = createSymbol(131072 /* SymbolFlags.Signature */, getDeclarationName(node)); // TODO: GH#18217
+ addDeclarationToSymbol(symbol, node, 131072 /* SymbolFlags.Signature */);
+ var typeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */);
+ addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* SymbolFlags.TypeLiteral */);
typeLiteralSymbol.members = ts.createSymbolTable();
typeLiteralSymbol.members.set(symbol.escapedName, symbol);
}
@@ -45435,7 +46387,7 @@ var ts;
var seen = new ts.Map();
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
var prop = _a[_i];
- if (prop.kind === 296 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) {
+ if (prop.kind === 298 /* SyntaxKind.SpreadAssignment */ || prop.name.kind !== 79 /* SyntaxKind.Identifier */) {
continue;
}
var identifier = prop.name;
@@ -45447,9 +46399,9 @@ var ts;
// c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true.
// d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true
// and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields
- var currentKind = prop.kind === 294 /* PropertyAssignment */ || prop.kind === 295 /* ShorthandPropertyAssignment */ || prop.kind === 168 /* MethodDeclaration */
- ? 1 /* Property */
- : 2 /* Accessor */;
+ var currentKind = prop.kind === 296 /* SyntaxKind.PropertyAssignment */ || prop.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ || prop.kind === 169 /* SyntaxKind.MethodDeclaration */
+ ? 1 /* ElementKind.Property */
+ : 2 /* ElementKind.Accessor */;
var existingKind = seen.get(identifier.escapedText);
if (!existingKind) {
seen.set(identifier.escapedText, currentKind);
@@ -45457,17 +46409,17 @@ var ts;
}
}
}
- return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object" /* Object */);
+ return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__object" /* InternalSymbolName.Object */);
}
function bindJsxAttributes(node) {
- return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__jsxAttributes" /* JSXAttributes */);
+ return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__jsxAttributes" /* InternalSymbolName.JSXAttributes */);
}
function bindJsxAttribute(node, symbolFlags, symbolExcludes) {
return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
}
function bindAnonymousDeclaration(node, symbolFlags, name) {
var symbol = createSymbol(symbolFlags, name);
- if (symbolFlags & (8 /* EnumMember */ | 106500 /* ClassMember */)) {
+ if (symbolFlags & (8 /* SymbolFlags.EnumMember */ | 106500 /* SymbolFlags.ClassMember */)) {
symbol.parent = container.symbol;
}
addDeclarationToSymbol(symbol, node, symbolFlags);
@@ -45475,10 +46427,10 @@ var ts;
}
function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) {
switch (blockScopeContainer.kind) {
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
declareModuleMember(node, symbolFlags, symbolExcludes);
break;
- case 303 /* SourceFile */:
+ case 305 /* SyntaxKind.SourceFile */:
if (ts.isExternalOrCommonJsModule(container)) {
declareModuleMember(node, symbolFlags, symbolExcludes);
break;
@@ -45504,9 +46456,9 @@ var ts;
for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) {
var typeAlias = delayedTypeAliases_1[_i];
var host = typeAlias.parent.parent;
- container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file;
+ container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* ContainerFlags.IsContainer */); }) || file;
blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file;
- currentFlow = initFlowNode({ flags: 2 /* Start */ });
+ currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ });
parent = typeAlias;
bind(typeAlias.typeExpression);
var declName = ts.getNameOfDeclaration(typeAlias);
@@ -45517,8 +46469,8 @@ var ts;
bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false);
var oldContainer = container;
switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) {
- case 1 /* ExportsProperty */:
- case 2 /* ModuleExports */:
+ case 1 /* AssignmentDeclarationKind.ExportsProperty */:
+ case 2 /* AssignmentDeclarationKind.ModuleExports */:
if (!ts.isExternalOrCommonJsModule(file)) {
container = undefined;
}
@@ -45526,29 +46478,29 @@ var ts;
container = file;
}
break;
- case 4 /* ThisProperty */:
+ case 4 /* AssignmentDeclarationKind.ThisProperty */:
container = declName.parent.expression;
break;
- case 3 /* PrototypeProperty */:
+ case 3 /* AssignmentDeclarationKind.PrototypeProperty */:
container = declName.parent.expression.name;
break;
- case 5 /* Property */:
+ case 5 /* AssignmentDeclarationKind.Property */:
container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file
: ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name
: declName.parent.expression;
break;
- case 0 /* None */:
+ case 0 /* AssignmentDeclarationKind.None */:
return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration");
}
if (container) {
- declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */);
+ declareModuleMember(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */);
}
container = oldContainer;
}
}
- else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* Identifier */) {
+ else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* SyntaxKind.Identifier */) {
parent = typeAlias.parent;
- bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */);
+ bindBlockScopedDeclaration(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */);
}
else {
bind(typeAlias.fullName);
@@ -45566,24 +46518,24 @@ var ts;
function checkContextualIdentifier(node) {
// Report error only if there are no parse errors in file
if (!file.parseDiagnostics.length &&
- !(node.flags & 8388608 /* Ambient */) &&
- !(node.flags & 4194304 /* JSDoc */) &&
+ !(node.flags & 16777216 /* NodeFlags.Ambient */) &&
+ !(node.flags & 8388608 /* NodeFlags.JSDoc */) &&
!ts.isIdentifierName(node)) {
// strict mode identifiers
if (inStrictMode &&
- node.originalKeywordKind >= 117 /* FirstFutureReservedWord */ &&
- node.originalKeywordKind <= 125 /* LastFutureReservedWord */) {
+ node.originalKeywordKind >= 117 /* SyntaxKind.FirstFutureReservedWord */ &&
+ node.originalKeywordKind <= 125 /* SyntaxKind.LastFutureReservedWord */) {
file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node)));
}
- else if (node.originalKeywordKind === 132 /* AwaitKeyword */) {
+ else if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) {
if (ts.isExternalModule(file) && ts.isInTopLevelContext(node)) {
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.declarationNameToString(node)));
}
- else if (node.flags & 32768 /* AwaitContext */) {
+ else if (node.flags & 32768 /* NodeFlags.AwaitContext */) {
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node)));
}
}
- else if (node.originalKeywordKind === 125 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) {
+ else if (node.originalKeywordKind === 125 /* SyntaxKind.YieldKeyword */ && node.flags & 8192 /* NodeFlags.YieldContext */) {
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node)));
}
}
@@ -45625,7 +46577,7 @@ var ts;
}
function checkStrictModeDeleteExpression(node) {
// Grammar checking
- if (inStrictMode && node.expression.kind === 79 /* Identifier */) {
+ if (inStrictMode && node.expression.kind === 79 /* SyntaxKind.Identifier */) {
// When a delete operator occurs within strict mode code, a SyntaxError is thrown if its
// UnaryExpression is a direct reference to a variable, function argument, or function name
var span = ts.getErrorSpanForNode(file, node.expression);
@@ -45636,7 +46588,7 @@ var ts;
return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments");
}
function checkStrictModeEvalOrArguments(contextNode, name) {
- if (name && name.kind === 79 /* Identifier */) {
+ if (name && name.kind === 79 /* SyntaxKind.Identifier */) {
var identifier = name;
if (isEvalOrArgumentsIdentifier(identifier)) {
// We check first if the name is inside class declaration or class expression; if so give explicit message
@@ -45675,10 +46627,10 @@ var ts;
return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5;
}
function checkStrictModeFunctionDeclaration(node) {
- if (languageVersion < 2 /* ES2015 */) {
+ if (languageVersion < 2 /* ScriptTarget.ES2015 */) {
// Report error if function is not top level function declaration
- if (blockScopeContainer.kind !== 303 /* SourceFile */ &&
- blockScopeContainer.kind !== 260 /* ModuleDeclaration */ &&
+ if (blockScopeContainer.kind !== 305 /* SyntaxKind.SourceFile */ &&
+ blockScopeContainer.kind !== 261 /* SyntaxKind.ModuleDeclaration */ &&
!ts.isFunctionLikeOrClassStaticBlockDeclaration(blockScopeContainer)) {
// We check first if the name is inside class declaration or class expression; if so give explicit message
// otherwise report generic error message.
@@ -45688,7 +46640,7 @@ var ts;
}
}
function checkStrictModeNumericLiteral(node) {
- if (languageVersion < 1 /* ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* Octal */) {
+ if (languageVersion < 1 /* ScriptTarget.ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* TokenFlags.Octal */) {
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode));
}
}
@@ -45704,7 +46656,7 @@ var ts;
function checkStrictModePrefixUnaryExpression(node) {
// Grammar checking
if (inStrictMode) {
- if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) {
+ if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) {
checkStrictModeEvalOrArguments(node, node.operand);
}
}
@@ -45717,7 +46669,7 @@ var ts;
}
function checkStrictModeLabeledStatement(node) {
// Grammar checking for labeledStatement
- if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ES2015 */) {
+ if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ScriptTarget.ES2015 */) {
if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) {
errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here);
}
@@ -45775,11 +46727,11 @@ var ts;
// the current 'container' node when it changes. This helps us know which symbol table
// a local should go into for example. Since terminal nodes are known not to have
// children, as an optimization we don't process those.
- if (node.kind > 159 /* LastToken */) {
+ if (node.kind > 160 /* SyntaxKind.LastToken */) {
var saveParent = parent;
parent = node;
var containerFlags = getContainerFlags(node);
- if (containerFlags === 0 /* None */) {
+ if (containerFlags === 0 /* ContainerFlags.None */) {
bindChildren(node);
}
else {
@@ -45789,7 +46741,7 @@ var ts;
}
else {
var saveParent = parent;
- if (node.kind === 1 /* EndOfFileToken */)
+ if (node.kind === 1 /* SyntaxKind.EndOfFileToken */)
parent = node;
bindJSDoc(node);
parent = saveParent;
@@ -45837,7 +46789,7 @@ var ts;
function bindWorker(node) {
switch (node.kind) {
/* Strict mode checks */
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
// for typedef type names with namespaces, bind the new jsdoc type symbol here
// because it requires all containing namespaces to be in effect, namely the
// current "blockScopeContainer" needs to be set to its immediate namespace parent.
@@ -45846,28 +46798,28 @@ var ts;
while (parentNode && !ts.isJSDocTypeAlias(parentNode)) {
parentNode = parentNode.parent;
}
- bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */);
+ bindBlockScopedDeclaration(parentNode, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */);
break;
}
// falls through
- case 108 /* ThisKeyword */:
- if (currentFlow && (ts.isExpression(node) || parent.kind === 295 /* ShorthandPropertyAssignment */)) {
+ case 108 /* SyntaxKind.ThisKeyword */:
+ if (currentFlow && (ts.isExpression(node) || parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */)) {
node.flowNode = currentFlow;
}
return checkContextualIdentifier(node);
- case 160 /* QualifiedName */:
+ case 161 /* SyntaxKind.QualifiedName */:
if (currentFlow && ts.isPartOfTypeQuery(node)) {
node.flowNode = currentFlow;
}
break;
- case 230 /* MetaProperty */:
- case 106 /* SuperKeyword */:
+ case 231 /* SyntaxKind.MetaProperty */:
+ case 106 /* SyntaxKind.SuperKeyword */:
node.flowNode = currentFlow;
break;
- case 80 /* PrivateIdentifier */:
+ case 80 /* SyntaxKind.PrivateIdentifier */:
return checkPrivateIdentifier(node);
- case 205 /* PropertyAccessExpression */:
- case 206 /* ElementAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
var expr = node;
if (currentFlow && isNarrowableReference(expr)) {
expr.flowNode = currentFlow;
@@ -45879,28 +46831,28 @@ var ts;
file.commonJsModuleIndicator &&
ts.isModuleExportsAccessExpression(expr) &&
!lookupSymbolForName(blockScopeContainer, "module")) {
- declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */);
+ declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* SymbolFlags.FunctionScopedVariable */ | 134217728 /* SymbolFlags.ModuleExports */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */);
}
break;
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
var specialKind = ts.getAssignmentDeclarationKind(node);
switch (specialKind) {
- case 1 /* ExportsProperty */:
+ case 1 /* AssignmentDeclarationKind.ExportsProperty */:
bindExportsPropertyAssignment(node);
break;
- case 2 /* ModuleExports */:
+ case 2 /* AssignmentDeclarationKind.ModuleExports */:
bindModuleExportsAssignment(node);
break;
- case 3 /* PrototypeProperty */:
+ case 3 /* AssignmentDeclarationKind.PrototypeProperty */:
bindPrototypePropertyAssignment(node.left, node);
break;
- case 6 /* Prototype */:
+ case 6 /* AssignmentDeclarationKind.Prototype */:
bindPrototypeAssignment(node);
break;
- case 4 /* ThisProperty */:
+ case 4 /* AssignmentDeclarationKind.ThisProperty */:
bindThisPropertyAssignment(node);
break;
- case 5 /* Property */:
+ case 5 /* AssignmentDeclarationKind.Property */:
var expression = node.left.expression;
if (ts.isInJSFile(node) && ts.isIdentifier(expression)) {
var symbol = lookupSymbolForName(blockScopeContainer, expression.escapedText);
@@ -45911,94 +46863,94 @@ var ts;
}
bindSpecialPropertyAssignment(node);
break;
- case 0 /* None */:
+ case 0 /* AssignmentDeclarationKind.None */:
// Nothing to do
break;
default:
ts.Debug.fail("Unknown binary expression special property assignment kind");
}
return checkStrictModeBinaryExpression(node);
- case 291 /* CatchClause */:
+ case 292 /* SyntaxKind.CatchClause */:
return checkStrictModeCatchClause(node);
- case 214 /* DeleteExpression */:
+ case 215 /* SyntaxKind.DeleteExpression */:
return checkStrictModeDeleteExpression(node);
- case 8 /* NumericLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
return checkStrictModeNumericLiteral(node);
- case 219 /* PostfixUnaryExpression */:
+ case 220 /* SyntaxKind.PostfixUnaryExpression */:
return checkStrictModePostfixUnaryExpression(node);
- case 218 /* PrefixUnaryExpression */:
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
return checkStrictModePrefixUnaryExpression(node);
- case 247 /* WithStatement */:
+ case 248 /* SyntaxKind.WithStatement */:
return checkStrictModeWithStatement(node);
- case 249 /* LabeledStatement */:
+ case 250 /* SyntaxKind.LabeledStatement */:
return checkStrictModeLabeledStatement(node);
- case 191 /* ThisType */:
+ case 192 /* SyntaxKind.ThisType */:
seenThisKeyword = true;
return;
- case 176 /* TypePredicate */:
+ case 177 /* SyntaxKind.TypePredicate */:
break; // Binding the children will handle everything
- case 162 /* TypeParameter */:
+ case 163 /* SyntaxKind.TypeParameter */:
return bindTypeParameter(node);
- case 163 /* Parameter */:
+ case 164 /* SyntaxKind.Parameter */:
return bindParameter(node);
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return bindVariableDeclarationOrBindingElement(node);
- case 202 /* BindingElement */:
+ case 203 /* SyntaxKind.BindingElement */:
node.flowNode = currentFlow;
return bindVariableDeclarationOrBindingElement(node);
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
return bindPropertyWorker(node);
- case 294 /* PropertyAssignment */:
- case 295 /* ShorthandPropertyAssignment */:
- return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */);
- case 297 /* EnumMember */:
- return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */);
- case 173 /* CallSignature */:
- case 174 /* ConstructSignature */:
- case 175 /* IndexSignature */:
- return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */);
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
+ return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */);
+ case 299 /* SyntaxKind.EnumMember */:
+ return bindPropertyOrMethodOrAccessor(node, 8 /* SymbolFlags.EnumMember */, 900095 /* SymbolFlags.EnumMemberExcludes */);
+ case 174 /* SyntaxKind.CallSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 176 /* SyntaxKind.IndexSignature */:
+ return declareSymbolAndAddToSymbolTable(node, 131072 /* SymbolFlags.Signature */, 0 /* SymbolFlags.None */);
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
// If this is an ObjectLiteralExpression method, then it sits in the same space
// as other properties in the object literal. So we use SymbolFlags.PropertyExcludes
// so that it will conflict with any other object literal members with the same
// name.
- return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */);
- case 255 /* FunctionDeclaration */:
+ return bindPropertyOrMethodOrAccessor(node, 8192 /* SymbolFlags.Method */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), ts.isObjectLiteralMethod(node) ? 0 /* SymbolFlags.PropertyExcludes */ : 103359 /* SymbolFlags.MethodExcludes */);
+ case 256 /* SyntaxKind.FunctionDeclaration */:
return bindFunctionDeclaration(node);
- case 170 /* Constructor */:
- return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */);
- case 171 /* GetAccessor */:
- return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */);
- case 172 /* SetAccessor */:
- return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */);
- case 178 /* FunctionType */:
- case 315 /* JSDocFunctionType */:
- case 321 /* JSDocSignature */:
- case 179 /* ConstructorType */:
+ case 171 /* SyntaxKind.Constructor */:
+ return declareSymbolAndAddToSymbolTable(node, 16384 /* SymbolFlags.Constructor */, /*symbolExcludes:*/ 0 /* SymbolFlags.None */);
+ case 172 /* SyntaxKind.GetAccessor */:
+ return bindPropertyOrMethodOrAccessor(node, 32768 /* SymbolFlags.GetAccessor */, 46015 /* SymbolFlags.GetAccessorExcludes */);
+ case 173 /* SyntaxKind.SetAccessor */:
+ return bindPropertyOrMethodOrAccessor(node, 65536 /* SymbolFlags.SetAccessor */, 78783 /* SymbolFlags.SetAccessorExcludes */);
+ case 179 /* SyntaxKind.FunctionType */:
+ case 317 /* SyntaxKind.JSDocFunctionType */:
+ case 323 /* SyntaxKind.JSDocSignature */:
+ case 180 /* SyntaxKind.ConstructorType */:
return bindFunctionOrConstructorType(node);
- case 181 /* TypeLiteral */:
- case 320 /* JSDocTypeLiteral */:
- case 194 /* MappedType */:
+ case 182 /* SyntaxKind.TypeLiteral */:
+ case 322 /* SyntaxKind.JSDocTypeLiteral */:
+ case 195 /* SyntaxKind.MappedType */:
return bindAnonymousTypeWorker(node);
- case 330 /* JSDocClassTag */:
+ case 332 /* SyntaxKind.JSDocClassTag */:
return bindJSDocClassTag(node);
- case 204 /* ObjectLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
return bindObjectLiteralExpression(node);
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
return bindFunctionExpression(node);
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
var assignmentKind = ts.getAssignmentDeclarationKind(node);
switch (assignmentKind) {
- case 7 /* ObjectDefinePropertyValue */:
+ case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */:
return bindObjectDefinePropertyAssignment(node);
- case 8 /* ObjectDefinePropertyExports */:
+ case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */:
return bindObjectDefinePropertyExport(node);
- case 9 /* ObjectDefinePrototypeProperty */:
+ case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */:
return bindObjectDefinePrototypeProperty(node);
- case 0 /* None */:
+ case 0 /* AssignmentDeclarationKind.None */:
break; // Nothing to do
default:
return ts.Debug.fail("Unknown call expression assignment declaration kind");
@@ -46008,73 +46960,73 @@ var ts;
}
break;
// Members of classes, interfaces, and modules
- case 225 /* ClassExpression */:
- case 256 /* ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
// All classes are automatically in strict mode in ES6.
inStrictMode = true;
return bindClassLikeDeclaration(node);
- case 257 /* InterfaceDeclaration */:
- return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */);
- case 258 /* TypeAliasDeclaration */:
- return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */);
- case 259 /* EnumDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ return bindBlockScopedDeclaration(node, 64 /* SymbolFlags.Interface */, 788872 /* SymbolFlags.InterfaceExcludes */);
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ return bindBlockScopedDeclaration(node, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */);
+ case 260 /* SyntaxKind.EnumDeclaration */:
return bindEnumDeclaration(node);
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
return bindModuleDeclaration(node);
// Jsx-attributes
- case 285 /* JsxAttributes */:
+ case 286 /* SyntaxKind.JsxAttributes */:
return bindJsxAttributes(node);
- case 284 /* JsxAttribute */:
- return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */);
+ case 285 /* SyntaxKind.JsxAttribute */:
+ return bindJsxAttribute(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */);
// Imports and exports
- case 264 /* ImportEqualsDeclaration */:
- case 267 /* NamespaceImport */:
- case 269 /* ImportSpecifier */:
- case 274 /* ExportSpecifier */:
- return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
- case 263 /* NamespaceExportDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 268 /* SyntaxKind.NamespaceImport */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
+ case 275 /* SyntaxKind.ExportSpecifier */:
+ return declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */);
+ case 264 /* SyntaxKind.NamespaceExportDeclaration */:
return bindNamespaceExportDeclaration(node);
- case 266 /* ImportClause */:
+ case 267 /* SyntaxKind.ImportClause */:
return bindImportClause(node);
- case 271 /* ExportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
return bindExportDeclaration(node);
- case 270 /* ExportAssignment */:
+ case 271 /* SyntaxKind.ExportAssignment */:
return bindExportAssignment(node);
- case 303 /* SourceFile */:
+ case 305 /* SyntaxKind.SourceFile */:
updateStrictModeStatementList(node.statements);
return bindSourceFileIfExternalModule();
- case 234 /* Block */:
+ case 235 /* SyntaxKind.Block */:
if (!ts.isFunctionLikeOrClassStaticBlockDeclaration(node.parent)) {
return;
}
// falls through
- case 261 /* ModuleBlock */:
+ case 262 /* SyntaxKind.ModuleBlock */:
return updateStrictModeStatementList(node.statements);
- case 338 /* JSDocParameterTag */:
- if (node.parent.kind === 321 /* JSDocSignature */) {
+ case 340 /* SyntaxKind.JSDocParameterTag */:
+ if (node.parent.kind === 323 /* SyntaxKind.JSDocSignature */) {
return bindParameter(node);
}
- if (node.parent.kind !== 320 /* JSDocTypeLiteral */) {
+ if (node.parent.kind !== 322 /* SyntaxKind.JSDocTypeLiteral */) {
break;
}
// falls through
- case 345 /* JSDocPropertyTag */:
+ case 347 /* SyntaxKind.JSDocPropertyTag */:
var propTag = node;
- var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 314 /* JSDocOptionalType */ ?
- 4 /* Property */ | 16777216 /* Optional */ :
- 4 /* Property */;
- return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */);
- case 343 /* JSDocTypedefTag */:
- case 336 /* JSDocCallbackTag */:
- case 337 /* JSDocEnumTag */:
+ var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */ ?
+ 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */ :
+ 4 /* SymbolFlags.Property */;
+ return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* SymbolFlags.PropertyExcludes */);
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
+ case 338 /* SyntaxKind.JSDocCallbackTag */:
+ case 339 /* SyntaxKind.JSDocEnumTag */:
return (delayedTypeAliases || (delayedTypeAliases = [])).push(node);
}
}
function bindPropertyWorker(node) {
- return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */);
+ return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */);
}
function bindAnonymousTypeWorker(node) {
- return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type" /* Type */);
+ return bindAnonymousDeclaration(node, 2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */);
}
function bindSourceFileIfExternalModule() {
setExportContextFlag(file);
@@ -46085,27 +47037,27 @@ var ts;
bindSourceFileAsExternalModule();
// Create symbol equivalent for the module.exports = {}
var originalSymbol = file.symbol;
- declareSymbol(file.symbol.exports, file.symbol, file, 4 /* Property */, 67108863 /* All */);
+ declareSymbol(file.symbol.exports, file.symbol, file, 4 /* SymbolFlags.Property */, 67108863 /* SymbolFlags.All */);
file.symbol = originalSymbol;
}
}
function bindSourceFileAsExternalModule() {
- bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"".concat(ts.removeFileExtension(file.fileName), "\""));
+ bindAnonymousDeclaration(file, 512 /* SymbolFlags.ValueModule */, "\"".concat(ts.removeFileExtension(file.fileName), "\""));
}
function bindExportAssignment(node) {
if (!container.symbol || !container.symbol.exports) {
// Incorrect export assignment in some sort of block construct
- bindAnonymousDeclaration(node, 111551 /* Value */, getDeclarationName(node));
+ bindAnonymousDeclaration(node, 111551 /* SymbolFlags.Value */, getDeclarationName(node));
}
else {
var flags = ts.exportAssignmentIsAlias(node)
// An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression;
- ? 2097152 /* Alias */
+ ? 2097152 /* SymbolFlags.Alias */
// An export default clause with any other expression exports a value
- : 4 /* Property */;
+ : 4 /* SymbolFlags.Property */;
// If there is an `export default x;` alias declaration, can't `export default` anything else.
// (In contrast, you can still have `export default function f() {}` and `export default interface I {}`.)
- var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* All */);
+ var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* SymbolFlags.All */);
if (node.isExportEquals) {
// Will be an error later, since the module already has other exports. Just make sure this has a valueDeclaration set.
ts.setValueDeclaration(symbol, node);
@@ -46125,28 +47077,28 @@ var ts;
}
else {
file.symbol.globalExports = file.symbol.globalExports || ts.createSymbolTable();
- declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
+ declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */);
}
}
function bindExportDeclaration(node) {
if (!container.symbol || !container.symbol.exports) {
// Export * in some sort of block construct
- bindAnonymousDeclaration(node, 8388608 /* ExportStar */, getDeclarationName(node));
+ bindAnonymousDeclaration(node, 8388608 /* SymbolFlags.ExportStar */, getDeclarationName(node));
}
else if (!node.exportClause) {
// All export * declarations are collected in an __export symbol
- declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* ExportStar */, 0 /* None */);
+ declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* SymbolFlags.ExportStar */, 0 /* SymbolFlags.None */);
}
else if (ts.isNamespaceExport(node.exportClause)) {
// declareSymbol walks up parents to find name text, parent _must_ be set
// but won't be set by the normal binder walk until `bindChildren` later on.
ts.setParent(node.exportClause, node);
- declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
+ declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */);
}
}
function bindImportClause(node) {
if (node.name) {
- declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
+ declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */);
}
}
function setCommonJsModuleIndicator(node) {
@@ -46165,13 +47117,13 @@ var ts;
}
var symbol = forEachIdentifierInEntityName(node.arguments[0], /*parent*/ undefined, function (id, symbol) {
if (symbol) {
- addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */);
+ addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */);
}
return symbol;
});
if (symbol) {
- var flags = 4 /* Property */ | 1048576 /* ExportValue */;
- declareSymbol(symbol.exports, symbol, node, flags, 0 /* None */);
+ var flags = 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */;
+ declareSymbol(symbol.exports, symbol, node, flags, 0 /* SymbolFlags.None */);
}
}
function bindExportsPropertyAssignment(node) {
@@ -46182,15 +47134,15 @@ var ts;
}
var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) {
if (symbol) {
- addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */);
+ addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */);
}
return symbol;
});
if (symbol) {
var isAlias = ts.isAliasableExpression(node.right) && (ts.isExportsIdentifier(node.left.expression) || ts.isModuleExportsAccessExpression(node.left.expression));
- var flags = isAlias ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */;
+ var flags = isAlias ? 2097152 /* SymbolFlags.Alias */ : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */;
ts.setParent(node.left, node);
- declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */);
+ declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* SymbolFlags.None */);
}
}
function bindModuleExportsAssignment(node) {
@@ -46211,13 +47163,13 @@ var ts;
}
// 'module.exports = expr' assignment
var flags = ts.exportAssignmentIsAlias(node)
- ? 2097152 /* Alias */
- : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */;
- var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */);
+ ? 2097152 /* SymbolFlags.Alias */
+ : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */ | 512 /* SymbolFlags.ValueModule */;
+ var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */);
ts.setValueDeclaration(symbol, node);
}
function bindExportAssignedObjectMemberAlias(node) {
- declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* Alias */ | 67108864 /* Assignment */, 0 /* None */);
+ declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* SymbolFlags.Alias */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */);
}
function bindThisPropertyAssignment(node) {
ts.Debug.assert(ts.isInJSFile(node));
@@ -46229,11 +47181,11 @@ var ts;
}
var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false);
switch (thisContainer.kind) {
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
var constructorSymbol = thisContainer.symbol;
// For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression.
- if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* EqualsToken */) {
+ if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) {
var l = thisContainer.parent.left;
if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) {
constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer);
@@ -46247,17 +47199,17 @@ var ts;
bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol, constructorSymbol.members);
}
else {
- declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */);
+ declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.PropertyExcludes */ & ~4 /* SymbolFlags.Property */);
}
- addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */);
+ addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* SymbolFlags.Class */);
}
break;
- case 170 /* Constructor */:
- case 166 /* PropertyDeclaration */:
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 169 /* ClassStaticBlockDeclaration */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 170 /* SyntaxKind.ClassStaticBlockDeclaration */:
// this.foo assignment in a JavaScript class
// Bind this property to the containing class
var containingClass = thisContainer.parent;
@@ -46266,19 +47218,19 @@ var ts;
bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol, symbolTable);
}
else {
- declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true);
+ declareSymbol(symbolTable, containingClass.symbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true);
}
break;
- case 303 /* SourceFile */:
+ case 305 /* SyntaxKind.SourceFile */:
// this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script
if (ts.hasDynamicName(node)) {
break;
}
else if (thisContainer.commonJsModuleIndicator) {
- declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */);
+ declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */, 0 /* SymbolFlags.None */);
}
else {
- declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */);
+ declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */);
}
break;
default:
@@ -46286,7 +47238,7 @@ var ts;
}
}
function bindDynamicallyNamedThisPropertyAssignment(node, symbol, symbolTable) {
- declareSymbol(symbolTable, symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true);
+ declareSymbol(symbolTable, symbol, node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true);
addLateBoundAssignmentDeclarationToSymbol(node, symbol);
}
function addLateBoundAssignmentDeclarationToSymbol(node, symbol) {
@@ -46295,10 +47247,10 @@ var ts;
}
}
function bindSpecialPropertyDeclaration(node) {
- if (node.expression.kind === 108 /* ThisKeyword */) {
+ if (node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) {
bindThisPropertyAssignment(node);
}
- else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 303 /* SourceFile */) {
+ else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */) {
if (ts.isPrototypeAccess(node.expression)) {
bindPrototypePropertyAssignment(node, node.parent);
}
@@ -46317,7 +47269,7 @@ var ts;
var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression);
if (namespaceSymbol && namespaceSymbol.valueDeclaration) {
// Ensure the namespace symbol becomes class-like
- addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */);
+ addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */);
}
bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true);
}
@@ -46338,7 +47290,7 @@ var ts;
}
function bindObjectDefinePropertyAssignment(node) {
var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]);
- var isToplevel = node.parent.parent.kind === 303 /* SourceFile */;
+ var isToplevel = node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */;
namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false);
bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false);
}
@@ -46350,7 +47302,7 @@ var ts;
return;
}
var rootExpr = ts.getLeftmostAccessExpression(node.left);
- if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* Alias */) {
+ if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* SymbolFlags.Alias */) {
return;
}
// Fix up parent pointers since we're going to use these nodes before we bind into them
@@ -46363,7 +47315,7 @@ var ts;
bindExportsPropertyAssignment(node);
}
else if (ts.hasDynamicName(node)) {
- bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */);
+ bindAnonymousDeclaration(node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, "__computed" /* InternalSymbolName.Computed */);
var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false);
addLateBoundAssignmentDeclarationToSymbol(node, sym);
}
@@ -46381,13 +47333,13 @@ var ts;
bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false);
}
function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) {
- if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* Alias */) {
+ if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* SymbolFlags.Alias */) {
return namespaceSymbol;
}
if (isToplevel && !isPrototypeProperty) {
// make symbols or add declarations for intermediate containers
- var flags_2 = 1536 /* Module */ | 67108864 /* Assignment */;
- var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */;
+ var flags_2 = 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */;
+ var excludeFlags_1 = 110735 /* SymbolFlags.ValueModuleExcludes */ & ~67108864 /* SymbolFlags.Assignment */;
namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) {
if (symbol) {
addDeclarationToSymbol(symbol, id, flags_2);
@@ -46401,7 +47353,7 @@ var ts;
});
}
if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) {
- addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */);
+ addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */);
}
return namespaceSymbol;
}
@@ -46413,12 +47365,12 @@ var ts;
var symbolTable = isPrototypeProperty ?
(namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) :
(namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable()));
- var includes = 0 /* None */;
- var excludes = 0 /* None */;
+ var includes = 0 /* SymbolFlags.None */;
+ var excludes = 0 /* SymbolFlags.None */;
// Method-like
if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) {
- includes = 8192 /* Method */;
- excludes = 103359 /* MethodExcludes */;
+ includes = 8192 /* SymbolFlags.Method */;
+ excludes = 103359 /* SymbolFlags.MethodExcludes */;
}
// Maybe accessor-like
else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) {
@@ -46428,27 +47380,27 @@ var ts;
})) {
// We mix in `SymbolFLags.Property` so in the checker `getTypeOfVariableParameterOrProperty` is used for this
// symbol, instead of `getTypeOfAccessor` (which will assert as there is no real accessor declaration)
- includes |= 65536 /* SetAccessor */ | 4 /* Property */;
- excludes |= 78783 /* SetAccessorExcludes */;
+ includes |= 65536 /* SymbolFlags.SetAccessor */ | 4 /* SymbolFlags.Property */;
+ excludes |= 78783 /* SymbolFlags.SetAccessorExcludes */;
}
if (ts.some(declaration.arguments[2].properties, function (p) {
var id = ts.getNameOfDeclaration(p);
return !!id && ts.isIdentifier(id) && ts.idText(id) === "get";
})) {
- includes |= 32768 /* GetAccessor */ | 4 /* Property */;
- excludes |= 46015 /* GetAccessorExcludes */;
+ includes |= 32768 /* SymbolFlags.GetAccessor */ | 4 /* SymbolFlags.Property */;
+ excludes |= 46015 /* SymbolFlags.GetAccessorExcludes */;
}
}
- if (includes === 0 /* None */) {
- includes = 4 /* Property */;
- excludes = 0 /* PropertyExcludes */;
+ if (includes === 0 /* SymbolFlags.None */) {
+ includes = 4 /* SymbolFlags.Property */;
+ excludes = 0 /* SymbolFlags.PropertyExcludes */;
}
- declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */);
+ declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* SymbolFlags.Assignment */, excludes & ~67108864 /* SymbolFlags.Assignment */);
}
function isTopLevelNamespaceAssignment(propertyAccess) {
return ts.isBinaryExpression(propertyAccess.parent)
- ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 303 /* SourceFile */
- : propertyAccess.parent.parent.kind === 303 /* SourceFile */;
+ ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 305 /* SyntaxKind.SourceFile */
+ : propertyAccess.parent.parent.kind === 305 /* SyntaxKind.SourceFile */;
}
function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) {
var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer);
@@ -46467,7 +47419,7 @@ var ts;
* - with non-empty object literals if assigned to the prototype property
*/
function isExpandoSymbol(symbol) {
- if (symbol.flags & (16 /* Function */ | 32 /* Class */ | 1024 /* NamespaceModule */)) {
+ if (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 1024 /* SymbolFlags.NamespaceModule */)) {
return true;
}
var node = symbol.valueDeclaration;
@@ -46482,7 +47434,7 @@ var ts;
init = init && ts.getRightMostAssignedExpression(init);
if (init) {
var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node);
- return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment);
+ return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || init.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment);
}
return false;
}
@@ -46527,12 +47479,12 @@ var ts;
}
}
function bindClassLikeDeclaration(node) {
- if (node.kind === 256 /* ClassDeclaration */) {
- bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */);
+ if (node.kind === 257 /* SyntaxKind.ClassDeclaration */) {
+ bindBlockScopedDeclaration(node, 32 /* SymbolFlags.Class */, 899503 /* SymbolFlags.ClassExcludes */);
}
else {
- var bindingName = node.name ? node.name.escapedText : "__class" /* Class */;
- bindAnonymousDeclaration(node, 32 /* Class */, bindingName);
+ var bindingName = node.name ? node.name.escapedText : "__class" /* InternalSymbolName.Class */;
+ bindAnonymousDeclaration(node, 32 /* SymbolFlags.Class */, bindingName);
// Add name of class expression into the map for semantic classifier
if (node.name) {
classifiableNames.add(node.name.escapedText);
@@ -46548,7 +47500,7 @@ var ts;
// Note: we check for this here because this class may be merging into a module. The
// module might have an exported variable called 'prototype'. We can't allow that as
// that would clash with the built-in 'prototype' for the class.
- var prototypeSymbol = createSymbol(4 /* Property */ | 4194304 /* Prototype */, "prototype");
+ var prototypeSymbol = createSymbol(4 /* SymbolFlags.Property */ | 4194304 /* SymbolFlags.Prototype */, "prototype");
var symbolExport = symbol.exports.get(prototypeSymbol.escapedName);
if (symbolExport) {
if (node.name) {
@@ -46561,19 +47513,19 @@ var ts;
}
function bindEnumDeclaration(node) {
return ts.isEnumConst(node)
- ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */)
- : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */);
+ ? bindBlockScopedDeclaration(node, 128 /* SymbolFlags.ConstEnum */, 899967 /* SymbolFlags.ConstEnumExcludes */)
+ : bindBlockScopedDeclaration(node, 256 /* SymbolFlags.RegularEnum */, 899327 /* SymbolFlags.RegularEnumExcludes */);
}
function bindVariableDeclarationOrBindingElement(node) {
if (inStrictMode) {
checkStrictModeEvalOrArguments(node, node.name);
}
if (!ts.isBindingPattern(node.name)) {
- if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node)) {
- declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
+ if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */)) {
+ declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */);
}
else if (ts.isBlockOrCatchScoped(node)) {
- bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */);
+ bindBlockScopedDeclaration(node, 2 /* SymbolFlags.BlockScopedVariable */, 111551 /* SymbolFlags.BlockScopedVariableExcludes */);
}
else if (ts.isParameterDeclaration(node)) {
// It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration
@@ -46585,72 +47537,72 @@ var ts;
// function foo([a,a]) {} // Duplicate Identifier error
// function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter
// // which correctly set excluded symbols
- declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */);
+ declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */);
}
else {
- declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */);
+ declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */);
}
}
}
function bindParameter(node) {
- if (node.kind === 338 /* JSDocParameterTag */ && container.kind !== 321 /* JSDocSignature */) {
+ if (node.kind === 340 /* SyntaxKind.JSDocParameterTag */ && container.kind !== 323 /* SyntaxKind.JSDocSignature */) {
return;
}
- if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) {
+ if (inStrictMode && !(node.flags & 16777216 /* NodeFlags.Ambient */)) {
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
// strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
checkStrictModeEvalOrArguments(node, node.name);
}
if (ts.isBindingPattern(node.name)) {
- bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node));
+ bindAnonymousDeclaration(node, 1 /* SymbolFlags.FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node));
}
else {
- declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */);
+ declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */);
}
// If this is a property-parameter, then also declare the property symbol into the
// containing class.
if (ts.isParameterPropertyDeclaration(node, node.parent)) {
var classDeclaration = node.parent.parent;
- declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */);
+ declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */);
}
}
function bindFunctionDeclaration(node) {
- if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) {
+ if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) {
if (ts.isAsyncFunction(node)) {
- emitFlags |= 2048 /* HasAsyncFunctions */;
+ emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */;
}
}
checkStrictModeFunctionName(node);
if (inStrictMode) {
checkStrictModeFunctionDeclaration(node);
- bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */);
+ bindBlockScopedDeclaration(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */);
}
else {
- declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */);
+ declareSymbolAndAddToSymbolTable(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */);
}
}
function bindFunctionExpression(node) {
- if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) {
+ if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) {
if (ts.isAsyncFunction(node)) {
- emitFlags |= 2048 /* HasAsyncFunctions */;
+ emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */;
}
}
if (currentFlow) {
node.flowNode = currentFlow;
}
checkStrictModeFunctionName(node);
- var bindingName = node.name ? node.name.escapedText : "__function" /* Function */;
- return bindAnonymousDeclaration(node, 16 /* Function */, bindingName);
+ var bindingName = node.name ? node.name.escapedText : "__function" /* InternalSymbolName.Function */;
+ return bindAnonymousDeclaration(node, 16 /* SymbolFlags.Function */, bindingName);
}
function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) {
- if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */) && ts.isAsyncFunction(node)) {
- emitFlags |= 2048 /* HasAsyncFunctions */;
+ if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.isAsyncFunction(node)) {
+ emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */;
}
if (currentFlow && ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) {
node.flowNode = currentFlow;
}
return ts.hasDynamicName(node)
- ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* Computed */)
+ ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* InternalSymbolName.Computed */)
: declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
}
function getInferTypeContainer(node) {
@@ -46664,45 +47616,45 @@ var ts;
if (!container_1.locals) {
container_1.locals = ts.createSymbolTable();
}
- declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */);
+ declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */);
}
else {
- declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */);
+ declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */);
}
}
- else if (node.parent.kind === 189 /* InferType */) {
+ else if (node.parent.kind === 190 /* SyntaxKind.InferType */) {
var container_2 = getInferTypeContainer(node.parent);
if (container_2) {
if (!container_2.locals) {
container_2.locals = ts.createSymbolTable();
}
- declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */);
+ declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */);
}
else {
- bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217
+ bindAnonymousDeclaration(node, 262144 /* SymbolFlags.TypeParameter */, getDeclarationName(node)); // TODO: GH#18217
}
}
else {
- declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */);
+ declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */);
}
}
// reachability checks
function shouldReportErrorOnModuleDeclaration(node) {
var instanceState = getModuleInstanceState(node);
- return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && ts.shouldPreserveConstEnums(options));
+ return instanceState === 1 /* ModuleInstanceState.Instantiated */ || (instanceState === 2 /* ModuleInstanceState.ConstEnumOnly */ && ts.shouldPreserveConstEnums(options));
}
function checkUnreachable(node) {
- if (!(currentFlow.flags & 1 /* Unreachable */)) {
+ if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */)) {
return false;
}
if (currentFlow === unreachableFlow) {
var reportError =
// report error on all statements except empty ones
- (ts.isStatementButNotDeclaration(node) && node.kind !== 235 /* EmptyStatement */) ||
+ (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* SyntaxKind.EmptyStatement */) ||
// report error on class declarations
- node.kind === 256 /* ClassDeclaration */ ||
+ node.kind === 257 /* SyntaxKind.ClassDeclaration */ ||
// report error on instantiated modules or const-enums only modules if preserveConstEnums is set
- (node.kind === 260 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node));
+ (node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node));
if (reportError) {
currentFlow = reportedUnreachableFlow;
if (!options.allowUnreachableCode) {
@@ -46716,9 +47668,9 @@ var ts;
// Rationale: we don't want to report errors on non-initialized var's since they are hoisted
// On the other side we do want to report errors on non-initialized 'lets' because of TDZ
var isError_1 = ts.unreachableCodeIsError(options) &&
- !(node.flags & 8388608 /* Ambient */) &&
+ !(node.flags & 16777216 /* NodeFlags.Ambient */) &&
(!ts.isVariableStatement(node) ||
- !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) ||
+ !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* NodeFlags.BlockScoped */) ||
node.declarationList.declarations.some(function (d) { return !!d.initializer; }));
eachUnreachableRange(node, function (start, end) { return errorOrSuggestionOnRange(isError_1, start, end, ts.Diagnostics.Unreachable_code_detected); });
}
@@ -46742,17 +47694,17 @@ var ts;
// Don't remove statements that can validly be used before they appear.
return !ts.isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !ts.isEnumDeclaration(s) &&
// `var x;` may declare a variable used above
- !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* Let */ | 2 /* Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; }));
+ !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* NodeFlags.Let */ | 2 /* NodeFlags.Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; }));
}
function isPurelyTypeDeclaration(s) {
switch (s.kind) {
- case 257 /* InterfaceDeclaration */:
- case 258 /* TypeAliasDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
return true;
- case 260 /* ModuleDeclaration */:
- return getModuleInstanceState(s) !== 1 /* Instantiated */;
- case 259 /* EnumDeclaration */:
- return ts.hasSyntacticModifier(s, 2048 /* Const */);
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ return getModuleInstanceState(s) !== 1 /* ModuleInstanceState.Instantiated */;
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ return ts.hasSyntacticModifier(s, 2048 /* ModifierFlags.Const */);
default:
return false;
}
@@ -46837,32 +47789,32 @@ var ts;
if (shouldBail)
return;
// Visit the type's related types, if any
- if (type.flags & 524288 /* Object */) {
+ if (type.flags & 524288 /* TypeFlags.Object */) {
var objectType = type;
var objectFlags = objectType.objectFlags;
- if (objectFlags & 4 /* Reference */) {
+ if (objectFlags & 4 /* ObjectFlags.Reference */) {
visitTypeReference(type);
}
- if (objectFlags & 32 /* Mapped */) {
+ if (objectFlags & 32 /* ObjectFlags.Mapped */) {
visitMappedType(type);
}
- if (objectFlags & (1 /* Class */ | 2 /* Interface */)) {
+ if (objectFlags & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) {
visitInterfaceType(type);
}
- if (objectFlags & (8 /* Tuple */ | 16 /* Anonymous */)) {
+ if (objectFlags & (8 /* ObjectFlags.Tuple */ | 16 /* ObjectFlags.Anonymous */)) {
visitObjectType(objectType);
}
}
- if (type.flags & 262144 /* TypeParameter */) {
+ if (type.flags & 262144 /* TypeFlags.TypeParameter */) {
visitTypeParameter(type);
}
- if (type.flags & 3145728 /* UnionOrIntersection */) {
+ if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) {
visitUnionOrIntersectionType(type);
}
- if (type.flags & 4194304 /* Index */) {
+ if (type.flags & 4194304 /* TypeFlags.Index */) {
visitIndexType(type);
}
- if (type.flags & 8388608 /* IndexedAccess */) {
+ if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) {
visitIndexedAccessType(type);
}
}
@@ -46951,7 +47903,7 @@ var ts;
// (their type resolved directly to the member deeply referenced)
// So to get the intervening symbols, we need to check if there's a type
// query node on any of the symbol's declarations and get symbols there
- if (d.type && d.type.kind === 180 /* TypeQuery */) {
+ if (d.type && d.type.kind === 181 /* SyntaxKind.TypeQuery */) {
var query = d.type;
var entity = getResolvedSymbol(getFirstIdentifier(query.exprName));
visitSymbol(entity);
@@ -47085,24 +48037,24 @@ var ts;
TypeFacts[TypeFacts["AndFactsMask"] = 16768959] = "AndFactsMask";
})(TypeFacts || (TypeFacts = {}));
var typeofEQFacts = new ts.Map(ts.getEntries({
- string: 1 /* TypeofEQString */,
- number: 2 /* TypeofEQNumber */,
- bigint: 4 /* TypeofEQBigInt */,
- boolean: 8 /* TypeofEQBoolean */,
- symbol: 16 /* TypeofEQSymbol */,
- undefined: 65536 /* EQUndefined */,
- object: 32 /* TypeofEQObject */,
- function: 64 /* TypeofEQFunction */
+ string: 1 /* TypeFacts.TypeofEQString */,
+ number: 2 /* TypeFacts.TypeofEQNumber */,
+ bigint: 4 /* TypeFacts.TypeofEQBigInt */,
+ boolean: 8 /* TypeFacts.TypeofEQBoolean */,
+ symbol: 16 /* TypeFacts.TypeofEQSymbol */,
+ undefined: 65536 /* TypeFacts.EQUndefined */,
+ object: 32 /* TypeFacts.TypeofEQObject */,
+ function: 64 /* TypeFacts.TypeofEQFunction */
}));
var typeofNEFacts = new ts.Map(ts.getEntries({
- string: 256 /* TypeofNEString */,
- number: 512 /* TypeofNENumber */,
- bigint: 1024 /* TypeofNEBigInt */,
- boolean: 2048 /* TypeofNEBoolean */,
- symbol: 4096 /* TypeofNESymbol */,
- undefined: 524288 /* NEUndefined */,
- object: 8192 /* TypeofNEObject */,
- function: 16384 /* TypeofNEFunction */
+ string: 256 /* TypeFacts.TypeofNEString */,
+ number: 512 /* TypeFacts.TypeofNENumber */,
+ bigint: 1024 /* TypeFacts.TypeofNEBigInt */,
+ boolean: 2048 /* TypeFacts.TypeofNEBoolean */,
+ symbol: 4096 /* TypeFacts.TypeofNESymbol */,
+ undefined: 524288 /* TypeFacts.NEUndefined */,
+ object: 8192 /* TypeFacts.TypeofNEObject */,
+ function: 16384 /* TypeFacts.TypeofNEFunction */
}));
var TypeSystemPropertyName;
(function (TypeSystemPropertyName) {
@@ -47114,6 +48066,7 @@ var ts;
TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType";
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedTypeArguments"] = 6] = "ResolvedTypeArguments";
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseTypes"] = 7] = "ResolvedBaseTypes";
+ TypeSystemPropertyName[TypeSystemPropertyName["WriteType"] = 8] = "WriteType";
})(TypeSystemPropertyName || (TypeSystemPropertyName = {}));
var CheckMode;
(function (CheckMode) {
@@ -47123,7 +48076,8 @@ var ts;
CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive";
CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
- CheckMode[CheckMode["RestBindingElement"] = 32] = "RestBindingElement";
+ CheckMode[CheckMode["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
+ CheckMode[CheckMode["RestBindingElement"] = 64] = "RestBindingElement";
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
// we need to preserve generic types instead of substituting them for constraints
})(CheckMode || (CheckMode = {}));
@@ -47206,10 +48160,10 @@ var ts;
IntrinsicTypeKind[IntrinsicTypeKind["Uncapitalize"] = 3] = "Uncapitalize";
})(IntrinsicTypeKind || (IntrinsicTypeKind = {}));
var intrinsicTypeKinds = new ts.Map(ts.getEntries({
- Uppercase: 0 /* Uppercase */,
- Lowercase: 1 /* Lowercase */,
- Capitalize: 2 /* Capitalize */,
- Uncapitalize: 3 /* Uncapitalize */
+ Uppercase: 0 /* IntrinsicTypeKind.Uppercase */,
+ Lowercase: 1 /* IntrinsicTypeKind.Lowercase */,
+ Capitalize: 2 /* IntrinsicTypeKind.Capitalize */,
+ Uncapitalize: 3 /* IntrinsicTypeKind.Uncapitalize */
}));
function SymbolLinks() {
}
@@ -47234,11 +48188,11 @@ var ts;
ts.getSymbolId = getSymbolId;
function isInstantiatedModule(node, preserveConstEnums) {
var moduleState = ts.getModuleInstanceState(node);
- return moduleState === 1 /* Instantiated */ ||
- (preserveConstEnums && moduleState === 2 /* ConstEnumOnly */);
+ return moduleState === 1 /* ModuleInstanceState.Instantiated */ ||
+ (preserveConstEnums && moduleState === 2 /* ModuleInstanceState.ConstEnumOnly */);
}
ts.isInstantiatedModule = isInstantiatedModule;
- function createTypeChecker(host, produceDiagnostics) {
+ function createTypeChecker(host) {
var getPackagesMap = ts.memoize(function () {
// A package name maps to true when we detect it has .d.ts files.
// This is useful as an approximation of whether a package bundles its own types.
@@ -47250,11 +48204,15 @@ var ts;
return;
sf.resolvedModules.forEach(function (r) {
if (r && r.packageId)
- map.set(r.packageId.name, r.extension === ".d.ts" /* Dts */ || !!map.get(r.packageId.name));
+ map.set(r.packageId.name, r.extension === ".d.ts" /* Extension.Dts */ || !!map.get(r.packageId.name));
});
});
return map;
});
+ var deferredDiagnosticsCallbacks = [];
+ var addLazyDiagnostic = function (arg) {
+ deferredDiagnosticsCallbacks.push(arg);
+ };
// Cancellation that controls whether or not we can cancel in the middle of type checking.
// In general cancelling is *not* safe for the type checker. We might be in the middle of
// computing something, and we will leave our internals in an inconsistent state. Callers
@@ -47278,8 +48236,9 @@ var ts;
var instantiationDepth = 0;
var inlineLevel = 0;
var currentNode;
+ var varianceTypeParameter;
var emptySymbols = ts.createSymbolTable();
- var arrayVariances = [1 /* Covariant */];
+ var arrayVariances = [1 /* VarianceFlags.Covariant */];
var compilerOptions = host.getCompilerOptions();
var languageVersion = ts.getEmitScriptTarget(compilerOptions);
var moduleKind = ts.getEmitModuleKind(compilerOptions);
@@ -47293,20 +48252,20 @@ var ts;
var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis");
var useUnknownInCatchVariables = ts.getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables");
var keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
- var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 16384 /* FreshLiteral */;
+ var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* ObjectFlags.FreshLiteral */;
var exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes;
var checkBinaryExpression = createCheckBinaryExpression();
var emitResolver = createResolver();
var nodeBuilder = createNodeBuilder();
var globals = ts.createSymbolTable();
- var undefinedSymbol = createSymbol(4 /* Property */, "undefined");
+ var undefinedSymbol = createSymbol(4 /* SymbolFlags.Property */, "undefined");
undefinedSymbol.declarations = [];
- var globalThisSymbol = createSymbol(1536 /* Module */, "globalThis", 8 /* Readonly */);
+ var globalThisSymbol = createSymbol(1536 /* SymbolFlags.Module */, "globalThis", 8 /* CheckFlags.Readonly */);
globalThisSymbol.exports = globals;
globalThisSymbol.declarations = [];
globals.set(globalThisSymbol.escapedName, globalThisSymbol);
- var argumentsSymbol = createSymbol(4 /* Property */, "arguments");
- var requireSymbol = createSymbol(4 /* Property */, "require");
+ var argumentsSymbol = createSymbol(4 /* SymbolFlags.Property */, "arguments");
+ var requireSymbol = createSymbol(4 /* SymbolFlags.Property */, "require");
/** This will be set during calls to `getResolvedSignature` where services determines an apparent number of arguments greater than what is actually provided. */
var apparentArgumentCount;
// for public members that accept a Node or one of its subtypes, we must guard against
@@ -47358,10 +48317,10 @@ var ts;
return lexicallyScopedIdentifier ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) : undefined;
},
getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); },
- getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* String */ ? stringType : numberType); },
+ getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); },
getIndexInfosOfType: getIndexInfosOfType,
getSignaturesOfType: getSignaturesOfType,
- getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* String */ ? stringType : numberType); },
+ getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); },
getIndexType: function (type) { return getIndexType(type); },
getBaseTypes: getBaseTypes,
getBaseTypeOfLiteralType: getBaseTypeOfLiteralType,
@@ -47456,26 +48415,10 @@ var ts;
if (!node) {
return undefined;
}
- var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
- var containingCallResolvedSignature = containingCall && getNodeLinks(containingCall).resolvedSignature;
- if (contextFlags & 4 /* Completions */ && containingCall) {
- var toMarkSkip = node;
- do {
- getNodeLinks(toMarkSkip).skipDirectInference = true;
- toMarkSkip = toMarkSkip.parent;
- } while (toMarkSkip && toMarkSkip !== containingCall);
- getNodeLinks(containingCall).resolvedSignature = undefined;
- }
- var result = getContextualType(node, contextFlags);
- if (contextFlags & 4 /* Completions */ && containingCall) {
- var toMarkSkip = node;
- do {
- getNodeLinks(toMarkSkip).skipDirectInference = undefined;
- toMarkSkip = toMarkSkip.parent;
- } while (toMarkSkip && toMarkSkip !== containingCall);
- getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
+ if (contextFlags & 4 /* ContextFlags.Completions */) {
+ return runWithInferenceBlockedFromSourceNode(node, function () { return getContextualType(node, contextFlags); });
}
- return result;
+ return getContextualType(node, contextFlags);
},
getContextualTypeForObjectLiteralElement: function (nodeIn) {
var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
@@ -47493,10 +48436,13 @@ var ts;
getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType,
getFullyQualifiedName: getFullyQualifiedName,
getResolvedSignature: function (node, candidatesOutArray, argumentCount) {
- return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */);
+ return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* CheckMode.Normal */);
+ },
+ getResolvedSignatureForStringLiteralCompletions: function (call, editingArgument, candidatesOutArray) {
+ return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* CheckMode.IsForStringLiteralArgumentCompletions */, editingArgument);
},
getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) {
- return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */);
+ return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* CheckMode.IsForSignatureHelp */);
},
getExpandedParameters: getExpandedParameters,
hasEffectiveRestParameter: hasEffectiveRestParameter,
@@ -47582,7 +48528,7 @@ var ts;
getSuggestionForNonexistentExport: getSuggestionForNonexistentExport,
getSuggestedSymbolForNonexistentClassMember: getSuggestedSymbolForNonexistentClassMember,
getBaseConstraintOfType: getBaseConstraintOfType,
- getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; },
+ getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeFlags.TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; },
resolveName: function (name, location, meaning, excludeGlobals) {
return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false, excludeGlobals);
},
@@ -47617,12 +48563,12 @@ var ts;
// Do this in a finally block so we can ensure that it gets reset back to nothing after
// this call is done.
cancellationToken = ct;
- // Ensure file is type checked
- checkSourceFile(file);
- ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */));
+ // Ensure file is type checked, with _eager_ diagnostic production, so identifiers are registered as potentially unused
+ checkSourceFileWithEagerDiagnostics(file);
+ ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* NodeCheckFlags.TypeChecked */));
diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName));
checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) {
- if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 8388608 /* Ambient */))) {
+ if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) {
(diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion }));
}
});
@@ -47647,10 +48593,34 @@ var ts;
getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
getMemberOverrideModifierStatus: getMemberOverrideModifierStatus,
};
- function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode) {
+ function runWithInferenceBlockedFromSourceNode(node, fn) {
+ var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
+ var containingCallResolvedSignature = containingCall && getNodeLinks(containingCall).resolvedSignature;
+ if (containingCall) {
+ var toMarkSkip = node;
+ do {
+ getNodeLinks(toMarkSkip).skipDirectInference = true;
+ toMarkSkip = toMarkSkip.parent;
+ } while (toMarkSkip && toMarkSkip !== containingCall);
+ getNodeLinks(containingCall).resolvedSignature = undefined;
+ }
+ var result = fn();
+ if (containingCall) {
+ var toMarkSkip = node;
+ do {
+ getNodeLinks(toMarkSkip).skipDirectInference = undefined;
+ toMarkSkip = toMarkSkip.parent;
+ } while (toMarkSkip && toMarkSkip !== containingCall);
+ getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
+ }
+ return result;
+ }
+ function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode, editingArgument) {
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
apparentArgumentCount = argumentCount;
- var res = node ? getResolvedSignature(node, candidatesOutArray, checkMode) : undefined;
+ var res = !node ? undefined :
+ editingArgument ? runWithInferenceBlockedFromSourceNode(editingArgument, function () { return getResolvedSignature(node, candidatesOutArray, checkMode); }) :
+ getResolvedSignature(node, candidatesOutArray, checkMode);
apparentArgumentCount = undefined;
return res;
}
@@ -47668,32 +48638,33 @@ var ts;
var subtypeReductionCache = new ts.Map();
var evolvingArrayTypes = [];
var undefinedProperties = new ts.Map();
- var unknownSymbol = createSymbol(4 /* Property */, "unknown");
- var resolvingSymbol = createSymbol(0, "__resolving__" /* Resolving */);
+ var markerTypes = new ts.Set();
+ var unknownSymbol = createSymbol(4 /* SymbolFlags.Property */, "unknown");
+ var resolvingSymbol = createSymbol(0, "__resolving__" /* InternalSymbolName.Resolving */);
var unresolvedSymbols = new ts.Map();
var errorTypes = new ts.Map();
- var anyType = createIntrinsicType(1 /* Any */, "any");
- var autoType = createIntrinsicType(1 /* Any */, "any");
- var wildcardType = createIntrinsicType(1 /* Any */, "any");
- var errorType = createIntrinsicType(1 /* Any */, "error");
- var unresolvedType = createIntrinsicType(1 /* Any */, "unresolved");
- var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 131072 /* ContainsWideningType */);
- var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic");
- var unknownType = createIntrinsicType(2 /* Unknown */, "unknown");
- var nonNullUnknownType = createIntrinsicType(2 /* Unknown */, "unknown");
- var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined");
- var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 131072 /* ContainsWideningType */);
- var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined");
- var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* Undefined */, "undefined") : undefinedType;
- var nullType = createIntrinsicType(65536 /* Null */, "null");
- var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 131072 /* ContainsWideningType */);
- var stringType = createIntrinsicType(4 /* String */, "string");
- var numberType = createIntrinsicType(8 /* Number */, "number");
- var bigintType = createIntrinsicType(64 /* BigInt */, "bigint");
- var falseType = createIntrinsicType(512 /* BooleanLiteral */, "false");
- var regularFalseType = createIntrinsicType(512 /* BooleanLiteral */, "false");
- var trueType = createIntrinsicType(512 /* BooleanLiteral */, "true");
- var regularTrueType = createIntrinsicType(512 /* BooleanLiteral */, "true");
+ var anyType = createIntrinsicType(1 /* TypeFlags.Any */, "any");
+ var autoType = createIntrinsicType(1 /* TypeFlags.Any */, "any");
+ var wildcardType = createIntrinsicType(1 /* TypeFlags.Any */, "any");
+ var errorType = createIntrinsicType(1 /* TypeFlags.Any */, "error");
+ var unresolvedType = createIntrinsicType(1 /* TypeFlags.Any */, "unresolved");
+ var nonInferrableAnyType = createIntrinsicType(1 /* TypeFlags.Any */, "any", 65536 /* ObjectFlags.ContainsWideningType */);
+ var intrinsicMarkerType = createIntrinsicType(1 /* TypeFlags.Any */, "intrinsic");
+ var unknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown");
+ var nonNullUnknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown");
+ var undefinedType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined");
+ var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined", 65536 /* ObjectFlags.ContainsWideningType */);
+ var optionalType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined");
+ var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined") : undefinedType;
+ var nullType = createIntrinsicType(65536 /* TypeFlags.Null */, "null");
+ var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* TypeFlags.Null */, "null", 65536 /* ObjectFlags.ContainsWideningType */);
+ var stringType = createIntrinsicType(4 /* TypeFlags.String */, "string");
+ var numberType = createIntrinsicType(8 /* TypeFlags.Number */, "number");
+ var bigintType = createIntrinsicType(64 /* TypeFlags.BigInt */, "bigint");
+ var falseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false");
+ var regularFalseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false");
+ var trueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true");
+ var regularTrueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true");
trueType.regularType = regularTrueType;
trueType.freshType = trueType;
regularTrueType.regularType = regularTrueType;
@@ -47703,25 +48674,28 @@ var ts;
regularFalseType.regularType = regularFalseType;
regularFalseType.freshType = falseType;
var booleanType = getUnionType([regularFalseType, regularTrueType]);
- var esSymbolType = createIntrinsicType(4096 /* ESSymbol */, "symbol");
- var voidType = createIntrinsicType(16384 /* Void */, "void");
- var neverType = createIntrinsicType(131072 /* Never */, "never");
- var silentNeverType = createIntrinsicType(131072 /* Never */, "never");
- var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 524288 /* NonInferrableType */);
- var implicitNeverType = createIntrinsicType(131072 /* Never */, "never");
- var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never");
- var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object");
+ var esSymbolType = createIntrinsicType(4096 /* TypeFlags.ESSymbol */, "symbol");
+ var voidType = createIntrinsicType(16384 /* TypeFlags.Void */, "void");
+ var neverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never");
+ var silentNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never");
+ var nonInferrableType = createIntrinsicType(131072 /* TypeFlags.Never */, "never", 262144 /* ObjectFlags.NonInferrableType */);
+ var implicitNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never");
+ var unreachableNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never");
+ var nonPrimitiveType = createIntrinsicType(67108864 /* TypeFlags.NonPrimitive */, "object");
var stringOrNumberType = getUnionType([stringType, numberType]);
var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]);
var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType;
var numberOrBigIntType = getUnionType([numberType, bigintType]);
var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
- var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; });
- var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; });
+ var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type
+ var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? getRestrictiveTypeParameter(t) : t; });
+ var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? wildcardType : t; });
+ var uniqueLiteralType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal
+ var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints)
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 /* JsxAttributes */;
- var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
+ emptyJsxObjectType.objectFlags |= 2048 /* ObjectFlags.JsxAttributes */;
+ var emptyTypeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */);
emptyTypeLiteralSymbol.members = ts.createSymbolTable();
var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
@@ -47729,7 +48703,7 @@ var ts;
var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
// The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated
// in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes.
- anyFunctionType.objectFlags |= 524288 /* NonInferrableType */;
+ anyFunctionType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */;
var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
@@ -47737,11 +48711,11 @@ var ts;
var markerSubType = createTypeParameter();
markerSubType.constraint = markerSuperType;
var markerOtherType = createTypeParameter();
- var noTypePredicate = createTypePredicate(1 /* Identifier */, "<<unresolved>>", 0, anyType);
- var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */);
- var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */);
- var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */);
- var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */);
+ var noTypePredicate = createTypePredicate(1 /* TypePredicateKind.Identifier */, "<<unresolved>>", 0, anyType);
+ var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */);
+ var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */);
+ var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */);
+ var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */);
var enumNumberIndexInfo = createIndexInfo(numberType, stringType, /*isReadonly*/ true);
var iterationTypesCache = new ts.Map(); // cache for common IterationTypes instances
var noIterationTypes = {
@@ -47889,7 +48863,7 @@ var ts;
var enumRelation = new ts.Map();
var builtinGlobals = ts.createSymbolTable();
builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol);
- // Extensions suggested for path imports when module resolution is node12 or higher.
+ // Extensions suggested for path imports when module resolution is node16 or higher.
// The first element of each tuple is the extension a file has.
// The second element of each tuple is the extension that should be used in a path import.
// e.g. if we want to import file `foo.mts`, we should write `import {} from "./foo.mjs".
@@ -47900,7 +48874,7 @@ var ts;
[".mjs", ".mjs"],
[".js", ".js"],
[".cjs", ".cjs"],
- [".tsx", compilerOptions.jsx === 1 /* Preserve */ ? ".jsx" : ".js"],
+ [".tsx", compilerOptions.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" : ".js"],
[".jsx", ".jsx"],
[".json", ".json"],
];
@@ -48046,7 +49020,7 @@ var ts;
return diagnostic;
}
function isDeprecatedSymbol(symbol) {
- return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 134217728 /* Deprecated */);
+ return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* NodeFlags.Deprecated */);
}
function addDeprecatedSuggestion(location, declarations, deprecatedEntity) {
var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity);
@@ -48060,44 +49034,44 @@ var ts;
}
function createSymbol(flags, name, checkFlags) {
symbolCount++;
- var symbol = new Symbol(flags | 33554432 /* Transient */, name);
+ var symbol = new Symbol(flags | 33554432 /* SymbolFlags.Transient */, name);
symbol.checkFlags = checkFlags || 0;
return symbol;
}
function getExcludedSymbolFlags(flags) {
var result = 0;
- if (flags & 2 /* BlockScopedVariable */)
- result |= 111551 /* BlockScopedVariableExcludes */;
- if (flags & 1 /* FunctionScopedVariable */)
- result |= 111550 /* FunctionScopedVariableExcludes */;
- if (flags & 4 /* Property */)
- result |= 0 /* PropertyExcludes */;
- if (flags & 8 /* EnumMember */)
- result |= 900095 /* EnumMemberExcludes */;
- if (flags & 16 /* Function */)
- result |= 110991 /* FunctionExcludes */;
- if (flags & 32 /* Class */)
- result |= 899503 /* ClassExcludes */;
- if (flags & 64 /* Interface */)
- result |= 788872 /* InterfaceExcludes */;
- if (flags & 256 /* RegularEnum */)
- result |= 899327 /* RegularEnumExcludes */;
- if (flags & 128 /* ConstEnum */)
- result |= 899967 /* ConstEnumExcludes */;
- if (flags & 512 /* ValueModule */)
- result |= 110735 /* ValueModuleExcludes */;
- if (flags & 8192 /* Method */)
- result |= 103359 /* MethodExcludes */;
- if (flags & 32768 /* GetAccessor */)
- result |= 46015 /* GetAccessorExcludes */;
- if (flags & 65536 /* SetAccessor */)
- result |= 78783 /* SetAccessorExcludes */;
- if (flags & 262144 /* TypeParameter */)
- result |= 526824 /* TypeParameterExcludes */;
- if (flags & 524288 /* TypeAlias */)
- result |= 788968 /* TypeAliasExcludes */;
- if (flags & 2097152 /* Alias */)
- result |= 2097152 /* AliasExcludes */;
+ if (flags & 2 /* SymbolFlags.BlockScopedVariable */)
+ result |= 111551 /* SymbolFlags.BlockScopedVariableExcludes */;
+ if (flags & 1 /* SymbolFlags.FunctionScopedVariable */)
+ result |= 111550 /* SymbolFlags.FunctionScopedVariableExcludes */;
+ if (flags & 4 /* SymbolFlags.Property */)
+ result |= 0 /* SymbolFlags.PropertyExcludes */;
+ if (flags & 8 /* SymbolFlags.EnumMember */)
+ result |= 900095 /* SymbolFlags.EnumMemberExcludes */;
+ if (flags & 16 /* SymbolFlags.Function */)
+ result |= 110991 /* SymbolFlags.FunctionExcludes */;
+ if (flags & 32 /* SymbolFlags.Class */)
+ result |= 899503 /* SymbolFlags.ClassExcludes */;
+ if (flags & 64 /* SymbolFlags.Interface */)
+ result |= 788872 /* SymbolFlags.InterfaceExcludes */;
+ if (flags & 256 /* SymbolFlags.RegularEnum */)
+ result |= 899327 /* SymbolFlags.RegularEnumExcludes */;
+ if (flags & 128 /* SymbolFlags.ConstEnum */)
+ result |= 899967 /* SymbolFlags.ConstEnumExcludes */;
+ if (flags & 512 /* SymbolFlags.ValueModule */)
+ result |= 110735 /* SymbolFlags.ValueModuleExcludes */;
+ if (flags & 8192 /* SymbolFlags.Method */)
+ result |= 103359 /* SymbolFlags.MethodExcludes */;
+ if (flags & 32768 /* SymbolFlags.GetAccessor */)
+ result |= 46015 /* SymbolFlags.GetAccessorExcludes */;
+ if (flags & 65536 /* SymbolFlags.SetAccessor */)
+ result |= 78783 /* SymbolFlags.SetAccessorExcludes */;
+ if (flags & 262144 /* SymbolFlags.TypeParameter */)
+ result |= 526824 /* SymbolFlags.TypeParameterExcludes */;
+ if (flags & 524288 /* SymbolFlags.TypeAlias */)
+ result |= 788968 /* SymbolFlags.TypeAliasExcludes */;
+ if (flags & 2097152 /* SymbolFlags.Alias */)
+ result |= 2097152 /* SymbolFlags.AliasExcludes */;
return result;
}
function recordMergedSymbol(target, source) {
@@ -48129,13 +49103,13 @@ var ts;
function mergeSymbol(target, source, unidirectional) {
if (unidirectional === void 0) { unidirectional = false; }
if (!(target.flags & getExcludedSymbolFlags(source.flags)) ||
- (source.flags | target.flags) & 67108864 /* Assignment */) {
+ (source.flags | target.flags) & 67108864 /* SymbolFlags.Assignment */) {
if (source === target) {
// This can happen when an export assigned namespace exports something also erroneously exported at the top level
// See `declarationFileNoCrashOnExtraExportModifier` for an example
return target;
}
- if (!(target.flags & 33554432 /* Transient */)) {
+ if (!(target.flags & 33554432 /* SymbolFlags.Transient */)) {
var resolvedTarget = resolveSymbol(target);
if (resolvedTarget === unknownSymbol) {
return source;
@@ -48143,7 +49117,7 @@ var ts;
target = cloneSymbol(resolvedTarget);
}
// Javascript static-property-assignment declarations always merge, even though they are also values
- if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) {
+ if (source.flags & 512 /* SymbolFlags.ValueModule */ && target.flags & 512 /* SymbolFlags.ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) {
// reset flag when merging instantiated module into value module that has only const enums
target.constEnumOnlyModule = false;
}
@@ -48166,7 +49140,7 @@ var ts;
recordMergedSymbol(target, source);
}
}
- else if (target.flags & 1024 /* NamespaceModule */) {
+ else if (target.flags & 1024 /* SymbolFlags.NamespaceModule */) {
// Do not report an error when merging `var globalThis` with the built-in `globalThis`,
// as we will already report a "Declaration name conflicts..." error, and this error
// won't make much sense.
@@ -48175,8 +49149,8 @@ var ts;
}
}
else { // error
- var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */);
- var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */);
+ var isEitherEnum = !!(target.flags & 384 /* SymbolFlags.Enum */ || source.flags & 384 /* SymbolFlags.Enum */);
+ var isEitherBlockScoped_1 = !!(target.flags & 2 /* SymbolFlags.BlockScopedVariable */ || source.flags & 2 /* SymbolFlags.BlockScopedVariable */);
var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
: isEitherBlockScoped_1 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
: ts.Diagnostics.Duplicate_identifier_0;
@@ -48187,7 +49161,7 @@ var ts;
var symbolName_1 = symbolToString(source);
// Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch
if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) {
- var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* LessThan */ ? sourceSymbolFile : targetSymbolFile;
+ var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* Comparison.LessThan */ ? sourceSymbolFile : targetSymbolFile;
var secondFile_1 = firstFile_1 === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile;
var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, "".concat(firstFile_1.path, "|").concat(secondFile_1.path), function () {
return ({ firstFile: firstFile_1, secondFile: secondFile_1, conflictingSymbols: new ts.Map() });
@@ -48232,7 +49206,7 @@ var ts;
err.relatedInformation = err.relatedInformation || [];
var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here, symbolName);
var followOnMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics.and_here);
- if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* EqualTo */; }))
+ if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* Comparison.EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* Comparison.EqualTo */; }))
return "continue";
ts.addRelatedInfo(err, !ts.length(err.relatedInformation) ? leadingMessage : followOnMessage);
};
@@ -48274,7 +49248,7 @@ var ts;
else {
// find a module that about to be augmented
// do not validate names of augmentations that are defined in ambient context
- var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608 /* Ambient */)
+ var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* NodeFlags.Ambient */)
? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found
: undefined;
var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true);
@@ -48283,7 +49257,7 @@ var ts;
}
// obtain item referenced by 'export='
mainModule_1 = resolveExternalModuleSymbol(mainModule_1);
- if (mainModule_1.flags & 1920 /* Namespace */) {
+ if (mainModule_1.flags & 1920 /* SymbolFlags.Namespace */) {
// If we're merging an augmentation to a pattern ambient module, we want to
// perform the merge unidirectionally from the augmentation ('a.foo') to
// the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you
@@ -48298,9 +49272,9 @@ var ts;
patternAmbientModuleAugmentations.set(moduleName.text, merged);
}
else {
- if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) {
+ if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) {
// We may need to merge the module augmentation's exports into the target symbols of the resolved exports
- var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* resolvedExports */);
+ var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */);
for (var _i = 0, _d = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _d.length; _i++) {
var _e = _d[_i], key = _e[0], value = _e[1];
if (resolvedExports.has(key) && !mainModule_1.exports.has(key)) {
@@ -48333,7 +49307,7 @@ var ts;
}
}
function getSymbolLinks(symbol) {
- if (symbol.flags & 33554432 /* Transient */)
+ if (symbol.flags & 33554432 /* SymbolFlags.Transient */)
return symbol;
var id = getSymbolId(symbol);
return symbolLinks[id] || (symbolLinks[id] = new SymbolLinks());
@@ -48343,17 +49317,17 @@ var ts;
return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks());
}
function isGlobalSourceFile(node) {
- return node.kind === 303 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node);
+ return node.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(node);
}
function getSymbol(symbols, name, meaning) {
if (meaning) {
var symbol = getMergedSymbol(symbols.get(name));
if (symbol) {
- ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here.");
+ ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here.");
if (symbol.flags & meaning) {
return symbol;
}
- if (symbol.flags & 2097152 /* Alias */) {
+ if (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
var target = resolveAlias(symbol);
// Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors
if (target === unknownSymbol || target.flags & meaning) {
@@ -48373,8 +49347,8 @@ var ts;
function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) {
var constructorDeclaration = parameter.parent;
var classDeclaration = parameter.parent.parent;
- var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* Value */);
- var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* Value */);
+ var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* SymbolFlags.Value */);
+ var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* SymbolFlags.Value */);
if (parameterSymbol && propertySymbol) {
return [parameterSymbol, propertySymbol];
}
@@ -48388,7 +49362,7 @@ var ts;
if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
(!ts.outFile(compilerOptions)) ||
isInTypeQuery(usage) ||
- declaration.flags & 8388608 /* Ambient */) {
+ declaration.flags & 16777216 /* NodeFlags.Ambient */) {
// nodes are in different files and order cannot be determined
return true;
}
@@ -48402,17 +49376,17 @@ var ts;
}
if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) {
// declaration is before usage
- if (declaration.kind === 202 /* BindingElement */) {
+ if (declaration.kind === 203 /* SyntaxKind.BindingElement */) {
// still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2])
- var errorBindingElement = ts.getAncestor(usage, 202 /* BindingElement */);
+ var errorBindingElement = ts.getAncestor(usage, 203 /* SyntaxKind.BindingElement */);
if (errorBindingElement) {
return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) ||
declaration.pos < errorBindingElement.pos;
}
// or it might be illegal if usage happens before parent variable is declared (eg var [a] = a)
- return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 253 /* VariableDeclaration */), usage);
+ return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 254 /* SyntaxKind.VariableDeclaration */), usage);
}
- else if (declaration.kind === 253 /* VariableDeclaration */) {
+ else if (declaration.kind === 254 /* SyntaxKind.VariableDeclaration */) {
// still might be illegal if usage is in the initializer of the variable declaration (eg var a = a)
return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage);
}
@@ -48426,7 +49400,7 @@ var ts;
}
else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) {
// foo = this.bar is illegal in esnext+useDefineForClassFields when bar is a parameter property
- return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields
+ return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields
&& ts.getContainingClass(declaration) === ts.getContainingClass(usage)
&& isUsedInFunctionOrInstanceProperty(usage, declaration));
}
@@ -48442,19 +49416,19 @@ var ts;
// or if usage is in a type context:
// 1. inside a type query (typeof in type position)
// 2. inside a jsdoc comment
- if (usage.parent.kind === 274 /* ExportSpecifier */ || (usage.parent.kind === 270 /* ExportAssignment */ && usage.parent.isExportEquals)) {
+ if (usage.parent.kind === 275 /* SyntaxKind.ExportSpecifier */ || (usage.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.parent.isExportEquals)) {
// export specifiers do not use the variable, they only make it available for use
return true;
}
// When resolving symbols for exports, the `usage` location passed in can be the export site directly
- if (usage.kind === 270 /* ExportAssignment */ && usage.isExportEquals) {
+ if (usage.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.isExportEquals) {
return true;
}
- if (!!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) {
+ if (!!(usage.flags & 8388608 /* NodeFlags.JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) {
return true;
}
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
- if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields
+ if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields
&& ts.getContainingClass(declaration)
&& (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) {
return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true);
@@ -48469,9 +49443,9 @@ var ts;
}
function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) {
switch (declaration.parent.parent.kind) {
- case 236 /* VariableStatement */:
- case 241 /* ForStatement */:
- case 243 /* ForOfStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
// variable statement/for/for-of statement case,
// use site should not be inside variable declaration (initializer of declaration or binding element)
if (isSameScopeDescendentOf(usage, declaration, declContainer)) {
@@ -48499,7 +49473,7 @@ var ts;
var initializerOfProperty = propertyDeclaration.initializer === current;
if (initializerOfProperty) {
if (ts.isStatic(current.parent)) {
- if (declaration.kind === 168 /* MethodDeclaration */) {
+ if (declaration.kind === 169 /* SyntaxKind.MethodDeclaration */) {
return true;
}
if (ts.isPropertyDeclaration(declaration) && ts.getContainingClass(usage) === ts.getContainingClass(declaration)) {
@@ -48514,7 +49488,7 @@ var ts;
}
}
else {
- var isDeclarationInstanceProperty = declaration.kind === 166 /* PropertyDeclaration */ && !ts.isStatic(declaration);
+ var isDeclarationInstanceProperty = declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(declaration);
if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) {
return true;
}
@@ -48537,19 +49511,19 @@ var ts;
return "quit";
}
switch (node.kind) {
- case 213 /* ArrowFunction */:
+ case 214 /* SyntaxKind.ArrowFunction */:
return true;
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
// even when stopping at any property declaration, they need to come from the same class
return stopAtAnyPropertyDeclaration &&
(ts.isPropertyDeclaration(declaration) && node.parent === declaration.parent
|| ts.isParameterPropertyDeclaration(declaration, declaration.parent) && node.parent === declaration.parent.parent)
? "quit" : true;
- case 234 /* Block */:
+ case 235 /* SyntaxKind.Block */:
switch (node.parent.kind) {
- case 171 /* GetAccessor */:
- case 168 /* MethodDeclaration */:
- case 172 /* SetAccessor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 173 /* SyntaxKind.SetAccessor */:
return true;
default:
return false;
@@ -48574,7 +49548,7 @@ var ts;
// - optional chaining pre-es2020
// - nullish coalesce pre-es2020
// - spread assignment in binding pattern pre-es2017
- if (target >= 2 /* ES2015 */) {
+ if (target >= 2 /* ScriptTarget.ES2015 */) {
var links = getNodeLinks(functionLocation);
if (links.declarationRequiresScopeChange === undefined) {
links.declarationRequiresScopeChange = ts.forEach(functionLocation.parameters, requiresScopeChange) || false;
@@ -48589,30 +49563,30 @@ var ts;
}
function requiresScopeChangeWorker(node) {
switch (node.kind) {
- case 213 /* ArrowFunction */:
- case 212 /* FunctionExpression */:
- case 255 /* FunctionDeclaration */:
- case 170 /* Constructor */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 171 /* SyntaxKind.Constructor */:
// do not descend into these
return false;
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 294 /* PropertyAssignment */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
return requiresScopeChangeWorker(node.name);
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
// static properties in classes introduce temporary variables
if (ts.hasStaticModifier(node)) {
- return target < 99 /* ESNext */ || !useDefineForClassFields;
+ return target < 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields;
}
return requiresScopeChangeWorker(node.name);
default:
// null coalesce and optional chain pre-es2020 produce temporary variables
if (ts.isNullishCoalesce(node) || ts.isOptionalChain(node)) {
- return target < 7 /* ES2020 */;
+ return target < 7 /* ScriptTarget.ES2020 */;
}
if (ts.isBindingElement(node) && node.dotDotDotToken && ts.isObjectBindingPattern(node.parent)) {
- return target < 4 /* ES2017 */;
+ return target < 4 /* ScriptTarget.ES2017 */;
}
if (ts.isTypeNode(node))
return false;
@@ -48620,6 +49594,10 @@ var ts;
}
}
}
+ function isConstAssertion(location) {
+ return (ts.isAssertionExpression(location) && ts.isConstTypeReference(location.type))
+ || (ts.isJSDocTypeTag(location) && ts.isConstTypeReference(location.typeExpression));
+ }
/**
* Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and
* the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with
@@ -48645,6 +49623,11 @@ var ts;
var grandparent;
var isInExternalModule = false;
loop: while (location) {
+ if (name === "const" && isConstAssertion(location)) {
+ // `const` in an `as const` has no symbol, but issues no error because there is no *actual* lookup of the type
+ // (it refers to the constant type of the expression instead)
+ return undefined;
+ }
// Locals of a source file are not in scope (because they get merged into the global symbol table)
if (location.locals && !isGlobalSourceFile(location)) {
if (result = lookup(location.locals, name, meaning)) {
@@ -48656,35 +49639,35 @@ var ts;
// - parameters are only in the scope of function body
// This restriction does not apply to JSDoc comment types because they are parented
// at a higher level than type parameters would normally be
- if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 318 /* JSDocComment */) {
- useResult = result.flags & 262144 /* TypeParameter */
+ if (meaning & result.flags & 788968 /* SymbolFlags.Type */ && lastLocation.kind !== 320 /* SyntaxKind.JSDoc */) {
+ useResult = result.flags & 262144 /* SymbolFlags.TypeParameter */
// type parameters are visible in parameter list, return type and type parameter list
? lastLocation === location.type ||
- lastLocation.kind === 163 /* Parameter */ ||
- lastLocation.kind === 338 /* JSDocParameterTag */ ||
- lastLocation.kind === 339 /* JSDocReturnTag */ ||
- lastLocation.kind === 162 /* TypeParameter */
+ lastLocation.kind === 164 /* SyntaxKind.Parameter */ ||
+ lastLocation.kind === 340 /* SyntaxKind.JSDocParameterTag */ ||
+ lastLocation.kind === 341 /* SyntaxKind.JSDocReturnTag */ ||
+ lastLocation.kind === 163 /* SyntaxKind.TypeParameter */
// local types not visible outside the function body
: false;
}
- if (meaning & result.flags & 3 /* Variable */) {
+ if (meaning & result.flags & 3 /* SymbolFlags.Variable */) {
// expression inside parameter will lookup as normal variable scope when targeting es2015+
if (useOuterVariableScopeInParameter(result, location, lastLocation)) {
useResult = false;
}
- else if (result.flags & 1 /* FunctionScopedVariable */) {
+ else if (result.flags & 1 /* SymbolFlags.FunctionScopedVariable */) {
// parameters are visible only inside function body, parameter list and return type
// technically for parameter list case here we might mix parameters and variables declared in function,
// however it is detected separately when checking initializers of parameters
// to make sure that they reference no variables declared after them.
useResult =
- lastLocation.kind === 163 /* Parameter */ ||
+ lastLocation.kind === 164 /* SyntaxKind.Parameter */ ||
(lastLocation === location.type &&
!!ts.findAncestor(result.valueDeclaration, ts.isParameter));
}
}
}
- else if (location.kind === 188 /* ConditionalType */) {
+ else if (location.kind === 189 /* SyntaxKind.ConditionalType */) {
// A type parameter declared using 'infer T' in a conditional type is visible only in
// the true branch of the conditional type.
useResult = lastLocation === location.trueType;
@@ -48699,17 +49682,17 @@ var ts;
}
withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation);
switch (location.kind) {
- case 303 /* SourceFile */:
+ case 305 /* SyntaxKind.SourceFile */:
if (!ts.isExternalOrCommonJsModule(location))
break;
isInExternalModule = true;
// falls through
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols;
- if (location.kind === 303 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) {
+ if (location.kind === 305 /* SyntaxKind.SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isGlobalScopeAugmentation(location))) {
// It's an external module. First see if the module has an export default and if the local
// name of that export default matches.
- if (result = moduleExports.get("default" /* Default */)) {
+ if (result = moduleExports.get("default" /* InternalSymbolName.Default */)) {
var localSymbol = ts.getLocalSymbolForExportDefault(result);
if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) {
break loop;
@@ -48729,13 +49712,13 @@ var ts;
// which is not the desired behavior.
var moduleExport = moduleExports.get(name);
if (moduleExport &&
- moduleExport.flags === 2097152 /* Alias */ &&
- (ts.getDeclarationOfKind(moduleExport, 274 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 273 /* NamespaceExport */))) {
+ moduleExport.flags === 2097152 /* SymbolFlags.Alias */ &&
+ (ts.getDeclarationOfKind(moduleExport, 275 /* SyntaxKind.ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 274 /* SyntaxKind.NamespaceExport */))) {
break;
}
}
// ES6 exports are also visible locally (except for 'default'), but commonjs exports are not (except typedefs)
- if (name !== "default" /* Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* ModuleMember */))) {
+ if (name !== "default" /* InternalSymbolName.Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* SymbolFlags.ModuleMember */))) {
if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_b = result.declarations) === null || _b === void 0 ? void 0 : _b.some(ts.isJSDocTypeAlias))) {
result = undefined;
}
@@ -48744,12 +49727,12 @@ var ts;
}
}
break;
- case 259 /* EnumDeclaration */:
- if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* EnumMember */)) {
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* SymbolFlags.EnumMember */)) {
break loop;
}
break;
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
// TypeScript 1.0 spec (April 2014): 8.4.1
// Initializer expressions for instance member variables are evaluated in the scope
// of the class constructor body but are not permitted to reference parameters or
@@ -48759,20 +49742,20 @@ var ts;
if (!ts.isStatic(location)) {
var ctor = findConstructorDeclaration(location.parent);
if (ctor && ctor.locals) {
- if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) {
+ if (lookup(ctor.locals, name, meaning & 111551 /* SymbolFlags.Value */)) {
// Remember the property node, it will be used later to report appropriate error
propertyWithInvalidInitializer = location;
}
}
}
break;
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- case 257 /* InterfaceDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
// The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals
// These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would
// trigger resolving late-bound names, which we may already be in the process of doing while we're here!
- if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* Type */)) {
+ if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* SymbolFlags.Type */)) {
if (!isTypeParameterSymbolDeclaredInContainer(result, location)) {
// ignore type parameters not declared in this container
result = undefined;
@@ -48787,7 +49770,7 @@ var ts;
}
break loop;
}
- if (location.kind === 225 /* ClassExpression */ && meaning & 32 /* Class */) {
+ if (location.kind === 226 /* SyntaxKind.ClassExpression */ && meaning & 32 /* SymbolFlags.Class */) {
var className = location.name;
if (className && name === className.escapedText) {
result = location.symbol;
@@ -48795,11 +49778,11 @@ var ts;
}
}
break;
- case 227 /* ExpressionWithTypeArguments */:
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
// The type parameters of a class are not in scope in the base class expression.
- if (lastLocation === location.expression && location.parent.token === 94 /* ExtendsKeyword */) {
+ if (lastLocation === location.expression && location.parent.token === 94 /* SyntaxKind.ExtendsKeyword */) {
var container = location.parent.parent;
- if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) {
+ if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* SymbolFlags.Type */))) {
if (nameNotFoundMessage) {
error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters);
}
@@ -48815,39 +49798,39 @@ var ts;
// [foo<T>()]() { } // <-- Reference to T from class's own computed property
// }
//
- case 161 /* ComputedPropertyName */:
+ case 162 /* SyntaxKind.ComputedPropertyName */:
grandparent = location.parent.parent;
- if (ts.isClassLike(grandparent) || grandparent.kind === 257 /* InterfaceDeclaration */) {
+ if (ts.isClassLike(grandparent) || grandparent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) {
// A reference to this grandparent's type parameters would be an error
- if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) {
+ if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* SymbolFlags.Type */)) {
error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type);
return undefined;
}
}
break;
- case 213 /* ArrowFunction */:
+ case 214 /* SyntaxKind.ArrowFunction */:
// when targeting ES6 or higher there is no 'arguments' in an arrow function
// for lower compile targets the resolved symbol is used to emit an error
- if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */) {
+ if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */) {
break;
}
// falls through
- case 168 /* MethodDeclaration */:
- case 170 /* Constructor */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 255 /* FunctionDeclaration */:
- if (meaning & 3 /* Variable */ && name === "arguments") {
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") {
result = argumentsSymbol;
break loop;
}
break;
- case 212 /* FunctionExpression */:
- if (meaning & 3 /* Variable */ && name === "arguments") {
+ case 213 /* SyntaxKind.FunctionExpression */:
+ if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") {
result = argumentsSymbol;
break loop;
}
- if (meaning & 16 /* Function */) {
+ if (meaning & 16 /* SymbolFlags.Function */) {
var functionName = location.name;
if (functionName && name === functionName.escapedText) {
result = location.symbol;
@@ -48855,7 +49838,7 @@ var ts;
}
}
break;
- case 164 /* Decorator */:
+ case 165 /* SyntaxKind.Decorator */:
// Decorators are resolved at the class declaration. Resolving at the parameter
// or member would result in looking up locals in the method.
//
@@ -48864,7 +49847,7 @@ var ts;
// method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter.
// }
//
- if (location.parent && location.parent.kind === 163 /* Parameter */) {
+ if (location.parent && location.parent.kind === 164 /* SyntaxKind.Parameter */) {
location = location.parent;
}
//
@@ -48879,20 +49862,20 @@ var ts;
// declare function y(x: T): any;
// @param(1 as T) // <-- T should resolve to the type alias outside of class C
// class C<T> {}
- if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 256 /* ClassDeclaration */)) {
+ if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 257 /* SyntaxKind.ClassDeclaration */)) {
location = location.parent;
}
break;
- case 343 /* JSDocTypedefTag */:
- case 336 /* JSDocCallbackTag */:
- case 337 /* JSDocEnumTag */:
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
+ case 338 /* SyntaxKind.JSDocCallbackTag */:
+ case 339 /* SyntaxKind.JSDocEnumTag */:
// js type aliases do not resolve names from their host, so skip past it
var root = ts.getJSDocRoot(location);
if (root) {
location = root.parent;
}
break;
- case 163 /* Parameter */:
+ case 164 /* SyntaxKind.Parameter */:
if (lastLocation && (lastLocation === location.initializer ||
lastLocation === location.name && ts.isBindingPattern(lastLocation))) {
if (!associatedDeclarationForContainingInitializerOrBindingName) {
@@ -48900,7 +49883,7 @@ var ts;
}
}
break;
- case 202 /* BindingElement */:
+ case 203 /* SyntaxKind.BindingElement */:
if (lastLocation && (lastLocation === location.initializer ||
lastLocation === location.name && ts.isBindingPattern(lastLocation))) {
if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) {
@@ -48908,8 +49891,8 @@ var ts;
}
}
break;
- case 189 /* InferType */:
- if (meaning & 262144 /* TypeParameter */) {
+ case 190 /* SyntaxKind.InferType */:
+ if (meaning & 262144 /* SymbolFlags.TypeParameter */) {
var parameterName = location.typeParameter.name;
if (parameterName && name === parameterName.escapedText) {
result = location.typeParameter.symbol;
@@ -48934,7 +49917,7 @@ var ts;
}
if (!result) {
if (lastLocation) {
- ts.Debug.assert(lastLocation.kind === 303 /* SourceFile */);
+ ts.Debug.assert(lastLocation.kind === 305 /* SyntaxKind.SourceFile */);
if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) {
return lastLocation.symbol;
}
@@ -48951,141 +49934,145 @@ var ts;
}
}
if (!result) {
- if (nameNotFoundMessage && produceDiagnostics) {
- if (!errorLocation ||
- !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
- !checkAndReportErrorForExtendingInterface(errorLocation) &&
- !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
- !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
- !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
- !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
- !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
- var suggestion = void 0;
- if (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) {
- suggestion = undefined;
- }
- if (suggestion) {
- var suggestionName = symbolToString(suggestion);
- var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false);
- var message = meaning === 1920 /* Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1
- : isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1
- : ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1;
- var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName);
- addErrorOrSuggestion(!isUncheckedJS, diagnostic);
- if (suggestion.valueDeclaration) {
- ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
+ if (nameNotFoundMessage) {
+ addLazyDiagnostic(function () {
+ if (!errorLocation ||
+ !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
+ !checkAndReportErrorForExtendingInterface(errorLocation) &&
+ !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
+ !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
+ !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
+ !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
+ !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
+ var suggestion = void 0;
+ if (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) {
+ suggestion = undefined;
}
- }
- }
- if (!suggestion) {
- if (nameArg) {
- var lib = getSuggestedLibForNonExistentName(nameArg);
- if (lib) {
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
+ if (suggestion) {
+ var suggestionName = symbolToString(suggestion);
+ var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false);
+ var message = meaning === 1920 /* SymbolFlags.Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1
+ : isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1
+ : ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1;
+ var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName);
+ addErrorOrSuggestion(!isUncheckedJS, diagnostic);
+ if (suggestion.valueDeclaration) {
+ ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
+ }
}
- else {
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
+ }
+ if (!suggestion) {
+ if (nameArg) {
+ var lib = getSuggestedLibForNonExistentName(nameArg);
+ if (lib) {
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
+ }
+ else {
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
+ }
}
}
+ suggestionCount++;
}
- suggestionCount++;
- }
+ });
}
return undefined;
}
+ if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields)) {
+ // We have a match, but the reference occurred within a property initializer and the identifier also binds
+ // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
+ // with ESNext+useDefineForClassFields because the scope semantics are different.
+ 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));
+ return undefined;
+ }
// Perform extra checks only if error reporting was requested
- if (nameNotFoundMessage && produceDiagnostics) {
- if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
- // We have a match, but the reference occurred within a property initializer and the identifier also binds
- // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
- // with ESNext+useDefineForClassFields because the scope semantics are different.
- 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));
- return undefined;
- }
- // Only check for block-scoped variable if we have an error location and are looking for the
- // name with variable meaning
- // For example,
- // declare module foo {
- // interface bar {}
- // }
- // const foo/*1*/: foo/*2*/.bar;
- // The foo at /*1*/ and /*2*/ will share same symbol with two meanings:
- // block-scoped variable and namespace module. However, only when we
- // try to resolve name in /*1*/ which is used in variable position,
- // we want to check for block-scoped
- if (errorLocation &&
- (meaning & 2 /* BlockScopedVariable */ ||
- ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) {
- var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
- if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) {
- checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
- }
- }
- // If we're in an external module, we can't reference value symbols created from UMD export declarations
- if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 4194304 /* JSDoc */)) {
- var merged = getMergedSymbol(result);
- if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
- errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name));
- }
- }
- // If we're in a parameter initializer or binding name, we can't reference the values of the parameter whose initializer we're within or parameters to the right
- if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) {
- var candidate = getMergedSymbol(getLateBoundSymbol(result));
- var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName);
- // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself
- if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializerOrBindingName)) {
- error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_itself, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name));
- }
- // And it cannot refer to any declarations which come after it
- else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializerOrBindingName.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) {
- error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
- }
- }
- if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
- var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
- if (typeOnlyDeclaration) {
- var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
- ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
- : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
- var unescapedName = ts.unescapeLeadingUnderscores(name);
- addTypeOnlyDeclarationRelatedInfo(error(errorLocation, message, unescapedName), typeOnlyDeclaration, unescapedName);
+ if (nameNotFoundMessage) {
+ addLazyDiagnostic(function () {
+ // Only check for block-scoped variable if we have an error location and are looking for the
+ // name with variable meaning
+ // For example,
+ // declare module foo {
+ // interface bar {}
+ // }
+ // const foo/*1*/: foo/*2*/.bar;
+ // The foo at /*1*/ and /*2*/ will share same symbol with two meanings:
+ // block-scoped variable and namespace module. However, only when we
+ // try to resolve name in /*1*/ which is used in variable position,
+ // we want to check for block-scoped
+ if (errorLocation &&
+ (meaning & 2 /* SymbolFlags.BlockScopedVariable */ ||
+ ((meaning & 32 /* SymbolFlags.Class */ || meaning & 384 /* SymbolFlags.Enum */) && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */))) {
+ var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
+ if (exportOrLocalSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* SymbolFlags.Class */ || exportOrLocalSymbol.flags & 384 /* SymbolFlags.Enum */) {
+ checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
+ }
+ }
+ // If we're in an external module, we can't reference value symbols created from UMD export declarations
+ if (result && isInExternalModule && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */ && !(originalLocation.flags & 8388608 /* NodeFlags.JSDoc */)) {
+ var merged = getMergedSymbol(result);
+ if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
+ errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name));
+ }
+ }
+ // If we're in a parameter initializer or binding name, we can't reference the values of the parameter whose initializer we're within or parameters to the right
+ if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */) {
+ var candidate = getMergedSymbol(getLateBoundSymbol(result));
+ var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName);
+ // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself
+ if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializerOrBindingName)) {
+ error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_itself, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name));
+ }
+ // And it cannot refer to any declarations which come after it
+ else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializerOrBindingName.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) {
+ error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
+ }
+ }
+ if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
+ var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
+ if (typeOnlyDeclaration) {
+ var message = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */
+ ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
+ : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
+ var unescapedName = ts.unescapeLeadingUnderscores(name);
+ addTypeOnlyDeclarationRelatedInfo(error(errorLocation, message, unescapedName), typeOnlyDeclaration, unescapedName);
+ }
}
- }
+ });
}
return result;
}
function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) {
if (!typeOnlyDeclaration)
return diagnostic;
- return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 274 /* ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName));
+ return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName));
}
function getIsDeferredContext(location, lastLocation) {
- if (location.kind !== 213 /* ArrowFunction */ && location.kind !== 212 /* FunctionExpression */) {
+ if (location.kind !== 214 /* SyntaxKind.ArrowFunction */ && location.kind !== 213 /* SyntaxKind.FunctionExpression */) {
// initializers in instance property declaration of class like entities are executed in constructor and thus deferred
return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) ||
- (location.kind === 166 /* PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred
+ (location.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred
}
if (lastLocation && lastLocation === location.name) {
return false;
}
// generator functions and async functions are not inlined in control flow when immediately invoked
- if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* Async */)) {
+ if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* ModifierFlags.Async */)) {
return true;
}
return !ts.getImmediatelyInvokedFunctionExpression(location);
}
function isSelfReferenceLocation(node) {
switch (node.kind) {
- case 255 /* FunctionDeclaration */:
- case 256 /* ClassDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 259 /* EnumDeclaration */:
- case 258 /* TypeAliasDeclaration */:
- case 260 /* ModuleDeclaration */: // For `namespace N { N; }`
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */: // For `namespace N { N; }`
return true;
default:
return false;
@@ -49098,7 +50085,7 @@ var ts;
if (symbol.declarations) {
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var decl = _a[_i];
- if (decl.kind === 162 /* TypeParameter */) {
+ if (decl.kind === 163 /* SyntaxKind.TypeParameter */) {
var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent;
if (parent === container) {
return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); // TODO: GH#18217
@@ -49142,7 +50129,7 @@ var ts;
}
function checkAndReportErrorForExtendingInterface(errorLocation) {
var expression = getEntityNameForExtendingInterface(errorLocation);
- if (expression && resolveEntityName(expression, 64 /* Interface */, /*ignoreErrors*/ true)) {
+ if (expression && resolveEntityName(expression, 64 /* SymbolFlags.Interface */, /*ignoreErrors*/ true)) {
error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression));
return true;
}
@@ -49154,10 +50141,10 @@ var ts;
*/
function getEntityNameForExtendingInterface(node) {
switch (node.kind) {
- case 79 /* Identifier */:
- case 205 /* PropertyAccessExpression */:
+ case 79 /* SyntaxKind.Identifier */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined;
- case 227 /* ExpressionWithTypeArguments */:
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
if (ts.isEntityNameExpression(node.expression)) {
return node.expression;
}
@@ -49167,9 +50154,9 @@ var ts;
}
}
function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) {
- var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* Value */ : 0);
+ var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* SymbolFlags.Value */ : 0);
if (meaning === namespaceMeaning) {
- var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
+ var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
var parent = errorLocation.parent;
if (symbol) {
if (ts.isQualifiedName(parent)) {
@@ -49188,9 +50175,9 @@ var ts;
return false;
}
function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) {
- if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) {
- var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
- if (symbol && !(symbol.flags & 1920 /* Namespace */)) {
+ if (meaning & (788968 /* SymbolFlags.Type */ & ~1920 /* SymbolFlags.Namespace */)) {
+ var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* SymbolFlags.Type */ & 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
+ if (symbol && !(symbol.flags & 1920 /* SymbolFlags.Namespace */)) {
error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.unescapeLeadingUnderscores(name));
return true;
}
@@ -49201,20 +50188,20 @@ var ts;
return name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never" || name === "unknown";
}
function checkAndReportErrorForExportingPrimitiveType(errorLocation, name) {
- if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 274 /* ExportSpecifier */) {
+ if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) {
error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name);
return true;
}
return false;
}
function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
- if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) {
+ if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */)) {
if (isPrimitiveTypeName(name)) {
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 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
- if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) {
+ var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
+ if (symbol && !(symbol.flags & 1024 /* SymbolFlags.NamespaceModule */)) {
var rawName = ts.unescapeLeadingUnderscores(name);
if (isES2015OrLaterConstructorName(name)) {
error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later, rawName);
@@ -49236,7 +50223,7 @@ var ts;
});
if (container && container.members.length === 1) {
var type = getDeclaredTypeOfSymbol(symbol);
- return !!(type.flags & 1048576 /* Union */) && allTypesAssignableToKind(type, 384 /* StringOrNumberLiteral */, /*strict*/ true);
+ return !!(type.flags & 1048576 /* TypeFlags.Union */) && allTypesAssignableToKind(type, 384 /* TypeFlags.StringOrNumberLiteral */, /*strict*/ true);
}
return false;
}
@@ -49253,15 +50240,15 @@ var ts;
return false;
}
function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) {
- if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */ & ~788968 /* Type */)) {
- var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
+ if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~788968 /* SymbolFlags.Type */)) {
+ var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
if (symbol) {
error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name));
return true;
}
}
- else if (meaning & (788968 /* Type */ & ~1024 /* NamespaceModule */ & ~111551 /* Value */)) {
- var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~788968 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
+ else if (meaning & (788968 /* SymbolFlags.Type */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */)) {
+ var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) & ~788968 /* SymbolFlags.Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
if (symbol) {
error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name));
return true;
@@ -49271,29 +50258,29 @@ var ts;
}
function checkResolvedBlockScopedVariable(result, errorLocation) {
var _a;
- ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */));
- if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) {
+ ts.Debug.assert(!!(result.flags & 2 /* SymbolFlags.BlockScopedVariable */ || result.flags & 32 /* SymbolFlags.Class */ || result.flags & 384 /* SymbolFlags.Enum */));
+ if (result.flags & (16 /* SymbolFlags.Function */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 67108864 /* SymbolFlags.Assignment */) && result.flags & 32 /* SymbolFlags.Class */) {
// constructor functions aren't block scoped
return;
}
// Block-scoped variables cannot be used before their definition
- var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 259 /* EnumDeclaration */); });
+ var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* SyntaxKind.EnumDeclaration */); });
if (declaration === undefined)
return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration");
- if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
+ if (!(declaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
var diagnosticMessage = void 0;
var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration));
- if (result.flags & 2 /* BlockScopedVariable */) {
+ if (result.flags & 2 /* SymbolFlags.BlockScopedVariable */) {
diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName);
}
- else if (result.flags & 32 /* Class */) {
+ else if (result.flags & 32 /* SymbolFlags.Class */) {
diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
}
- else if (result.flags & 256 /* RegularEnum */) {
+ else if (result.flags & 256 /* SymbolFlags.RegularEnum */) {
diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName);
}
else {
- ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */));
+ ts.Debug.assert(!!(result.flags & 128 /* SymbolFlags.ConstEnum */));
if (ts.shouldPreserveConstEnums(compilerOptions)) {
diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName);
}
@@ -49314,13 +50301,13 @@ var ts;
}
function getAnyImportSyntax(node) {
switch (node.kind) {
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return node;
- case 266 /* ImportClause */:
+ case 267 /* SyntaxKind.ImportClause */:
return node.parent;
- case 267 /* NamespaceImport */:
+ case 268 /* SyntaxKind.NamespaceImport */:
return node.parent.parent;
- case 269 /* ImportSpecifier */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
return node.parent.parent.parent;
default:
return undefined;
@@ -49345,22 +50332,22 @@ var ts;
* const { x } = require ...
*/
function isAliasSymbolDeclaration(node) {
- return node.kind === 264 /* ImportEqualsDeclaration */
- || node.kind === 263 /* NamespaceExportDeclaration */
- || node.kind === 266 /* ImportClause */ && !!node.name
- || node.kind === 267 /* NamespaceImport */
- || node.kind === 273 /* NamespaceExport */
- || node.kind === 269 /* ImportSpecifier */
- || node.kind === 274 /* ExportSpecifier */
- || node.kind === 270 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node)
- || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && ts.exportAssignmentIsAlias(node)
+ return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */
+ || node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */
+ || node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name
+ || node.kind === 268 /* SyntaxKind.NamespaceImport */
+ || node.kind === 274 /* SyntaxKind.NamespaceExport */
+ || node.kind === 270 /* SyntaxKind.ImportSpecifier */
+ || node.kind === 275 /* SyntaxKind.ExportSpecifier */
+ || node.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.exportAssignmentIsAlias(node)
+ || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && ts.exportAssignmentIsAlias(node)
|| ts.isAccessExpression(node)
&& ts.isBinaryExpression(node.parent)
&& node.parent.left === node
- && node.parent.operatorToken.kind === 63 /* EqualsToken */
+ && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */
&& isAliasableOrJsExpression(node.parent.right)
- || node.kind === 295 /* ShorthandPropertyAssignment */
- || node.kind === 294 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
+ || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */
+ || node.kind === 296 /* SyntaxKind.PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
|| ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
}
function isAliasableOrJsExpression(e) {
@@ -49374,7 +50361,7 @@ var ts;
? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText))
: undefined;
}
- if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 276 /* ExternalModuleReference */) {
+ if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) {
var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node));
var resolved_4 = resolveExternalModuleSymbol(immediate);
markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, /*overwriteEmpty*/ false);
@@ -49387,7 +50374,7 @@ var ts;
function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) {
if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false) && !node.isTypeOnly) {
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node));
- var isExport = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */;
+ var isExport = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */;
var message = isExport
? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type
: ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type;
@@ -49399,14 +50386,14 @@ var ts;
}
}
function resolveExportByName(moduleSymbol, name, sourceNode, dontResolveAlias) {
- var exportValue = moduleSymbol.exports.get("export=" /* ExportEquals */);
+ var exportValue = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */);
var exportSymbol = exportValue ? getPropertyOfType(getTypeOfSymbol(exportValue), name) : moduleSymbol.exports.get(name);
var resolved = resolveSymbol(exportSymbol, dontResolveAlias);
markSymbolOfAliasDeclarationIfTypeOnly(sourceNode, exportSymbol, resolved, /*overwriteEmpty*/ false);
return resolved;
}
function isSyntacticDefault(node) {
- return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node));
+ return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node));
}
function getUsageModeForExpression(usage) {
return ts.isStringLiteralLike(usage) ? ts.getModeForUsageLocation(ts.getSourceFileOfNode(usage), usage) : undefined;
@@ -49416,7 +50403,7 @@ var ts;
}
function isOnlyImportedAsDefault(usage) {
var usageMode = getUsageModeForExpression(usage);
- return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Json */);
+ return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Extension.Json */);
}
function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
var usageMode = file && getUsageModeForExpression(usage);
@@ -49433,7 +50420,7 @@ var ts;
// Declaration files (and ambient modules)
if (!file || file.isDeclarationFile) {
// Definitely cannot have a synthetic default if they have a syntactic default member specified
- var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration
+ var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration
if (defaultExportSymbol && ts.some(defaultExportSymbol.declarations, isSyntacticDefault)) {
return false;
}
@@ -49465,7 +50452,7 @@ var ts;
exportDefaultSymbol = moduleSymbol;
}
else {
- exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias);
+ exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, node, dontResolveAlias);
}
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
var hasDefaultOnly = isOnlyImportedAsDefault(node.parent.moduleSpecifier);
@@ -49473,7 +50460,7 @@ var ts;
if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
if (hasExportAssignmentSymbol(moduleSymbol)) {
var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
- var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */);
+ var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */);
var exportAssignment = exportEqualsSymbol.valueDeclaration;
var err = error(node.name, ts.Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName);
if (exportAssignment) {
@@ -49501,12 +50488,12 @@ var ts;
}
else {
var diagnostic = error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol));
- var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */);
+ var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */);
if (exportStar) {
var defaultExport = (_c = exportStar.declarations) === null || _c === void 0 ? void 0 : _c.find(function (decl) {
var _a, _b;
return !!(ts.isExportDeclaration(decl) && decl.moduleSpecifier &&
- ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */)));
+ ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */)));
});
if (defaultExport) {
ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(defaultExport, ts.Diagnostics.export_Asterisk_does_not_re_export_a_default));
@@ -49550,7 +50537,7 @@ var ts;
if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) {
return unknownSymbol;
}
- if (valueSymbol.flags & (788968 /* Type */ | 1920 /* Namespace */)) {
+ if (valueSymbol.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) {
return valueSymbol;
}
var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName);
@@ -49565,7 +50552,7 @@ var ts;
return result;
}
function getExportOfModule(symbol, name, specifier, dontResolveAlias) {
- if (symbol.flags & 1536 /* Module */) {
+ if (symbol.flags & 1536 /* SymbolFlags.Module */) {
var exportSymbol = getExportsOfSymbol(symbol).get(name.escapedText);
var resolved = resolveSymbol(exportSymbol, dontResolveAlias);
markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, /*overwriteEmpty*/ false);
@@ -49573,7 +50560,7 @@ var ts;
}
}
function getPropertyOfVariable(symbol, name) {
- if (symbol.flags & 3 /* Variable */) {
+ if (symbol.flags & 3 /* SymbolFlags.Variable */) {
var typeAnnotation = symbol.valueDeclaration.type;
if (typeAnnotation) {
return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name));
@@ -49589,7 +50576,7 @@ var ts;
if (!ts.isIdentifier(name)) {
return undefined;
}
- var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions));
+ var suppressInteropError = name.escapedText === "default" /* InternalSymbolName.Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions));
var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError);
if (targetSymbol) {
if (name.escapedText) {
@@ -49598,7 +50585,7 @@ var ts;
}
var symbolFromVariable = void 0;
// First check if module was specified with "export=". If so, get the member from the resolved type
- if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* ExportEquals */)) {
+ if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */)) {
symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.escapedText, /*skipObjectFunctionPropertyAugment*/ true);
}
else {
@@ -49607,7 +50594,7 @@ var ts;
// if symbolFromVariable is export - get its final target
symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias);
var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
- if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) {
+ if (symbolFromModule === undefined && name.escapedText === "default" /* InternalSymbolName.Default */) {
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
@@ -49628,7 +50615,7 @@ var ts;
}
}
else {
- if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */)) {
+ if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */)) {
error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName);
}
else {
@@ -49645,7 +50632,7 @@ var ts;
var localSymbol = (_b = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals) === null || _b === void 0 ? void 0 : _b.get(name.escapedText);
var exports = moduleSymbol.exports;
if (localSymbol) {
- var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* ExportEquals */);
+ var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* InternalSymbolName.ExportEquals */);
if (exportedEqualsSymbol) {
getSymbolIfSameReference(exportedEqualsSymbol, localSymbol) ? reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) :
error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName);
@@ -49725,7 +50712,7 @@ var ts;
if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) {
return undefined;
}
- var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias);
+ var aliasLike = resolveEntityName(expression, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontResolveAlias);
if (aliasLike) {
return aliasLike;
}
@@ -49737,7 +50724,7 @@ var ts;
return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve);
}
function getTargetOfAccessExpression(node, dontRecursivelyResolve) {
- if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) {
+ if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) {
return undefined;
}
return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve);
@@ -49745,31 +50732,31 @@ var ts;
function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) {
if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; }
switch (node.kind) {
- case 264 /* ImportEqualsDeclaration */:
- case 253 /* VariableDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve);
- case 266 /* ImportClause */:
+ case 267 /* SyntaxKind.ImportClause */:
return getTargetOfImportClause(node, dontRecursivelyResolve);
- case 267 /* NamespaceImport */:
+ case 268 /* SyntaxKind.NamespaceImport */:
return getTargetOfNamespaceImport(node, dontRecursivelyResolve);
- case 273 /* NamespaceExport */:
+ case 274 /* SyntaxKind.NamespaceExport */:
return getTargetOfNamespaceExport(node, dontRecursivelyResolve);
- case 269 /* ImportSpecifier */:
- case 202 /* BindingElement */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
+ case 203 /* SyntaxKind.BindingElement */:
return getTargetOfImportSpecifier(node, dontRecursivelyResolve);
- case 274 /* ExportSpecifier */:
- return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve);
- case 270 /* ExportAssignment */:
- case 220 /* BinaryExpression */:
+ case 275 /* SyntaxKind.ExportSpecifier */:
+ return getTargetOfExportSpecifier(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, dontRecursivelyResolve);
+ case 271 /* SyntaxKind.ExportAssignment */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return getTargetOfExportAssignment(node, dontRecursivelyResolve);
- case 263 /* NamespaceExportDeclaration */:
+ case 264 /* SyntaxKind.NamespaceExportDeclaration */:
return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve);
- case 295 /* ShorthandPropertyAssignment */:
- return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve);
- case 294 /* PropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
+ return resolveEntityName(node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve);
+ case 296 /* SyntaxKind.PropertyAssignment */:
return getTargetOfPropertyAssignment(node, dontRecursivelyResolve);
- case 206 /* ElementAccessExpression */:
- case 205 /* PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
return getTargetOfAccessExpression(node, dontRecursivelyResolve);
default:
return ts.Debug.fail();
@@ -49780,38 +50767,38 @@ var ts;
* OR Is a JSContainer which may merge an alias with a local declaration
*/
function isNonLocalAlias(symbol, excludes) {
- if (excludes === void 0) { excludes = 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */; }
+ if (excludes === void 0) { excludes = 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */; }
if (!symbol)
return false;
- return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* Assignment */);
+ return (symbol.flags & (2097152 /* SymbolFlags.Alias */ | excludes)) === 2097152 /* SymbolFlags.Alias */ || !!(symbol.flags & 2097152 /* SymbolFlags.Alias */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */);
}
function resolveSymbol(symbol, dontResolveAlias) {
return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol;
}
function resolveAlias(symbol) {
- ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here.");
+ ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here.");
var links = getSymbolLinks(symbol);
- if (!links.target) {
- links.target = resolvingSymbol;
+ if (!links.aliasTarget) {
+ links.aliasTarget = resolvingSymbol;
var node = getDeclarationOfAliasSymbol(symbol);
if (!node)
return ts.Debug.fail();
var target = getTargetOfAliasDeclaration(node);
- if (links.target === resolvingSymbol) {
- links.target = target || unknownSymbol;
+ if (links.aliasTarget === resolvingSymbol) {
+ links.aliasTarget = target || unknownSymbol;
}
else {
error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol));
}
}
- else if (links.target === resolvingSymbol) {
- links.target = unknownSymbol;
+ else if (links.aliasTarget === resolvingSymbol) {
+ links.aliasTarget = unknownSymbol;
}
- return links.target;
+ return links.aliasTarget;
}
function tryResolveAlias(symbol) {
var links = getSymbolLinks(symbol);
- if (links.target !== resolvingSymbol) {
+ if (links.aliasTarget !== resolvingSymbol) {
return resolveAlias(symbol);
}
return undefined;
@@ -49854,7 +50841,7 @@ var ts;
function markSymbolOfAliasDeclarationIfTypeOnlyWorker(aliasDeclarationLinks, target, overwriteEmpty) {
var _a, _b, _c;
if (target && (aliasDeclarationLinks.typeOnlyDeclaration === undefined || overwriteEmpty && aliasDeclarationLinks.typeOnlyDeclaration === false)) {
- var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* ExportEquals */)) !== null && _b !== void 0 ? _b : target;
+ var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* InternalSymbolName.ExportEquals */)) !== null && _b !== void 0 ? _b : target;
var typeOnly = exportSymbol.declarations && ts.find(exportSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
aliasDeclarationLinks.typeOnlyDeclaration = (_c = typeOnly !== null && typeOnly !== void 0 ? typeOnly : getSymbolLinks(exportSymbol).typeOnlyDeclaration) !== null && _c !== void 0 ? _c : false;
}
@@ -49862,7 +50849,7 @@ var ts;
}
/** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */
function getTypeOnlyAliasDeclaration(symbol) {
- if (!(symbol.flags & 2097152 /* Alias */)) {
+ if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) {
return undefined;
}
var links = getSymbolLinks(symbol);
@@ -49873,7 +50860,7 @@ var ts;
var target = resolveAlias(symbol);
if (target) {
var markAlias = target === unknownSymbol ||
- ((target.flags & 111551 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol));
+ ((target.flags & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol));
if (markAlias) {
markAliasSymbolAsReferenced(symbol);
}
@@ -49894,7 +50881,7 @@ var ts;
// position.
if (ts.isInternalModuleImportEqualsDeclaration(node)) {
var target = resolveSymbol(symbol);
- if (target === unknownSymbol || target.flags & 111551 /* Value */) {
+ if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
// import foo = <symbol>
checkExpressionCached(node.moduleReference);
}
@@ -49917,22 +50904,22 @@ var ts;
// import a = |b|; // Namespace
// import a = |b.c|; // Value, type, namespace
// import a = |b.c|.d; // Namespace
- if (entityName.kind === 79 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) {
+ if (entityName.kind === 79 /* SyntaxKind.Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) {
entityName = entityName.parent;
}
// Check for case 1 and 3 in the above example
- if (entityName.kind === 79 /* Identifier */ || entityName.parent.kind === 160 /* QualifiedName */) {
- return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias);
+ if (entityName.kind === 79 /* SyntaxKind.Identifier */ || entityName.parent.kind === 161 /* SyntaxKind.QualifiedName */) {
+ return resolveEntityName(entityName, 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias);
}
else {
// Case 2 in above example
// entityName.kind could be a QualifiedName or a Missing identifier
- ts.Debug.assert(entityName.parent.kind === 264 /* ImportEqualsDeclaration */);
- return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias);
+ ts.Debug.assert(entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */);
+ return resolveEntityName(entityName, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias);
}
}
function getFullyQualifiedName(symbol, containingLocation) {
- return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* DoNotIncludeSymbolChain */ | 4 /* AllowAnyNodeKind */);
+ return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */);
}
function getContainingQualifiedNameNode(node) {
while (ts.isQualifiedName(node.parent)) {
@@ -49942,7 +50929,7 @@ var ts;
}
function tryGetQualifiedNameAsValue(node) {
var left = ts.getFirstIdentifier(node);
- var symbol = resolveName(left, left.escapedText, 111551 /* Value */, undefined, left, /*isUse*/ true);
+ var symbol = resolveName(left, left.escapedText, 111551 /* SymbolFlags.Value */, undefined, left, /*isUse*/ true);
if (!symbol) {
return undefined;
}
@@ -49963,9 +50950,9 @@ var ts;
if (ts.nodeIsMissing(name)) {
return undefined;
}
- var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0);
+ var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* SymbolFlags.Value */ : 0);
var symbol;
- if (name.kind === 79 /* Identifier */) {
+ if (name.kind === 79 /* SyntaxKind.Identifier */) {
var message = meaning === namespaceMeaning || ts.nodeIsSynthesized(name) ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name));
var symbolFromJSPrototype = ts.isInJSFile(name) && !ts.nodeIsSynthesized(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined;
symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true, false));
@@ -49973,9 +50960,9 @@ var ts;
return getMergedSymbol(symbolFromJSPrototype);
}
}
- else if (name.kind === 160 /* QualifiedName */ || name.kind === 205 /* PropertyAccessExpression */) {
- var left = name.kind === 160 /* QualifiedName */ ? name.left : name.expression;
- var right = name.kind === 160 /* QualifiedName */ ? name.right : name.name;
+ else if (name.kind === 161 /* SyntaxKind.QualifiedName */ || name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) {
+ var left = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.left : name.expression;
+ var right = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right : name.name;
var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location);
if (!namespace || ts.nodeIsMissing(right)) {
return undefined;
@@ -50009,7 +50996,7 @@ var ts;
}
var containingQualifiedName = ts.isQualifiedName(name) && getContainingQualifiedNameNode(name);
var canSuggestTypeof = globalObjectType // <-- can't pull on types if global types aren't initialized yet
- && (meaning & 788968 /* Type */)
+ && (meaning & 788968 /* SymbolFlags.Type */)
&& containingQualifiedName
&& !ts.isTypeOfExpression(containingQualifiedName.parent)
&& tryGetQualifiedNameAsValue(containingQualifiedName);
@@ -50017,8 +51004,8 @@ var ts;
error(containingQualifiedName, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.entityNameToString(containingQualifiedName));
return undefined;
}
- if (meaning & 1920 /* Namespace */ && ts.isQualifiedName(name.parent)) {
- var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* Type */));
+ if (meaning & 1920 /* SymbolFlags.Namespace */ && ts.isQualifiedName(name.parent)) {
+ var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* SymbolFlags.Type */));
if (exportedTypeSymbol) {
error(name.parent.right, ts.Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, symbolToString(exportedTypeSymbol), ts.unescapeLeadingUnderscores(name.parent.right.escapedText));
return undefined;
@@ -50032,8 +51019,8 @@ var ts;
else {
throw ts.Debug.assertNever(name, "Unknown entity name kind.");
}
- ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here.");
- if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 270 /* ExportAssignment */)) {
+ ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here.");
+ if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* SymbolFlags.Alias */ || name.parent.kind === 271 /* SyntaxKind.ExportAssignment */)) {
markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ true);
}
return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol);
@@ -50053,7 +51040,7 @@ var ts;
}
}
function getAssignmentDeclarationLocation(node) {
- var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); });
+ var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* NodeFlags.JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); });
if (typeAlias) {
return;
}
@@ -50074,7 +51061,7 @@ var ts;
}
if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) &&
ts.isBinaryExpression(host.parent.parent) &&
- ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* Prototype */) {
+ ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) {
// X.prototype = { /** @param {K} p */m() { } } <-- look for K on X's declaration
var symbol = getSymbolOfNode(host.parent.parent.left);
if (symbol) {
@@ -50105,7 +51092,7 @@ var ts;
*/
function getExpandoSymbol(symbol) {
var decl = symbol.valueDeclaration;
- if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) {
+ if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* SymbolFlags.TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) {
return undefined;
}
var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl);
@@ -50130,7 +51117,7 @@ var ts;
: undefined;
}
function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
- var _a, _b, _c, _d, _e, _f, _g;
+ var _a, _b, _c, _d, _e, _f, _g, _h;
if (isForAugmentation === void 0) { isForAugmentation = false; }
if (ts.startsWith(moduleReference, "@types/")) {
var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
@@ -50165,14 +51152,15 @@ var ts;
if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference);
}
- if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) {
+ if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) {
var isSyncImport = (currentSourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS && !ts.findAncestor(location, ts.isImportCall)) || !!ts.findAncestor(location, ts.isImportEqualsDeclaration);
- if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
+ 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;
+ // An override clause will take effect for type-only imports and import types, and allows importing the types across formats, regardless of
+ // normal mode restrictions
+ 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 (mode === ts.ModuleKind.ESNext && compilerOptions.resolveJsonModule && resolvedModule.extension === ".json" /* Json */) {
- error(errorNode, ts.Diagnostics.JSON_imports_are_experimental_in_ES_module_mode_imports);
- }
}
// merged symbol is module declaration symbol combined with all augmentations
return getMergedSymbol(sourceFile.symbol);
@@ -50225,7 +51213,7 @@ var ts;
var tsExtension = ts.tryExtractTSExtension(moduleReference);
var isExtensionlessRelativePathImport = ts.pathIsRelative(moduleReference) && !ts.hasExtension(moduleReference);
var moduleResolutionKind = ts.getEmitModuleResolutionKind(compilerOptions);
- var resolutionIsNode12OrNext = moduleResolutionKind === ts.ModuleResolutionKind.Node12 ||
+ var resolutionIsNode16OrNext = moduleResolutionKind === ts.ModuleResolutionKind.Node16 ||
moduleResolutionKind === ts.ModuleResolutionKind.NodeNext;
if (tsExtension) {
var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead;
@@ -50236,27 +51224,27 @@ var ts;
* @see https://github.com/microsoft/TypeScript/issues/42151
*/
if (moduleKind >= ts.ModuleKind.ES2015) {
- replacedImportSource += tsExtension === ".mts" /* Mts */ ? ".mjs" : tsExtension === ".cts" /* Cts */ ? ".cjs" : ".js";
+ replacedImportSource += tsExtension === ".mts" /* Extension.Mts */ ? ".mjs" : tsExtension === ".cts" /* Extension.Cts */ ? ".cjs" : ".js";
}
error(errorNode, diag, tsExtension, replacedImportSource);
}
else if (!compilerOptions.resolveJsonModule &&
- ts.fileExtensionIs(moduleReference, ".json" /* Json */) &&
+ ts.fileExtensionIs(moduleReference, ".json" /* Extension.Json */) &&
ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic &&
ts.hasJsonModuleEmitEnabled(compilerOptions)) {
error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
}
- else if (mode === ts.ModuleKind.ESNext && resolutionIsNode12OrNext && isExtensionlessRelativePathImport) {
+ else if (mode === ts.ModuleKind.ESNext && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) {
var absoluteRef_1 = ts.getNormalizedAbsolutePath(moduleReference, ts.getDirectoryPath(currentSourceFile.path));
- var suggestedExt = (_g = suggestedExtensions.find(function (_a) {
+ var suggestedExt = (_h = suggestedExtensions.find(function (_a) {
var actualExt = _a[0], _importExt = _a[1];
return host.fileExists(absoluteRef_1 + actualExt);
- })) === null || _g === void 0 ? void 0 : _g[1];
+ })) === null || _h === void 0 ? void 0 : _h[1];
if (suggestedExt) {
- error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt);
+ error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt);
}
else {
- error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path);
+ error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path);
}
}
else {
@@ -50288,27 +51276,27 @@ var ts;
}
function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) {
if (moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.exports) {
- var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias);
+ var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */), dontResolveAlias);
var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol));
return getMergedSymbol(exported) || moduleSymbol;
}
return undefined;
}
function getCommonJsExportEquals(exported, moduleSymbol) {
- if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) {
+ if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* SymbolFlags.Alias */) {
return exported;
}
var links = getSymbolLinks(exported);
if (links.cjsExportMerged) {
return links.cjsExportMerged;
}
- var merged = exported.flags & 33554432 /* Transient */ ? exported : cloneSymbol(exported);
- merged.flags = merged.flags | 512 /* ValueModule */;
+ var merged = exported.flags & 33554432 /* SymbolFlags.Transient */ ? exported : cloneSymbol(exported);
+ merged.flags = merged.flags | 512 /* SymbolFlags.ValueModule */;
if (merged.exports === undefined) {
merged.exports = ts.createSymbolTable();
}
moduleSymbol.exports.forEach(function (s, name) {
- if (name === "export=" /* ExportEquals */)
+ if (name === "export=" /* InternalSymbolName.ExportEquals */)
return;
merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s);
});
@@ -50319,9 +51307,10 @@ var ts;
// references a symbol that is at least declared as a module or a variable. The target of the 'export =' may
// combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable).
function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) {
+ var _a;
var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias);
if (!dontResolveAlias && symbol) {
- if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 303 /* SourceFile */)) {
+ if (!suppressInteropError && !(symbol.flags & (1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */)) && !ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */)) {
var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015
? "allowSyntheticDefaultImports"
: "esModuleInterop";
@@ -50337,12 +51326,16 @@ var ts;
if (defaultOnlyType) {
return cloneTypeAsModuleType(symbol, defaultOnlyType, referenceParent);
}
- if (ts.getESModuleInterop(compilerOptions)) {
- var sigs = getSignaturesOfStructuredType(type, 0 /* Call */);
+ var targetFile = (_a = moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
+ var isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getUsageModeForExpression(reference), targetFile.impliedNodeFormat);
+ if (ts.getESModuleInterop(compilerOptions) || isEsmCjsRef) {
+ var sigs = getSignaturesOfStructuredType(type, 0 /* SignatureKind.Call */);
if (!sigs || !sigs.length) {
- sigs = getSignaturesOfStructuredType(type, 1 /* Construct */);
+ sigs = getSignaturesOfStructuredType(type, 1 /* SignatureKind.Construct */);
}
- if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */, /*skipObjectFunctionPropertyAugment*/ true)) {
+ if ((sigs && sigs.length) ||
+ getPropertyOfType(type, "default" /* InternalSymbolName.Default */, /*skipObjectFunctionPropertyAugment*/ true) ||
+ isEsmCjsRef) {
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference);
return cloneTypeAsModuleType(symbol, moduleType, referenceParent);
}
@@ -50373,7 +51366,7 @@ var ts;
return result;
}
function hasExportAssignmentSymbol(moduleSymbol) {
- return moduleSymbol.exports.get("export=" /* ExportEquals */) !== undefined;
+ return moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */) !== undefined;
}
function getExportsOfModuleAsArray(moduleSymbol) {
return symbolsToArray(getExportsOfModule(moduleSymbol));
@@ -50425,15 +51418,15 @@ var ts;
return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type, memberName) : undefined;
}
function shouldTreatPropertiesOfExternalModuleAsExports(resolvedExternalModuleType) {
- return !(resolvedExternalModuleType.flags & 131068 /* Primitive */ ||
- ts.getObjectFlags(resolvedExternalModuleType) & 1 /* Class */ ||
+ return !(resolvedExternalModuleType.flags & 131068 /* TypeFlags.Primitive */ ||
+ ts.getObjectFlags(resolvedExternalModuleType) & 1 /* ObjectFlags.Class */ ||
// `isArrayOrTupleLikeType` is too expensive to use in this auto-imports hot path
isArrayType(resolvedExternalModuleType) ||
isTupleType(resolvedExternalModuleType));
}
function getExportsOfSymbol(symbol) {
- return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) :
- symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) :
+ return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */) :
+ symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModule(symbol) :
symbol.exports || emptySymbols;
}
function getExportsOfModule(moduleSymbol) {
@@ -50448,7 +51441,7 @@ var ts;
if (!source)
return;
source.forEach(function (sourceSymbol, id) {
- if (id === "default" /* Default */)
+ if (id === "default" /* InternalSymbolName.Default */)
return;
var targetSymbol = target.get(id);
if (!targetSymbol) {
@@ -50483,7 +51476,7 @@ var ts;
}
var symbols = new ts.Map(symbol.exports);
// All export * declarations are collected in an __export symbol by the binder
- var exportStars = symbol.exports.get("__export" /* ExportStar */);
+ var exportStars = symbol.exports.get("__export" /* InternalSymbolName.ExportStar */);
if (exportStars) {
var nestedSymbols = ts.createSymbolTable();
var lookupTable_1 = new ts.Map();
@@ -50572,21 +51565,21 @@ var ts;
function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) {
var container = getParentOfSymbol(symbol);
// Type parameters end up in the `members` lists but are not externally visible
- if (container && !(symbol.flags & 262144 /* TypeParameter */)) {
+ if (container && !(symbol.flags & 262144 /* SymbolFlags.TypeParameter */)) {
var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
var objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning);
if (enclosingDeclaration &&
container.flags & getQualifiedLeftMeaning(meaning) &&
- getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) {
+ getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */, /*externalOnly*/ false)) {
return ts.append(ts.concatenate(ts.concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer); // This order expresses a preference for the real container if it is in scope
}
// we potentially have a symbol which is a member of the instance side of something - look for a variable in scope with the container's type
// which may be acting like a namespace (eg, `Symbol` acts like a namespace when looking up `Symbol.toStringTag`)
var firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning))
- && container.flags & 788968 /* Type */
- && getDeclaredTypeOfSymbol(container).flags & 524288 /* Object */
- && meaning === 111551 /* Value */
+ && container.flags & 788968 /* SymbolFlags.Type */
+ && getDeclaredTypeOfSymbol(container).flags & 524288 /* TypeFlags.Object */
+ && meaning === 111551 /* SymbolFlags.Value */
? forEachSymbolTableInScope(enclosingDeclaration, function (t) {
return ts.forEachEntry(t, function (s) {
if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) {
@@ -50600,10 +51593,17 @@ var ts;
return res;
}
var candidates = ts.mapDefined(symbol.declarations, function (d) {
- if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) {
- return getSymbolOfNode(d.parent);
+ if (!ts.isAmbientModule(d) && d.parent) {
+ // direct children of a module
+ if (hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) {
+ return getSymbolOfNode(d.parent);
+ }
+ // export ='d member of an ambient module
+ if (ts.isModuleBlock(d.parent) && d.parent.parent && resolveExternalModuleSymbol(getSymbolOfNode(d.parent.parent)) === symbol) {
+ return getSymbolOfNode(d.parent.parent);
+ }
}
- if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) {
+ if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) {
if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) {
return getSymbolOfNode(ts.getSourceFileOfNode(d));
}
@@ -50624,7 +51624,7 @@ var ts;
// from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however,
// we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal.
var firstDecl = !!ts.length(symbol.declarations) && ts.first(symbol.declarations);
- if (meaning & 111551 /* Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) {
+ if (meaning & 111551 /* SymbolFlags.Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) {
if (ts.isObjectLiteralExpression(firstDecl) && firstDecl === firstDecl.parent.initializer || ts.isTypeLiteralNode(firstDecl) && firstDecl === firstDecl.parent.type) {
return getSymbolOfNode(firstDecl.parent);
}
@@ -50632,7 +51632,7 @@ var ts;
}
function getFileSymbolIfFileSymbolExportEqualsContainer(d, container) {
var fileSymbol = getExternalModuleContainer(d);
- var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */);
+ var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */);
return exported && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined;
}
function getAliasForSymbolInContainer(container, symbol) {
@@ -50642,7 +51642,7 @@ var ts;
}
// Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return
// the container itself as the alias for the symbol
- var exportEquals = container.exports && container.exports.get("export=" /* ExportEquals */);
+ var exportEquals = container.exports && container.exports.get("export=" /* InternalSymbolName.ExportEquals */);
if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) {
return container;
}
@@ -50666,16 +51666,16 @@ var ts;
}
}
function getExportSymbolOfValueSymbolIfExported(symbol) {
- return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? symbol.exportSymbol : symbol);
+ return getMergedSymbol(symbol && (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) !== 0 && symbol.exportSymbol || symbol);
}
function symbolIsValue(symbol) {
- return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */ && !getTypeOnlyAliasDeclaration(symbol));
+ return !!(symbol.flags & 111551 /* SymbolFlags.Value */ || symbol.flags & 2097152 /* SymbolFlags.Alias */ && resolveAlias(symbol).flags & 111551 /* SymbolFlags.Value */ && !getTypeOnlyAliasDeclaration(symbol));
}
function findConstructorDeclaration(node) {
var members = node.members;
for (var _i = 0, members_3 = members; _i < members_3.length; _i++) {
var member = members_3[_i];
- if (member.kind === 170 /* Constructor */ && ts.nodeIsPresent(member.body)) {
+ if (member.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(member.body)) {
return member;
}
}
@@ -50684,9 +51684,7 @@ var ts;
var result = new Type(checker, flags);
typeCount++;
result.id = typeCount;
- if (produceDiagnostics) { // Only record types from one checker
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.recordType(result);
- }
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.recordType(result);
return result;
}
function createOriginType(flags) {
@@ -50700,7 +51698,7 @@ var ts;
return type;
}
function createObjectType(objectFlags, symbol) {
- var type = createType(524288 /* Object */);
+ var type = createType(524288 /* TypeFlags.Object */);
type.objectFlags = objectFlags;
type.symbol = symbol;
type.members = undefined;
@@ -50714,7 +51712,7 @@ var ts;
return getUnionType(ts.arrayFrom(typeofEQFacts.keys(), getStringLiteralType));
}
function createTypeParameter(symbol) {
- var type = createType(262144 /* TypeParameter */);
+ var type = createType(262144 /* TypeFlags.TypeParameter */);
if (symbol)
type.symbol = symbol;
return type;
@@ -50724,11 +51722,11 @@ var ts;
// with at least two underscores. The @ character indicates that the name is denoted by a well known ES
// Symbol instance and the # character indicates that the name is a PrivateIdentifier.
function isReservedMemberName(name) {
- return name.charCodeAt(0) === 95 /* _ */ &&
- name.charCodeAt(1) === 95 /* _ */ &&
- name.charCodeAt(2) !== 95 /* _ */ &&
- name.charCodeAt(2) !== 64 /* at */ &&
- name.charCodeAt(2) !== 35 /* hash */;
+ return name.charCodeAt(0) === 95 /* CharacterCodes._ */ &&
+ name.charCodeAt(1) === 95 /* CharacterCodes._ */ &&
+ name.charCodeAt(2) !== 95 /* CharacterCodes._ */ &&
+ name.charCodeAt(2) !== 64 /* CharacterCodes.at */ &&
+ name.charCodeAt(2) !== 35 /* CharacterCodes.hash */;
}
function getNamedMembers(members) {
var result;
@@ -50760,14 +51758,14 @@ var ts;
return resolved;
}
function createAnonymousType(symbol, members, callSignatures, constructSignatures, indexInfos) {
- return setStructuredTypeMembers(createObjectType(16 /* Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos);
+ return setStructuredTypeMembers(createObjectType(16 /* ObjectFlags.Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos);
}
function getResolvedTypeWithoutAbstractConstructSignatures(type) {
if (type.constructSignatures.length === 0)
return type;
if (type.objectTypeWithoutAbstractConstructSignatures)
return type.objectTypeWithoutAbstractConstructSignatures;
- var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* Abstract */); });
+ var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* SignatureFlags.Abstract */); });
if (type.constructSignatures === constructSignatures)
return type;
var typeCopy = createAnonymousType(type.symbol, type.members, type.callSignatures, ts.some(constructSignatures) ? constructSignatures : ts.emptyArray, type.indexInfos);
@@ -50785,12 +51783,12 @@ var ts;
}
}
switch (location.kind) {
- case 303 /* SourceFile */:
+ case 305 /* SyntaxKind.SourceFile */:
if (!ts.isExternalOrCommonJsModule(location)) {
break;
}
// falls through
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
var sym = getSymbolOfNode(location);
// `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten
// into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred
@@ -50799,9 +51797,9 @@ var ts;
return { value: result };
}
break;
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- case 257 /* InterfaceDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
// Type parameters are bound into `members` lists so they can merge across declarations
// This is troublesome, since in all other respects, they behave like locals :cries:
// TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol
@@ -50812,7 +51810,7 @@ var ts;
var table_1;
// TODO: Should this filtered table be cached in some way?
(getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) {
- if (memberSymbol.flags & (788968 /* Type */ & ~67108864 /* Assignment */)) {
+ if (memberSymbol.flags & (788968 /* SymbolFlags.Type */ & ~67108864 /* SymbolFlags.Assignment */)) {
(table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol);
}
});
@@ -50831,7 +51829,7 @@ var ts;
}
function getQualifiedLeftMeaning(rightMeaning) {
// If we are looking in value space, the parent meaning is value, other wise it is namespace
- return rightMeaning === 111551 /* Value */ ? 111551 /* Value */ : 1920 /* Namespace */;
+ return rightMeaning === 111551 /* SymbolFlags.Value */ ? 111551 /* SymbolFlags.Value */ : 1920 /* SymbolFlags.Namespace */;
}
function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) {
if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = new ts.Map(); }
@@ -50886,9 +51884,9 @@ var ts;
}
// Check if symbol is any of the aliases in scope
var result = ts.forEachEntry(symbols, function (symbolFromSymbolTable) {
- if (symbolFromSymbolTable.flags & 2097152 /* Alias */
- && symbolFromSymbolTable.escapedName !== "export=" /* ExportEquals */
- && symbolFromSymbolTable.escapedName !== "default" /* Default */
+ if (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */
+ && symbolFromSymbolTable.escapedName !== "export=" /* InternalSymbolName.ExportEquals */
+ && symbolFromSymbolTable.escapedName !== "default" /* InternalSymbolName.Default */
&& !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration)))
// If `!useOnlyExternalAliasing`, we can use any type of alias to get the name
&& (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration))
@@ -50896,7 +51894,7 @@ var ts;
&& (isLocalNameLookup ? !ts.some(symbolFromSymbolTable.declarations, ts.isNamespaceReexportDeclaration) : true)
// While exports are generally considered to be in scope, export-specifier declared symbols are _not_
// See similar comment in `resolveName` for details
- && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 274 /* ExportSpecifier */))) {
+ && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */))) {
var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable);
var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification);
if (candidate) {
@@ -50940,7 +51938,7 @@ var ts;
return true;
}
// Qualify if the symbol from symbol table has same meaning as expected
- symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 274 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
+ symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
if (symbolFromSymbolTable.flags & meaning) {
qualify = true;
return true;
@@ -50955,10 +51953,10 @@ var ts;
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var declaration = _a[_i];
switch (declaration.kind) {
- case 166 /* PropertyDeclaration */:
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
continue;
default:
return false;
@@ -50969,16 +51967,16 @@ var ts;
return false;
}
function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) {
- var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true);
- return access.accessibility === 0 /* Accessible */;
+ var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* SymbolFlags.Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true);
+ return access.accessibility === 0 /* SymbolAccessibility.Accessible */;
}
function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) {
- var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true);
- return access.accessibility === 0 /* Accessible */;
+ var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* SymbolFlags.Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true);
+ return access.accessibility === 0 /* SymbolAccessibility.Accessible */;
}
function isSymbolAccessibleByFlags(typeSymbol, enclosingDeclaration, flags) {
var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, flags, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ false);
- return access.accessibility === 0 /* Accessible */;
+ return access.accessibility === 0 /* SymbolAccessibility.Accessible */;
}
function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible, allowModules) {
if (!ts.length(symbols))
@@ -51008,7 +52006,7 @@ var ts;
}
// Any meaning of a module symbol is always accessible via an `import` type
return {
- accessibility: 0 /* Accessible */
+ accessibility: 0 /* SymbolAccessibility.Accessible */
};
}
}
@@ -51032,14 +52030,14 @@ var ts;
}
if (earlyModuleBail) {
return {
- accessibility: 0 /* Accessible */
+ accessibility: 0 /* SymbolAccessibility.Accessible */
};
}
if (hadAccessibleChain) {
return {
- accessibility: 1 /* NotAccessible */,
+ accessibility: 1 /* SymbolAccessibility.NotAccessible */,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
- errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* Namespace */) : undefined,
+ errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */) : undefined,
};
}
}
@@ -51068,7 +52066,7 @@ var ts;
if (symbolExternalModule !== enclosingExternalModule) {
// name from different external module that is not visible
return {
- accessibility: 2 /* CannotBeNamed */,
+ accessibility: 2 /* SymbolAccessibility.CannotBeNamed */,
errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
errorModuleName: symbolToString(symbolExternalModule),
errorNode: ts.isInJSFile(enclosingDeclaration) ? enclosingDeclaration : undefined,
@@ -51077,28 +52075,28 @@ var ts;
}
// Just a local name that is not accessible
return {
- accessibility: 1 /* NotAccessible */,
+ accessibility: 1 /* SymbolAccessibility.NotAccessible */,
errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
};
}
- return { accessibility: 0 /* Accessible */ };
+ return { accessibility: 0 /* SymbolAccessibility.Accessible */ };
}
function getExternalModuleContainer(declaration) {
var node = ts.findAncestor(declaration, hasExternalModuleSymbol);
return node && getSymbolOfNode(node);
}
function hasExternalModuleSymbol(declaration) {
- return ts.isAmbientModule(declaration) || (declaration.kind === 303 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration));
+ return ts.isAmbientModule(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration));
}
function hasNonGlobalAugmentationExternalModuleSymbol(declaration) {
- return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 303 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration));
+ return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration));
}
function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) {
var aliasesToMakeVisible;
- if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* Identifier */; }), getIsDeclarationVisible)) {
+ if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* SyntaxKind.Identifier */; }), getIsDeclarationVisible)) {
return undefined;
}
- return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible };
+ return { accessibility: 0 /* SymbolAccessibility.Accessible */, aliasesToMakeVisible: aliasesToMakeVisible };
function getIsDeclarationVisible(declaration) {
var _a, _b;
if (!isDeclarationVisible(declaration)) {
@@ -51106,24 +52104,24 @@ var ts;
// because these kind of aliases can be used to name types in declaration file
var anyImportSyntax = getAnyImportSyntax(declaration);
if (anyImportSyntax &&
- !ts.hasSyntacticModifier(anyImportSyntax, 1 /* Export */) && // import clause without export
+ !ts.hasSyntacticModifier(anyImportSyntax, 1 /* ModifierFlags.Export */) && // import clause without export
isDeclarationVisible(anyImportSyntax.parent)) {
return addVisibleAlias(declaration, anyImportSyntax);
}
else if (ts.isVariableDeclaration(declaration) && ts.isVariableStatement(declaration.parent.parent) &&
- !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* Export */) && // unexported variable statement
+ !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* ModifierFlags.Export */) && // unexported variable statement
isDeclarationVisible(declaration.parent.parent.parent)) {
return addVisibleAlias(declaration, declaration.parent.parent);
}
else if (ts.isLateVisibilityPaintedStatement(declaration) // unexported top-level statement
- && !ts.hasSyntacticModifier(declaration, 1 /* Export */)
+ && !ts.hasSyntacticModifier(declaration, 1 /* ModifierFlags.Export */)
&& isDeclarationVisible(declaration.parent)) {
return addVisibleAlias(declaration, declaration);
}
- else if (symbol.flags & 2097152 /* Alias */ && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement
+ else if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement
&& 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 /* Export */)
+ && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* ModifierFlags.Export */)
&& declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file)
&& isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) {
return addVisibleAlias(declaration, declaration.parent.parent.parent.parent);
@@ -51147,83 +52145,83 @@ var ts;
function isEntityNameVisible(entityName, enclosingDeclaration) {
// get symbol of the first identifier of the entityName
var meaning;
- if (entityName.parent.kind === 180 /* TypeQuery */ ||
- ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) ||
- entityName.parent.kind === 161 /* ComputedPropertyName */) {
+ if (entityName.parent.kind === 181 /* SyntaxKind.TypeQuery */ ||
+ entityName.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) ||
+ entityName.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) {
// Typeof value
- meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
+ meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */;
}
- else if (entityName.kind === 160 /* QualifiedName */ || entityName.kind === 205 /* PropertyAccessExpression */ ||
- entityName.parent.kind === 264 /* ImportEqualsDeclaration */) {
+ else if (entityName.kind === 161 /* SyntaxKind.QualifiedName */ || entityName.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ||
+ entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
// Left identifier from type reference or TypeAlias
// Entity name of the import declaration
- meaning = 1920 /* Namespace */;
+ meaning = 1920 /* SymbolFlags.Namespace */;
}
else {
// Type Reference or TypeAlias entity = Identifier
- meaning = 788968 /* Type */;
+ meaning = 788968 /* SymbolFlags.Type */;
}
var firstIdentifier = ts.getFirstIdentifier(entityName);
var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
- if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) {
- return { accessibility: 0 /* Accessible */ };
+ if (symbol && symbol.flags & 262144 /* SymbolFlags.TypeParameter */ && meaning & 788968 /* SymbolFlags.Type */) {
+ return { accessibility: 0 /* SymbolAccessibility.Accessible */ };
}
// Verify if the symbol is accessible
return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || {
- accessibility: 1 /* NotAccessible */,
+ accessibility: 1 /* SymbolAccessibility.NotAccessible */,
errorSymbolName: ts.getTextOfNode(firstIdentifier),
errorNode: firstIdentifier
};
}
function symbolToString(symbol, enclosingDeclaration, meaning, flags, writer) {
- if (flags === void 0) { flags = 4 /* AllowAnyNodeKind */; }
- var nodeFlags = 70221824 /* IgnoreErrors */;
- if (flags & 2 /* UseOnlyExternalAliasing */) {
- nodeFlags |= 128 /* UseOnlyExternalAliasing */;
+ if (flags === void 0) { flags = 4 /* SymbolFormatFlags.AllowAnyNodeKind */; }
+ var nodeFlags = 70221824 /* NodeBuilderFlags.IgnoreErrors */;
+ if (flags & 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */) {
+ nodeFlags |= 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */;
}
- if (flags & 1 /* WriteTypeParametersOrArguments */) {
- nodeFlags |= 512 /* WriteTypeParametersInQualifiedName */;
+ if (flags & 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */) {
+ nodeFlags |= 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */;
}
- if (flags & 8 /* UseAliasDefinedOutsideCurrentScope */) {
- nodeFlags |= 16384 /* UseAliasDefinedOutsideCurrentScope */;
+ if (flags & 8 /* SymbolFormatFlags.UseAliasDefinedOutsideCurrentScope */) {
+ nodeFlags |= 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */;
}
- if (flags & 16 /* DoNotIncludeSymbolChain */) {
- nodeFlags |= 134217728 /* DoNotIncludeSymbolChain */;
+ if (flags & 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */) {
+ nodeFlags |= 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */;
}
- var builder = flags & 4 /* AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName;
+ var builder = flags & 4 /* SymbolFormatFlags.AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName;
return writer ? symbolToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(symbolToStringWorker);
function symbolToStringWorker(writer) {
var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags); // TODO: GH#18217
// add neverAsciiEscape for GH#39027
- var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 303 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true });
+ var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 305 /* SyntaxKind.SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true });
var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
- printer.writeNode(4 /* Unspecified */, entity, /*sourceFile*/ sourceFile, writer);
+ printer.writeNode(4 /* EmitHint.Unspecified */, entity, /*sourceFile*/ sourceFile, writer);
return writer;
}
}
function signatureToString(signature, enclosingDeclaration, flags, kind, writer) {
- if (flags === void 0) { flags = 0 /* None */; }
+ if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; }
return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker);
function signatureToStringWorker(writer) {
var sigOutput;
- if (flags & 262144 /* WriteArrowStyleSignature */) {
- sigOutput = kind === 1 /* Construct */ ? 179 /* ConstructorType */ : 178 /* FunctionType */;
+ if (flags & 262144 /* TypeFormatFlags.WriteArrowStyleSignature */) {
+ sigOutput = kind === 1 /* SignatureKind.Construct */ ? 180 /* SyntaxKind.ConstructorType */ : 179 /* SyntaxKind.FunctionType */;
}
else {
- sigOutput = kind === 1 /* Construct */ ? 174 /* ConstructSignature */ : 173 /* CallSignature */;
+ sigOutput = kind === 1 /* SignatureKind.Construct */ ? 175 /* SyntaxKind.ConstructSignature */ : 174 /* SyntaxKind.CallSignature */;
}
- var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */);
+ var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */);
var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
- printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217
+ printer.writeNode(4 /* EmitHint.Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217
return writer;
}
}
function typeToString(type, enclosingDeclaration, flags, writer) {
- if (flags === void 0) { flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; }
+ if (flags === void 0) { flags = 1048576 /* TypeFormatFlags.AllowUniqueESSymbolType */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; }
if (writer === void 0) { writer = ts.createTextWriter(""); }
- var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */;
- var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0), writer);
+ var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* TypeFormatFlags.NoTruncation */;
+ var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | (noTruncation ? 1 /* NodeBuilderFlags.NoTruncation */ : 0), writer);
if (typeNode === undefined)
return ts.Debug.fail("should always get typenode");
// The unresolved type gets a synthesized comment on `any` to hint to users that it's not a plain `any`.
@@ -51231,7 +52229,7 @@ var ts;
var options = { removeComments: type !== unresolvedType };
var printer = ts.createPrinter(options);
var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
- printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer);
+ printer.writeNode(4 /* EmitHint.Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer);
var result = writer.getText();
var maxLength = noTruncation ? ts.noTruncationMaximumTruncationLength * 2 : ts.defaultMaximumTruncationLength * 2;
if (maxLength && result && result.length >= maxLength) {
@@ -51249,17 +52247,17 @@ var ts;
return [leftStr, rightStr];
}
function getTypeNameForErrorDisplay(type) {
- return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */);
+ return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */);
}
function symbolValueDeclarationIsContextSensitive(symbol) {
return symbol && !!symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration);
}
function toNodeBuilderFlags(flags) {
- if (flags === void 0) { flags = 0 /* None */; }
- return flags & 814775659 /* NodeBuilderFlagsMask */;
+ if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; }
+ return flags & 814775659 /* TypeFormatFlags.NodeBuilderFlagsMask */;
}
function isClassInstanceSide(type) {
- return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */)));
+ return !!type.symbol && !!(type.symbol.flags & 32 /* SymbolFlags.Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* TypeFlags.Object */) && !!(ts.getObjectFlags(type) & 16777216 /* ObjectFlags.IsClassInstanceClone */)));
}
function createNodeBuilder() {
return {
@@ -51293,12 +52291,12 @@ var ts;
};
function withContext(enclosingDeclaration, flags, tracker, cb) {
var _a, _b;
- ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0);
+ ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* NodeFlags.Synthesized */) === 0);
var context = {
enclosingDeclaration: enclosingDeclaration,
- flags: flags || 0 /* None */,
+ flags: flags || 0 /* NodeBuilderFlags.None */,
// If no full tracker is provided, fake up a dummy one with a basic limited-functionality moduleResolverHost
- tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? {
+ tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */ ? {
getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; },
getCurrentDirectory: function () { return host.getCurrentDirectory(); },
getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache),
@@ -51320,7 +52318,7 @@ var ts;
};
context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker);
var resultingNode = cb(context);
- if (context.truncating && context.flags & 1 /* NoTruncation */) {
+ if (context.truncating && context.flags & 1 /* NodeBuilderFlags.NoTruncation */) {
(_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportTruncationError) === null || _b === void 0 ? void 0 : _b.call(_a);
}
return context.encounteredError ? undefined : resultingNode;
@@ -51355,62 +52353,62 @@ var ts;
function checkTruncationLength(context) {
if (context.truncating)
return context.truncating;
- return context.truncating = context.approximateLength > ((context.flags & 1 /* NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength);
+ return context.truncating = context.approximateLength > ((context.flags & 1 /* NodeBuilderFlags.NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength);
}
function typeToTypeNodeHelper(type, context) {
if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
cancellationToken.throwIfCancellationRequested();
}
- var inTypeAlias = context.flags & 8388608 /* InTypeAlias */;
- context.flags &= ~8388608 /* InTypeAlias */;
+ var inTypeAlias = context.flags & 8388608 /* NodeBuilderFlags.InTypeAlias */;
+ context.flags &= ~8388608 /* NodeBuilderFlags.InTypeAlias */;
if (!type) {
- if (!(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) {
+ if (!(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) {
context.encounteredError = true;
return undefined; // TODO: GH#18217
}
context.approximateLength += 3;
- return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */);
+ return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */);
}
- if (!(context.flags & 536870912 /* NoTypeReduction */)) {
+ if (!(context.flags & 536870912 /* NodeBuilderFlags.NoTypeReduction */)) {
type = getReducedType(type);
}
- if (type.flags & 1 /* Any */) {
+ if (type.flags & 1 /* TypeFlags.Any */) {
if (type.aliasSymbol) {
return ts.factory.createTypeReferenceNode(symbolToEntityNameNode(type.aliasSymbol), mapToTypeNodes(type.aliasTypeArguments, context));
}
if (type === unresolvedType) {
- return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "unresolved");
+ return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), 3 /* SyntaxKind.MultiLineCommentTrivia */, "unresolved");
}
context.approximateLength += 3;
- return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* IntrinsicKeyword */ : 130 /* AnyKeyword */);
+ return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* SyntaxKind.IntrinsicKeyword */ : 130 /* SyntaxKind.AnyKeyword */);
}
- if (type.flags & 2 /* Unknown */) {
- return ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */);
+ if (type.flags & 2 /* TypeFlags.Unknown */) {
+ return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */);
}
- if (type.flags & 4 /* String */) {
+ if (type.flags & 4 /* TypeFlags.String */) {
context.approximateLength += 6;
- return ts.factory.createKeywordTypeNode(149 /* StringKeyword */);
+ return ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */);
}
- if (type.flags & 8 /* Number */) {
+ if (type.flags & 8 /* TypeFlags.Number */) {
context.approximateLength += 6;
- return ts.factory.createKeywordTypeNode(146 /* NumberKeyword */);
+ return ts.factory.createKeywordTypeNode(147 /* SyntaxKind.NumberKeyword */);
}
- if (type.flags & 64 /* BigInt */) {
+ if (type.flags & 64 /* TypeFlags.BigInt */) {
context.approximateLength += 6;
- return ts.factory.createKeywordTypeNode(157 /* BigIntKeyword */);
+ return ts.factory.createKeywordTypeNode(158 /* SyntaxKind.BigIntKeyword */);
}
- if (type.flags & 16 /* Boolean */ && !type.aliasSymbol) {
+ if (type.flags & 16 /* TypeFlags.Boolean */ && !type.aliasSymbol) {
context.approximateLength += 7;
- return ts.factory.createKeywordTypeNode(133 /* BooleanKeyword */);
+ return ts.factory.createKeywordTypeNode(133 /* SyntaxKind.BooleanKeyword */);
}
- if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) {
+ if (type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */)) {
var parentSymbol = getParentOfSymbol(type.symbol);
- var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */);
+ var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* SymbolFlags.Type */);
if (getDeclaredTypeOfSymbol(parentSymbol) === type) {
return parentName;
}
var memberName = ts.symbolName(type.symbol);
- if (ts.isIdentifierText(memberName, 0 /* ES3 */)) {
+ if (ts.isIdentifierText(memberName, 0 /* ScriptTarget.ES3 */)) {
return appendReferenceToType(parentName, ts.factory.createTypeReferenceNode(memberName, /*typeArguments*/ undefined));
}
if (ts.isImportTypeNode(parentName)) {
@@ -51424,66 +52422,66 @@ var ts;
return ts.Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`.");
}
}
- if (type.flags & 1056 /* EnumLike */) {
- return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
+ if (type.flags & 1056 /* TypeFlags.EnumLike */) {
+ return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */);
}
- if (type.flags & 128 /* StringLiteral */) {
+ if (type.flags & 128 /* TypeFlags.StringLiteral */) {
context.approximateLength += (type.value.length + 2);
- return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* UseSingleQuotesForStringLiteralType */)), 16777216 /* NoAsciiEscaping */));
+ return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */)), 16777216 /* EmitFlags.NoAsciiEscaping */));
}
- if (type.flags & 256 /* NumberLiteral */) {
+ if (type.flags & 256 /* TypeFlags.NumberLiteral */) {
var value = type.value;
context.approximateLength += ("" + value).length;
- return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value));
+ return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value));
}
- if (type.flags & 2048 /* BigIntLiteral */) {
+ if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) {
context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1;
return ts.factory.createLiteralTypeNode((ts.factory.createBigIntLiteral(type.value)));
}
- if (type.flags & 512 /* BooleanLiteral */) {
+ if (type.flags & 512 /* TypeFlags.BooleanLiteral */) {
context.approximateLength += type.intrinsicName.length;
return ts.factory.createLiteralTypeNode(type.intrinsicName === "true" ? ts.factory.createTrue() : ts.factory.createFalse());
}
- if (type.flags & 8192 /* UniqueESSymbol */) {
- if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) {
+ if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) {
+ if (!(context.flags & 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */)) {
if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
context.approximateLength += 6;
- return symbolToTypeNode(type.symbol, context, 111551 /* Value */);
+ return symbolToTypeNode(type.symbol, context, 111551 /* SymbolFlags.Value */);
}
if (context.tracker.reportInaccessibleUniqueSymbolError) {
context.tracker.reportInaccessibleUniqueSymbolError();
}
}
context.approximateLength += 13;
- return ts.factory.createTypeOperatorNode(153 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(150 /* SymbolKeyword */));
+ return ts.factory.createTypeOperatorNode(154 /* SyntaxKind.UniqueKeyword */, ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */));
}
- if (type.flags & 16384 /* Void */) {
+ if (type.flags & 16384 /* TypeFlags.Void */) {
context.approximateLength += 4;
- return ts.factory.createKeywordTypeNode(114 /* VoidKeyword */);
+ return ts.factory.createKeywordTypeNode(114 /* SyntaxKind.VoidKeyword */);
}
- if (type.flags & 32768 /* Undefined */) {
+ if (type.flags & 32768 /* TypeFlags.Undefined */) {
context.approximateLength += 9;
- return ts.factory.createKeywordTypeNode(152 /* UndefinedKeyword */);
+ return ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */);
}
- if (type.flags & 65536 /* Null */) {
+ if (type.flags & 65536 /* TypeFlags.Null */) {
context.approximateLength += 4;
return ts.factory.createLiteralTypeNode(ts.factory.createNull());
}
- if (type.flags & 131072 /* Never */) {
+ if (type.flags & 131072 /* TypeFlags.Never */) {
context.approximateLength += 5;
- return ts.factory.createKeywordTypeNode(143 /* NeverKeyword */);
+ return ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */);
}
- if (type.flags & 4096 /* ESSymbol */) {
+ if (type.flags & 4096 /* TypeFlags.ESSymbol */) {
context.approximateLength += 6;
- return ts.factory.createKeywordTypeNode(150 /* SymbolKeyword */);
+ return ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */);
}
- if (type.flags & 67108864 /* NonPrimitive */) {
+ if (type.flags & 67108864 /* TypeFlags.NonPrimitive */) {
context.approximateLength += 6;
- return ts.factory.createKeywordTypeNode(147 /* ObjectKeyword */);
+ return ts.factory.createKeywordTypeNode(148 /* SyntaxKind.ObjectKeyword */);
}
if (ts.isThisTypeParameter(type)) {
- if (context.flags & 4194304 /* InObjectTypeLiteral */) {
- if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) {
+ if (context.flags & 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */) {
+ if (!context.encounteredError && !(context.flags & 32768 /* NodeBuilderFlags.AllowThisInObjectLiteral */)) {
context.encounteredError = true;
}
if (context.tracker.reportInaccessibleThisError) {
@@ -51493,65 +52491,81 @@ var ts;
context.approximateLength += 4;
return ts.factory.createThisTypeNode();
}
- if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
+ if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
- if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */))
+ if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* SymbolFlags.Class */))
return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""), typeArgumentNodes);
- return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes);
+ return symbolToTypeNode(type.aliasSymbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes);
}
var objectFlags = ts.getObjectFlags(type);
- if (objectFlags & 4 /* Reference */) {
- ts.Debug.assert(!!(type.flags & 524288 /* Object */));
+ if (objectFlags & 4 /* ObjectFlags.Reference */) {
+ ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */));
return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type);
}
- if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) {
- if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) {
+ if (type.flags & 262144 /* TypeFlags.TypeParameter */ || objectFlags & 3 /* ObjectFlags.ClassOrInterface */) {
+ if (type.flags & 262144 /* TypeFlags.TypeParameter */ && ts.contains(context.inferTypeParameters, type)) {
context.approximateLength += (ts.symbolName(type.symbol).length + 6);
- return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined));
+ var constraintNode = void 0;
+ var constraint = getConstraintOfTypeParameter(type);
+ if (constraint) {
+ // If the infer type has a constraint that is not the same as the constraint
+ // we would have normally inferred based on context, we emit the constraint
+ // using `infer T extends ?`. We omit inferred constraints from type references
+ // as they may be elided.
+ var inferredConstraint = getInferredTypeParameterConstraint(type, /*omitTypeReferences*/ true);
+ if (!(inferredConstraint && isTypeIdenticalTo(constraint, inferredConstraint))) {
+ context.approximateLength += 9;
+ constraintNode = constraint && typeToTypeNodeHelper(constraint, context);
+ }
+ }
+ return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode));
}
- if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ &&
- type.flags & 262144 /* TypeParameter */ &&
+ if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ &&
+ type.flags & 262144 /* TypeFlags.TypeParameter */ &&
!isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
- var name = typeParameterToName(type, context);
- context.approximateLength += ts.idText(name).length;
- return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(ts.idText(name)), /*typeArguments*/ undefined);
+ var name_2 = typeParameterToName(type, context);
+ context.approximateLength += ts.idText(name_2).length;
+ return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(ts.idText(name_2)), /*typeArguments*/ undefined);
}
// Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter.
- return type.symbol
- ? symbolToTypeNode(type.symbol, context, 788968 /* Type */)
- : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("?"), /*typeArguments*/ undefined);
+ if (type.symbol) {
+ return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */);
+ }
+ var name = (type === markerSuperType || type === markerSubType) && varianceTypeParameter && varianceTypeParameter.symbol ?
+ (type === markerSubType ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?";
+ return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(name), /*typeArguments*/ undefined);
}
- if (type.flags & 1048576 /* Union */ && type.origin) {
+ if (type.flags & 1048576 /* TypeFlags.Union */ && type.origin) {
type = type.origin;
}
- if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) {
- var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types;
+ if (type.flags & (1048576 /* TypeFlags.Union */ | 2097152 /* TypeFlags.Intersection */)) {
+ var types = type.flags & 1048576 /* TypeFlags.Union */ ? formatUnionTypes(type.types) : type.types;
if (ts.length(types) === 1) {
return typeToTypeNodeHelper(types[0], context);
}
var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true);
if (typeNodes && typeNodes.length > 0) {
- return type.flags & 1048576 /* Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes);
+ return type.flags & 1048576 /* TypeFlags.Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes);
}
else {
- if (!context.encounteredError && !(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) {
+ if (!context.encounteredError && !(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) {
context.encounteredError = true;
}
return undefined; // TODO: GH#18217
}
}
- if (objectFlags & (16 /* Anonymous */ | 32 /* Mapped */)) {
- ts.Debug.assert(!!(type.flags & 524288 /* Object */));
+ if (objectFlags & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) {
+ ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */));
// The type is an object literal type.
return createAnonymousTypeNode(type);
}
- if (type.flags & 4194304 /* Index */) {
+ if (type.flags & 4194304 /* TypeFlags.Index */) {
var indexedType = type.type;
context.approximateLength += 6;
var indexTypeNode = typeToTypeNodeHelper(indexedType, context);
- return ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, indexTypeNode);
+ return ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, indexTypeNode);
}
- if (type.flags & 134217728 /* TemplateLiteral */) {
+ if (type.flags & 134217728 /* TypeFlags.TemplateLiteral */) {
var texts_1 = type.texts;
var types_1 = type.types;
var templateHead = ts.factory.createTemplateHead(texts_1[0]);
@@ -51559,39 +52573,63 @@ var ts;
context.approximateLength += 2;
return ts.factory.createTemplateLiteralType(templateHead, templateSpans);
}
- if (type.flags & 268435456 /* StringMapping */) {
+ if (type.flags & 268435456 /* TypeFlags.StringMapping */) {
var typeNode = typeToTypeNodeHelper(type.type, context);
- return symbolToTypeNode(type.symbol, context, 788968 /* Type */, [typeNode]);
+ return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, [typeNode]);
}
- if (type.flags & 8388608 /* IndexedAccess */) {
+ if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) {
var objectTypeNode = typeToTypeNodeHelper(type.objectType, context);
var indexTypeNode = typeToTypeNodeHelper(type.indexType, context);
context.approximateLength += 2;
return ts.factory.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode);
}
- if (type.flags & 16777216 /* Conditional */) {
+ if (type.flags & 16777216 /* TypeFlags.Conditional */) {
return visitAndTransformType(type, function (type) { return conditionalTypeToTypeNode(type); });
}
- if (type.flags & 33554432 /* Substitution */) {
+ if (type.flags & 33554432 /* TypeFlags.Substitution */) {
return typeToTypeNodeHelper(type.baseType, context);
}
return ts.Debug.fail("Should be unreachable.");
function conditionalTypeToTypeNode(type) {
var checkTypeNode = typeToTypeNodeHelper(type.checkType, context);
+ context.approximateLength += 15;
+ if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeFlags.TypeParameter */)) {
+ var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T"));
+ var name = typeParameterToName(newParam, context);
+ var newTypeVariable = ts.factory.createTypeReferenceNode(name);
+ context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type
+ var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper);
+ var saveInferTypeParameters_1 = context.inferTypeParameters;
+ context.inferTypeParameters = type.root.inferTypeParameters;
+ var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context);
+ context.inferTypeParameters = saveInferTypeParameters_1;
+ var trueTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.trueType), newMapper));
+ var falseTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.falseType), newMapper));
+ // outermost conditional makes `T` a type parameter, allowing the inner conditionals to be distributive
+ // second conditional makes `T` have `T & checkType` substitution, so it is correctly usable as the checkType
+ // inner conditional runs the check the user provided on the check type (distributively) and returns the result
+ // checkType extends infer T ? T extends checkType ? T extends extendsType<T> ? trueType<T> : falseType<T> : never : never;
+ // this is potentially simplifiable to
+ // checkType extends infer T ? T extends checkType & extendsType<T> ? trueType<T> : falseType<T> : never;
+ // but that may confuse users who read the output more.
+ // On the other hand,
+ // checkType extends infer T extends checkType ? T extends extendsType<T> ? trueType<T> : falseType<T> : never;
+ // may also work with `infer ... extends ...` in, but would produce declarations only compatible with the latest TS.
+ return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */));
+ }
var saveInferTypeParameters = context.inferTypeParameters;
context.inferTypeParameters = type.root.inferTypeParameters;
var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context);
context.inferTypeParameters = saveInferTypeParameters;
var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type));
var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type));
- context.approximateLength += 15;
return ts.factory.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode);
}
function typeToTypeNodeOrCircularityElision(type) {
var _a, _b, _c;
- if (type.flags & 1048576 /* Union */) {
+ if (type.flags & 1048576 /* TypeFlags.Union */) {
if ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(getTypeId(type))) {
- if (!(context.flags & 131072 /* AllowAnonymousIdentifier */)) {
+ if (!(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) {
context.encounteredError = true;
(_c = (_b = context.tracker) === null || _b === void 0 ? void 0 : _b.reportCyclicStructureError) === null || _c === void 0 ? void 0 : _c.call(_b);
}
@@ -51602,40 +52640,53 @@ var ts;
return typeToTypeNodeHelper(type, context);
}
function createMappedTypeNodeFromType(type) {
- ts.Debug.assert(!!(type.flags & 524288 /* Object */));
+ ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */));
var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined;
var questionToken = type.declaration.questionToken ? ts.factory.createToken(type.declaration.questionToken.kind) : undefined;
var appropriateConstraintTypeNode;
+ var newTypeVariable;
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
// We have a { [P in keyof T]: X }
// We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType`
- appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context));
+ if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeFlags.TypeParameter */) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) {
+ var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T"));
+ var name = typeParameterToName(newParam, context);
+ newTypeVariable = ts.factory.createTypeReferenceNode(name);
+ }
+ appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context));
}
else {
appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context);
}
var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode);
var nameTypeNode = type.declaration.nameType ? typeToTypeNodeHelper(getNameTypeFromMappedType(type), context) : undefined;
- var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context);
+ var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), context);
var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined);
context.approximateLength += 10;
- return ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
+ var result = ts.setEmitFlags(mappedTypeNode, 1 /* EmitFlags.SingleLine */);
+ if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeFlags.TypeParameter */) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) {
+ // homomorphic mapped type with a non-homomorphic naive inlining
+ // wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting
+ // type stays homomorphic
+ return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */));
+ }
+ return result;
}
function createAnonymousTypeNode(type) {
var _a;
var typeId = type.id;
var symbol = type.symbol;
if (symbol) {
- var isInstanceType = isClassInstanceSide(type) ? 788968 /* Type */ : 111551 /* Value */;
+ var isInstanceType = isClassInstanceSide(type) ? 788968 /* SymbolFlags.Type */ : 111551 /* SymbolFlags.Value */;
if (isJSConstructor(symbol.valueDeclaration)) {
// Instance and static types share the same symbol; only add 'typeof' for the static side.
return symbolToTypeNode(symbol, context, isInstanceType);
}
// Always use 'typeof T' for type of class, enum, and module objects
- else if (symbol.flags & 32 /* Class */
+ else if (symbol.flags & 32 /* SymbolFlags.Class */
&& !getBaseTypeVariableOfClass(symbol)
- && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 225 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) ||
- symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) ||
+ && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 226 /* SyntaxKind.ClassExpression */ && context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */) ||
+ symbol.flags & (384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */) ||
shouldWriteTypeOfFunctionSymbol()) {
return symbolToTypeNode(symbol, context, isInstanceType);
}
@@ -51644,7 +52695,7 @@ var ts;
var typeAlias = getTypeAliasForTypeLiteral(type);
if (typeAlias) {
// The specified symbol flags need to be reinterpreted as type flags
- return symbolToTypeNode(typeAlias, context, 788968 /* Type */);
+ return symbolToTypeNode(typeAlias, context, 788968 /* SymbolFlags.Type */);
}
else {
return createElidedInformationPlaceholder(context);
@@ -51660,26 +52711,26 @@ var ts;
}
function shouldWriteTypeOfFunctionSymbol() {
var _a;
- var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */) && // typeof static method
+ var isStaticMethodSymbol = !!(symbol.flags & 8192 /* SymbolFlags.Method */) && // typeof static method
ts.some(symbol.declarations, function (declaration) { return ts.isStatic(declaration); });
- var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) &&
+ var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* SymbolFlags.Function */) &&
(symbol.parent || // is exported function symbol
ts.forEach(symbol.declarations, function (declaration) {
- return declaration.parent.kind === 303 /* SourceFile */ || declaration.parent.kind === 261 /* ModuleBlock */;
+ return declaration.parent.kind === 305 /* SyntaxKind.SourceFile */ || declaration.parent.kind === 262 /* SyntaxKind.ModuleBlock */;
}));
if (isStaticMethodSymbol || isNonLocalFunctionSymbol) {
// typeof is allowed only for static/non local functions
- return (!!(context.flags & 4096 /* UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively
- (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed
+ return (!!(context.flags & 4096 /* NodeBuilderFlags.UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively
+ (!(context.flags & 8 /* NodeBuilderFlags.UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed
}
}
}
function visitAndTransformType(type, transform) {
var _a, _b;
var typeId = type.id;
- var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */;
- var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) :
- type.flags & 16777216 /* Conditional */ ? "N" + getNodeId(type.root.node) :
+ var isConstructorObject = ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & 32 /* SymbolFlags.Class */;
+ var id = ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.node ? "N" + getNodeId(type.node) :
+ type.flags & 16777216 /* TypeFlags.Conditional */ ? "N" + getNodeId(type.root.node) :
type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) :
undefined;
// Since instantiations of the same anonymous type have the same symbol, tracking symbols instead
@@ -51731,7 +52782,15 @@ var ts;
if (!ts.nodeIsSynthesized(node) && ts.getParseTreeNode(node) === node) {
return node;
}
- return ts.setTextRange(ts.factory.cloneNode(ts.visitEachChild(node, deepCloneOrReuseNode, ts.nullTransformationContext)), node);
+ return ts.setTextRange(ts.factory.cloneNode(ts.visitEachChild(node, deepCloneOrReuseNode, ts.nullTransformationContext, deepCloneOrReuseNodes)), node);
+ }
+ function deepCloneOrReuseNodes(nodes, visitor, test, start, count) {
+ if (nodes && nodes.length === 0) {
+ // Ensure we explicitly make a copy of an empty array; visitNodes will not do this unless the array has elements,
+ // which can lead to us reusing the same empty NodeArray more than once within the same AST during type noding.
+ return ts.setTextRange(ts.factory.createNodeArray(/*nodes*/ undefined, nodes.hasTrailingComma), nodes);
+ }
+ return ts.visitNodes(nodes, visitor, test, start, count);
}
}
function createTypeNodeFromObjectType(type) {
@@ -51742,20 +52801,20 @@ var ts;
if (!resolved.properties.length && !resolved.indexInfos.length) {
if (!resolved.callSignatures.length && !resolved.constructSignatures.length) {
context.approximateLength += 2;
- return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* SingleLine */);
+ return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* EmitFlags.SingleLine */);
}
if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) {
var signature = resolved.callSignatures[0];
- var signatureNode = signatureToSignatureDeclarationHelper(signature, 178 /* FunctionType */, context);
+ var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* SyntaxKind.FunctionType */, context);
return signatureNode;
}
if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) {
var signature = resolved.constructSignatures[0];
- var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* ConstructorType */, context);
+ var signatureNode = signatureToSignatureDeclarationHelper(signature, 180 /* SyntaxKind.ConstructorType */, context);
return signatureNode;
}
}
- var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* Abstract */); });
+ var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); });
if (ts.some(abstractSignatures)) {
var types = ts.map(abstractSignatures, getOrCreateTypeFromSignature);
// count the number of type elements excluding abstract constructors
@@ -51764,8 +52823,8 @@ var ts;
resolved.indexInfos.length +
// exclude `prototype` when writing a class expression as a type literal, as per
// the logic in `createTypeNodesFromResolvedType`.
- (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ ?
- ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* Prototype */); }) :
+ (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ ?
+ ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */); }) :
ts.length(resolved.properties));
// don't include an empty object literal if there were no other static-side
// properties to write, i.e. `abstract class C { }` becomes `abstract new () => {}`
@@ -51777,27 +52836,27 @@ var ts;
return typeToTypeNodeHelper(getIntersectionType(types), context);
}
var savedFlags = context.flags;
- context.flags |= 4194304 /* InObjectTypeLiteral */;
+ context.flags |= 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */;
var members = createTypeNodesFromResolvedType(resolved);
context.flags = savedFlags;
var typeLiteralNode = ts.factory.createTypeLiteralNode(members);
context.approximateLength += 2;
- ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */);
+ ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* NodeBuilderFlags.MultilineObjectLiterals */) ? 0 : 1 /* EmitFlags.SingleLine */);
return typeLiteralNode;
}
function typeReferenceToTypeNode(type) {
var typeArguments = getTypeArguments(type);
if (type.target === globalArrayType || type.target === globalReadonlyArrayType) {
- if (context.flags & 2 /* WriteArrayAsGenericType */) {
+ if (context.flags & 2 /* NodeBuilderFlags.WriteArrayAsGenericType */) {
var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context);
return ts.factory.createTypeReferenceNode(type.target === globalArrayType ? "Array" : "ReadonlyArray", [typeArgumentNode]);
}
var elementType = typeToTypeNodeHelper(typeArguments[0], context);
var arrayType = ts.factory.createArrayTypeNode(elementType);
- return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(144 /* ReadonlyKeyword */, arrayType);
+ return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, arrayType);
}
- else if (type.target.objectFlags & 8 /* Tuple */) {
- typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* Optional */)); });
+ else if (type.target.objectFlags & 8 /* ObjectFlags.Tuple */) {
+ typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* ElementFlags.Optional */)); });
if (typeArguments.length > 0) {
var arity = getTypeReferenceArity(type);
var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context);
@@ -51805,7 +52864,7 @@ var ts;
if (type.target.labeledElementDeclarations) {
for (var i = 0; i < tupleConstituentNodes.length; i++) {
var flags = type.target.elementFlags[i];
- tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* Variable */ ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) :
+ tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* ElementFlags.Variable */ ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* ElementFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) :
tupleConstituentNodes[i]);
}
}
@@ -51813,23 +52872,23 @@ var ts;
for (var i = 0; i < Math.min(arity, tupleConstituentNodes.length); i++) {
var flags = type.target.elementFlags[i];
tupleConstituentNodes[i] =
- flags & 12 /* Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) :
- flags & 2 /* Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) :
+ flags & 12 /* ElementFlags.Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) :
+ flags & 2 /* ElementFlags.Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) :
tupleConstituentNodes[i];
}
}
- var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* SingleLine */);
- return type.target.readonly ? ts.factory.createTypeOperatorNode(144 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode;
+ var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* EmitFlags.SingleLine */);
+ return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode;
}
}
- if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) {
- var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* SingleLine */);
- return type.target.readonly ? ts.factory.createTypeOperatorNode(144 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode;
+ if (context.encounteredError || (context.flags & 524288 /* NodeBuilderFlags.AllowEmptyTuple */)) {
+ var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* EmitFlags.SingleLine */);
+ return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode;
}
context.encounteredError = true;
return undefined; // TODO: GH#18217
}
- else if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ &&
+ else if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ &&
type.symbol.valueDeclaration &&
ts.isClassLike(type.symbol.valueDeclaration) &&
!isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
@@ -51853,8 +52912,8 @@ var ts;
if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) {
var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context);
var flags_3 = context.flags;
- context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */;
- var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice);
+ context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */;
+ var ref = symbolToTypeNode(parent, context, 788968 /* SymbolFlags.Type */, typeArgumentSlice);
context.flags = flags_3;
resultType = !resultType ? ref : appendReferenceToType(resultType, ref);
}
@@ -51866,8 +52925,8 @@ var ts;
typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context);
}
var flags = context.flags;
- context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */;
- var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* Type */, typeArgumentNodes);
+ context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */;
+ var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes);
context.flags = flags;
return !resultType ? finalRef : appendReferenceToType(resultType, finalRef);
}
@@ -51931,17 +52990,17 @@ var ts;
var typeElements = [];
for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) {
var signature = _a[_i];
- typeElements.push(signatureToSignatureDeclarationHelper(signature, 173 /* CallSignature */, context));
+ typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* SyntaxKind.CallSignature */, context));
}
for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) {
var signature = _c[_b];
- if (signature.flags & 4 /* Abstract */)
+ if (signature.flags & 4 /* SignatureFlags.Abstract */)
continue;
- typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* ConstructSignature */, context));
+ typeElements.push(signatureToSignatureDeclarationHelper(signature, 175 /* SyntaxKind.ConstructSignature */, context));
}
for (var _d = 0, _e = resolvedType.indexInfos; _d < _e.length; _d++) {
var info = _e[_d];
- typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined));
+ typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined));
}
var properties = resolvedType.properties;
if (!properties) {
@@ -51951,11 +53010,11 @@ var ts;
for (var _f = 0, properties_1 = properties; _f < properties_1.length; _f++) {
var propertySymbol = properties_1[_f];
i++;
- if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) {
- if (propertySymbol.flags & 4194304 /* Prototype */) {
+ if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */) {
+ if (propertySymbol.flags & 4194304 /* SymbolFlags.Prototype */) {
continue;
}
- if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* Private */ | 16 /* Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) {
+ if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) {
context.tracker.reportPrivateInBaseOfClassExpression(ts.unescapeLeadingUnderscores(propertySymbol.escapedName));
}
}
@@ -51971,10 +53030,10 @@ var ts;
}
function createElidedInformationPlaceholder(context) {
context.approximateLength += 3;
- if (!(context.flags & 1 /* NoTruncation */)) {
+ if (!(context.flags & 1 /* NodeBuilderFlags.NoTruncation */)) {
return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("..."), /*typeArguments*/ undefined);
}
- return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */);
+ return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */);
}
function shouldUsePlaceholderForProperty(propertySymbol, context) {
var _a;
@@ -51984,19 +53043,19 @@ var ts;
// Since anonymous types usually come from expressions, this allows us to preserve the output
// for deep mappings which likely come from expressions, while truncating those parts which
// come from mappings over library functions.
- return !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */)
+ return !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */)
&& (ts.contains(context.reverseMappedStack, propertySymbol)
|| (((_a = context.reverseMappedStack) === null || _a === void 0 ? void 0 : _a[0])
- && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* Anonymous */)));
+ && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* ObjectFlags.Anonymous */)));
}
function addPropertyToElementList(propertySymbol, context, typeElements) {
var _a, _b;
- var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */);
+ var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */);
var propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ?
anyType : getNonMissingTypeOfSymbol(propertySymbol);
var saveEnclosingDeclaration = context.enclosingDeclaration;
context.enclosingDeclaration = undefined;
- if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */ && isLateBoundName(propertySymbol.escapedName)) {
+ if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* CheckFlags.Late */ && isLateBoundName(propertySymbol.escapedName)) {
if (propertySymbol.declarations) {
var decl = ts.first(propertySymbol.declarations);
if (hasLateBindableName(decl)) {
@@ -52019,12 +53078,12 @@ var ts;
var propertyName = getPropertyNameNodeForSymbol(propertySymbol, context);
context.enclosingDeclaration = saveEnclosingDeclaration;
context.approximateLength += (ts.symbolName(propertySymbol).length + 1);
- var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined;
- if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) {
- var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */);
+ var optionalToken = propertySymbol.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined;
+ if (propertySymbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) {
+ var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* TypeFlags.Undefined */); }), 0 /* SignatureKind.Call */);
for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) {
var signature = signatures_1[_i];
- var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 167 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken });
+ var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 168 /* SyntaxKind.MethodSignature */, context, { name: propertyName, questionToken: optionalToken });
typeElements.push(preserveCommentsOn(methodDeclaration));
}
}
@@ -52038,12 +53097,12 @@ var ts;
context.reverseMappedStack || (context.reverseMappedStack = []);
context.reverseMappedStack.push(propertySymbol);
}
- propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */);
+ propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */);
if (propertyIsReverseMapped) {
context.reverseMappedStack.pop();
}
}
- var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(144 /* ReadonlyKeyword */)] : undefined;
+ var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined;
if (modifiers) {
context.approximateLength += 9;
}
@@ -52052,11 +53111,11 @@ var ts;
}
function preserveCommentsOn(node) {
var _a;
- if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 345 /* JSDocPropertyTag */; })) {
- var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 345 /* JSDocPropertyTag */; });
+ if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; })) {
+ var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; });
var commentText = ts.getTextOfJSDocComment(d.comment);
if (commentText) {
- ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]);
+ ts.setSyntheticLeadingComments(node, [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]);
}
}
else if (propertySymbol.valueDeclaration) {
@@ -52080,7 +53139,7 @@ var ts;
];
}
}
- var mayHaveNameCollisions = !(context.flags & 64 /* UseFullyQualifiedType */);
+ var mayHaveNameCollisions = !(context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */);
/** Map from type reference identifier text to [type, index in `result` where the type node is] */
var seenNames = mayHaveNameCollisions ? ts.createUnderscoreEscapedMultiMap() : undefined;
var result_5 = [];
@@ -52114,7 +53173,7 @@ var ts;
// type node for each entry by that name with the
// `UseFullyQualifiedType` flag enabled.
var saveContextFlags = context.flags;
- context.flags |= 64 /* UseFullyQualifiedType */;
+ context.flags |= 64 /* NodeBuilderFlags.UseFullyQualifiedType */;
seenNames.forEach(function (types) {
if (!ts.arrayIsHomogeneous(types, function (_a, _b) {
var a = _a[0];
@@ -52149,22 +53208,22 @@ var ts;
if (!typeNode) {
typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context);
}
- if (!indexInfo.type && !(context.flags & 2097152 /* AllowEmptyIndexInfoType */)) {
+ if (!indexInfo.type && !(context.flags & 2097152 /* NodeBuilderFlags.AllowEmptyIndexInfoType */)) {
context.encounteredError = true;
}
context.approximateLength += (name.length + 4);
return ts.factory.createIndexSignature(
- /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(144 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode);
+ /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode);
}
function signatureToSignatureDeclarationHelper(signature, kind, context, options) {
var _a, _b, _c, _d;
- var suppressAny = context.flags & 256 /* SuppressAnyReturnType */;
+ var suppressAny = context.flags & 256 /* NodeBuilderFlags.SuppressAnyReturnType */;
if (suppressAny)
- context.flags &= ~256 /* SuppressAnyReturnType */; // suppress only toplevel `any`s
+ context.flags &= ~256 /* NodeBuilderFlags.SuppressAnyReturnType */; // suppress only toplevel `any`s
context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum
var typeParameters;
var typeArguments;
- if (context.flags & 32 /* WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) {
+ if (context.flags & 32 /* NodeBuilderFlags.WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) {
typeArguments = signature.target.typeParameters.map(function (parameter) { return typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context); });
}
else {
@@ -52172,7 +53231,7 @@ var ts;
}
var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0];
// If the expanded parameter list had a variadic in a non-trailing position, don't expand it
- var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 170 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); });
+ var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* CheckFlags.RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* SyntaxKind.Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); });
var thisParameter = tryGetThisParameterDeclaration(signature, context);
if (thisParameter) {
parameters.unshift(thisParameter);
@@ -52180,11 +53239,11 @@ var ts;
var returnTypeNode;
var typePredicate = getTypePredicateOfSignature(signature);
if (typePredicate) {
- var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ?
- ts.factory.createToken(128 /* AssertsKeyword */) :
+ var assertsModifier = typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ?
+ ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) :
undefined;
- var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ?
- ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) :
+ var parameterName = typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ?
+ ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* EmitFlags.NoAsciiEscaping */) :
ts.factory.createThisTypeNode();
var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context);
returnTypeNode = ts.factory.createTypePredicateNode(assertsModifier, parameterName, typeNode);
@@ -52195,28 +53254,28 @@ var ts;
returnTypeNode = serializeReturnTypeForSignature(context, returnType, signature, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports);
}
else if (!suppressAny) {
- returnTypeNode = ts.factory.createKeywordTypeNode(130 /* AnyKeyword */);
+ returnTypeNode = ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */);
}
}
var modifiers = options === null || options === void 0 ? void 0 : options.modifiers;
- if ((kind === 179 /* ConstructorType */) && signature.flags & 4 /* Abstract */) {
+ if ((kind === 180 /* SyntaxKind.ConstructorType */) && signature.flags & 4 /* SignatureFlags.Abstract */) {
var flags = ts.modifiersToFlags(modifiers);
- modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* Abstract */);
- }
- var node = kind === 173 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) :
- kind === 174 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) :
- kind === 167 /* MethodSignature */ ? 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 === 168 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) :
- kind === 170 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) :
- kind === 171 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) :
- kind === 172 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) :
- kind === 175 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) :
- kind === 315 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) :
- kind === 178 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) :
- kind === 179 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) :
- kind === 255 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) :
- kind === 212 /* FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ 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 === 213 /* ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) :
+ modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* ModifierFlags.Abstract */);
+ }
+ var node = kind === 174 /* SyntaxKind.CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) :
+ kind === 175 /* SyntaxKind.ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) :
+ kind === 168 /* SyntaxKind.MethodSignature */ ? 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 /* SyntaxKind.MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) :
+ kind === 171 /* SyntaxKind.Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) :
+ kind === 172 /* SyntaxKind.GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) :
+ kind === 173 /* SyntaxKind.SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) :
+ kind === 176 /* SyntaxKind.IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) :
+ kind === 317 /* SyntaxKind.JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) :
+ kind === 179 /* SyntaxKind.FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) :
+ kind === 180 /* SyntaxKind.ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) :
+ kind === 256 /* SyntaxKind.FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) :
+ kind === 213 /* SyntaxKind.FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ 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 /* SyntaxKind.ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) :
ts.Debug.assertNever(kind);
if (typeArguments) {
node.typeArguments = ts.factory.createNodeArray(typeArguments);
@@ -52240,12 +53299,13 @@ var ts;
}
function typeParameterToDeclarationWithConstraint(type, context, constraintNode) {
var savedContextFlags = context.flags;
- context.flags &= ~512 /* WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic
+ context.flags &= ~512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic
+ var modifiers = ts.factory.createModifiersFromModifierFlags(getVarianceModifiers(type));
var name = typeParameterToName(type, context);
var defaultParameter = getDefaultFromTypeParameter(type);
var defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter, context);
context.flags = savedContextFlags;
- return ts.factory.createTypeParameterDeclaration(name, constraintNode, defaultParameterNode);
+ return ts.factory.createTypeParameterDeclaration(modifiers, name, constraintNode, defaultParameterNode);
}
function typeParameterToDeclaration(type, context, constraint) {
if (constraint === void 0) { constraint = getConstraintOfTypeParameter(type); }
@@ -52253,29 +53313,26 @@ var ts;
return typeParameterToDeclarationWithConstraint(type, context, constraintNode);
}
function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) {
- var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 163 /* Parameter */);
+ var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 164 /* SyntaxKind.Parameter */);
if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) {
- parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 338 /* JSDocParameterTag */);
+ parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 340 /* SyntaxKind.JSDocParameterTag */);
}
var parameterType = getTypeOfSymbol(parameterSymbol);
if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
parameterType = getOptionalType(parameterType);
}
- if ((context.flags & 1073741824 /* NoUndefinedOptionalParameterType */) && parameterDeclaration && !ts.isJSDocParameterTag(parameterDeclaration) && isOptionalUninitializedParameter(parameterDeclaration)) {
- parameterType = getTypeWithFacts(parameterType, 524288 /* NEUndefined */);
- }
var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports);
- var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined;
- var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
- var dotDotDotToken = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined;
+ var modifiers = !(context.flags & 8192 /* NodeBuilderFlags.OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined;
+ var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* CheckFlags.RestParameter */;
+ var dotDotDotToken = isRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined;
var name = parameterDeclaration ? parameterDeclaration.name ?
- parameterDeclaration.name.kind === 79 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) :
- parameterDeclaration.name.kind === 160 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) :
+ parameterDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* EmitFlags.NoAsciiEscaping */) :
+ parameterDeclaration.name.kind === 161 /* SyntaxKind.QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* EmitFlags.NoAsciiEscaping */) :
cloneBindingName(parameterDeclaration.name) :
ts.symbolName(parameterSymbol) :
ts.symbolName(parameterSymbol);
- var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */;
- var questionToken = isOptional ? ts.factory.createToken(57 /* QuestionToken */) : undefined;
+ var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* CheckFlags.OptionalParameter */;
+ var questionToken = isOptional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined;
var parameterNode = ts.factory.createParameterDeclaration(
/*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode,
/*initializer*/ undefined);
@@ -52295,7 +53352,7 @@ var ts;
if (!ts.nodeIsSynthesized(visited)) {
visited = ts.factory.cloneNode(visited);
}
- return ts.setEmitFlags(visited, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */);
+ return ts.setEmitFlags(visited, 1 /* EmitFlags.SingleLine */ | 16777216 /* EmitFlags.NoAsciiEscaping */);
}
}
}
@@ -52304,9 +53361,9 @@ var ts;
return;
// get symbol of the first identifier of the entityName
var firstIdentifier = ts.getFirstIdentifier(accessExpression);
- var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
+ var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
if (name) {
- context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */);
+ context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* SymbolFlags.Value */);
}
}
function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) {
@@ -52316,8 +53373,8 @@ var ts;
function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) {
// Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration.
var chain;
- var isTypeParameter = symbol.flags & 262144 /* TypeParameter */;
- if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* UseFullyQualifiedType */) && !(context.flags & 134217728 /* DoNotIncludeSymbolChain */)) {
+ var isTypeParameter = symbol.flags & 262144 /* SymbolFlags.TypeParameter */;
+ if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */) && !(context.flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */)) {
chain = ts.Debug.checkDefined(getSymbolChain(symbol, meaning, /*endOfChain*/ true));
ts.Debug.assert(chain && chain.length > 0);
}
@@ -52327,7 +53384,7 @@ var ts;
return chain;
/** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */
function getSymbolChain(symbol, meaning, endOfChain) {
- var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* UseOnlyExternalAliasing */));
+ var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */));
var parentSpecifiers;
if (!accessibleSymbolChain ||
needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) {
@@ -52346,8 +53403,8 @@ var ts;
var parent = sortedParents_1[_i];
var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false);
if (parentChain) {
- if (parent.exports && parent.exports.get("export=" /* ExportEquals */) &&
- getSymbolIfSameReference(parent.exports.get("export=" /* ExportEquals */), symbol)) {
+ if (parent.exports && parent.exports.get("export=" /* InternalSymbolName.ExportEquals */) &&
+ getSymbolIfSameReference(parent.exports.get("export=" /* InternalSymbolName.ExportEquals */), symbol)) {
// parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent
// No need to lookup an alias for the symbol in itself
accessibleSymbolChain = parentChain;
@@ -52366,7 +53423,7 @@ var ts;
// If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols.
endOfChain ||
// If a parent symbol is an anonymous type, don't write it.
- !(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) {
+ !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */))) {
// If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.)
if (!endOfChain && !yieldModuleSymbol && !!ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
return;
@@ -52396,7 +53453,7 @@ var ts;
function typeParametersToTypeParameterDeclarations(symbol, context) {
var typeParameterNodes;
var targetSymbol = getTargetSymbol(symbol);
- if (targetSymbol.flags & (32 /* Class */ | 64 /* Interface */ | 524288 /* TypeAlias */)) {
+ if (targetSymbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 524288 /* SymbolFlags.TypeAlias */)) {
typeParameterNodes = ts.factory.createNodeArray(ts.map(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), function (tp) { return typeParameterToDeclaration(tp, context); }));
}
return typeParameterNodes;
@@ -52411,11 +53468,11 @@ var ts;
}
(context.typeParameterSymbolList || (context.typeParameterSymbolList = new ts.Set())).add(symbolId);
var typeParameterNodes;
- if (context.flags & 512 /* WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) {
+ if (context.flags & 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) {
var parentSymbol = symbol;
var nextSymbol_1 = chain[index + 1];
- if (ts.getCheckFlags(nextSymbol_1) & 1 /* Instantiated */) {
- var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* Alias */ ? resolveAlias(parentSymbol) : parentSymbol);
+ if (ts.getCheckFlags(nextSymbol_1) & 1 /* CheckFlags.Instantiated */) {
+ var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(parentSymbol) : parentSymbol);
typeParameterNodes = mapToTypeNodes(ts.map(params, function (t) { return getMappedType(t, nextSymbol_1.mapper); }), context);
}
else {
@@ -52433,13 +53490,13 @@ var ts;
}
return top;
}
- function getSpecifierForModuleSymbol(symbol, context) {
+ function getSpecifierForModuleSymbol(symbol, context, overrideImportMode) {
var _a;
- var file = ts.getDeclarationOfKind(symbol, 303 /* SourceFile */);
+ var file = ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */);
if (!file) {
var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); });
if (equivalentFileSymbol) {
- file = ts.getDeclarationOfKind(equivalentFileSymbol, 303 /* SourceFile */);
+ file = ts.getDeclarationOfKind(equivalentFileSymbol, 305 /* SyntaxKind.SourceFile */);
}
}
if (file && file.moduleName !== undefined) {
@@ -52468,8 +53525,10 @@ var ts;
return ts.getSourceFileOfNode(ts.getNonAugmentationDeclaration(symbol)).fileName; // A resolver may not be provided for baselines and errors - in those cases we use the fileName in full
}
var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration));
+ var resolutionMode = overrideImportMode || (contextFile === null || contextFile === void 0 ? void 0 : contextFile.impliedNodeFormat);
+ var cacheKey = getSpecifierCacheKey(contextFile.path, resolutionMode);
var links = getSymbolLinks(symbol);
- var specifier = links.specifierCache && links.specifierCache.get(contextFile.path);
+ var specifier = links.specifierCache && links.specifierCache.get(cacheKey);
if (!specifier) {
var isBundle_1 = !!ts.outFile(compilerOptions);
// For declaration bundles, we need to generate absolute paths relative to the common source dir for imports,
@@ -52478,30 +53537,70 @@ var ts;
// specifier preference
var moduleResolverHost = context.tracker.moduleResolverHost;
var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions;
- specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, checker, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "project-relative", importModuleSpecifierEnding: isBundle_1 ? "minimal" : undefined }));
+ specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, checker, specifierCompilerOptions, contextFile, moduleResolverHost, {
+ importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "project-relative",
+ importModuleSpecifierEnding: isBundle_1 ? "minimal"
+ : resolutionMode === ts.ModuleKind.ESNext ? "js"
+ : undefined,
+ }, { overrideImportMode: overrideImportMode }));
(_a = links.specifierCache) !== null && _a !== void 0 ? _a : (links.specifierCache = new ts.Map());
- links.specifierCache.set(contextFile.path, specifier);
+ links.specifierCache.set(cacheKey, specifier);
}
return specifier;
+ function getSpecifierCacheKey(path, mode) {
+ return mode === undefined ? path : "".concat(mode, "|").concat(path);
+ }
}
function symbolToEntityNameNode(symbol) {
var identifier = ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(symbol.escapedName));
return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier;
}
function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
- var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module
- var isTypeOf = meaning === 111551 /* Value */;
+ var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module
+ var isTypeOf = meaning === 111551 /* SymbolFlags.Value */;
if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
// module is root, must use `ImportTypeNode`
var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined;
var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context);
- var specifier = getSpecifierForModuleSymbol(chain[0], context);
- if (!(context.flags & 67108864 /* AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) {
- // If ultimately we can only name the symbol with a reference that dives into a `node_modules` folder, we should error
- // since declaration files with these kinds of references are liable to fail when published :(
- context.encounteredError = true;
- if (context.tracker.reportLikelyUnsafeImportRequiredError) {
- context.tracker.reportLikelyUnsafeImportRequiredError(specifier);
+ var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration));
+ var targetFile = ts.getSourceFileOfModule(chain[0]);
+ var specifier = void 0;
+ var assertion = void 0;
+ if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) {
+ // An `import` type directed at an esm format file is only going to resolve in esm mode - set the esm mode assertion
+ if ((targetFile === null || targetFile === void 0 ? void 0 : targetFile.impliedNodeFormat) === ts.ModuleKind.ESNext && targetFile.impliedNodeFormat !== (contextFile === null || contextFile === void 0 ? void 0 : contextFile.impliedNodeFormat)) {
+ specifier = getSpecifierForModuleSymbol(chain[0], context, ts.ModuleKind.ESNext);
+ assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
+ ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral("import"))
+ ])));
+ }
+ }
+ if (!specifier) {
+ specifier = getSpecifierForModuleSymbol(chain[0], context);
+ }
+ if (!(context.flags & 67108864 /* NodeBuilderFlags.AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) {
+ var oldSpecifier = specifier;
+ if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) {
+ // We might be able to write a portable import type using a mode override; try specifier generation again, but with a different mode set
+ var swappedMode = (contextFile === null || contextFile === void 0 ? void 0 : contextFile.impliedNodeFormat) === ts.ModuleKind.ESNext ? ts.ModuleKind.CommonJS : ts.ModuleKind.ESNext;
+ specifier = getSpecifierForModuleSymbol(chain[0], context, swappedMode);
+ if (specifier.indexOf("/node_modules/") >= 0) {
+ // Still unreachable :(
+ specifier = oldSpecifier;
+ }
+ else {
+ assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
+ ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral(swappedMode === ts.ModuleKind.ESNext ? "import" : "require"))
+ ])));
+ }
+ }
+ if (!assertion) {
+ // If ultimately we can only name the symbol with a reference that dives into a `node_modules` folder, we should error
+ // since declaration files with these kinds of references are liable to fail when published :(
+ context.encounteredError = true;
+ if (context.tracker.reportLikelyUnsafeImportRequiredError) {
+ context.tracker.reportLikelyUnsafeImportRequiredError(oldSpecifier);
+ }
}
}
var lit = ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(specifier));
@@ -52513,12 +53612,12 @@ var ts;
var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right;
lastId.typeArguments = undefined;
}
- return ts.factory.createImportTypeNode(lit, nonRootParts, typeParameterNodes, isTypeOf);
+ return ts.factory.createImportTypeNode(lit, assertion, nonRootParts, typeParameterNodes, isTypeOf);
}
else {
var splitNode = getTopmostIndexedAccessType(nonRootParts);
var qualifier = splitNode.objectType.typeName;
- return ts.factory.createIndexedAccessTypeNode(ts.factory.createImportTypeNode(lit, qualifier, typeParameterNodes, isTypeOf), splitNode.indexType);
+ return ts.factory.createIndexedAccessTypeNode(ts.factory.createImportTypeNode(lit, assertion, qualifier, typeParameterNodes, isTypeOf), splitNode.indexType);
}
}
var entityName = createAccessFromSymbolChain(chain, chain.length - 1, 0);
@@ -52540,27 +53639,35 @@ var ts;
var parent = chain[index - 1];
var symbolName;
if (index === 0) {
- context.flags |= 16777216 /* InInitialEntityName */;
+ context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */;
symbolName = getNameOfSymbolAsWritten(symbol, context);
context.approximateLength += (symbolName ? symbolName.length : 0) + 1;
- context.flags ^= 16777216 /* InInitialEntityName */;
+ context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */;
}
else {
if (parent && getExportsOfSymbol(parent)) {
var exports_2 = getExportsOfSymbol(parent);
ts.forEachEntry(exports_2, function (ex, name) {
- if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) {
+ if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* InternalSymbolName.ExportEquals */) {
symbolName = ts.unescapeLeadingUnderscores(name);
return true;
}
});
}
}
- if (!symbolName) {
+ if (symbolName === undefined) {
+ var name = ts.firstDefined(symbol.declarations, ts.getNameOfDeclaration);
+ if (name && ts.isComputedPropertyName(name) && ts.isEntityName(name.expression)) {
+ var LHS = createAccessFromSymbolChain(chain, index - 1, stopper);
+ if (ts.isEntityName(LHS)) {
+ return ts.factory.createIndexedAccessTypeNode(ts.factory.createParenthesizedType(ts.factory.createTypeQueryNode(LHS)), ts.factory.createTypeQueryNode(name.expression));
+ }
+ return LHS;
+ }
symbolName = getNameOfSymbolAsWritten(symbol, context);
}
context.approximateLength += symbolName.length + 1;
- if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent &&
+ if (!(context.flags & 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */) && parent &&
getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) &&
getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) {
// Should use an indexed access
@@ -52572,7 +53679,7 @@ var ts;
return ts.factory.createIndexedAccessTypeNode(ts.factory.createTypeReferenceNode(LHS, typeParameterNodes), ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(symbolName)));
}
}
- var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */);
+ var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */);
identifier.symbol = symbol;
if (index > stopper) {
var LHS = createAccessFromSymbolChain(chain, index - 1, stopper);
@@ -52585,9 +53692,9 @@ var ts;
}
}
function typeParameterShadowsNameInScope(escapedName, context, type) {
- var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false);
+ var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* SymbolFlags.Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false);
if (result) {
- if (result.flags & 262144 /* TypeParameter */ && result === type.symbol) {
+ if (result.flags & 262144 /* SymbolFlags.TypeParameter */ && result === type.symbol) {
return false;
}
return true;
@@ -52596,17 +53703,17 @@ var ts;
}
function typeParameterToName(type, context) {
var _a, _b;
- if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) {
+ if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) {
var cached = context.typeParameterNames.get(getTypeId(type));
if (cached) {
return cached;
}
}
- var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true);
- if (!(result.kind & 79 /* Identifier */)) {
+ var result = symbolToName(type.symbol, context, 788968 /* SymbolFlags.Type */, /*expectsIdentifier*/ true);
+ if (!(result.kind & 79 /* SyntaxKind.Identifier */)) {
return ts.factory.createIdentifier("(Missing type parameter)");
}
- if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
+ if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) {
var rawtext = result.escapedText;
var i = ((_a = context.typeParameterNamesByTextNextNameCount) === null || _a === void 0 ? void 0 : _a.get(rawtext)) || 0;
var text = rawtext;
@@ -52629,7 +53736,7 @@ var ts;
var chain = lookupSymbolChain(symbol, context, meaning);
if (expectsIdentifier && chain.length !== 1
&& !context.encounteredError
- && !(context.flags & 65536 /* AllowQualifiedNameInPlaceOfIdentifier */)) {
+ && !(context.flags & 65536 /* NodeBuilderFlags.AllowQualifiedNameInPlaceOfIdentifier */)) {
context.encounteredError = true;
}
return createEntityNameFromSymbolChain(chain, chain.length - 1);
@@ -52637,13 +53744,13 @@ var ts;
var typeParameterNodes = lookupTypeParameterNodes(chain, index, context);
var symbol = chain[index];
if (index === 0) {
- context.flags |= 16777216 /* InInitialEntityName */;
+ context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */;
}
var symbolName = getNameOfSymbolAsWritten(symbol, context);
if (index === 0) {
- context.flags ^= 16777216 /* InInitialEntityName */;
+ context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */;
}
- var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */);
+ var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */);
identifier.symbol = symbol;
return index > 0 ? ts.factory.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier;
}
@@ -52655,38 +53762,38 @@ var ts;
var typeParameterNodes = lookupTypeParameterNodes(chain, index, context);
var symbol = chain[index];
if (index === 0) {
- context.flags |= 16777216 /* InInitialEntityName */;
+ context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */;
}
var symbolName = getNameOfSymbolAsWritten(symbol, context);
if (index === 0) {
- context.flags ^= 16777216 /* InInitialEntityName */;
+ context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */;
}
var firstChar = symbolName.charCodeAt(0);
if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
return ts.factory.createStringLiteral(getSpecifierForModuleSymbol(symbol, context));
}
- var canUsePropertyAccess = firstChar === 35 /* hash */ ?
+ var canUsePropertyAccess = firstChar === 35 /* CharacterCodes.hash */ ?
symbolName.length > 1 && ts.isIdentifierStart(symbolName.charCodeAt(1), languageVersion) :
ts.isIdentifierStart(firstChar, languageVersion);
if (index === 0 || canUsePropertyAccess) {
- var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */);
+ var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */);
identifier.symbol = symbol;
return index > 0 ? ts.factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain, index - 1), identifier) : identifier;
}
else {
- if (firstChar === 91 /* openBracket */) {
+ if (firstChar === 91 /* CharacterCodes.openBracket */) {
symbolName = symbolName.substring(1, symbolName.length - 1);
firstChar = symbolName.charCodeAt(0);
}
var expression = void 0;
- if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* EnumMember */)) {
- expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* singleQuote */);
+ if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* SymbolFlags.EnumMember */)) {
+ expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* CharacterCodes.singleQuote */);
}
else if (("" + +symbolName) === symbolName) {
expression = ts.factory.createNumericLiteral(+symbolName);
}
if (!expression) {
- expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */);
+ expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */);
expression.symbol = symbol;
}
return ts.factory.createElementAccessExpression(createExpressionFromSymbolChain(chain, index - 1), expression);
@@ -52715,7 +53822,7 @@ var ts;
function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) {
var nameType = getSymbolLinks(symbol).nameType;
if (nameType) {
- if (nameType.flags & 384 /* StringOrNumberLiteral */) {
+ if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) {
var name = "" + nameType.value;
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) {
return ts.factory.createStringLiteral(name, !!singleQuote);
@@ -52725,8 +53832,8 @@ var ts;
}
return ts.createPropertyNameNodeForIdentifierOrLiteral(name, ts.getEmitScriptTarget(compilerOptions));
}
- if (nameType.flags & 8192 /* UniqueESSymbol */) {
- return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */));
+ if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) {
+ return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* SymbolFlags.Value */));
}
}
}
@@ -52760,7 +53867,7 @@ var ts;
return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); });
}
function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) {
- return !(ts.getObjectFlags(type) & 4 /* Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
+ return !(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
}
/**
* Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag
@@ -52772,7 +53879,7 @@ var ts;
if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) {
// try to reuse the existing annotation
var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation);
- if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
+ if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
if (result_6) {
return result_6;
@@ -52781,20 +53888,30 @@ var ts;
}
}
var oldFlags = context.flags;
- if (type.flags & 8192 /* UniqueESSymbol */ &&
+ if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ &&
type.symbol === symbol && (!context.enclosingDeclaration || ts.some(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); }))) {
- context.flags |= 1048576 /* AllowUniqueESSymbolType */;
+ context.flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */;
}
var result = typeToTypeNodeHelper(type, context);
context.flags = oldFlags;
return result;
}
+ function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type) {
+ var typeFromTypeNode = getTypeFromTypeNode(typeNode);
+ if (typeFromTypeNode === type) {
+ return true;
+ }
+ if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) {
+ return getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */) === typeFromTypeNode;
+ }
+ return false;
+ }
function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
if (!isErrorType(type) && context.enclosingDeclaration) {
var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation) {
var annotated = getTypeFromTypeNode(annotation);
- var thisInstantiated = annotated.flags & 262144 /* TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated;
+ var thisInstantiated = annotated.flags & 262144 /* TypeFlags.TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated;
if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) {
var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled);
if (result) {
@@ -52813,20 +53930,20 @@ var ts;
introducesError = true;
return { introducesError: introducesError, node: node };
}
- var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true);
+ var sym = resolveEntityName(leftmost, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true);
if (sym) {
- if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* Accessible */) {
+ if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* SymbolAccessibility.Accessible */) {
introducesError = true;
}
else {
- (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* All */);
+ (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */);
includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym);
}
if (ts.isIdentifier(node)) {
var type = getDeclaredTypeOfSymbol(sym);
- var name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node);
+ var name = sym.flags & 262144 /* SymbolFlags.TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node);
name.symbol = sym; // for quickinfo, which uses identifier symbol information
- return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) };
+ return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* EmitFlags.NoAsciiEscaping */) };
}
}
return { introducesError: introducesError, node: node };
@@ -52844,17 +53961,17 @@ var ts;
return transformed === existing ? ts.setTextRange(ts.factory.cloneNode(existing), existing) : transformed;
function visitExistingNodeTreeSymbols(node) {
// We don't _actually_ support jsdoc namepath types, emit `any` instead
- if (ts.isJSDocAllType(node) || node.kind === 317 /* JSDocNamepathType */) {
- return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */);
+ if (ts.isJSDocAllType(node) || node.kind === 319 /* SyntaxKind.JSDocNamepathType */) {
+ return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */);
}
if (ts.isJSDocUnknownType(node)) {
- return ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */);
+ return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */);
}
if (ts.isJSDocNullableType(node)) {
return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createLiteralTypeNode(ts.factory.createNull())]);
}
if (ts.isJSDocOptionalType(node)) {
- return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(152 /* UndefinedKeyword */)]);
+ return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)]);
}
if (ts.isJSDocNonNullableType(node)) {
return ts.visitNode(node.type, visitExistingNodeTreeSymbols);
@@ -52868,11 +53985,11 @@ var ts;
var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText);
var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined;
return ts.factory.createPropertySignature(
- /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */));
+ /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */));
}));
}
if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") {
- return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), node);
+ return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), node);
}
if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) {
return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature(
@@ -52889,16 +54006,16 @@ var ts;
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(
/*decorators*/ undefined,
/*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols),
- /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */));
+ /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */));
}
else {
return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols),
- /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */));
+ /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */));
}
}
- if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* Type */, /*ignoreErrors*/ true))) {
+ if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true))) {
return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
}
if (ts.isLiteralImportTypeNode(node)) {
@@ -52907,7 +54024,7 @@ var ts;
nodeSymbol &&
(
// The import type resolved using jsdoc fallback logic
- (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */)) ||
+ (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* SymbolFlags.Type */)) ||
// The import type had type arguments autofilled by js fallback logic
!(ts.length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) {
return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
@@ -52922,11 +54039,11 @@ var ts;
}
}
if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) {
- ts.setEmitFlags(node, 1 /* SingleLine */);
+ ts.setEmitFlags(node, 1 /* EmitFlags.SingleLine */);
}
return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext);
function getEffectiveDotDotDotForParameter(p) {
- return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined);
+ return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined);
}
/** Note that `new:T` parameters are not handled, but should be before calling this function. */
function getNameForJSDocFunctionParameter(p, index) {
@@ -52963,8 +54080,8 @@ var ts;
}
}
function symbolTableToDeclarationStatements(symbolTable, context, bundled) {
- var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 168 /* MethodDeclaration */, /*useAcessors*/ true);
- var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 167 /* MethodSignature */, /*useAcessors*/ false);
+ var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169 /* SyntaxKind.MethodDeclaration */, /*useAcessors*/ true);
+ var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168 /* SyntaxKind.MethodSignature */, /*useAcessors*/ false);
// TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of
// declaration mapping
// We save the enclosing declaration off here so it's not adjusted by well-meaning declaration
@@ -52977,10 +54094,10 @@ var ts;
var oldcontext = context;
context = __assign(__assign({}, oldcontext), { usedSymbolNames: new ts.Set(oldcontext.usedSymbolNames), remappedSymbolNames: new ts.Map(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) {
var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeAliases*/ false);
- if (accessibleResult.accessibility === 0 /* Accessible */) {
+ if (accessibleResult.accessibility === 0 /* SymbolAccessibility.Accessible */) {
// Lookup the root symbol of the chain of refs we'll use to access it and serialize it
var chain = lookupSymbolChainWorker(sym, context, meaning);
- if (!(sym.flags & 4 /* Property */)) {
+ if (!(sym.flags & 4 /* SymbolFlags.Property */)) {
includePrivateSymbol(chain[0]);
}
}
@@ -52995,16 +54112,16 @@ var ts;
void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames`
});
var addingDeclare = !bundled;
- var exportEquals = symbolTable.get("export=" /* ExportEquals */);
- if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* Alias */) {
+ var exportEquals = symbolTable.get("export=" /* InternalSymbolName.ExportEquals */);
+ if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* SymbolFlags.Alias */) {
symbolTable = ts.createSymbolTable();
// Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up)
- symbolTable.set("export=" /* ExportEquals */, exportEquals);
+ symbolTable.set("export=" /* InternalSymbolName.ExportEquals */, exportEquals);
}
visitSymbolTable(symbolTable);
return mergeRedundantStatements(results);
function isIdentifierAndNotUndefined(node) {
- return !!node && node.kind === 79 /* Identifier */;
+ return !!node && node.kind === 79 /* SyntaxKind.Identifier */;
}
function getNamesOfDeclaration(statement) {
if (ts.isVariableStatement(statement)) {
@@ -53021,8 +54138,8 @@ var ts;
ns.body && ts.isModuleBlock(ns.body)) {
// Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from
// the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments
- var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* Export */); });
- var name_2 = ns.name;
+ var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* ModifierFlags.Export */); });
+ 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(
@@ -53033,13 +54150,13 @@ var ts;
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, nsIndex), true), [ns], false), statements.slice(nsIndex + 1), true);
}
// Pass 1: Flatten `export namespace _exports {} export = _exports;` so long as the `export=` only points at a single namespace declaration
- if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, name_2); })) {
+ if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, name_3); })) {
results = [];
// If the namespace contains no export assignments or declarations, and no declarations flagged with `export`, then _everything_ is exported -
// to respect this as the top level, we need to add an `export` modifier to everything
- var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); });
+ var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* ModifierFlags.Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); });
ts.forEach(body.statements, function (s) {
- addResult(s, mixinExportFlag_1 ? 1 /* Export */ : 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag
+ addResult(s, mixinExportFlag_1 ? 1 /* ModifierFlags.Export */ : 0 /* ModifierFlags.None */); // Recalculates the ambient (and export, if applicable from above) flag
});
statements = __spreadArray(__spreadArray([], ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), true), results, true);
}
@@ -53135,11 +54252,11 @@ var ts;
isTypeDeclaration(node);
}
function addExportModifier(node) {
- var flags = (ts.getEffectiveModifierFlags(node) | 1 /* Export */) & ~2 /* Ambient */;
+ var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */;
return ts.factory.updateModifiers(node, flags);
}
function removeExportModifier(node) {
- var flags = ts.getEffectiveModifierFlags(node) & ~1 /* Export */;
+ var flags = ts.getEffectiveModifierFlags(node) & ~1 /* ModifierFlags.Export */;
return ts.factory.updateModifiers(node, flags);
}
function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) {
@@ -53190,39 +54307,39 @@ var ts;
// If it's a class/interface/function: emit a class/interface/function with a `default` modifier
// These forms can merge, eg (`export default 12; export default interface A {}`)
function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) {
- var _a, _b;
+ var _a, _b, _c, _d;
var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName);
- var isDefault = symbol.escapedName === "default" /* Default */;
- if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) {
+ var isDefault = symbol.escapedName === "default" /* InternalSymbolName.Default */;
+ if (isPrivate && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) {
// Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :(
context.encounteredError = true;
// TODO: Issue error via symbol tracker?
return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name
}
- var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* ExportDoesNotSupportDefaultModifier */
- || (symbol.flags & 16 /* Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* Alias */); // An alias symbol should preclude needing to make an alias ourselves
+ var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* SymbolFlags.ExportDoesNotSupportDefaultModifier */
+ || (symbol.flags & 16 /* SymbolFlags.Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* SymbolFlags.Alias */); // An alias symbol should preclude needing to make an alias ourselves
var needsExportDeclaration = !needsPostExportDefault && !isPrivate && ts.isStringANonContextualKeyword(symbolName) && !isDefault;
// `serializeVariableOrProperty` will handle adding the export declaration if it is run (since `getInternalSymbolName` will create the name mapping), so we need to ensuer we unset `needsExportDeclaration` if it is
if (needsPostExportDefault || needsExportDeclaration) {
isPrivate = true;
}
- var modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* Default */ : 0);
- var isConstMergedWithNS = symbol.flags & 1536 /* Module */ &&
- symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) &&
- symbol.escapedName !== "export=" /* ExportEquals */;
+ var modifierFlags = (!isPrivate ? 1 /* ModifierFlags.Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* ModifierFlags.Default */ : 0);
+ var isConstMergedWithNS = symbol.flags & 1536 /* SymbolFlags.Module */ &&
+ symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) &&
+ symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */;
var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol);
- if (symbol.flags & (16 /* Function */ | 8192 /* Method */) || isConstMergedWithNSPrintableAsSignatureMerge) {
+ if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) || isConstMergedWithNSPrintableAsSignatureMerge) {
serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
}
- if (symbol.flags & 524288 /* TypeAlias */) {
+ if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) {
serializeTypeAlias(symbol, symbolName, modifierFlags);
}
// Need to skip over export= symbols below - json source files get a single `Property` flagged
// symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is.
- if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */)
- && symbol.escapedName !== "export=" /* ExportEquals */
- && !(symbol.flags & 4194304 /* Prototype */)
- && !(symbol.flags & 32 /* Class */)
+ if (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */)
+ && symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */
+ && !(symbol.flags & 4194304 /* SymbolFlags.Prototype */)
+ && !(symbol.flags & 32 /* SymbolFlags.Class */)
&& !isConstMergedWithNSPrintableAsSignatureMerge) {
if (propertyAsAlias) {
var createdExport = serializeMaybeAliasAssignment(symbol);
@@ -53234,36 +54351,40 @@ var ts;
else {
var type = getTypeOfSymbol(symbol);
var localName = getInternalSymbolName(symbol, symbolName);
- if (!(symbol.flags & 16 /* Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) {
+ if (!(symbol.flags & 16 /* SymbolFlags.Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) {
// If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns
serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags);
}
else {
// A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_
// `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property`
- var flags = !(symbol.flags & 2 /* BlockScopedVariable */) ? undefined
- : isConstVariable(symbol) ? 2 /* Const */
- : 1 /* Let */;
- var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol);
+ var flags = !(symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */)
+ ? ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isSourceFile((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration)
+ ? 2 /* NodeFlags.Const */
+ : undefined
+ : isConstVariable(symbol)
+ ? 2 /* NodeFlags.Const */
+ : 1 /* NodeFlags.Let */;
+ var name = (needsPostExportDefault || !(symbol.flags & 4 /* SymbolFlags.Property */)) ? localName : getUnusedName(localName, symbol);
var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); });
if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) {
textRange = textRange.parent.parent;
}
- var propertyAccessRequire = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isPropertyAccessExpression);
+ var propertyAccessRequire = (_c = symbol.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isPropertyAccessExpression);
if (propertyAccessRequire && ts.isBinaryExpression(propertyAccessRequire.parent) && ts.isIdentifier(propertyAccessRequire.parent.right)
- && ((_b = type.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration) && ts.isSourceFile(type.symbol.valueDeclaration)) {
+ && ((_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(
/*decorators*/ undefined,
/*modifiers*/ undefined,
- /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* None */);
- context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* Value */);
+ /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* ModifierFlags.None */);
+ context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* SymbolFlags.Value */);
}
else {
var statement = ts.setTextRange(ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([
ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled))
], flags)), textRange);
- addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags);
+ addResult(statement, name !== localName ? modifierFlags & ~1 /* ModifierFlags.Export */ : modifierFlags);
if (name !== localName && !isPrivate) {
// We rename the variable declaration we generate for Property symbols since they may have a name which
// conflicts with a local declaration. For example, given input:
@@ -53289,7 +54410,7 @@ var ts;
addResult(ts.factory.createExportDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined,
- /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* None */);
+ /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* ModifierFlags.None */);
needsExportDeclaration = false;
needsPostExportDefault = false;
}
@@ -53297,11 +54418,11 @@ var ts;
}
}
}
- if (symbol.flags & 384 /* Enum */) {
+ if (symbol.flags & 384 /* SymbolFlags.Enum */) {
serializeEnum(symbol, symbolName, modifierFlags);
}
- if (symbol.flags & 32 /* Class */) {
- if (symbol.flags & 4 /* Property */
+ if (symbol.flags & 32 /* SymbolFlags.Class */) {
+ if (symbol.flags & 4 /* SymbolFlags.Property */
&& symbol.valueDeclaration
&& ts.isBinaryExpression(symbol.valueDeclaration.parent)
&& ts.isClassExpression(symbol.valueDeclaration.parent.right)) {
@@ -53314,40 +54435,40 @@ var ts;
serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
}
}
- if ((symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) {
+ if ((symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) {
serializeModule(symbol, symbolName, modifierFlags);
}
// The class meaning serialization should handle serializing all interface members
- if (symbol.flags & 64 /* Interface */ && !(symbol.flags & 32 /* Class */)) {
+ if (symbol.flags & 64 /* SymbolFlags.Interface */ && !(symbol.flags & 32 /* SymbolFlags.Class */)) {
serializeInterface(symbol, symbolName, modifierFlags);
}
- if (symbol.flags & 2097152 /* Alias */) {
+ if (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
}
- if (symbol.flags & 4 /* Property */ && symbol.escapedName === "export=" /* ExportEquals */) {
+ if (symbol.flags & 4 /* SymbolFlags.Property */ && symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) {
serializeMaybeAliasAssignment(symbol);
}
- if (symbol.flags & 8388608 /* ExportStar */) {
+ if (symbol.flags & 8388608 /* SymbolFlags.ExportStar */) {
// synthesize export * from "moduleReference"
// Straightforward - only one thing to do - make an export declaration
if (symbol.declarations) {
- for (var _i = 0, _c = symbol.declarations; _i < _c.length; _i++) {
- var node = _c[_i];
+ for (var _i = 0, _e = symbol.declarations; _i < _e.length; _i++) {
+ var node = _e[_i];
var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
if (!resolvedModule)
continue;
- addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */);
+ addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* ModifierFlags.None */);
}
}
}
if (needsPostExportDefault) {
- addResult(ts.factory.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* None */);
+ addResult(ts.factory.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* ModifierFlags.None */);
}
else if (needsExportDeclaration) {
addResult(ts.factory.createExportDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined,
- /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* None */);
+ /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* ModifierFlags.None */);
}
}
function includePrivateSymbol(symbol) {
@@ -53360,7 +54481,7 @@ var ts;
// will throw a wrench in this, since those may have been nested, but we'll need to synthesize them in the outer scope
// anyway, as that's the only place the import they translate to is valid. In such a case, we might need to use a unique name
// for the moved import; which hopefully the above `getUnusedName` call should produce.
- var isExternalImportAlias = !!(symbol.flags & 2097152 /* Alias */) && !ts.some(symbol.declarations, function (d) {
+ var isExternalImportAlias = !!(symbol.flags & 2097152 /* SymbolFlags.Alias */) && !ts.some(symbol.declarations, function (d) {
return !!ts.findAncestor(d, ts.isExportDeclaration) ||
ts.isNamespaceExport(d) ||
(ts.isImportEqualsDeclaration(d) && !ts.isExternalModuleReference(d.moduleReference));
@@ -53374,23 +54495,23 @@ var ts;
// Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node`
function addResult(node, additionalModifierFlags) {
if (ts.canHaveModifiers(node)) {
- var newModifierFlags = 0 /* None */;
+ var newModifierFlags = 0 /* ModifierFlags.None */;
var enclosingDeclaration_1 = context.enclosingDeclaration &&
(ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration);
- if (additionalModifierFlags & 1 /* Export */ &&
+ if (additionalModifierFlags & 1 /* ModifierFlags.Export */ &&
enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) &&
canHaveExportModifier(node)) {
// Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private
- newModifierFlags |= 1 /* Export */;
+ newModifierFlags |= 1 /* ModifierFlags.Export */;
}
- if (addingDeclare && !(newModifierFlags & 1 /* Export */) &&
- (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 8388608 /* Ambient */)) &&
+ if (addingDeclare && !(newModifierFlags & 1 /* ModifierFlags.Export */) &&
+ (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* NodeFlags.Ambient */)) &&
(ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) {
// Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope
- newModifierFlags |= 2 /* Ambient */;
+ newModifierFlags |= 2 /* ModifierFlags.Ambient */;
}
- if ((additionalModifierFlags & 512 /* Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) {
- newModifierFlags |= 512 /* Default */;
+ if ((additionalModifierFlags & 512 /* ModifierFlags.Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) {
+ newModifierFlags |= 512 /* ModifierFlags.Default */;
}
if (newModifierFlags) {
node = ts.factory.updateModifiers(node, newModifierFlags | ts.getEffectiveModifierFlags(node));
@@ -53406,14 +54527,14 @@ var ts;
var jsdocAliasDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isJSDocTypeAlias);
var commentText = ts.getTextOfJSDocComment(jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined);
var oldFlags = context.flags;
- context.flags |= 8388608 /* InTypeAlias */;
+ context.flags |= 8388608 /* NodeBuilderFlags.InTypeAlias */;
var oldEnclosingDecl = context.enclosingDeclaration;
context.enclosingDeclaration = jsdocAliasDecl;
var typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression
&& ts.isJSDocTypeExpression(jsdocAliasDecl.typeExpression)
&& serializeExistingTypeNode(context, jsdocAliasDecl.typeExpression.type, includePrivateSymbol, bundled)
|| typeToTypeNodeHelper(aliasType, context);
- addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags);
+ addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags);
context.flags = oldFlags;
context.enclosingDeclaration = oldEnclosingDecl;
}
@@ -53424,10 +54545,10 @@ var ts;
var baseTypes = getBaseTypes(interfaceType);
var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined;
var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); });
- var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 173 /* CallSignature */);
- var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 174 /* ConstructSignature */);
+ var callSignatures = serializeSignatures(0 /* SignatureKind.Call */, interfaceType, baseType, 174 /* SyntaxKind.CallSignature */);
+ var constructSignatures = serializeSignatures(1 /* SignatureKind.Construct */, interfaceType, baseType, 175 /* SyntaxKind.ConstructSignature */);
var indexSignatures = serializeIndexSignatures(interfaceType, baseType);
- var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))];
+ var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* SymbolFlags.Value */); }))];
addResult(ts.factory.createInterfaceDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures, true), constructSignatures, true), callSignatures, true), members, true)), modifierFlags);
@@ -53436,7 +54557,7 @@ var ts;
return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember);
}
function isTypeOnlyNamespace(symbol) {
- return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* Value */); });
+ return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* SymbolFlags.Value */); });
}
function serializeModule(symbol, symbolName, modifierFlags) {
var members = getNamespaceMembersForSerialization(symbol);
@@ -53449,7 +54570,7 @@ var ts;
// so we don't even have placeholders to fill in.
if (ts.length(realMembers)) {
var localName = getInternalSymbolName(symbol, symbolName);
- serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* Function */ | 67108864 /* Assignment */)));
+ serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* SymbolFlags.Function */ | 67108864 /* SymbolFlags.Assignment */)));
}
if (ts.length(mergedMembers)) {
var containingFile_1 = ts.getSourceFileOfNode(context.enclosingDeclaration);
@@ -53457,7 +54578,7 @@ var ts;
var nsBody = ts.factory.createModuleBlock([ts.factory.createExportDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined,
- /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) {
+ /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; }), function (s) {
var _a, _b;
var name = ts.unescapeLeadingUnderscores(s.escapedName);
var localName = getInternalSymbolName(s, name);
@@ -53473,12 +54594,12 @@ var ts;
})))]);
addResult(ts.factory.createModuleDeclaration(
/*decorators*/ undefined,
- /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* Namespace */), 0 /* None */);
+ /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* NodeFlags.Namespace */), 0 /* ModifierFlags.None */);
}
}
function serializeEnum(symbol, symbolName, modifierFlags) {
addResult(ts.factory.createEnumDeclaration(
- /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* EnumMember */); }), function (p) {
+ /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* ModifierFlags.Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* SymbolFlags.EnumMember */); }), function (p) {
// TODO: Handle computed names
// I hate that to get the initialized value we need to walk back to the declarations here; but there's no
// other way to get the possible const value of an enum member that I'm aware of, as the value is cached
@@ -53490,22 +54611,22 @@ var ts;
})), modifierFlags);
}
function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) {
- var signatures = getSignaturesOfType(type, 0 /* Call */);
+ var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */);
for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) {
var sig = signatures_2[_i];
// Each overload becomes a separate function declaration, in order
- var decl = signatureToSignatureDeclarationHelper(sig, 255 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled });
+ var decl = signatureToSignatureDeclarationHelper(sig, 256 /* SyntaxKind.FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled });
addResult(ts.setTextRange(decl, getSignatureTextRangeLocation(sig)), modifierFlags);
}
// Module symbol emit will take care of module-y members, provided it has exports
- if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) {
+ if (!(symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) {
var props = ts.filter(getPropertiesOfType(type), isNamespaceMember);
serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true);
}
}
function getSignatureTextRangeLocation(signature) {
if (signature.declaration && signature.declaration.parent) {
- if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* Property */) {
+ if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* AssignmentDeclarationKind.Property */) {
return signature.declaration.parent;
}
// for expressions assigned to `var`s, use the `var` as the text range
@@ -53539,7 +54660,7 @@ var ts;
// emit akin to the above would be needed.
// Add a namespace
// Create namespace as non-synthetic so it is usable as an enclosing declaration
- var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* Namespace */);
+ var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */);
ts.setParent(fakespace, enclosingDeclaration);
fakespace.locals = ts.createSymbolTable(props);
fakespace.symbol = props[0].parent;
@@ -53560,15 +54681,15 @@ var ts;
var defaultReplaced = ts.map(declarations, function (d) { return ts.isExportAssignment(d) && !d.isExportEquals && ts.isIdentifier(d.expression) ? ts.factory.createExportDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined,
- /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* Default */))])) : d; });
- var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced;
+ /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* InternalSymbolName.Default */))])) : d; });
+ var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* ModifierFlags.Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced;
fakespace = ts.factory.updateModuleDeclaration(fakespace, fakespace.decorators, fakespace.modifiers, fakespace.name, ts.factory.createModuleBlock(exportModifierStripped));
addResult(fakespace, modifierFlags); // namespaces can never be default exported
}
}
function isNamespaceMember(p) {
- return !!(p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) ||
- !(p.flags & 4194304 /* Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent));
+ return !!(p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */)) ||
+ !(p.flags & 4194304 /* SymbolFlags.Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent));
}
function sanitizeJSDocImplements(clauses) {
var result = ts.mapDefined(clauses, function (e) {
@@ -53617,7 +54738,7 @@ var ts;
var staticBaseType = isClass
? getBaseConstructorTypeOfClass(staticType)
: anyType;
- var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* ImplementsKeyword */, implementsExpressions)], true);
+ var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* SyntaxKind.ImplementsKeyword */, implementsExpressions)], true);
var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType));
var publicSymbolProps = ts.filter(symbolProps, function (s) {
// `valueDeclaration` could be undefined if inherited from
@@ -53644,17 +54765,17 @@ var ts;
ts.emptyArray;
var publicProperties = ts.flatMap(publicSymbolProps, function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); });
// Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics
- var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); });
+ var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); });
// When we encounter an `X.prototype.y` assignment in a JS file, we bind `X` as a class regardless as to whether
// the value is ever initialized with a class or function-like value. For cases where `X` could never be
// created via `new`, we will inject a `private constructor()` declaration to indicate it is not createable.
var isNonConstructableClassLikeInJsFile = !isClass &&
!!symbol.valueDeclaration &&
ts.isInJSFile(symbol.valueDeclaration) &&
- !ts.some(getSignaturesOfType(staticType, 1 /* Construct */));
+ !ts.some(getSignaturesOfType(staticType, 1 /* SignatureKind.Construct */));
var constructors = isNonConstructableClassLikeInJsFile ?
- [ts.factory.createConstructorDeclaration(/*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(8 /* Private */), [], /*body*/ undefined)] :
- serializeSignatures(1 /* Construct */, staticType, staticBaseType, 170 /* Constructor */);
+ [ts.factory.createConstructorDeclaration(/*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(8 /* ModifierFlags.Private */), [], /*body*/ undefined)] :
+ serializeSignatures(1 /* SignatureKind.Construct */, staticType, staticBaseType, 171 /* SyntaxKind.Constructor */);
var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]);
context.enclosingDeclaration = oldEnclosing;
addResult(ts.setTextRange(ts.factory.createClassDeclaration(
@@ -53697,15 +54818,15 @@ var ts;
// If `target` refers to a shorthand module symbol, the name we're trying to pull out isn;t recoverable from the target symbol
// In such a scenario, we must fall back to looking for an alias declaration on `symbol` and pulling the target name from that
var verbatimTargetName = ts.isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || ts.unescapeLeadingUnderscores(target.escapedName);
- if (verbatimTargetName === "export=" /* ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) {
+ if (verbatimTargetName === "export=" /* InternalSymbolName.ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) {
// target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match
- verbatimTargetName = "default" /* Default */;
+ verbatimTargetName = "default" /* InternalSymbolName.Default */;
}
var targetName = getInternalSymbolName(target, verbatimTargetName);
includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first
switch (node.kind) {
- case 202 /* BindingElement */:
- if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 253 /* VariableDeclaration */) {
+ case 203 /* SyntaxKind.BindingElement */:
+ if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254 /* SyntaxKind.VariableDeclaration */) {
// const { SomeClass } = require('./lib');
var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); // './lib'
var propertyName = node.propertyName;
@@ -53713,19 +54834,19 @@ var ts;
/*decorators*/ undefined,
/*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier(
/*isTypeOnly*/ false, propertyName && ts.isIdentifier(propertyName) ? ts.factory.createIdentifier(ts.idText(propertyName)) : undefined, ts.factory.createIdentifier(localName))])), ts.factory.createStringLiteral(specifier_1),
- /*importClause*/ undefined), 0 /* None */);
+ /*importClause*/ undefined), 0 /* ModifierFlags.None */);
break;
}
// We don't know how to serialize this (nested?) binding element
ts.Debug.failBadSyntaxKind(((_c = node.parent) === null || _c === void 0 ? void 0 : _c.parent) || node, "Unhandled binding element grandparent kind in declaration serialization");
break;
- case 295 /* ShorthandPropertyAssignment */:
- if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 220 /* BinaryExpression */) {
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
+ if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 221 /* SyntaxKind.BinaryExpression */) {
// module.exports = { SomeClass }
serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName);
}
break;
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
// commonjs require: const x = require('y')
if (ts.isPropertyAccessExpression(node.initializer)) {
// const x = require('y').z
@@ -53736,7 +54857,7 @@ var ts;
addResult(ts.factory.createImportEqualsDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined,
- /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* None */);
+ /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* ModifierFlags.None */);
// import x = _x.z
addResult(ts.factory.createImportEqualsDeclaration(
/*decorators*/ undefined,
@@ -53745,30 +54866,30 @@ var ts;
break;
}
// else fall through and treat commonjs require just like import=
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
// This _specifically_ only exists to handle json declarations - where we make aliases, but since
// we emit no declarations for the json document, must not refer to it in the declarations
- if (target.escapedName === "export=" /* ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) {
+ if (target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) {
serializeMaybeAliasAssignment(symbol);
break;
}
// Could be a local `import localName = ns.member` or
// an external `import localName = require("whatever")`
- var isLocalImport = !(target.flags & 512 /* ValueModule */) && !ts.isVariableDeclaration(node);
+ var isLocalImport = !(target.flags & 512 /* SymbolFlags.ValueModule */) && !ts.isVariableDeclaration(node);
addResult(ts.factory.createImportEqualsDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined,
/*isTypeOnly*/ false, ts.factory.createIdentifier(localName), isLocalImport
- ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)
- : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* None */);
+ ? symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false)
+ : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* ModifierFlags.None */);
break;
- case 263 /* NamespaceExportDeclaration */:
+ case 264 /* SyntaxKind.NamespaceExportDeclaration */:
// export as namespace foo
// TODO: Not part of a file's local or export symbol tables
// Is bound into file.symbol.globalExports instead, which we don't currently traverse
- addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */);
+ addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* ModifierFlags.None */);
break;
- case 266 /* ImportClause */:
+ case 267 /* SyntaxKind.ImportClause */:
addResult(ts.factory.createImportDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, ts.factory.createIdentifier(localName), /*namedBindings*/ undefined),
@@ -53776,21 +54897,21 @@ var ts;
// And then made into a default by the `esModuleInterop` or `allowSyntheticDefaultImports` flag
// In such cases, the `target` refers to the module itself already
ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)),
- /*assertClause*/ undefined), 0 /* None */);
+ /*assertClause*/ undefined), 0 /* ModifierFlags.None */);
break;
- case 267 /* NamespaceImport */:
+ case 268 /* SyntaxKind.NamespaceImport */:
addResult(ts.factory.createImportDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)),
- /*assertClause*/ undefined), 0 /* None */);
+ /*assertClause*/ undefined), 0 /* ModifierFlags.None */);
break;
- case 273 /* NamespaceExport */:
+ case 274 /* SyntaxKind.NamespaceExport */:
addResult(ts.factory.createExportDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined,
- /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */);
+ /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* ModifierFlags.None */);
break;
- case 269 /* ImportSpecifier */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
addResult(ts.factory.createImportDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined, ts.factory.createImportClause(
@@ -53799,9 +54920,9 @@ var ts;
ts.factory.createImportSpecifier(
/*isTypeOnly*/ false, localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName))
])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)),
- /*assertClause*/ undefined), 0 /* None */);
+ /*assertClause*/ undefined), 0 /* ModifierFlags.None */);
break;
- case 274 /* ExportSpecifier */:
+ case 275 /* SyntaxKind.ExportSpecifier */:
// does not use localName because the symbol name in this case refers to the name in the exports table,
// which we must exactly preserve
var specifier = node.parent.parent.moduleSpecifier;
@@ -53809,16 +54930,16 @@ var ts;
// another file
serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.factory.createStringLiteral(specifier.text) : undefined);
break;
- case 270 /* ExportAssignment */:
+ case 271 /* SyntaxKind.ExportAssignment */:
serializeMaybeAliasAssignment(symbol);
break;
- case 220 /* BinaryExpression */:
- case 205 /* PropertyAccessExpression */:
- case 206 /* ElementAccessExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
// Could be best encoded as though an export specifier or as though an export assignment
// If name is default or export=, do an export assignment
// Otherwise do an export specifier
- if (symbol.escapedName === "default" /* Default */ || symbol.escapedName === "export=" /* ExportEquals */) {
+ if (symbol.escapedName === "default" /* InternalSymbolName.Default */ || symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) {
serializeMaybeAliasAssignment(symbol);
}
else {
@@ -53833,18 +54954,18 @@ var ts;
addResult(ts.factory.createExportDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined,
- /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */);
+ /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* ModifierFlags.None */);
}
/**
* Returns `true` if an export assignment or declaration was produced for the symbol
*/
function serializeMaybeAliasAssignment(symbol) {
- if (symbol.flags & 4194304 /* Prototype */) {
+ if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) {
return false;
}
var name = ts.unescapeLeadingUnderscores(symbol.escapedName);
- var isExportEquals = name === "export=" /* ExportEquals */;
- var isDefault = name === "default" /* Default */;
+ var isExportEquals = name === "export=" /* InternalSymbolName.ExportEquals */;
+ var isDefault = name === "default" /* InternalSymbolName.Default */;
var isExportAssignmentCompatibleSymbolName = isExportEquals || isDefault;
// synthesize export = ref
// ref should refer to either be a locally scoped symbol which we need to emit, or
@@ -53859,7 +54980,7 @@ var ts;
// Technically, this is all that's required in the case where the assignment is an entity name expression
var expr = aliasDecl && ((ts.isExportAssignment(aliasDecl) || ts.isBinaryExpression(aliasDecl)) ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl));
var first_1 = expr && ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined;
- var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration);
+ var referenced = first_1 && resolveEntityName(first_1, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration);
if (referenced || target) {
includePrivateSymbol(referenced || target);
}
@@ -53873,7 +54994,7 @@ var ts;
if (isExportAssignmentCompatibleSymbolName) {
results.push(ts.factory.createExportAssignment(
/*decorators*/ undefined,
- /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */)));
+ /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* SymbolFlags.All */)));
}
else {
if (first_1 === expr && first_1) {
@@ -53889,7 +55010,7 @@ var ts;
addResult(ts.factory.createImportEqualsDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined,
- /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)), 0 /* None */);
+ /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false)), 0 /* ModifierFlags.None */);
serializeExportSpecifier(name, varName);
}
}
@@ -53904,17 +55025,17 @@ var ts;
var typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol)));
if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) {
// If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const
- serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 1 /* Export */);
+ serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* ModifierFlags.None */ : 1 /* ModifierFlags.Export */);
}
else {
var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([
ts.factory.createVariableDeclaration(varName, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled))
- ], 2 /* Const */));
+ ], 2 /* NodeFlags.Const */));
// Inlined JSON types exported with [module.]exports= will already emit an export=, so should use `declare`.
// Otherwise, the type itself should be exported.
- addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */
- : name === varName ? 1 /* Export */
- : 0 /* None */);
+ addResult(statement, target && target.flags & 4 /* SymbolFlags.Property */ && target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ModifierFlags.Ambient */
+ : name === varName ? 1 /* ModifierFlags.Export */
+ : 0 /* ModifierFlags.None */);
}
if (isExportAssignmentCompatibleSymbolName) {
results.push(ts.factory.createExportAssignment(
@@ -53934,11 +55055,11 @@ var ts;
// context source file, and whose property names are all valid identifiers and not late-bound, _and_
// whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it)
var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration);
- return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) &&
+ return ts.getObjectFlags(typeToSerialize) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */) &&
!ts.length(getIndexInfosOfType(typeToSerialize)) &&
!isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class
- !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) &&
- !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK
+ !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* SignatureKind.Call */))) &&
+ !ts.length(getSignaturesOfType(typeToSerialize, 1 /* SignatureKind.Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK
!getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) &&
!(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) &&
!ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) &&
@@ -53949,25 +55070,25 @@ var ts;
return function serializePropertySymbol(p, isStatic, baseType) {
var _a, _b, _c, _d, _e;
var modifierFlags = ts.getDeclarationModifierFlagsFromSymbol(p);
- var isPrivate = !!(modifierFlags & 8 /* Private */);
- if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) {
+ var isPrivate = !!(modifierFlags & 8 /* ModifierFlags.Private */);
+ if (isStatic && (p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */))) {
// Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols
// need to be merged namespace members
return [];
}
- if (p.flags & 4194304 /* Prototype */ ||
+ if (p.flags & 4194304 /* SymbolFlags.Prototype */ ||
(baseType && getPropertyOfType(baseType, p.escapedName)
&& isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p)
- && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */)
+ && (p.flags & 16777216 /* SymbolFlags.Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* SymbolFlags.Optional */)
&& isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) {
return [];
}
- var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0);
+ var flag = (modifierFlags & ~256 /* ModifierFlags.Async */) | (isStatic ? 32 /* ModifierFlags.Static */ : 0);
var name = getPropertyNameNodeForSymbol(p, context);
var firstPropertyLikeDecl = (_a = p.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression));
- if (p.flags & 98304 /* Accessor */ && useAccessors) {
+ if (p.flags & 98304 /* SymbolFlags.Accessor */ && useAccessors) {
var result = [];
- if (p.flags & 65536 /* SetAccessor */) {
+ if (p.flags & 65536 /* SymbolFlags.SetAccessor */) {
result.push(ts.setTextRange(ts.factory.createSetAccessorDeclaration(
/*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [ts.factory.createParameterDeclaration(
/*decorators*/ undefined,
@@ -53976,8 +55097,8 @@ var ts;
/*questionToken*/ undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))],
/*body*/ undefined), ((_b = p.declarations) === null || _b === void 0 ? void 0 : _b.find(ts.isSetAccessor)) || firstPropertyLikeDecl));
}
- if (p.flags & 32768 /* GetAccessor */) {
- var isPrivate_1 = modifierFlags & 8 /* Private */;
+ if (p.flags & 32768 /* SymbolFlags.GetAccessor */) {
+ var isPrivate_1 = modifierFlags & 8 /* ModifierFlags.Private */;
result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration(
/*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled),
/*body*/ undefined), ((_c = p.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isGetAccessor)) || firstPropertyLikeDecl));
@@ -53986,19 +55107,19 @@ var ts;
}
// This is an else/if as accessors and properties can't merge in TS, but might in JS
// If this happens, we assume the accessor takes priority, as it imposes more constraints
- else if (p.flags & (4 /* Property */ | 3 /* Variable */ | 98304 /* Accessor */)) {
+ else if (p.flags & (4 /* SymbolFlags.Property */ | 3 /* SymbolFlags.Variable */ | 98304 /* SymbolFlags.Accessor */)) {
return ts.setTextRange(createProperty(
- /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled),
+ /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled),
// TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357
// interface members can't have initializers, however class members _can_
/*initializer*/ undefined), ((_d = p.declarations) === null || _d === void 0 ? void 0 : _d.find(ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration))) || firstPropertyLikeDecl);
}
- if (p.flags & (8192 /* Method */ | 16 /* Function */)) {
+ if (p.flags & (8192 /* SymbolFlags.Method */ | 16 /* SymbolFlags.Function */)) {
var type = getTypeOfSymbol(p);
- var signatures = getSignaturesOfType(type, 0 /* Call */);
- if (flag & 8 /* Private */) {
+ var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */);
+ if (flag & 8 /* ModifierFlags.Private */) {
return ts.setTextRange(createProperty(
- /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined,
+ /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined,
/*type*/ undefined,
/*initializer*/ undefined), ((_e = p.declarations) === null || _e === void 0 ? void 0 : _e.find(ts.isFunctionLikeDeclaration)) || signatures[0] && signatures[0].declaration || p.declarations && p.declarations[0]);
}
@@ -54008,7 +55129,7 @@ var ts;
// Each overload becomes a separate method declaration, in order
var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context, {
name: name,
- questionToken: p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined,
+ questionToken: p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined,
modifiers: flag ? ts.factory.createModifiersFromModifierFlags(flag) : undefined
});
var location = sig.declaration && ts.isPrototypePropertyAssignment(sig.declaration.parent) ? sig.declaration.parent : sig.declaration;
@@ -54025,13 +55146,13 @@ var ts;
}
function serializeSignatures(kind, input, baseType, outputKind) {
var signatures = getSignaturesOfType(input, kind);
- if (kind === 1 /* Construct */) {
+ if (kind === 1 /* SignatureKind.Construct */) {
if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) {
return []; // No base type, every constructor is empty - elide the extraneous `constructor()`
}
if (baseType) {
// If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations
- var baseSigs = getSignaturesOfType(baseType, 1 /* Construct */);
+ var baseSigs = getSignaturesOfType(baseType, 1 /* SignatureKind.Construct */);
if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) {
return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list
}
@@ -54052,7 +55173,7 @@ var ts;
for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) {
var s = signatures_4[_i];
if (s.declaration) {
- privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* Private */ | 16 /* Protected */);
+ privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */);
}
}
if (privateProtected) {
@@ -54088,15 +55209,15 @@ var ts;
return results;
}
function serializeBaseType(t, staticType, rootName) {
- var ref = trySerializeAsTypeReference(t, 111551 /* Value */);
+ var ref = trySerializeAsTypeReference(t, 111551 /* SymbolFlags.Value */);
if (ref) {
return ref;
}
var tempName = getUnusedName("".concat(rootName, "_base"));
var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([
ts.factory.createVariableDeclaration(tempName, /*exclamationToken*/ undefined, typeToTypeNodeHelper(staticType, context))
- ], 2 /* Const */));
- addResult(statement, 0 /* None */);
+ ], 2 /* NodeFlags.Const */));
+ addResult(statement, 0 /* ModifierFlags.None */);
return ts.factory.createExpressionWithTypeArguments(ts.factory.createIdentifier(tempName), /*typeArgs*/ undefined);
}
function trySerializeAsTypeReference(t, flags) {
@@ -54106,22 +55227,22 @@ var ts;
// which we can't write out in a syntactically valid way as an expression
if (t.target && isSymbolAccessibleByFlags(t.target.symbol, enclosingDeclaration, flags)) {
typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); });
- reference = symbolToExpression(t.target.symbol, context, 788968 /* Type */);
+ reference = symbolToExpression(t.target.symbol, context, 788968 /* SymbolFlags.Type */);
}
else if (t.symbol && isSymbolAccessibleByFlags(t.symbol, enclosingDeclaration, flags)) {
- reference = symbolToExpression(t.symbol, context, 788968 /* Type */);
+ reference = symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */);
}
if (reference) {
return ts.factory.createExpressionWithTypeArguments(reference, typeArgs);
}
}
function serializeImplementedType(t) {
- var ref = trySerializeAsTypeReference(t, 788968 /* Type */);
+ var ref = trySerializeAsTypeReference(t, 788968 /* SymbolFlags.Type */);
if (ref) {
return ref;
}
if (t.symbol) {
- return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* Type */), /*typeArgs*/ undefined);
+ return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */), /*typeArgs*/ undefined);
}
}
function getUnusedName(input, symbol) {
@@ -54148,17 +55269,17 @@ var ts;
return input;
}
function getNameCandidateWorker(symbol, localName) {
- if (localName === "default" /* Default */ || localName === "__class" /* Class */ || localName === "__function" /* Function */) {
+ if (localName === "default" /* InternalSymbolName.Default */ || localName === "__class" /* InternalSymbolName.Class */ || localName === "__function" /* InternalSymbolName.Function */) {
var flags = context.flags;
- context.flags |= 16777216 /* InInitialEntityName */;
+ context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */;
var nameCandidate = getNameOfSymbolAsWritten(symbol, context);
context.flags = flags;
localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate;
}
- if (localName === "default" /* Default */) {
+ if (localName === "default" /* InternalSymbolName.Default */) {
localName = "_default";
}
- else if (localName === "export=" /* ExportEquals */) {
+ else if (localName === "export=" /* InternalSymbolName.ExportEquals */) {
localName = "_exports";
}
localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_");
@@ -54177,14 +55298,14 @@ var ts;
}
}
function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) {
- if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; }
+ if (flags === void 0) { flags = 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; }
return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker);
function typePredicateToStringWorker(writer) {
- var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createToken(128 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217
+ var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) : undefined, typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */) // TODO: GH#18217
);
var printer = ts.createPrinter({ removeComments: true });
var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
- printer.writeNode(4 /* Unspecified */, predicate, /*sourceFile*/ sourceFile, writer);
+ printer.writeNode(4 /* EmitHint.Unspecified */, predicate, /*sourceFile*/ sourceFile, writer);
return writer;
}
}
@@ -54194,10 +55315,10 @@ var ts;
for (var i = 0; i < types.length; i++) {
var t = types[i];
flags |= t.flags;
- if (!(t.flags & 98304 /* Nullable */)) {
- if (t.flags & (512 /* BooleanLiteral */ | 1024 /* EnumLiteral */)) {
- var baseType = t.flags & 512 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t);
- if (baseType.flags & 1048576 /* Union */) {
+ if (!(t.flags & 98304 /* TypeFlags.Nullable */)) {
+ if (t.flags & (512 /* TypeFlags.BooleanLiteral */ | 1024 /* TypeFlags.EnumLiteral */)) {
+ var baseType = t.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t);
+ if (baseType.flags & 1048576 /* TypeFlags.Union */) {
var count = baseType.types.length;
if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) {
result.push(baseType);
@@ -54209,25 +55330,25 @@ var ts;
result.push(t);
}
}
- if (flags & 65536 /* Null */)
+ if (flags & 65536 /* TypeFlags.Null */)
result.push(nullType);
- if (flags & 32768 /* Undefined */)
+ if (flags & 32768 /* TypeFlags.Undefined */)
result.push(undefinedType);
return result || types;
}
function visibilityToString(flags) {
- if (flags === 8 /* Private */) {
+ if (flags === 8 /* ModifierFlags.Private */) {
return "private";
}
- if (flags === 16 /* Protected */) {
+ if (flags === 16 /* ModifierFlags.Protected */) {
return "protected";
}
return "public";
}
function getTypeAliasForTypeLiteral(type) {
- if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && type.symbol.declarations) {
+ if (type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && type.symbol.declarations) {
var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent);
- if (node.kind === 258 /* TypeAliasDeclaration */) {
+ if (node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) {
return getSymbolOfNode(node);
}
}
@@ -54235,26 +55356,26 @@ var ts;
}
function isTopLevelInExternalModuleAugmentation(node) {
return node && node.parent &&
- node.parent.kind === 261 /* ModuleBlock */ &&
+ node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ &&
ts.isExternalModuleAugmentation(node.parent.parent);
}
function isDefaultBindingContext(location) {
- return location.kind === 303 /* SourceFile */ || ts.isAmbientModule(location);
+ return location.kind === 305 /* SyntaxKind.SourceFile */ || ts.isAmbientModule(location);
}
function getNameOfSymbolFromNameType(symbol, context) {
var nameType = getSymbolLinks(symbol).nameType;
if (nameType) {
- if (nameType.flags & 384 /* StringOrNumberLiteral */) {
+ if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) {
var name = "" + nameType.value;
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) {
- return "\"".concat(ts.escapeString(name, 34 /* doubleQuote */), "\"");
+ return "\"".concat(ts.escapeString(name, 34 /* CharacterCodes.doubleQuote */), "\"");
}
if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) {
return "[".concat(name, "]");
}
return name;
}
- if (nameType.flags & 8192 /* UniqueESSymbol */) {
+ if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) {
return "[".concat(getNameOfSymbolAsWritten(nameType.symbol, context), "]");
}
}
@@ -54267,9 +55388,9 @@ var ts;
* It will also use a representation of a number as written instead of a decimal form, e.g. `0o11` instead of `9`.
*/
function getNameOfSymbolAsWritten(symbol, context) {
- if (context && symbol.escapedName === "default" /* Default */ && !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */) &&
+ if (context && symbol.escapedName === "default" /* InternalSymbolName.Default */ && !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */) &&
// If it's not the first part of an entity name, it must print as `default`
- (!(context.flags & 16777216 /* InInitialEntityName */) ||
+ (!(context.flags & 16777216 /* NodeBuilderFlags.InInitialEntityName */) ||
// if the symbol is synthesized, it will only be referenced externally it must print as `default`
!symbol.declarations ||
// if not in the same binding context (source file, module declaration), it must print as `default`
@@ -54278,14 +55399,14 @@ var ts;
}
if (symbol.declarations && symbol.declarations.length) {
var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; }); // Try using a declaration with a name, first
- var name_3 = declaration && ts.getNameOfDeclaration(declaration);
- if (declaration && name_3) {
+ var name_4 = declaration && ts.getNameOfDeclaration(declaration);
+ if (declaration && name_4) {
if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) {
return ts.symbolName(symbol);
}
- if (ts.isComputedPropertyName(name_3) && !(ts.getCheckFlags(symbol) & 4096 /* Late */)) {
+ if (ts.isComputedPropertyName(name_4) && !(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */)) {
var nameType = getSymbolLinks(symbol).nameType;
- if (nameType && nameType.flags & 384 /* StringOrNumberLiteral */) {
+ if (nameType && nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) {
// Computed property name isn't late bound, but has a well-known name type - use name type to generate a symbol name
var result = getNameOfSymbolFromNameType(symbol, context);
if (result !== undefined) {
@@ -54293,22 +55414,22 @@ var ts;
}
}
}
- return ts.declarationNameToString(name_3);
+ return ts.declarationNameToString(name_4);
}
if (!declaration) {
declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway
}
- if (declaration.parent && declaration.parent.kind === 253 /* VariableDeclaration */) {
+ if (declaration.parent && declaration.parent.kind === 254 /* SyntaxKind.VariableDeclaration */) {
return ts.declarationNameToString(declaration.parent.name);
}
switch (declaration.kind) {
- case 225 /* ClassExpression */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
- if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) {
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ if (context && !context.encounteredError && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) {
context.encounteredError = true;
}
- return declaration.kind === 225 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)";
+ return declaration.kind === 226 /* SyntaxKind.ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)";
}
}
var name = getNameOfSymbolFromNameType(symbol, context);
@@ -54325,84 +55446,84 @@ var ts;
return false;
function determineIfDeclarationIsVisible() {
switch (node.kind) {
- case 336 /* JSDocCallbackTag */:
- case 343 /* JSDocTypedefTag */:
- case 337 /* JSDocEnumTag */:
+ case 338 /* SyntaxKind.JSDocCallbackTag */:
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
+ case 339 /* SyntaxKind.JSDocEnumTag */:
// Top-level jsdoc type aliases are considered exported
// First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file
return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent));
- case 202 /* BindingElement */:
+ case 203 /* SyntaxKind.BindingElement */:
return isDeclarationVisible(node.parent.parent);
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
if (ts.isBindingPattern(node.name) &&
!node.name.elements.length) {
// If the binding pattern is empty, this variable declaration is not visible
return false;
}
// falls through
- case 260 /* ModuleDeclaration */:
- case 256 /* ClassDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 258 /* TypeAliasDeclaration */:
- case 255 /* FunctionDeclaration */:
- case 259 /* EnumDeclaration */:
- case 264 /* ImportEqualsDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
// external module augmentation is always visible
if (ts.isExternalModuleAugmentation(node)) {
return true;
}
var parent = getDeclarationContainer(node);
// If the node is not exported or it is not ambient module element (except import declaration)
- if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) &&
- !(node.kind !== 264 /* ImportEqualsDeclaration */ && parent.kind !== 303 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) {
+ if (!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) &&
+ !(node.kind !== 265 /* SyntaxKind.ImportEqualsDeclaration */ && parent.kind !== 305 /* SyntaxKind.SourceFile */ && parent.flags & 16777216 /* NodeFlags.Ambient */)) {
return isGlobalSourceFile(parent);
}
// Exported members/ambient module elements (exception import declaration) are visible if parent is visible
return isDeclarationVisible(parent);
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- if (ts.hasEffectiveModifier(node, 8 /* Private */ | 16 /* Protected */)) {
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) {
// Private/protected properties/methods are not visible
return false;
}
// Public properties/methods are visible if its parents are visible, so:
// falls through
- case 170 /* Constructor */:
- case 174 /* ConstructSignature */:
- case 173 /* CallSignature */:
- case 175 /* IndexSignature */:
- case 163 /* Parameter */:
- case 261 /* ModuleBlock */:
- case 178 /* FunctionType */:
- case 179 /* ConstructorType */:
- case 181 /* TypeLiteral */:
- case 177 /* TypeReference */:
- case 182 /* ArrayType */:
- case 183 /* TupleType */:
- case 186 /* UnionType */:
- case 187 /* IntersectionType */:
- case 190 /* ParenthesizedType */:
- case 196 /* NamedTupleMember */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 176 /* SyntaxKind.IndexSignature */:
+ case 164 /* SyntaxKind.Parameter */:
+ case 262 /* SyntaxKind.ModuleBlock */:
+ case 179 /* SyntaxKind.FunctionType */:
+ case 180 /* SyntaxKind.ConstructorType */:
+ case 182 /* SyntaxKind.TypeLiteral */:
+ case 178 /* SyntaxKind.TypeReference */:
+ case 183 /* SyntaxKind.ArrayType */:
+ case 184 /* SyntaxKind.TupleType */:
+ case 187 /* SyntaxKind.UnionType */:
+ case 188 /* SyntaxKind.IntersectionType */:
+ case 191 /* SyntaxKind.ParenthesizedType */:
+ case 197 /* SyntaxKind.NamedTupleMember */:
return isDeclarationVisible(node.parent);
// Default binding, import specifier and namespace import is visible
// only on demand so by default it is not visible
- case 266 /* ImportClause */:
- case 267 /* NamespaceImport */:
- case 269 /* ImportSpecifier */:
+ case 267 /* SyntaxKind.ImportClause */:
+ case 268 /* SyntaxKind.NamespaceImport */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
return false;
// Type parameters are always visible
- case 162 /* TypeParameter */:
+ case 163 /* SyntaxKind.TypeParameter */:
// Source file and namespace export are always visible
// falls through
- case 303 /* SourceFile */:
- case 263 /* NamespaceExportDeclaration */:
+ case 305 /* SyntaxKind.SourceFile */:
+ case 264 /* SyntaxKind.NamespaceExportDeclaration */:
return true;
// Export assignments do not create name bindings outside the module
- case 270 /* ExportAssignment */:
+ case 271 /* SyntaxKind.ExportAssignment */:
return false;
default:
return false;
@@ -54411,11 +55532,11 @@ var ts;
}
function collectLinkedAliases(node, setVisibility) {
var exportSymbol;
- if (node.parent && node.parent.kind === 270 /* ExportAssignment */) {
- exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false);
+ if (node.parent && node.parent.kind === 271 /* SyntaxKind.ExportAssignment */) {
+ exportSymbol = resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false);
}
- else if (node.parent.kind === 274 /* ExportSpecifier */) {
- exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */);
+ else if (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) {
+ exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */);
}
var result;
var visited;
@@ -54439,7 +55560,7 @@ var ts;
// Add the referenced top container visible
var internalModuleReference = declaration.moduleReference;
var firstIdentifier = ts.getFirstIdentifier(internalModuleReference);
- var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false);
+ var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, undefined, undefined, /*isUse*/ false);
if (importSymbol && visited) {
if (ts.tryAddToSet(visited, getSymbolId(importSymbol))) {
buildVisibleNodeList(importSymbol.declarations);
@@ -54488,22 +55609,24 @@ var ts;
}
function hasType(target, propertyName) {
switch (propertyName) {
- case 0 /* Type */:
+ case 0 /* TypeSystemPropertyName.Type */:
return !!getSymbolLinks(target).type;
- case 5 /* EnumTagType */:
+ case 5 /* TypeSystemPropertyName.EnumTagType */:
return !!(getNodeLinks(target).resolvedEnumType);
- case 2 /* DeclaredType */:
+ case 2 /* TypeSystemPropertyName.DeclaredType */:
return !!getSymbolLinks(target).declaredType;
- case 1 /* ResolvedBaseConstructorType */:
+ case 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */:
return !!target.resolvedBaseConstructorType;
- case 3 /* ResolvedReturnType */:
+ case 3 /* TypeSystemPropertyName.ResolvedReturnType */:
return !!target.resolvedReturnType;
- case 4 /* ImmediateBaseConstraint */:
+ case 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */:
return !!target.immediateBaseConstraint;
- case 6 /* ResolvedTypeArguments */:
+ case 6 /* TypeSystemPropertyName.ResolvedTypeArguments */:
return !!target.resolvedTypeArguments;
- case 7 /* ResolvedBaseTypes */:
+ case 7 /* TypeSystemPropertyName.ResolvedBaseTypes */:
return !!target.baseTypesResolved;
+ case 8 /* TypeSystemPropertyName.WriteType */:
+ return !!getSymbolLinks(target).writeType;
}
return ts.Debug.assertNever(propertyName);
}
@@ -54519,12 +55642,12 @@ var ts;
function getDeclarationContainer(node) {
return ts.findAncestor(ts.getRootDeclaration(node), function (node) {
switch (node.kind) {
- case 253 /* VariableDeclaration */:
- case 254 /* VariableDeclarationList */:
- case 269 /* ImportSpecifier */:
- case 268 /* NamedImports */:
- case 267 /* NamespaceImport */:
- case 266 /* ImportClause */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
+ case 255 /* SyntaxKind.VariableDeclarationList */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
+ case 269 /* SyntaxKind.NamedImports */:
+ case 268 /* SyntaxKind.NamespaceImport */:
+ case 267 /* SyntaxKind.ImportClause */:
return false;
default:
return true;
@@ -54549,28 +55672,28 @@ var ts;
return getTypeOfPropertyOfType(type, name) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || unknownType;
}
function isTypeAny(type) {
- return type && (type.flags & 1 /* Any */) !== 0;
+ return type && (type.flags & 1 /* TypeFlags.Any */) !== 0;
}
function isErrorType(type) {
// The only 'any' types that have alias symbols are those manufactured by getTypeFromTypeAliasReference for
// a reference to an unresolved symbol. We want those to behave like the errorType.
- return type === errorType || !!(type.flags & 1 /* Any */ && type.aliasSymbol);
+ return type === errorType || !!(type.flags & 1 /* TypeFlags.Any */ && type.aliasSymbol);
}
// Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
// assigned by contextual typing.
function getTypeForBindingElementParent(node, checkMode) {
- if (checkMode !== 0 /* Normal */) {
+ if (checkMode !== 0 /* CheckMode.Normal */) {
return getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode);
}
var symbol = getSymbolOfNode(node);
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode);
}
function getRestType(source, properties, symbol) {
- source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); });
- if (source.flags & 131072 /* Never */) {
+ source = filterType(source, function (t) { return !(t.flags & 98304 /* TypeFlags.Nullable */); });
+ if (source.flags & 131072 /* TypeFlags.Never */) {
return emptyObjectType;
}
- if (source.flags & 1048576 /* Union */) {
+ if (source.flags & 1048576 /* TypeFlags.Union */) {
return mapType(source, function (t) { return getRestType(t, properties, symbol); });
}
var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName));
@@ -54578,9 +55701,9 @@ var ts;
var unspreadableToRestKeys = [];
for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
var prop = _a[_i];
- var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */);
+ var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */);
if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType)
- && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */))
+ && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */))
&& isSpreadableProperty(prop)) {
spreadableProperties.push(prop);
}
@@ -54595,7 +55718,7 @@ var ts;
// they are explicitly omitted, as they would in the non-generic case.
omitKeyType = getUnionType(__spreadArray([omitKeyType], unspreadableToRestKeys, true));
}
- if (omitKeyType.flags & 131072 /* Never */) {
+ if (omitKeyType.flags & 131072 /* TypeFlags.Never */) {
return source;
}
var omitTypeAlias = getGlobalOmitSymbol();
@@ -54610,15 +55733,15 @@ var ts;
members.set(prop.escapedName, getSpreadSymbol(prop, /*readonly*/ false));
}
var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(source));
- result.objectFlags |= 8388608 /* ObjectRestType */;
+ result.objectFlags |= 4194304 /* ObjectFlags.ObjectRestType */;
return result;
}
function isGenericTypeWithUndefinedConstraint(type) {
- return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* Undefined */);
+ return !!(type.flags & 465829888 /* TypeFlags.Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* TypeFlags.Undefined */);
}
function getNonUndefinedType(type) {
- var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
- return getTypeWithFacts(typeOrConstraint, 524288 /* NEUndefined */);
+ var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* TypeFlags.Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
+ return getTypeWithFacts(typeOrConstraint, 524288 /* TypeFacts.NEUndefined */);
}
// Determine the control flow type associated with a destructuring declaration or assignment. The following
// forms of destructuring are possible:
@@ -54654,34 +55777,34 @@ var ts;
function getParentElementAccess(node) {
var ancestor = node.parent.parent;
switch (ancestor.kind) {
- case 202 /* BindingElement */:
- case 294 /* PropertyAssignment */:
+ case 203 /* SyntaxKind.BindingElement */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
return getSyntheticElementAccess(ancestor);
- case 203 /* ArrayLiteralExpression */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
return getSyntheticElementAccess(node.parent);
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return ancestor.initializer;
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return ancestor.right;
}
}
function getDestructuringPropertyName(node) {
var parent = node.parent;
- if (node.kind === 202 /* BindingElement */ && parent.kind === 200 /* ObjectBindingPattern */) {
+ if (node.kind === 203 /* SyntaxKind.BindingElement */ && parent.kind === 201 /* SyntaxKind.ObjectBindingPattern */) {
return getLiteralPropertyNameText(node.propertyName || node.name);
}
- if (node.kind === 294 /* PropertyAssignment */ || node.kind === 295 /* ShorthandPropertyAssignment */) {
+ if (node.kind === 296 /* SyntaxKind.PropertyAssignment */ || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) {
return getLiteralPropertyNameText(node.name);
}
return "" + parent.elements.indexOf(node);
}
function getLiteralPropertyNameText(name) {
var type = getLiteralTypeFromPropertyName(name);
- return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : undefined;
+ return type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */) ? "" + type.value : undefined;
}
/** Return the inferred type for a binding element */
function getTypeForBindingElement(declaration) {
- var checkMode = declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
+ var checkMode = declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */;
var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
}
@@ -54692,18 +55815,18 @@ var ts;
}
var pattern = declaration.parent;
// Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation
- if (strictNullChecks && declaration.flags & 8388608 /* Ambient */ && ts.isParameterDeclaration(declaration)) {
+ if (strictNullChecks && declaration.flags & 16777216 /* NodeFlags.Ambient */ && ts.isParameterDeclaration(declaration)) {
parentType = getNonNullableType(parentType);
}
// Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined`
- else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* EQUndefined */)) {
- parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */);
+ else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* TypeFacts.EQUndefined */)) {
+ parentType = getTypeWithFacts(parentType, 524288 /* TypeFacts.NEUndefined */);
}
var type;
- if (pattern.kind === 200 /* ObjectBindingPattern */) {
+ if (pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */) {
if (declaration.dotDotDotToken) {
parentType = getReducedType(parentType);
- if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) {
+ if (parentType.flags & 2 /* TypeFlags.Unknown */ || !isValidSpreadType(parentType)) {
error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types);
return errorType;
}
@@ -54720,7 +55843,7 @@ var ts;
// Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form)
var name = declaration.propertyName || declaration.name;
var indexType = getLiteralTypeFromPropertyName(name);
- var declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name);
+ var declaredType = getIndexedAccessType(parentType, indexType, 32 /* AccessFlags.ExpressionPosition */, name);
type = getFlowTypeOfDestructuring(declaration, declaredType);
}
}
@@ -54728,7 +55851,7 @@ var ts;
// This elementType will be used if the specific property corresponding to this index is not
// present (aka the tuple element property). This call also checks that the parentType is in
// fact an iterable or array (depending on target language).
- var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* PossiblyOutOfBounds */), parentType, undefinedType, pattern);
+ var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* IterationUse.PossiblyOutOfBounds */), parentType, undefinedType, pattern);
var index_2 = pattern.elements.indexOf(declaration);
if (declaration.dotDotDotToken) {
// If the parent is a tuple type, the rest element has a tuple type of the
@@ -54740,7 +55863,7 @@ var ts;
}
else if (isArrayLikeType(parentType)) {
var indexType = getNumberLiteralType(index_2);
- var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0);
+ var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0);
var declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType;
type = getFlowTypeOfDestructuring(declaration, declaredType);
}
@@ -54754,9 +55877,9 @@ var ts;
if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
// In strict null checking mode, if a default value of a non-undefined type is specified, remove
// undefined from the final type.
- return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
+ return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)) & 32768 /* TypeFlags.Undefined */) ? getNonUndefinedType(type) : type;
}
- return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */));
+ return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)], 2 /* UnionReduction.Subtype */));
}
function getTypeForDeclarationFromJSDocComment(declaration) {
var jsdocType = ts.getJSDocType(declaration);
@@ -54767,11 +55890,11 @@ var ts;
}
function isNullOrUndefined(node) {
var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true);
- return expr.kind === 104 /* NullKeyword */ || expr.kind === 79 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol;
+ return expr.kind === 104 /* SyntaxKind.NullKeyword */ || expr.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(expr) === undefinedSymbol;
}
function isEmptyArrayLiteral(node) {
var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true);
- return expr.kind === 203 /* ArrayLiteralExpression */ && expr.elements.length === 0;
+ return expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && expr.elements.length === 0;
}
function addOptionality(type, isProperty, isOptional) {
if (isProperty === void 0) { isProperty = false; }
@@ -54782,11 +55905,11 @@ var ts;
function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) {
// A variable declared in a for..in statement is of type string, or of type keyof T when the
// right hand expression is of a type parameter type.
- if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 242 /* ForInStatement */) {
+ if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) {
var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, /*checkMode*/ checkMode)));
- return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType;
+ return indexType.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */) ? getExtractStringType(indexType) : stringType;
}
- if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForOfStatement */) {
+ if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) {
// checkRightHandSideOfForOf will return undefined if the for-of expression type was
// missing properties/signatures required to get its iteratedType (like
// [Symbol.iterator] or next). This may be because we accessed properties from anyType,
@@ -54808,11 +55931,11 @@ var ts;
}
if ((noImplicitAny || ts.isInJSFile(declaration)) &&
ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) &&
- !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 8388608 /* Ambient */)) {
+ !(ts.getCombinedModifierFlags(declaration) & 1 /* ModifierFlags.Export */) && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) {
// If --noImplicitAny is on or the declaration is in a Javascript file,
// use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no
// initializer or a 'null' or 'undefined' initializer.
- if (!(ts.getCombinedNodeFlags(declaration) & 2 /* Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) {
+ if (!(ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) {
return autoType;
}
// Use control flow tracked 'any[]' type for non-ambient, non-exported variables with an empty array
@@ -54824,8 +55947,8 @@ var ts;
if (ts.isParameter(declaration)) {
var func = declaration.parent;
// For a parameter of a set accessor, use the type of the get accessor if one is present
- if (func.kind === 172 /* SetAccessor */ && hasBindableName(func)) {
- var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 171 /* GetAccessor */);
+ if (func.kind === 173 /* SyntaxKind.SetAccessor */ && hasBindableName(func)) {
+ var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 172 /* SyntaxKind.GetAccessor */);
if (getter) {
var getterSignature = getSignatureFromDeclaration(getter);
var thisParameter = getAccessorThisParameter(func);
@@ -54843,7 +55966,7 @@ var ts;
return type_1;
}
// Use contextual parameter type if one is available
- var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
+ var type = declaration.symbol.escapedName === "this" /* InternalSymbolName.This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
if (type) {
return addOptionality(type, /*isProperty*/ false, isOptional);
}
@@ -54866,14 +55989,14 @@ var ts;
if (!ts.hasStaticModifier(declaration)) {
var constructor = findConstructorDeclaration(declaration.parent);
var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) :
- ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) :
+ ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) :
undefined;
return type && addOptionality(type, /*isProperty*/ true, isOptional);
}
else {
var staticBlocks = ts.filter(declaration.parent.members, ts.isClassStaticBlockDeclaration);
var type = staticBlocks.length ? getFlowTypeInStaticBlocks(declaration.symbol, staticBlocks) :
- ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) :
+ ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) :
undefined;
return type && addOptionality(type, /*isProperty*/ true, isOptional);
}
@@ -54902,7 +56025,7 @@ var ts;
links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) {
return ts.isBinaryExpression(declaration) &&
isPossiblyAliasedThisProperty(declaration) &&
- (declaration.left.kind !== 206 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) &&
+ (declaration.left.kind !== 207 /* SyntaxKind.ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) &&
!getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration);
});
}
@@ -54924,7 +56047,7 @@ var ts;
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var declaration = _a[_i];
var container = ts.getThisContainer(declaration, /*includeArrowFunctions*/ false);
- if (container && (container.kind === 170 /* Constructor */ || isJSConstructor(container))) {
+ if (container && (container.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(container))) {
return container;
}
}
@@ -54984,7 +56107,7 @@ var ts;
}
function getFlowTypeOfProperty(reference, prop) {
var initialType = (prop === null || prop === void 0 ? void 0 : prop.valueDeclaration)
- && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */)
+ && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* ModifierFlags.Ambient */)
&& getTypeOfPropertyInBaseClass(prop)
|| undefinedType;
return getFlowTypeOfReference(reference, autoType, initialType);
@@ -55023,7 +56146,7 @@ var ts;
var kind = ts.isAccessExpression(expression)
? ts.getAssignmentDeclarationPropertyAccessKind(expression)
: ts.getAssignmentDeclarationKind(expression);
- if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) {
+ if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) {
if (isDeclarationInConstructor(expression)) {
definedInConstructor = true;
}
@@ -55053,12 +56176,12 @@ var ts;
definedInConstructor = true;
}
}
- var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217
- type = getUnionType(sourceTypes, 2 /* Subtype */);
+ var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) ? constructorTypes : types; // TODO: GH#18217
+ type = getUnionType(sourceTypes);
}
}
var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor));
- if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) {
+ if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) === neverType) {
reportImplicitAny(symbol.valueDeclaration, anyType);
return anyType;
}
@@ -55082,7 +56205,7 @@ var ts;
mergeSymbolTable(exports, s.exports);
}
var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, ts.emptyArray);
- type.objectFlags |= 8192 /* JSLiteral */;
+ type.objectFlags |= 4096 /* ObjectFlags.JSLiteral */;
return type;
}
function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) {
@@ -55138,10 +56261,13 @@ var ts;
if (containsSameNamedThisProperty(expression.left, expression.right)) {
return anyType;
}
- var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : getWidenedLiteralType(checkExpressionCached(expression.right));
- if (type.flags & 524288 /* Object */ &&
- kind === 2 /* ModuleExports */ &&
- symbol.escapedName === "export=" /* ExportEquals */) {
+ var isDirectExport = kind === 1 /* AssignmentDeclarationKind.ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression)));
+ var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol)
+ : isDirectExport ? getRegularTypeOfLiteralType(checkExpressionCached(expression.right))
+ : getWidenedLiteralType(checkExpressionCached(expression.right));
+ if (type.flags & 524288 /* TypeFlags.Object */ &&
+ kind === 2 /* AssignmentDeclarationKind.ModuleExports */ &&
+ symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) {
var exportedType = resolveStructuredTypeMembers(type);
var members_4 = ts.createSymbolTable();
ts.copyEntries(exportedType.members, members_4);
@@ -55153,7 +56279,7 @@ var ts;
var _a;
var exportedMember = members_4.get(name);
if (exportedMember && exportedMember !== s) {
- if (s.flags & 111551 /* Value */ && exportedMember.flags & 111551 /* Value */) {
+ if (s.flags & 111551 /* SymbolFlags.Value */ && exportedMember.flags & 111551 /* SymbolFlags.Value */) {
// If the member has an additional value-like declaration, union the types from the two declarations,
// but issue an error if they occurred in two different files. The purpose is to support a JS file with
// a pattern like:
@@ -55186,9 +56312,9 @@ var ts;
});
var result = createAnonymousType(initialSize !== members_4.size ? undefined : exportedType.symbol, // Only set the type's symbol if it looks to be the same as the original type
members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.indexInfos);
- result.objectFlags |= (ts.getObjectFlags(type) & 8192 /* JSLiteral */); // Propagate JSLiteral flag
- if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) {
- result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type
+ result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */); // Propagate JSLiteral flag
+ if (result.symbol && result.symbol.flags & 32 /* SymbolFlags.Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) {
+ result.objectFlags |= 16777216 /* ObjectFlags.IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type
}
return result;
}
@@ -55200,16 +56326,16 @@ var ts;
}
function containsSameNamedThisProperty(thisProperty, expression) {
return ts.isPropertyAccessExpression(thisProperty)
- && thisProperty.expression.kind === 108 /* ThisKeyword */
+ && thisProperty.expression.kind === 108 /* SyntaxKind.ThisKeyword */
&& ts.forEachChildRecursively(expression, function (n) { return isMatchingReference(thisProperty, n); });
}
function isDeclarationInConstructor(expression) {
var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false);
// Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added.
// Function expressions that are assigned to the prototype count as methods.
- return thisContainer.kind === 170 /* Constructor */ ||
- thisContainer.kind === 255 /* FunctionDeclaration */ ||
- (thisContainer.kind === 212 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent));
+ return thisContainer.kind === 171 /* SyntaxKind.Constructor */ ||
+ thisContainer.kind === 256 /* SyntaxKind.FunctionDeclaration */ ||
+ (thisContainer.kind === 213 /* SyntaxKind.FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent));
}
function getConstructorDefinedThisAssignmentTypes(types, declarations) {
ts.Debug.assert(types.length === declarations.length);
@@ -55229,7 +56355,7 @@ var ts;
// contextual type or, if the element itself is a binding pattern, with the type implied by that binding
// pattern.
var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType;
- return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType)));
+ return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* CheckMode.Normal */, contextualType)));
}
if (ts.isBindingPattern(element.name)) {
return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
@@ -55247,7 +56373,7 @@ var ts;
function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) {
var members = ts.createSymbolTable();
var stringIndexInfo;
- var objectFlags = 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */;
+ var objectFlags = 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */;
ts.forEach(pattern.elements, function (e) {
var name = e.propertyName || e.name;
if (e.dotDotDotToken) {
@@ -55257,11 +56383,11 @@ var ts;
var exprType = getLiteralTypeFromPropertyName(name);
if (!isTypeUsableAsPropertyName(exprType)) {
// do not include computed properties in the implied type
- objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */;
+ objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */;
return;
}
var text = getPropertyNameFromType(exprType);
- var flags = 4 /* Property */ | (e.initializer ? 16777216 /* Optional */ : 0);
+ var flags = 4 /* SymbolFlags.Property */ | (e.initializer ? 16777216 /* SymbolFlags.Optional */ : 0);
var symbol = createSymbol(flags, text);
symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors);
symbol.bindingElement = e;
@@ -55271,7 +56397,7 @@ var ts;
result.objectFlags |= objectFlags;
if (includePatternInType) {
result.pattern = pattern;
- result.objectFlags |= 262144 /* ContainsObjectOrArrayLiteral */;
+ result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */;
}
return result;
}
@@ -55279,18 +56405,18 @@ var ts;
function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) {
var elements = pattern.elements;
var lastElement = ts.lastOrUndefined(elements);
- var restElement = lastElement && lastElement.kind === 202 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined;
+ var restElement = lastElement && lastElement.kind === 203 /* SyntaxKind.BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined;
if (elements.length === 0 || elements.length === 1 && restElement) {
- return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType;
+ return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? createIterableType(anyType) : anyArrayType;
}
var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); });
var minLength = ts.findLastIndex(elements, function (e) { return !(e === restElement || ts.isOmittedExpression(e) || hasDefaultValue(e)); }, elements.length - 1) + 1;
- var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* Rest */ : i >= minLength ? 2 /* Optional */ : 1 /* Required */; });
+ var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* ElementFlags.Rest */ : i >= minLength ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */; });
var result = createTupleType(elementTypes, elementFlags);
if (includePatternInType) {
result = cloneTypeReference(result);
result.pattern = pattern;
- result.objectFlags |= 262144 /* ContainsObjectOrArrayLiteral */;
+ result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */;
}
return result;
}
@@ -55304,7 +56430,7 @@ var ts;
function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) {
if (includePatternInType === void 0) { includePatternInType = false; }
if (reportErrors === void 0) { reportErrors = false; }
- return pattern.kind === 200 /* ObjectBindingPattern */
+ return pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */
? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors)
: getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors);
}
@@ -55318,7 +56444,7 @@ var ts;
// binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the
// tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string.
function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
- return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* Normal */), declaration, reportErrors);
+ return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* CheckMode.Normal */), declaration, reportErrors);
}
function isGlobalSymbolConstructor(node) {
var symbol = getSymbolOfNode(node);
@@ -55328,14 +56454,14 @@ var ts;
function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors) {
if (type) {
// TODO: If back compat with pre-3.0/4.0 libs isn't required, remove the following SymbolConstructor special case transforming `symbol` into `unique symbol`
- if (type.flags & 4096 /* ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) {
+ if (type.flags & 4096 /* TypeFlags.ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) {
type = getESSymbolLikeTypeForNode(declaration);
}
if (reportErrors) {
reportErrorsFromWidening(declaration, type);
}
// always widen a 'unique symbol' type if the type was created for a different declaration.
- if (type.flags & 8192 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) {
+ if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) {
type = esSymbolType;
}
return getWidenedType(type);
@@ -55352,11 +56478,11 @@ var ts;
}
function declarationBelongsToPrivateAmbientMember(declaration) {
var root = ts.getRootDeclaration(declaration);
- var memberDeclaration = root.kind === 163 /* Parameter */ ? root.parent : root;
+ var memberDeclaration = root.kind === 164 /* SyntaxKind.Parameter */ ? root.parent : root;
return isPrivateWithinAmbient(memberDeclaration);
}
- function tryGetTypeFromEffectiveTypeNode(declaration) {
- var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
+ function tryGetTypeFromEffectiveTypeNode(node) {
+ var typeNode = ts.getEffectiveTypeAnnotationNode(node);
if (typeNode) {
return getTypeFromTypeNode(typeNode);
}
@@ -55376,14 +56502,14 @@ var ts;
}
function getTypeOfVariableOrParameterOrPropertyWorker(symbol) {
// Handle prototype property
- if (symbol.flags & 4194304 /* Prototype */) {
+ if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) {
return getTypeOfPrototypeProperty(symbol);
}
// CommonsJS require and module both have type any.
if (symbol === requireSymbol) {
return anyType;
}
- if (symbol.flags & 134217728 /* ModuleExports */ && symbol.valueDeclaration) {
+ if (symbol.flags & 134217728 /* SymbolFlags.ModuleExports */ && symbol.valueDeclaration) {
var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration));
var result = createSymbol(fileSymbol.flags, "exports");
result.declarations = fileSymbol.declarations ? fileSymbol.declarations.slice() : [];
@@ -55418,16 +56544,21 @@ var ts;
}
return getWidenedType(getWidenedLiteralType(checkExpression(declaration.statements[0].expression)));
}
+ if (ts.isAccessor(declaration)) {
+ // Binding of certain patterns in JS code will occasionally mark symbols as both properties
+ // and accessors. Here we dispatch to accessor resolution if needed.
+ return getTypeOfAccessors(symbol);
+ }
// Handle variable, parameter or property
- if (!pushTypeResolution(symbol, 0 /* Type */)) {
+ if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) {
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
- if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
+ if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) {
return getTypeOfFuncClassEnumModule(symbol);
}
return reportCircularityError(symbol);
}
var type;
- if (declaration.kind === 270 /* ExportAssignment */) {
+ if (declaration.kind === 271 /* SyntaxKind.ExportAssignment */) {
type = widenTypeForVariableLikeDeclaration(tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionCached(declaration.expression), declaration);
}
else if (ts.isBinaryExpression(declaration) ||
@@ -55446,7 +56577,7 @@ var ts;
|| ts.isMethodSignature(declaration)
|| ts.isSourceFile(declaration)) {
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
- if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) {
+ if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) {
return getTypeOfFuncClassEnumModule(symbol);
}
type = ts.isBinaryExpression(declaration.parent) ?
@@ -55460,10 +56591,10 @@ var ts;
type = tryGetTypeFromEffectiveTypeNode(declaration) || checkJsxAttribute(declaration);
}
else if (ts.isShorthandPropertyAssignment(declaration)) {
- type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* Normal */);
+ type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* CheckMode.Normal */);
}
else if (ts.isObjectLiteralMethod(declaration)) {
- type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* Normal */);
+ type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* CheckMode.Normal */);
}
else if (ts.isParameter(declaration)
|| ts.isPropertyDeclaration(declaration)
@@ -55481,15 +56612,12 @@ var ts;
else if (ts.isEnumMember(declaration)) {
type = getTypeOfEnumMember(symbol);
}
- else if (ts.isAccessor(declaration)) {
- type = resolveTypeOfAccessors(symbol) || ts.Debug.fail("Non-write accessor resolution must always produce a type");
- }
else {
return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
}
if (!popTypeResolution()) {
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
- if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
+ if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) {
return getTypeOfFuncClassEnumModule(symbol);
}
return reportCircularityError(symbol);
@@ -55498,7 +56626,7 @@ var ts;
}
function getAnnotatedAccessorTypeNode(accessor) {
if (accessor) {
- if (accessor.kind === 171 /* GetAccessor */) {
+ if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) {
var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor);
return getterTypeAnnotation;
}
@@ -55522,87 +56650,66 @@ var ts;
}
function getTypeOfAccessors(symbol) {
var links = getSymbolLinks(symbol);
- return links.type || (links.type = getTypeOfAccessorsWorker(symbol) || ts.Debug.fail("Read type of accessor must always produce a type"));
- }
- function getTypeOfSetAccessor(symbol) {
- var links = getSymbolLinks(symbol);
- return links.writeType || (links.writeType = getTypeOfAccessorsWorker(symbol, /*writing*/ true));
- }
- function getTypeOfAccessorsWorker(symbol, writing) {
- if (writing === void 0) { writing = false; }
- if (!pushTypeResolution(symbol, 0 /* Type */)) {
- return errorType;
- }
- var type = resolveTypeOfAccessors(symbol, writing);
- if (!popTypeResolution()) {
- type = anyType;
- if (noImplicitAny) {
- var getter = ts.getDeclarationOfKind(symbol, 171 /* GetAccessor */);
- error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol));
+ if (!links.type) {
+ if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) {
+ return errorType;
}
- }
- return type;
- }
- function resolveTypeOfAccessors(symbol, writing) {
- if (writing === void 0) { writing = false; }
- var getter = ts.getDeclarationOfKind(symbol, 171 /* GetAccessor */);
- var setter = ts.getDeclarationOfKind(symbol, 172 /* SetAccessor */);
- // For write operations, prioritize type annotations on the setter
- if (writing) {
- var setterType_1 = getAnnotatedAccessorType(setter);
- if (setterType_1) {
- return instantiateTypeIfNeeded(setterType_1, symbol);
- }
- }
- // Else defer to the getter type
- if (getter && ts.isInJSFile(getter)) {
- var jsDocType = getTypeForDeclarationFromJSDocComment(getter);
- if (jsDocType) {
- return instantiateTypeIfNeeded(jsDocType, symbol);
+ var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */);
+ var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */);
+ // We try to resolve a getter type annotation, a setter type annotation, or a getter function
+ // body return type inference, in that order.
+ var type = getter && ts.isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) ||
+ getAnnotatedAccessorType(getter) ||
+ getAnnotatedAccessorType(setter) ||
+ getter && getter.body && getReturnTypeFromBody(getter);
+ if (!type) {
+ if (setter && !isPrivateWithinAmbient(setter)) {
+ errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
+ }
+ else if (getter && !isPrivateWithinAmbient(getter)) {
+ errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
+ }
+ type = anyType;
}
- }
- // Try to see if the user specified a return type on the get-accessor.
- var getterType = getAnnotatedAccessorType(getter);
- if (getterType) {
- return instantiateTypeIfNeeded(getterType, symbol);
- }
- // If the user didn't specify a return type, try to use the set-accessor's parameter type.
- var setterType = getAnnotatedAccessorType(setter);
- if (setterType) {
- return setterType;
- }
- // If there are no specified types, try to infer it from the body of the get accessor if it exists.
- if (getter && getter.body) {
- var returnTypeFromBody = getReturnTypeFromBody(getter);
- return instantiateTypeIfNeeded(returnTypeFromBody, symbol);
- }
- // Otherwise, fall back to 'any'.
- if (setter) {
- if (!isPrivateWithinAmbient(setter)) {
- errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
+ if (!popTypeResolution()) {
+ if (getAnnotatedAccessorTypeNode(getter)) {
+ error(getter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
+ }
+ else if (getAnnotatedAccessorTypeNode(setter)) {
+ error(setter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
+ }
+ else if (getter && noImplicitAny) {
+ error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol));
+ }
+ type = anyType;
}
- return anyType;
+ links.type = type;
}
- else if (getter) {
- ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function");
- if (!isPrivateWithinAmbient(getter)) {
- errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
+ return links.type;
+ }
+ function getWriteTypeOfAccessors(symbol) {
+ var links = getSymbolLinks(symbol);
+ if (!links.writeType) {
+ if (!pushTypeResolution(symbol, 8 /* TypeSystemPropertyName.WriteType */)) {
+ return errorType;
}
- return anyType;
- }
- return undefined;
- function instantiateTypeIfNeeded(type, symbol) {
- if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) {
- var links = getSymbolLinks(symbol);
- return instantiateType(type, links.mapper);
+ var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */);
+ var writeType = getAnnotatedAccessorType(setter);
+ if (!popTypeResolution()) {
+ if (getAnnotatedAccessorTypeNode(setter)) {
+ error(setter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
+ }
+ writeType = anyType;
}
- return type;
+ // Absent an explicit setter type annotation we use the read type of the accessor.
+ links.writeType = writeType || getTypeOfAccessors(symbol);
}
+ return links.writeType;
}
function getBaseTypeVariableOfClass(symbol) {
var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol));
- return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType :
- baseConstructorType.flags & 2097152 /* Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeVariable */); }) :
+ return baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */ ? baseConstructorType :
+ baseConstructorType.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeFlags.TypeVariable */); }) :
undefined;
}
function getTypeOfFuncClassEnumModule(symbol) {
@@ -55623,21 +56730,21 @@ var ts;
}
function getTypeOfFuncClassEnumModuleWorker(symbol) {
var declaration = symbol.valueDeclaration;
- if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) {
+ if (symbol.flags & 1536 /* SymbolFlags.Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) {
return anyType;
}
- else if (declaration && (declaration.kind === 220 /* BinaryExpression */ ||
+ else if (declaration && (declaration.kind === 221 /* SyntaxKind.BinaryExpression */ ||
ts.isAccessExpression(declaration) &&
- declaration.parent.kind === 220 /* BinaryExpression */)) {
+ declaration.parent.kind === 221 /* SyntaxKind.BinaryExpression */)) {
return getWidenedTypeForAssignmentDeclaration(symbol);
}
- else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) {
+ else if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) {
var resolvedModule = resolveExternalModuleSymbol(symbol);
if (resolvedModule !== symbol) {
- if (!pushTypeResolution(symbol, 0 /* Type */)) {
+ if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) {
return errorType;
}
- var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */));
+ var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */));
var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
if (!popTypeResolution()) {
return reportCircularityError(symbol);
@@ -55645,13 +56752,13 @@ var ts;
return type_3;
}
}
- var type = createObjectType(16 /* Anonymous */, symbol);
- if (symbol.flags & 32 /* Class */) {
+ var type = createObjectType(16 /* ObjectFlags.Anonymous */, symbol);
+ if (symbol.flags & 32 /* SymbolFlags.Class */) {
var baseTypeVariable = getBaseTypeVariableOfClass(symbol);
return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type;
}
else {
- return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(type) : type;
+ return strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ ? getOptionalType(type) : type;
}
}
function getTypeOfEnumMember(symbol) {
@@ -55672,24 +56779,18 @@ var ts;
links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol)
: isDuplicatedCommonJSExport(symbol.declarations) ? autoType
: declaredType ? declaredType
- : targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol)
+ : targetSymbol.flags & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol)
: errorType;
}
return links.type;
}
function getTypeOfInstantiatedSymbol(symbol) {
var links = getSymbolLinks(symbol);
- if (!links.type) {
- if (!pushTypeResolution(symbol, 0 /* Type */)) {
- return links.type = errorType;
- }
- var type = instantiateType(getTypeOfSymbol(links.target), links.mapper);
- if (!popTypeResolution()) {
- type = reportCircularityError(symbol);
- }
- links.type = type;
- }
- return links.type;
+ return links.type || (links.type = instantiateType(getTypeOfSymbol(links.target), links.mapper));
+ }
+ function getWriteTypeOfInstantiatedSymbol(symbol) {
+ var links = getSymbolLinks(symbol);
+ return links.writeType || (links.writeType = instantiateType(getWriteTypeOfSymbol(links.target), links.mapper));
}
function reportCircularityError(symbol) {
var declaration = symbol.valueDeclaration;
@@ -55699,7 +56800,7 @@ var ts;
return errorType;
}
// Check if variable has initializer that circularly references the variable itself
- if (noImplicitAny && (declaration.kind !== 163 /* Parameter */ || declaration.initializer)) {
+ if (noImplicitAny && (declaration.kind !== 164 /* SyntaxKind.Parameter */ || declaration.initializer)) {
error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol));
}
// Circularities could also result from parameters in function expressions that end up
@@ -55712,7 +56813,7 @@ var ts;
if (!links.type) {
ts.Debug.assertIsDefined(links.deferralParent);
ts.Debug.assertIsDefined(links.deferralConstituents);
- links.type = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents);
+ links.type = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents);
}
return links.type;
}
@@ -55721,95 +56822,83 @@ var ts;
if (!links.writeType && links.deferralWriteConstituents) {
ts.Debug.assertIsDefined(links.deferralParent);
ts.Debug.assertIsDefined(links.deferralConstituents);
- links.writeType = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents);
+ links.writeType = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents);
}
return links.writeType;
}
/**
- * Distinct write types come only from set accessors, but union and intersection
- * properties deriving from set accessors will either pre-compute or defer the
- * union or intersection of the writeTypes of their constituents. To account for
- * this, we will assume that any deferred type or transient symbol may have a
- * `writeType` (or a deferred write type ready to be computed) that should be
- * used before looking for set accessor declarations.
+ * Distinct write types come only from set accessors, but synthetic union and intersection
+ * properties deriving from set accessors will either pre-compute or defer the union or
+ * intersection of the writeTypes of their constituents.
*/
function getWriteTypeOfSymbol(symbol) {
var checkFlags = ts.getCheckFlags(symbol);
- if (checkFlags & 65536 /* DeferredType */) {
- var writeType = getWriteTypeOfSymbolWithDeferredType(symbol);
- if (writeType) {
- return writeType;
- }
- }
- if (symbol.flags & 33554432 /* Transient */) {
- var writeType = symbol.writeType;
- if (writeType) {
- return writeType;
- }
- }
- return getSetAccessorTypeOfSymbol(symbol);
- }
- function getSetAccessorTypeOfSymbol(symbol) {
- if (symbol.flags & 98304 /* Accessor */) {
- var type = getTypeOfSetAccessor(symbol);
- if (type) {
- return type;
- }
+ if (symbol.flags & 4 /* SymbolFlags.Property */) {
+ return checkFlags & 2 /* CheckFlags.SyntheticProperty */ ?
+ checkFlags & 65536 /* CheckFlags.DeferredType */ ?
+ getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) :
+ symbol.writeType || symbol.type :
+ getTypeOfSymbol(symbol);
+ }
+ if (symbol.flags & 98304 /* SymbolFlags.Accessor */) {
+ return checkFlags & 1 /* CheckFlags.Instantiated */ ?
+ getWriteTypeOfInstantiatedSymbol(symbol) :
+ getWriteTypeOfAccessors(symbol);
}
return getTypeOfSymbol(symbol);
}
function getTypeOfSymbol(symbol) {
var checkFlags = ts.getCheckFlags(symbol);
- if (checkFlags & 65536 /* DeferredType */) {
+ if (checkFlags & 65536 /* CheckFlags.DeferredType */) {
return getTypeOfSymbolWithDeferredType(symbol);
}
- if (checkFlags & 1 /* Instantiated */) {
+ if (checkFlags & 1 /* CheckFlags.Instantiated */) {
return getTypeOfInstantiatedSymbol(symbol);
}
- if (checkFlags & 262144 /* Mapped */) {
+ if (checkFlags & 262144 /* CheckFlags.Mapped */) {
return getTypeOfMappedSymbol(symbol);
}
- if (checkFlags & 8192 /* ReverseMapped */) {
+ if (checkFlags & 8192 /* CheckFlags.ReverseMapped */) {
return getTypeOfReverseMappedSymbol(symbol);
}
- if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) {
+ if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) {
return getTypeOfVariableOrParameterOrProperty(symbol);
}
- if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) {
+ if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) {
return getTypeOfFuncClassEnumModule(symbol);
}
- if (symbol.flags & 8 /* EnumMember */) {
+ if (symbol.flags & 8 /* SymbolFlags.EnumMember */) {
return getTypeOfEnumMember(symbol);
}
- if (symbol.flags & 98304 /* Accessor */) {
+ if (symbol.flags & 98304 /* SymbolFlags.Accessor */) {
return getTypeOfAccessors(symbol);
}
- if (symbol.flags & 2097152 /* Alias */) {
+ if (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
return getTypeOfAlias(symbol);
}
return errorType;
}
function getNonMissingTypeOfSymbol(symbol) {
- return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* Optional */));
+ return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* SymbolFlags.Optional */));
}
function isReferenceToType(type, target) {
return type !== undefined
&& target !== undefined
- && (ts.getObjectFlags(type) & 4 /* Reference */) !== 0
+ && (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) !== 0
&& type.target === target;
}
function getTargetType(type) {
- return ts.getObjectFlags(type) & 4 /* Reference */ ? type.target : type;
+ return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target : type;
}
// TODO: GH#18217 If `checkBase` is undefined, we should not call this because this will always return false.
function hasBaseType(type, checkBase) {
return check(type);
function check(type) {
- if (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */)) {
+ if (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) {
var target = getTargetType(type);
return target === checkBase || ts.some(getBaseTypes(target), check);
}
- else if (type.flags & 2097152 /* Intersection */) {
+ else if (type.flags & 2097152 /* TypeFlags.Intersection */) {
return ts.some(type.types, check);
}
return false;
@@ -55832,7 +56921,7 @@ var ts;
if (node && ts.isBinaryExpression(node)) {
// prototype assignments get the outer type parameters of their constructor function
var assignmentKind = ts.getAssignmentDeclarationKind(node);
- if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) {
+ if (assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */ || assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */) {
var symbol = getSymbolOfNode(node.left);
if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) {
node = symbol.parent.valueDeclaration;
@@ -55843,46 +56932,46 @@ var ts;
return undefined;
}
switch (node.kind) {
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- case 257 /* InterfaceDeclaration */:
- case 173 /* CallSignature */:
- case 174 /* ConstructSignature */:
- case 167 /* MethodSignature */:
- case 178 /* FunctionType */:
- case 179 /* ConstructorType */:
- case 315 /* JSDocFunctionType */:
- case 255 /* FunctionDeclaration */:
- case 168 /* MethodDeclaration */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
- case 258 /* TypeAliasDeclaration */:
- case 342 /* JSDocTemplateTag */:
- case 343 /* JSDocTypedefTag */:
- case 337 /* JSDocEnumTag */:
- case 336 /* JSDocCallbackTag */:
- case 194 /* MappedType */:
- case 188 /* ConditionalType */: {
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 179 /* SyntaxKind.FunctionType */:
+ case 180 /* SyntaxKind.ConstructorType */:
+ case 317 /* SyntaxKind.JSDocFunctionType */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 344 /* SyntaxKind.JSDocTemplateTag */:
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
+ case 339 /* SyntaxKind.JSDocEnumTag */:
+ case 338 /* SyntaxKind.JSDocCallbackTag */:
+ case 195 /* SyntaxKind.MappedType */:
+ case 189 /* SyntaxKind.ConditionalType */: {
var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes);
- if (node.kind === 194 /* MappedType */) {
+ if (node.kind === 195 /* SyntaxKind.MappedType */) {
return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)));
}
- else if (node.kind === 188 /* ConditionalType */) {
+ else if (node.kind === 189 /* SyntaxKind.ConditionalType */) {
return ts.concatenate(outerTypeParameters, getInferTypeParameters(node));
}
var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node));
var thisType = includeThisTypes &&
- (node.kind === 256 /* ClassDeclaration */ || node.kind === 225 /* ClassExpression */ || node.kind === 257 /* InterfaceDeclaration */ || isJSConstructor(node)) &&
+ (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || isJSConstructor(node)) &&
getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType;
return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters;
}
- case 338 /* JSDocParameterTag */:
+ case 340 /* SyntaxKind.JSDocParameterTag */:
var paramSymbol = ts.getParameterSymbolFromJSDoc(node);
if (paramSymbol) {
node = paramSymbol.valueDeclaration;
}
break;
- case 318 /* JSDocComment */: {
+ case 320 /* SyntaxKind.JSDoc */: {
var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes);
return node.tags
? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; }))
@@ -55893,7 +56982,7 @@ var ts;
}
// The outer type parameters are those defined by enclosing generic classes, methods, or functions.
function getOuterTypeParametersOfClassOrInterface(symbol) {
- var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 257 /* InterfaceDeclaration */);
+ var declaration = symbol.flags & 32 /* SymbolFlags.Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */);
ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations");
return getOuterTypeParameters(declaration);
}
@@ -55906,9 +56995,9 @@ var ts;
var result;
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var node = _a[_i];
- if (node.kind === 257 /* InterfaceDeclaration */ ||
- node.kind === 256 /* ClassDeclaration */ ||
- node.kind === 225 /* ClassExpression */ ||
+ if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ ||
+ node.kind === 257 /* SyntaxKind.ClassDeclaration */ ||
+ node.kind === 226 /* SyntaxKind.ClassExpression */ ||
isJSConstructor(node) ||
ts.isTypeAlias(node)) {
var declaration = node;
@@ -55925,7 +57014,7 @@ var ts;
// A type is a mixin constructor if it has a single construct signature taking no type parameters and a single
// rest parameter of type any[].
function isMixinConstructorType(type) {
- var signatures = getSignaturesOfType(type, 1 /* Construct */);
+ var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */);
if (signatures.length === 1) {
var s = signatures[0];
if (!s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s)) {
@@ -55936,10 +57025,10 @@ var ts;
return false;
}
function isConstructorType(type) {
- if (getSignaturesOfType(type, 1 /* Construct */).length > 0) {
+ if (getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length > 0) {
return true;
}
- if (type.flags & 8650752 /* TypeVariable */) {
+ if (type.flags & 8650752 /* TypeFlags.TypeVariable */) {
var constraint = getBaseConstraintOfType(type);
return !!constraint && isMixinConstructorType(constraint);
}
@@ -55952,7 +57041,7 @@ var ts;
function getConstructorsForTypeArguments(type, typeArgumentNodes, location) {
var typeArgCount = ts.length(typeArgumentNodes);
var isJavascript = ts.isInJSFile(location);
- return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); });
+ return ts.filter(getSignaturesOfType(type, 1 /* SignatureKind.Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); });
}
function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) {
var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location);
@@ -55975,7 +57064,7 @@ var ts;
if (!baseTypeNode) {
return type.resolvedBaseConstructorType = undefinedType;
}
- if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) {
+ if (!pushTypeResolution(type, 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */)) {
return errorType;
}
var baseConstructorType = checkExpression(baseTypeNode.expression);
@@ -55983,7 +57072,7 @@ var ts;
ts.Debug.assert(!extended.typeArguments); // Because this is in a JS file, and baseTypeNode is in an @extends tag
checkExpression(extended.expression);
}
- if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */)) {
+ if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) {
// Resolving the members of a class requires us to resolve the base class of that class.
// We force resolution here such that we catch circularities now.
resolveStructuredTypeMembers(baseConstructorType);
@@ -55992,13 +57081,13 @@ var ts;
error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol));
return type.resolvedBaseConstructorType = errorType;
}
- if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) {
+ if (!(baseConstructorType.flags & 1 /* TypeFlags.Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) {
var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType));
- if (baseConstructorType.flags & 262144 /* TypeParameter */) {
+ if (baseConstructorType.flags & 262144 /* TypeFlags.TypeParameter */) {
var constraint = getConstraintFromTypeParameter(baseConstructorType);
var ctorReturn = unknownType;
if (constraint) {
- var ctorSig = getSignaturesOfType(constraint, 1 /* Construct */);
+ var ctorSig = getSignaturesOfType(constraint, 1 /* SignatureKind.Construct */);
if (ctorSig[0]) {
ctorReturn = getReturnTypeOfSignature(ctorSig[0]);
}
@@ -56038,19 +57127,19 @@ var ts;
return resolvedImplementsTypes;
}
function reportCircularBaseType(node, type) {
- error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */));
+ error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */));
}
function getBaseTypes(type) {
if (!type.baseTypesResolved) {
- if (pushTypeResolution(type, 7 /* ResolvedBaseTypes */)) {
- if (type.objectFlags & 8 /* Tuple */) {
+ if (pushTypeResolution(type, 7 /* TypeSystemPropertyName.ResolvedBaseTypes */)) {
+ if (type.objectFlags & 8 /* ObjectFlags.Tuple */) {
type.resolvedBaseTypes = [getTupleBaseType(type)];
}
- else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) {
- if (type.symbol.flags & 32 /* Class */) {
+ else if (type.symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) {
+ if (type.symbol.flags & 32 /* SymbolFlags.Class */) {
resolveBaseTypesOfClass(type);
}
- if (type.symbol.flags & 64 /* Interface */) {
+ if (type.symbol.flags & 64 /* SymbolFlags.Interface */) {
resolveBaseTypesOfInterface(type);
}
}
@@ -56060,7 +57149,7 @@ var ts;
if (!popTypeResolution() && type.symbol.declarations) {
for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) {
var declaration = _a[_i];
- if (declaration.kind === 256 /* ClassDeclaration */ || declaration.kind === 257 /* InterfaceDeclaration */) {
+ if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ || declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) {
reportCircularBaseType(declaration, type);
}
}
@@ -56071,26 +57160,26 @@ var ts;
return type.resolvedBaseTypes;
}
function getTupleBaseType(type) {
- var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; });
+ var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; });
return createArrayType(getUnionType(elementTypes || ts.emptyArray), type.readonly);
}
function resolveBaseTypesOfClass(type) {
type.resolvedBaseTypes = ts.resolvingEmptyArray;
var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type));
- if (!(baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 1 /* Any */))) {
+ if (!(baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 1 /* TypeFlags.Any */))) {
return type.resolvedBaseTypes = ts.emptyArray;
}
var baseTypeNode = getBaseTypeNodeOfClass(type);
var baseType;
var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined;
- if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ &&
+ if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* SymbolFlags.Class */ &&
areAllOuterTypeParametersApplied(originalBaseType)) {
// When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the
// class and all return the instance type of the class. There is no need for further checks and we can apply the
// type arguments in the same manner as a type reference to get the same error reporting experience.
baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol);
}
- else if (baseConstructorType.flags & 1 /* Any */) {
+ else if (baseConstructorType.flags & 1 /* TypeFlags.Any */) {
baseType = baseConstructorType;
}
else {
@@ -56115,7 +57204,7 @@ var ts;
return type.resolvedBaseTypes = ts.emptyArray;
}
if (type === reducedBaseType || hasBaseType(reducedBaseType, type)) {
- error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */));
+ error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */));
return type.resolvedBaseTypes = ts.emptyArray;
}
if (type.resolvedBaseTypes === ts.resolvingEmptyArray) {
@@ -56140,7 +57229,7 @@ var ts;
}
// A valid base type is `any`, an object type or intersection of object types.
function isValidBaseType(type) {
- if (type.flags & 262144 /* TypeParameter */) {
+ if (type.flags & 262144 /* TypeFlags.TypeParameter */) {
var constraint = getBaseConstraintOfType(type);
if (constraint) {
return isValidBaseType(constraint);
@@ -56148,15 +57237,15 @@ var ts;
}
// TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed?
// There's no reason a `T` should be allowed while a `Readonly<T>` should not.
- return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */) && !isGenericMappedType(type) ||
- type.flags & 2097152 /* Intersection */ && ts.every(type.types, isValidBaseType));
+ return !!(type.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 1 /* TypeFlags.Any */) && !isGenericMappedType(type) ||
+ type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isValidBaseType));
}
function resolveBaseTypesOfInterface(type) {
type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray;
if (type.symbol.declarations) {
for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) {
var declaration = _a[_i];
- if (declaration.kind === 257 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) {
+ if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) {
for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) {
var node = _c[_b];
var baseType = getReducedType(getTypeFromTypeNode(node));
@@ -56196,8 +57285,8 @@ var ts;
}
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var declaration = _a[_i];
- if (declaration.kind === 257 /* InterfaceDeclaration */) {
- if (declaration.flags & 128 /* ContainsThis */) {
+ if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) {
+ if (declaration.flags & 128 /* NodeFlags.ContainsThis */) {
return false;
}
var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration);
@@ -56205,8 +57294,8 @@ var ts;
for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) {
var node = baseTypeNodes_1[_b];
if (ts.isEntityNameExpression(node.expression)) {
- var baseSymbol = resolveEntityName(node.expression, 788968 /* Type */, /*ignoreErrors*/ true);
- if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) {
+ var baseSymbol = resolveEntityName(node.expression, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true);
+ if (!baseSymbol || !(baseSymbol.flags & 64 /* SymbolFlags.Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) {
return false;
}
}
@@ -56220,7 +57309,7 @@ var ts;
var links = getSymbolLinks(symbol);
var originalLinks = links;
if (!links.declaredType) {
- var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */;
+ var kind = symbol.flags & 32 /* SymbolFlags.Class */ ? 1 /* ObjectFlags.Class */ : 2 /* ObjectFlags.Interface */;
var merged = mergeJSSymbols(symbol, symbol.valueDeclaration && getAssignedClassSymbol(symbol.valueDeclaration));
if (merged) {
// note:we overwrite links because we just cloned the symbol
@@ -56234,8 +57323,8 @@ var ts;
// property types inferred from initializers and method return types inferred from return statements are very hard
// to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of
// "this" references.
- if (outerTypeParameters || localTypeParameters || kind === 1 /* Class */ || !isThislessInterface(symbol)) {
- type.objectFlags |= 4 /* Reference */;
+ if (outerTypeParameters || localTypeParameters || kind === 1 /* ObjectFlags.Class */ || !isThislessInterface(symbol)) {
+ type.objectFlags |= 4 /* ObjectFlags.Reference */;
type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters);
type.outerTypeParameters = outerTypeParameters;
type.localTypeParameters = localTypeParameters;
@@ -56256,7 +57345,7 @@ var ts;
if (!links.declaredType) {
// Note that we use the links object as the target here because the symbol object is used as the unique
// identity for resolution of the 'type' property in SymbolLinks.
- if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) {
+ if (!pushTypeResolution(symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) {
return errorType;
}
var declaration = ts.Debug.checkDefined((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isTypeAlias), "Type alias symbol with no valid declaration found");
@@ -56275,7 +57364,7 @@ var ts;
}
else {
type = errorType;
- if (declaration.kind === 337 /* JSDocEnumTag */) {
+ if (declaration.kind === 339 /* SyntaxKind.JSDocEnumTag */) {
error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
}
else {
@@ -56290,7 +57379,7 @@ var ts;
if (ts.isStringLiteralLike(expr)) {
return true;
}
- else if (expr.kind === 220 /* BinaryExpression */) {
+ else if (expr.kind === 221 /* SyntaxKind.BinaryExpression */) {
return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right);
}
return false;
@@ -56298,19 +57387,19 @@ var ts;
function isLiteralEnumMember(member) {
var expr = member.initializer;
if (!expr) {
- return !(member.flags & 8388608 /* Ambient */);
+ return !(member.flags & 16777216 /* NodeFlags.Ambient */);
}
switch (expr.kind) {
- case 10 /* StringLiteral */:
- case 8 /* NumericLiteral */:
- case 14 /* NoSubstitutionTemplateLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
return true;
- case 218 /* PrefixUnaryExpression */:
- return expr.operator === 40 /* MinusToken */ &&
- expr.operand.kind === 8 /* NumericLiteral */;
- case 79 /* Identifier */:
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
+ return expr.operator === 40 /* SyntaxKind.MinusToken */ &&
+ expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */;
+ case 79 /* SyntaxKind.Identifier */:
return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText);
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return isStringConcatExpression(expr);
default:
return false;
@@ -56325,11 +57414,11 @@ var ts;
if (symbol.declarations) {
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var declaration = _a[_i];
- if (declaration.kind === 259 /* EnumDeclaration */) {
+ if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) {
for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) {
var member = _c[_b];
if (member.initializer && ts.isStringLiteralLike(member.initializer)) {
- return links.enumKind = 1 /* Literal */;
+ return links.enumKind = 1 /* EnumKind.Literal */;
}
if (!isLiteralEnumMember(member)) {
hasNonLiteralMember = true;
@@ -56338,23 +57427,23 @@ var ts;
}
}
}
- return links.enumKind = hasNonLiteralMember ? 0 /* Numeric */ : 1 /* Literal */;
+ return links.enumKind = hasNonLiteralMember ? 0 /* EnumKind.Numeric */ : 1 /* EnumKind.Literal */;
}
function getBaseTypeOfEnumLiteralType(type) {
- return type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type;
+ return type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type;
}
function getDeclaredTypeOfEnum(symbol) {
var links = getSymbolLinks(symbol);
if (links.declaredType) {
return links.declaredType;
}
- if (getEnumKind(symbol) === 1 /* Literal */) {
+ if (getEnumKind(symbol) === 1 /* EnumKind.Literal */) {
enumCount++;
var memberTypeList = [];
if (symbol.declarations) {
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var declaration = _a[_i];
- if (declaration.kind === 259 /* EnumDeclaration */) {
+ if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) {
for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) {
var member = _c[_b];
var value = getEnumMemberValue(member);
@@ -56366,15 +57455,15 @@ var ts;
}
}
if (memberTypeList.length) {
- var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined);
- if (enumType_1.flags & 1048576 /* Union */) {
- enumType_1.flags |= 1024 /* EnumLiteral */;
+ var enumType_1 = getUnionType(memberTypeList, 1 /* UnionReduction.Literal */, symbol, /*aliasTypeArguments*/ undefined);
+ if (enumType_1.flags & 1048576 /* TypeFlags.Union */) {
+ enumType_1.flags |= 1024 /* TypeFlags.EnumLiteral */;
enumType_1.symbol = symbol;
}
return links.declaredType = enumType_1;
}
}
- var enumType = createType(32 /* Enum */);
+ var enumType = createType(32 /* TypeFlags.Enum */);
enumType.symbol = symbol;
return links.declaredType = enumType;
}
@@ -56400,22 +57489,22 @@ var ts;
return tryGetDeclaredTypeOfSymbol(symbol) || errorType;
}
function tryGetDeclaredTypeOfSymbol(symbol) {
- if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) {
+ if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) {
return getDeclaredTypeOfClassOrInterface(symbol);
}
- if (symbol.flags & 524288 /* TypeAlias */) {
+ if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) {
return getDeclaredTypeOfTypeAlias(symbol);
}
- if (symbol.flags & 262144 /* TypeParameter */) {
+ if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) {
return getDeclaredTypeOfTypeParameter(symbol);
}
- if (symbol.flags & 384 /* Enum */) {
+ if (symbol.flags & 384 /* SymbolFlags.Enum */) {
return getDeclaredTypeOfEnum(symbol);
}
- if (symbol.flags & 8 /* EnumMember */) {
+ if (symbol.flags & 8 /* SymbolFlags.EnumMember */) {
return getDeclaredTypeOfEnumMember(symbol);
}
- if (symbol.flags & 2097152 /* Alias */) {
+ if (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
return getDeclaredTypeOfAlias(symbol);
}
return undefined;
@@ -56427,22 +57516,22 @@ var ts;
*/
function isThislessType(node) {
switch (node.kind) {
- case 130 /* AnyKeyword */:
- case 154 /* UnknownKeyword */:
- case 149 /* StringKeyword */:
- case 146 /* NumberKeyword */:
- case 157 /* BigIntKeyword */:
- case 133 /* BooleanKeyword */:
- case 150 /* SymbolKeyword */:
- case 147 /* ObjectKeyword */:
- case 114 /* VoidKeyword */:
- case 152 /* UndefinedKeyword */:
- case 143 /* NeverKeyword */:
- case 195 /* LiteralType */:
+ case 130 /* SyntaxKind.AnyKeyword */:
+ case 155 /* SyntaxKind.UnknownKeyword */:
+ case 150 /* SyntaxKind.StringKeyword */:
+ case 147 /* SyntaxKind.NumberKeyword */:
+ case 158 /* SyntaxKind.BigIntKeyword */:
+ case 133 /* SyntaxKind.BooleanKeyword */:
+ case 151 /* SyntaxKind.SymbolKeyword */:
+ case 148 /* SyntaxKind.ObjectKeyword */:
+ case 114 /* SyntaxKind.VoidKeyword */:
+ case 153 /* SyntaxKind.UndefinedKeyword */:
+ case 143 /* SyntaxKind.NeverKeyword */:
+ case 196 /* SyntaxKind.LiteralType */:
return true;
- case 182 /* ArrayType */:
+ case 183 /* SyntaxKind.ArrayType */:
return isThislessType(node.elementType);
- case 177 /* TypeReference */:
+ case 178 /* SyntaxKind.TypeReference */:
return !node.typeArguments || node.typeArguments.every(isThislessType);
}
return false;
@@ -56468,7 +57557,7 @@ var ts;
function isThislessFunctionLikeDeclaration(node) {
var returnType = ts.getEffectiveReturnTypeNode(node);
var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
- return (node.kind === 170 /* Constructor */ || (!!returnType && isThislessType(returnType))) &&
+ return (node.kind === 171 /* SyntaxKind.Constructor */ || (!!returnType && isThislessType(returnType))) &&
node.parameters.every(isThislessVariableLikeDeclaration) &&
typeParameters.every(isThislessTypeParameter);
}
@@ -56484,14 +57573,14 @@ var ts;
var declaration = symbol.declarations[0];
if (declaration) {
switch (declaration.kind) {
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
return isThislessVariableLikeDeclaration(declaration);
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 170 /* Constructor */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
return isThislessFunctionLikeDeclaration(declaration);
}
}
@@ -56528,8 +57617,8 @@ var ts;
type.declaredCallSignatures = ts.emptyArray;
type.declaredConstructSignatures = ts.emptyArray;
type.declaredIndexInfos = ts.emptyArray;
- type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */));
- type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */));
+ type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* InternalSymbolName.Call */));
+ type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* InternalSymbolName.New */));
type.declaredIndexInfos = getIndexInfosOfSymbol(symbol);
}
return type;
@@ -56538,7 +57627,7 @@ var ts;
* Indicates whether a type can be used as a property name.
*/
function isTypeUsableAsPropertyName(type) {
- return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */);
+ return !!(type.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */);
}
/**
* Indicates whether a declaration name is definitely late-bindable.
@@ -56557,9 +57646,9 @@ var ts;
&& isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr));
}
function isLateBoundName(name) {
- return name.charCodeAt(0) === 95 /* _ */ &&
- name.charCodeAt(1) === 95 /* _ */ &&
- name.charCodeAt(2) === 64 /* at */;
+ return name.charCodeAt(0) === 95 /* CharacterCodes._ */ &&
+ name.charCodeAt(1) === 95 /* CharacterCodes._ */ &&
+ name.charCodeAt(2) === 64 /* CharacterCodes.at */;
}
/**
* Indicates whether a declaration has a late-bindable dynamic name.
@@ -56584,10 +57673,10 @@ var ts;
* Gets the symbolic name for a member from its type.
*/
function getPropertyNameFromType(type) {
- if (type.flags & 8192 /* UniqueESSymbol */) {
+ if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) {
return type.escapedName;
}
- if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
+ if (type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) {
return ts.escapeLeadingUnderscores("" + type.value);
}
return ts.Debug.fail();
@@ -56598,7 +57687,7 @@ var ts;
* members.
*/
function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) {
- ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* Late */), "Expected a late-bound symbol.");
+ ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */), "Expected a late-bound symbol.");
symbol.flags |= symbolFlags;
getSymbolLinks(member.symbol).lateSymbol = symbol;
if (!symbol.declarations) {
@@ -56607,7 +57696,7 @@ var ts;
else if (!member.symbol.isReplaceableByMethod) {
symbol.declarations.push(member);
}
- if (symbolFlags & 111551 /* Value */) {
+ if (symbolFlags & 111551 /* SymbolFlags.Value */) {
if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) {
symbol.valueDeclaration = member;
}
@@ -56656,7 +57745,7 @@ var ts;
// Get or add a late-bound symbol for the member. This allows us to merge late-bound accessor declarations.
var lateSymbol = lateSymbols.get(memberName);
if (!lateSymbol)
- lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */));
+ lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */));
// Report an error if a late-bound member has the same name as an early-bound member,
// or if we have another early-bound symbol declaration with the same name and
// conflicting flags.
@@ -56665,10 +57754,10 @@ var ts;
// If we have an existing early-bound member, combine its declarations so that we can
// report an error at each declaration.
var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
- var name_4 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName);
- ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_4); });
- error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_4);
- lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */);
+ var name_5 = !(type.flags & 8192 /* TypeFlags.UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName);
+ ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_5); });
+ error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_5);
+ lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */);
}
lateSymbol.nameType = type;
addDeclarationToLateBoundSymbol(lateSymbol, decl, symbolFlags);
@@ -56686,9 +57775,9 @@ var ts;
function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) {
var links = getSymbolLinks(symbol);
if (!links[resolutionKind]) {
- var isStatic_1 = resolutionKind === "resolvedExports" /* resolvedExports */;
+ var isStatic_1 = resolutionKind === "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */;
var earlySymbols = !isStatic_1 ? symbol.members :
- symbol.flags & 1536 /* Module */ ? getExportsOfModuleWorker(symbol) :
+ symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModuleWorker(symbol) :
symbol.exports;
// In the event we recursively resolve the members/exports of the symbol, we
// set the initial value of resolvedMembers/resolvedExports to the early-bound
@@ -56714,10 +57803,10 @@ var ts;
for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) {
var member = decls_1[_c];
var assignmentKind = ts.getAssignmentDeclarationKind(member);
- var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */
+ var isInstanceMember = assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */
|| ts.isBinaryExpression(member) && isPossiblyAliasedThisProperty(member, assignmentKind)
- || assignmentKind === 9 /* ObjectDefinePrototypeProperty */
- || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name
+ || assignmentKind === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */
+ || assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */; // A straight `Prototype` assignment probably can never have a computed name
if (isStatic_1 === !isInstanceMember && hasLateBindableName(member)) {
lateBindMember(symbol, earlySymbols, lateSymbols, member);
}
@@ -56733,8 +57822,8 @@ var ts;
* For a description of late-binding, see `lateBindMember`.
*/
function getMembersOfSymbol(symbol) {
- return symbol.flags & 6256 /* LateBindingContainer */
- ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* resolvedMembers */)
+ return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */
+ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* MembersOrExportsResolutionKind.resolvedMembers */)
: symbol.members || emptySymbols;
}
/**
@@ -56744,7 +57833,7 @@ var ts;
* For a description of late-binding, see `lateBindMember`.
*/
function getLateBoundSymbol(symbol) {
- if (symbol.flags & 106500 /* ClassMember */ && symbol.escapedName === "__computed" /* Computed */) {
+ if (symbol.flags & 106500 /* SymbolFlags.ClassMember */ && symbol.escapedName === "__computed" /* InternalSymbolName.Computed */) {
var links = getSymbolLinks(symbol);
if (!links.lateSymbol && ts.some(symbol.declarations, hasLateBindableName)) {
// force late binding of members/exports. This will set the late-bound symbol
@@ -56761,7 +57850,7 @@ var ts;
return symbol;
}
function getTypeWithThisArgument(type, thisArgument, needApparentType) {
- if (ts.getObjectFlags(type) & 4 /* Reference */) {
+ if (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) {
var target = type.target;
var typeArguments = getTypeArguments(type);
if (ts.length(target.typeParameters) === ts.length(typeArguments)) {
@@ -56769,7 +57858,7 @@ var ts;
return needApparentType ? getApparentType(ref) : ref;
}
}
- else if (type.flags & 2097152 /* Intersection */) {
+ else if (type.flags & 2097152 /* TypeFlags.Intersection */) {
var types = ts.sameMap(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); });
return types !== type.types ? getIntersectionType(types) : type;
}
@@ -56805,8 +57894,8 @@ var ts;
var baseType = baseTypes_1[_i];
var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType;
addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType));
- callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */));
- constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */));
+ callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* SignatureKind.Call */));
+ constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* SignatureKind.Construct */));
var inheritedIndexInfos = instantiatedBaseType !== anyType ? getIndexInfosOfType(instantiatedBaseType) : [createIndexInfo(stringType, anyType, /*isReadonly*/ false)];
indexInfos = ts.concatenate(indexInfos, ts.filter(inheritedIndexInfos, function (info) { return !findIndexInfo(indexInfos, info.keyType); }));
}
@@ -56841,7 +57930,7 @@ var ts;
}
function cloneSignature(sig) {
var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined,
- /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */);
+ /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */);
result.target = sig.target;
result.mapper = sig.mapper;
result.compositeSignatures = sig.compositeSignatures;
@@ -56851,24 +57940,24 @@ var ts;
function createUnionSignature(signature, unionSignatures) {
var result = cloneSignature(signature);
result.compositeSignatures = unionSignatures;
- result.compositeKind = 1048576 /* Union */;
+ result.compositeKind = 1048576 /* TypeFlags.Union */;
result.target = undefined;
result.mapper = undefined;
return result;
}
function getOptionalCallSignature(signature, callChainFlags) {
- if ((signature.flags & 24 /* CallChainFlags */) === callChainFlags) {
+ if ((signature.flags & 24 /* SignatureFlags.CallChainFlags */) === callChainFlags) {
return signature;
}
if (!signature.optionalCallSignatureCache) {
signature.optionalCallSignatureCache = {};
}
- var key = callChainFlags === 8 /* IsInnerCallChain */ ? "inner" : "outer";
+ var key = callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ ? "inner" : "outer";
return signature.optionalCallSignatureCache[key]
|| (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags));
}
function createOptionalCallSignature(signature, callChainFlags) {
- ts.Debug.assert(callChainFlags === 8 /* IsInnerCallChain */ || callChainFlags === 16 /* IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both.");
+ ts.Debug.assert(callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ || callChainFlags === 16 /* SignatureFlags.IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both.");
var result = cloneSignature(signature);
result.flags |= callChainFlags;
return result;
@@ -56880,7 +57969,7 @@ var ts;
if (isTupleType(restType)) {
return [expandSignatureParametersWithTupleMembers(restType, restIndex_1)];
}
- else if (!skipUnionExpanding && restType.flags & 1048576 /* Union */ && ts.every(restType.types, isTupleType)) {
+ else if (!skipUnionExpanding && restType.flags & 1048576 /* TypeFlags.Union */ && ts.every(restType.types, isTupleType)) {
return ts.map(restType.types, function (t) { return expandSignatureParametersWithTupleMembers(t, restIndex_1); });
}
}
@@ -56893,10 +57982,10 @@ var ts;
var tupleLabelName = !!associatedNames && getTupleElementLabel(associatedNames[i]);
var name = tupleLabelName || getParameterNameAtPosition(sig, restIndex + i, restType);
var flags = restType.target.elementFlags[i];
- var checkFlags = flags & 12 /* Variable */ ? 32768 /* RestParameter */ :
- flags & 2 /* Optional */ ? 16384 /* OptionalParameter */ : 0;
- var symbol = createSymbol(1 /* FunctionScopedVariable */, name, checkFlags);
- symbol.type = flags & 4 /* Rest */ ? createArrayType(t) : t;
+ var checkFlags = flags & 12 /* ElementFlags.Variable */ ? 32768 /* CheckFlags.RestParameter */ :
+ flags & 2 /* ElementFlags.Optional */ ? 16384 /* CheckFlags.OptionalParameter */ : 0;
+ var symbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, name, checkFlags);
+ symbol.type = flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t;
return symbol;
});
return ts.concatenate(sig.parameters.slice(0, restIndex), restParams);
@@ -56904,11 +57993,11 @@ var ts;
}
function getDefaultConstructSignatures(classType) {
var baseConstructorType = getBaseConstructorTypeOfClass(classType);
- var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */);
+ var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */);
var declaration = ts.getClassLikeDeclarationOfSymbol(classType.symbol);
- var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* Abstract */);
+ var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */);
if (baseSignatures.length === 0) {
- return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* Abstract */ : 0 /* None */)];
+ return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* SignatureFlags.Abstract */ : 0 /* SignatureFlags.None */)];
}
var baseTypeNode = getBaseTypeNodeOfClass(classType);
var isJavaScript = ts.isInJSFile(baseTypeNode);
@@ -56923,7 +58012,7 @@ var ts;
var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig);
sig.typeParameters = classType.localTypeParameters;
sig.resolvedReturnType = classType;
- sig.flags = isAbstract ? sig.flags | 4 /* Abstract */ : sig.flags & ~4 /* Abstract */;
+ sig.flags = isAbstract ? sig.flags | 4 /* SignatureFlags.Abstract */ : sig.flags & ~4 /* SignatureFlags.Abstract */;
result.push(sig);
}
}
@@ -57086,12 +58175,12 @@ var ts;
!leftName ? rightName :
!rightName ? leftName :
undefined;
- var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg".concat(i));
+ var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i));
paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType;
params[i] = paramSymbol;
}
if (needsExtraRestElement) {
- var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args");
+ var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args");
restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount));
if (shorter === right) {
restParamSymbol.type = instantiateType(restParamSymbol.type, mapper);
@@ -57113,11 +58202,11 @@ var ts;
var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount);
var result = createSignature(declaration, typeParams, thisParam, params,
/*resolvedReturnType*/ undefined,
- /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */);
- result.compositeKind = 1048576 /* Union */;
- result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]);
+ /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */);
+ result.compositeKind = 1048576 /* TypeFlags.Union */;
+ result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]);
if (paramMapper) {
- result.mapper = left.compositeKind !== 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper;
+ result.mapper = left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper;
}
return result;
}
@@ -57142,8 +58231,8 @@ var ts;
function resolveUnionTypeMembers(type) {
// The members and properties collections are empty for union types. To get all properties of a union
// type use getPropertiesOfType (only the language service uses this).
- var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* Call */); }));
- var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* Construct */); }));
+ var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* SignatureKind.Call */); }));
+ var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */); }));
var indexInfos = getUnionIndexInfos(type.types);
setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, indexInfos);
}
@@ -57151,7 +58240,7 @@ var ts;
return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]);
}
function findMixins(types) {
- var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* Construct */).length > 0; });
+ var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */).length > 0; });
var mixinFlags = ts.map(types, isMixinConstructorType);
if (constructorTypeCount > 0 && constructorTypeCount === ts.countWhere(mixinFlags, function (b) { return b; })) {
var firstMixinIndex = mixinFlags.indexOf(/*searchElement*/ true);
@@ -57166,7 +58255,7 @@ var ts;
mixedTypes.push(type);
}
else if (mixinFlags[i]) {
- mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* Construct */)[0]));
+ mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* SignatureKind.Construct */)[0]));
}
}
return getIntersectionType(mixedTypes);
@@ -57188,7 +58277,7 @@ var ts;
// '{ new(...args: any[]) => A } & { new(s: string) => B }' has a single construct signature
// 'new(s: string) => A & B'.
if (!mixinFlags[i]) {
- var signatures = getSignaturesOfType(t, 1 /* Construct */);
+ var signatures = getSignaturesOfType(t, 1 /* SignatureKind.Construct */);
if (signatures.length && mixinCount > 0) {
signatures = ts.map(signatures, function (s) {
var clone = cloneSignature(s);
@@ -57198,7 +58287,7 @@ var ts;
}
constructSignatures = appendSignatures(constructSignatures, signatures);
}
- callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* Call */));
+ callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* SignatureKind.Call */));
indexInfos = ts.reduceLeft(getIndexInfosOfType(t), function (infos, newInfo) { return appendIndexInfo(infos, newInfo, /*union*/ false); }, indexInfos);
};
for (var i = 0; i < types.length; i++) {
@@ -57234,87 +58323,88 @@ var ts;
* Converts an AnonymousType to a ResolvedType.
*/
function resolveAnonymousTypeMembers(type) {
- var symbol = getMergedSymbol(type.symbol);
if (type.target) {
setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
- var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false);
- var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper);
- var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper);
- var indexInfos = instantiateIndexInfos(getIndexInfosOfType(type.target), type.mapper);
- setStructuredTypeMembers(type, members, callSignatures, constructSignatures, indexInfos);
+ var members_6 = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false);
+ var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* SignatureKind.Call */), type.mapper);
+ var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* SignatureKind.Construct */), type.mapper);
+ var indexInfos_1 = instantiateIndexInfos(getIndexInfosOfType(type.target), type.mapper);
+ setStructuredTypeMembers(type, members_6, callSignatures, constructSignatures, indexInfos_1);
+ return;
}
- else if (symbol.flags & 2048 /* TypeLiteral */) {
+ var symbol = getMergedSymbol(type.symbol);
+ if (symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) {
setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
- var members = getMembersOfSymbol(symbol);
- var callSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */));
- var constructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */));
- var indexInfos = getIndexInfosOfSymbol(symbol);
- setStructuredTypeMembers(type, members, callSignatures, constructSignatures, indexInfos);
+ var members_7 = getMembersOfSymbol(symbol);
+ var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* InternalSymbolName.Call */));
+ var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* InternalSymbolName.New */));
+ var indexInfos_2 = getIndexInfosOfSymbol(symbol);
+ setStructuredTypeMembers(type, members_7, callSignatures, constructSignatures, indexInfos_2);
+ return;
}
- else {
- // Combinations of function, class, enum and module
- var members = emptySymbols;
- var indexInfos = void 0;
- if (symbol.exports) {
- members = getExportsOfSymbol(symbol);
- if (symbol === globalThisSymbol) {
- var varsOnly_1 = new ts.Map();
- members.forEach(function (p) {
- if (!(p.flags & 418 /* BlockScoped */)) {
- varsOnly_1.set(p.escapedName, p);
- }
- });
- members = varsOnly_1;
- }
+ // Combinations of function, class, enum and module
+ var members = emptySymbols;
+ var indexInfos;
+ if (symbol.exports) {
+ members = getExportsOfSymbol(symbol);
+ if (symbol === globalThisSymbol) {
+ var varsOnly_1 = new ts.Map();
+ members.forEach(function (p) {
+ var _a;
+ if (!(p.flags & 418 /* SymbolFlags.BlockScoped */) && !(p.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = p.declarations) === null || _a === void 0 ? void 0 : _a.length) && ts.every(p.declarations, ts.isAmbientModule))) {
+ varsOnly_1.set(p.escapedName, p);
+ }
+ });
+ members = varsOnly_1;
}
- var baseConstructorIndexInfo = void 0;
- setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, ts.emptyArray);
- if (symbol.flags & 32 /* Class */) {
- var classType = getDeclaredTypeOfClassOrInterface(symbol);
- var baseConstructorType = getBaseConstructorTypeOfClass(classType);
- if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) {
- members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members));
- addInheritedMembers(members, getPropertiesOfType(baseConstructorType));
- }
- else if (baseConstructorType === anyType) {
- baseConstructorIndexInfo = createIndexInfo(stringType, anyType, /*isReadonly*/ false);
- }
+ }
+ var baseConstructorIndexInfo;
+ setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, ts.emptyArray);
+ if (symbol.flags & 32 /* SymbolFlags.Class */) {
+ var classType = getDeclaredTypeOfClassOrInterface(symbol);
+ var baseConstructorType = getBaseConstructorTypeOfClass(classType);
+ if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 8650752 /* TypeFlags.TypeVariable */)) {
+ members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members));
+ addInheritedMembers(members, getPropertiesOfType(baseConstructorType));
}
- var indexSymbol = getIndexSymbolFromSymbolTable(members);
- if (indexSymbol) {
- indexInfos = getIndexInfosOfIndexSymbol(indexSymbol);
+ else if (baseConstructorType === anyType) {
+ baseConstructorIndexInfo = createIndexInfo(stringType, anyType, /*isReadonly*/ false);
}
- else {
- if (baseConstructorIndexInfo) {
- indexInfos = ts.append(indexInfos, baseConstructorIndexInfo);
- }
- if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ ||
- ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) {
- indexInfos = ts.append(indexInfos, enumNumberIndexInfo);
- }
+ }
+ var indexSymbol = getIndexSymbolFromSymbolTable(members);
+ if (indexSymbol) {
+ indexInfos = getIndexInfosOfIndexSymbol(indexSymbol);
+ }
+ else {
+ if (baseConstructorIndexInfo) {
+ indexInfos = ts.append(indexInfos, baseConstructorIndexInfo);
}
- setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, indexInfos || ts.emptyArray);
- // We resolve the members before computing the signatures because a signature may use
- // typeof with a qualified name expression that circularly references the type we are
- // in the process of resolving (see issue #6072). The temporarily empty signature list
- // will never be observed because a qualified name can't reference signatures.
- if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) {
- type.callSignatures = getSignaturesOfSymbol(symbol);
+ if (symbol.flags & 384 /* SymbolFlags.Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* TypeFlags.Enum */ ||
+ ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* TypeFlags.NumberLike */); }))) {
+ indexInfos = ts.append(indexInfos, enumNumberIndexInfo);
}
- // And likewise for construct signatures for classes
- if (symbol.flags & 32 /* Class */) {
- var classType_1 = getDeclaredTypeOfClassOrInterface(symbol);
- var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray;
- if (symbol.flags & 16 /* Function */) {
- constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ?
- createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */) :
- undefined; }));
- }
- if (!constructSignatures.length) {
- constructSignatures = getDefaultConstructSignatures(classType_1);
- }
- type.constructSignatures = constructSignatures;
+ }
+ setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, indexInfos || ts.emptyArray);
+ // We resolve the members before computing the signatures because a signature may use
+ // typeof with a qualified name expression that circularly references the type we are
+ // in the process of resolving (see issue #6072). The temporarily empty signature list
+ // will never be observed because a qualified name can't reference signatures.
+ if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) {
+ type.callSignatures = getSignaturesOfSymbol(symbol);
+ }
+ // And likewise for construct signatures for classes
+ if (symbol.flags & 32 /* SymbolFlags.Class */) {
+ var classType_1 = getDeclaredTypeOfClassOrInterface(symbol);
+ var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* InternalSymbolName.Constructor */)) : ts.emptyArray;
+ if (symbol.flags & 16 /* SymbolFlags.Function */) {
+ constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ?
+ createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */) :
+ undefined; }));
+ }
+ if (!constructSignatures.length) {
+ constructSignatures = getDefaultConstructSignatures(classType_1);
}
+ type.constructSignatures = constructSignatures;
}
}
function replaceIndexedAccess(instantiable, type, replacement) {
@@ -57326,20 +58416,20 @@ var ts;
function resolveReverseMappedTypeMembers(type) {
var indexInfo = getIndexInfoOfType(type.source, stringType);
var modifiers = getMappedTypeModifiers(type.mappedType);
- var readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true;
- var optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */;
+ var readonlyMask = modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? false : true;
+ var optionalMask = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 0 : 16777216 /* SymbolFlags.Optional */;
var indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : ts.emptyArray;
var members = ts.createSymbolTable();
for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) {
var prop = _a[_i];
- var checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0);
- var inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags);
+ var checkFlags = 8192 /* CheckFlags.ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* CheckFlags.Readonly */ : 0);
+ var inferredProp = createSymbol(4 /* SymbolFlags.Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags);
inferredProp.declarations = prop.declarations;
inferredProp.nameType = getSymbolLinks(prop).nameType;
inferredProp.propertyType = getTypeOfSymbol(prop);
- if (type.constraintType.type.flags & 8388608 /* IndexedAccess */
- && type.constraintType.type.objectType.flags & 262144 /* TypeParameter */
- && type.constraintType.type.indexType.flags & 262144 /* TypeParameter */) {
+ if (type.constraintType.type.flags & 8388608 /* TypeFlags.IndexedAccess */
+ && type.constraintType.type.objectType.flags & 262144 /* TypeFlags.TypeParameter */
+ && type.constraintType.type.indexType.flags & 262144 /* TypeFlags.TypeParameter */) {
// A reverse mapping of `{[K in keyof T[K_1]]: T[K_1]}` is the same as that of `{[K in keyof T]: T}`, since all we care about is
// inferring to the "type parameter" (or indexed access) shared by the constraint and template. So, to reduce the number of
// type identities produced, we simplify such indexed access occurences
@@ -57360,11 +58450,11 @@ var ts;
// bound includes those keys that are known to always be present, for example because
// because of constraints on type parameters (e.g. 'keyof T' for a constrained T).
function getLowerBoundOfKeyType(type) {
- if (type.flags & 4194304 /* Index */) {
+ if (type.flags & 4194304 /* TypeFlags.Index */) {
var t = getApparentType(type.type);
return isGenericTupleType(t) ? getKnownKeysOfTupleType(t) : getIndexType(t);
}
- if (type.flags & 16777216 /* Conditional */) {
+ if (type.flags & 16777216 /* TypeFlags.Conditional */) {
if (type.root.isDistributive) {
var checkType = type.checkType;
var constraint = getLowerBoundOfKeyType(checkType);
@@ -57374,29 +58464,29 @@ var ts;
}
return type;
}
- if (type.flags & 1048576 /* Union */) {
+ if (type.flags & 1048576 /* TypeFlags.Union */) {
return mapType(type, getLowerBoundOfKeyType);
}
- if (type.flags & 2097152 /* Intersection */) {
+ if (type.flags & 2097152 /* TypeFlags.Intersection */) {
return getIntersectionType(ts.sameMap(type.types, getLowerBoundOfKeyType));
}
return type;
}
function getIsLateCheckFlag(s) {
- return ts.getCheckFlags(s) & 4096 /* Late */;
+ return ts.getCheckFlags(s) & 4096 /* CheckFlags.Late */;
}
function forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(type, include, stringsOnly, cb) {
for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
var prop = _a[_i];
cb(getLiteralTypeFromProperty(prop, include));
}
- if (type.flags & 1 /* Any */) {
+ if (type.flags & 1 /* TypeFlags.Any */) {
cb(stringType);
}
else {
for (var _b = 0, _c = getIndexInfosOfType(type); _b < _c.length; _b++) {
var info = _c[_b];
- if (!stringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) {
+ if (!stringsOnly || info.keyType.flags & (4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */)) {
cb(info.keyType);
}
}
@@ -57416,7 +58506,7 @@ var ts;
var templateType = getTemplateTypeFromMappedType(type.target || type);
var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T'
var templateModifiers = getMappedTypeModifiers(type);
- var include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */;
+ var include = keyofStringsOnly ? 128 /* TypeFlags.StringLiteral */ : 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */;
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
// We have a { [P in keyof T]: X }
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, include, keyofStringsOnly, addMemberForKeyType);
@@ -57444,13 +58534,13 @@ var ts;
}
else {
var modifiersProp = isTypeUsableAsPropertyName(keyType) ? getPropertyOfType(modifiersType, getPropertyNameFromType(keyType)) : undefined;
- var isOptional = !!(templateModifiers & 4 /* IncludeOptional */ ||
- !(templateModifiers & 8 /* ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* Optional */);
- var isReadonly = !!(templateModifiers & 1 /* IncludeReadonly */ ||
- !(templateModifiers & 2 /* ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp));
- var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */;
+ var isOptional = !!(templateModifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ||
+ !(templateModifiers & 8 /* MappedTypeModifiers.ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */);
+ var isReadonly = !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ||
+ !(templateModifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp));
+ var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */;
var lateFlag = modifiersProp ? getIsLateCheckFlag(modifiersProp) : 0;
- var prop = createSymbol(4 /* Property */ | (isOptional ? 16777216 /* Optional */ : 0), propName, lateFlag | 262144 /* Mapped */ | (isReadonly ? 8 /* Readonly */ : 0) | (stripOptional ? 524288 /* StripOptional */ : 0));
+ var prop = createSymbol(4 /* SymbolFlags.Property */ | (isOptional ? 16777216 /* SymbolFlags.Optional */ : 0), propName, lateFlag | 262144 /* CheckFlags.Mapped */ | (isReadonly ? 8 /* CheckFlags.Readonly */ : 0) | (stripOptional ? 524288 /* CheckFlags.StripOptional */ : 0));
prop.mappedType = type;
prop.nameType = propNameType;
prop.keyType = keyType;
@@ -57463,12 +58553,12 @@ var ts;
members.set(propName, prop);
}
}
- else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ | 32 /* Enum */)) {
- var indexKeyType = propNameType.flags & (1 /* Any */ | 4 /* String */) ? stringType :
- propNameType.flags & (8 /* Number */ | 32 /* Enum */) ? numberType :
+ else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* TypeFlags.Any */ | 32 /* TypeFlags.Enum */)) {
+ var indexKeyType = propNameType.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */) ? stringType :
+ propNameType.flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */) ? numberType :
propNameType;
var propType = instantiateType(templateType, appendTypeMapping(type.mapper, typeParameter, keyType));
- var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* IncludeReadonly */));
+ var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */));
indexInfos = appendIndexInfo(indexInfos, indexInfo, /*union*/ true);
}
}
@@ -57476,7 +58566,7 @@ var ts;
function getTypeOfMappedSymbol(symbol) {
if (!symbol.type) {
var mappedType = symbol.mappedType;
- if (!pushTypeResolution(symbol, 0 /* Type */)) {
+ if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) {
mappedType.containsError = true;
return errorType;
}
@@ -57486,8 +58576,8 @@ var ts;
// When creating an optional property in strictNullChecks mode, if 'undefined' isn't assignable to the
// type, we include 'undefined' in the type. Similarly, when creating a non-optional property in strictNullChecks
// mode, if the underlying property is optional we remove 'undefined' from the type.
- var type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) :
- symbol.checkFlags & 524288 /* StripOptional */ ? removeMissingOrUndefinedType(propType) :
+ var type = strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) :
+ symbol.checkFlags & 524288 /* CheckFlags.StripOptional */ ? removeMissingOrUndefinedType(propType) :
propType;
if (!popTypeResolution()) {
error(currentNode, ts.Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(mappedType));
@@ -57513,7 +58603,7 @@ var ts;
function getTemplateTypeFromMappedType(type) {
return type.templateType ||
(type.templateType = type.declaration.type ?
- instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) :
+ instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), type.mapper) :
errorType);
}
function getConstraintDeclarationForMappedType(type) {
@@ -57521,8 +58611,8 @@ var ts;
}
function isMappedTypeWithKeyofConstraintDeclaration(type) {
var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217
- return constraintDeclaration.kind === 192 /* TypeOperator */ &&
- constraintDeclaration.operator === 140 /* KeyOfKeyword */;
+ return constraintDeclaration.kind === 193 /* SyntaxKind.TypeOperator */ &&
+ constraintDeclaration.operator === 140 /* SyntaxKind.KeyOfKeyword */;
}
function getModifiersTypeFromMappedType(type) {
if (!type.modifiersType) {
@@ -57538,20 +58628,20 @@ var ts;
// the modifiers type is T. Otherwise, the modifiers type is unknown.
var declaredType = getTypeFromMappedTypeNode(type.declaration);
var constraint = getConstraintTypeFromMappedType(declaredType);
- var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint;
- type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType;
+ var extendedConstraint = constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint;
+ type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* TypeFlags.Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType;
}
}
return type.modifiersType;
}
function getMappedTypeModifiers(type) {
var declaration = type.declaration;
- return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) |
- (declaration.questionToken ? declaration.questionToken.kind === 40 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0);
+ return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* SyntaxKind.MinusToken */ ? 2 /* MappedTypeModifiers.ExcludeReadonly */ : 1 /* MappedTypeModifiers.IncludeReadonly */ : 0) |
+ (declaration.questionToken ? declaration.questionToken.kind === 40 /* SyntaxKind.MinusToken */ ? 8 /* MappedTypeModifiers.ExcludeOptional */ : 4 /* MappedTypeModifiers.IncludeOptional */ : 0);
}
function getMappedTypeOptionality(type) {
var modifiers = getMappedTypeModifiers(type);
- return modifiers & 8 /* ExcludeOptional */ ? -1 : modifiers & 4 /* IncludeOptional */ ? 1 : 0;
+ return modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? -1 : modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 1 : 0;
}
function getCombinedMappedTypeOptionality(type) {
var optionality = getMappedTypeOptionality(type);
@@ -57559,34 +58649,34 @@ var ts;
return optionality || (isGenericMappedType(modifiersType) ? getMappedTypeOptionality(modifiersType) : 0);
}
function isPartialMappedType(type) {
- return !!(ts.getObjectFlags(type) & 32 /* Mapped */ && getMappedTypeModifiers(type) & 4 /* IncludeOptional */);
+ return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */);
}
function isGenericMappedType(type) {
- return !!(ts.getObjectFlags(type) & 32 /* Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type));
+ return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type));
}
function resolveStructuredTypeMembers(type) {
if (!type.members) {
- if (type.flags & 524288 /* Object */) {
- if (type.objectFlags & 4 /* Reference */) {
+ if (type.flags & 524288 /* TypeFlags.Object */) {
+ if (type.objectFlags & 4 /* ObjectFlags.Reference */) {
resolveTypeReferenceMembers(type);
}
- else if (type.objectFlags & 3 /* ClassOrInterface */) {
+ else if (type.objectFlags & 3 /* ObjectFlags.ClassOrInterface */) {
resolveClassOrInterfaceMembers(type);
}
- else if (type.objectFlags & 1024 /* ReverseMapped */) {
+ else if (type.objectFlags & 1024 /* ObjectFlags.ReverseMapped */) {
resolveReverseMappedTypeMembers(type);
}
- else if (type.objectFlags & 16 /* Anonymous */) {
+ else if (type.objectFlags & 16 /* ObjectFlags.Anonymous */) {
resolveAnonymousTypeMembers(type);
}
- else if (type.objectFlags & 32 /* Mapped */) {
+ else if (type.objectFlags & 32 /* ObjectFlags.Mapped */) {
resolveMappedTypeMembers(type);
}
}
- else if (type.flags & 1048576 /* Union */) {
+ else if (type.flags & 1048576 /* TypeFlags.Union */) {
resolveUnionTypeMembers(type);
}
- else if (type.flags & 2097152 /* Intersection */) {
+ else if (type.flags & 2097152 /* TypeFlags.Intersection */) {
resolveIntersectionTypeMembers(type);
}
}
@@ -57594,7 +58684,7 @@ var ts;
}
/** Return properties of an object type or an empty array for other types */
function getPropertiesOfObjectType(type) {
- if (type.flags & 524288 /* Object */) {
+ if (type.flags & 524288 /* TypeFlags.Object */) {
return resolveStructuredTypeMembers(type).properties;
}
return ts.emptyArray;
@@ -57603,7 +58693,7 @@ var ts;
* return the symbol for that property. Otherwise return undefined.
*/
function getPropertyOfObjectType(type, name) {
- if (type.flags & 524288 /* Object */) {
+ if (type.flags & 524288 /* TypeFlags.Object */) {
var resolved = resolveStructuredTypeMembers(type);
var symbol = resolved.members.get(name);
if (symbol && symbolIsValue(symbol)) {
@@ -57627,7 +58717,7 @@ var ts;
}
// The properties of a union type are those that are present in all constituent types, so
// we only need to check the properties of the first type without index signature
- if (type.flags & 1048576 /* Union */ && getIndexInfosOfType(current).length === 0) {
+ if (type.flags & 1048576 /* TypeFlags.Union */ && getIndexInfosOfType(current).length === 0) {
break;
}
}
@@ -57637,13 +58727,13 @@ var ts;
}
function getPropertiesOfType(type) {
type = getReducedApparentType(type);
- return type.flags & 3145728 /* UnionOrIntersection */ ?
+ return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ?
getPropertiesOfUnionOrIntersectionType(type) :
getPropertiesOfObjectType(type);
}
function forEachPropertyOfType(type, action) {
type = getReducedApparentType(type);
- if (type.flags & 3670016 /* StructuredType */) {
+ if (type.flags & 3670016 /* TypeFlags.StructuredType */) {
resolveStructuredTypeMembers(type).members.forEach(function (symbol, escapedName) {
if (isNamedMember(symbol, escapedName)) {
action(symbol, escapedName);
@@ -57662,7 +58752,7 @@ var ts;
}
function getAllPossiblePropertiesOfTypes(types) {
var unionType = getUnionType(types);
- if (!(unionType.flags & 1048576 /* Union */)) {
+ if (!(unionType.flags & 1048576 /* TypeFlags.Union */)) {
return getAugmentedPropertiesOfType(unionType);
}
var props = ts.createSymbolTable();
@@ -57681,9 +58771,9 @@ var ts;
return ts.arrayFrom(props.values());
}
function getConstraintOfType(type) {
- return type.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(type) :
- type.flags & 8388608 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) :
- type.flags & 16777216 /* Conditional */ ? getConstraintOfConditionalType(type) :
+ return type.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(type) :
+ type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getConstraintOfIndexedAccess(type) :
+ type.flags & 16777216 /* TypeFlags.Conditional */ ? getConstraintOfConditionalType(type) :
getBaseConstraintOfType(type);
}
function getConstraintOfTypeParameter(typeParameter) {
@@ -57744,7 +58834,7 @@ var ts;
var constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified;
if (constraint && constraint !== type.checkType) {
var instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
- if (!(instantiated.flags & 131072 /* Never */)) {
+ if (!(instantiated.flags & 131072 /* TypeFlags.Never */)) {
return instantiated;
}
}
@@ -57762,11 +58852,11 @@ var ts;
var hasDisjointDomainType = false;
for (var _i = 0, types_5 = types; _i < types_5.length; _i++) {
var t = types_5[_i];
- if (t.flags & 465829888 /* Instantiable */) {
+ if (t.flags & 465829888 /* TypeFlags.Instantiable */) {
// We keep following constraints as long as we have an instantiable type that is known
// not to be circular or infinite (hence we stop on index access types).
var constraint = getConstraintOfType(t);
- while (constraint && constraint.flags & (262144 /* TypeParameter */ | 4194304 /* Index */ | 16777216 /* Conditional */)) {
+ while (constraint && constraint.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */ | 16777216 /* TypeFlags.Conditional */)) {
constraint = getConstraintOfType(constraint);
}
if (constraint) {
@@ -57776,7 +58866,7 @@ var ts;
}
}
}
- else if (t.flags & 469892092 /* DisjointDomains */) {
+ else if (t.flags & 469892092 /* TypeFlags.DisjointDomains */) {
hasDisjointDomainType = true;
}
}
@@ -57788,7 +58878,7 @@ var ts;
// intersection operation to reduce the union constraints.
for (var _a = 0, types_6 = types; _a < types_6.length; _a++) {
var t = types_6[_a];
- if (t.flags & 469892092 /* DisjointDomains */) {
+ if (t.flags & 469892092 /* TypeFlags.DisjointDomains */) {
constraints = ts.append(constraints, t);
}
}
@@ -57798,11 +58888,11 @@ var ts;
return undefined;
}
function getBaseConstraintOfType(type) {
- if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) {
+ if (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */)) {
var constraint = getResolvedBaseConstraint(type);
return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined;
}
- return type.flags & 4194304 /* Index */ ? keyofConstraintType : undefined;
+ return type.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType : undefined;
}
/**
* This is similar to `getBaseConstraintOfType` except it returns the input type if there's no base constraint, instead of `undefined`
@@ -57827,7 +58917,7 @@ var ts;
return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type);
function getImmediateBaseConstraint(t) {
if (!t.immediateBaseConstraint) {
- if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) {
+ if (!pushTypeResolution(t, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */)) {
return circularConstraintType;
}
var result = void 0;
@@ -57837,13 +58927,14 @@ var ts;
// levels of nesting, we are presumably exploring a repeating pattern with a long cycle that hasn't
// yet triggered the deeply nested limiter. We have no test cases that actually get to 50 levels of
// nesting, so it is effectively just a safety stop.
- if (stack.length < 10 || stack.length < 50 && !isDeeplyNestedType(t, stack, stack.length)) {
- stack.push(t);
+ var identity_1 = getRecursionIdentity(t);
+ if (stack.length < 10 || stack.length < 50 && !ts.contains(stack, identity_1)) {
+ stack.push(identity_1);
result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false));
stack.pop();
}
if (!popTypeResolution()) {
- if (t.flags & 262144 /* TypeParameter */) {
+ if (t.flags & 262144 /* TypeFlags.TypeParameter */) {
var errorNode = getConstraintDeclaration(t);
if (errorNode) {
var diagnostic = error(errorNode, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(t));
@@ -57863,13 +58954,13 @@ var ts;
return c !== noConstraintType && c !== circularConstraintType ? c : undefined;
}
function computeBaseConstraint(t) {
- if (t.flags & 262144 /* TypeParameter */) {
+ if (t.flags & 262144 /* TypeFlags.TypeParameter */) {
var constraint = getConstraintFromTypeParameter(t);
return t.isThisType || !constraint ?
constraint :
getBaseConstraint(constraint);
}
- if (t.flags & 3145728 /* UnionOrIntersection */) {
+ if (t.flags & 3145728 /* TypeFlags.UnionOrIntersection */) {
var types = t.types;
var baseTypes = [];
var different = false;
@@ -57889,23 +58980,23 @@ var ts;
if (!different) {
return t;
}
- return t.flags & 1048576 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) :
- t.flags & 2097152 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) :
+ return t.flags & 1048576 /* TypeFlags.Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) :
+ t.flags & 2097152 /* TypeFlags.Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) :
undefined;
}
- if (t.flags & 4194304 /* Index */) {
+ if (t.flags & 4194304 /* TypeFlags.Index */) {
return keyofConstraintType;
}
- if (t.flags & 134217728 /* TemplateLiteral */) {
+ if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) {
var types = t.types;
var constraints = ts.mapDefined(types, getBaseConstraint);
return constraints.length === types.length ? getTemplateLiteralType(t.texts, constraints) : stringType;
}
- if (t.flags & 268435456 /* StringMapping */) {
+ if (t.flags & 268435456 /* TypeFlags.StringMapping */) {
var constraint = getBaseConstraint(t.type);
return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
}
- if (t.flags & 8388608 /* IndexedAccess */) {
+ if (t.flags & 8388608 /* TypeFlags.IndexedAccess */) {
if (isMappedTypeGenericIndexedAccess(t)) {
// For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic,
// we substitute an instantiation of E where P is replaced with X.
@@ -57916,11 +59007,11 @@ var ts;
var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags);
return baseIndexedAccess && getBaseConstraint(baseIndexedAccess);
}
- if (t.flags & 16777216 /* Conditional */) {
+ if (t.flags & 16777216 /* TypeFlags.Conditional */) {
var constraint = getConstraintFromConditionalType(t);
return constraint && getBaseConstraint(constraint);
}
- if (t.flags & 33554432 /* Substitution */) {
+ if (t.flags & 33554432 /* TypeFlags.Substitution */) {
return getBaseConstraint(t.substitute);
}
return t;
@@ -57979,15 +59070,17 @@ var ts;
var typeVariable = getHomomorphicTypeVariable(type);
if (typeVariable && !type.declaration.nameType) {
var constraint = getConstraintOfTypeParameter(typeVariable);
- if (constraint && (isArrayType(constraint) || isTupleType(constraint))) {
+ if (constraint && isArrayOrTupleType(constraint)) {
return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
}
}
return type;
}
function isMappedTypeGenericIndexedAccess(type) {
- return type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(type.objectType) & 32 /* Mapped */ &&
- !isGenericMappedType(type.objectType) && isGenericIndexType(type.indexType);
+ var objectType;
+ return !!(type.flags & 8388608 /* TypeFlags.IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* ObjectFlags.Mapped */ &&
+ !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) &&
+ !objectType.declaration.questionToken && !objectType.declaration.nameType);
}
/**
* For a type parameter, return the base constraint of the type parameter. For the string, number,
@@ -57995,17 +59088,17 @@ var ts;
* type itself.
*/
function getApparentType(type) {
- var t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType;
- return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) :
- t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) :
- t.flags & 402653316 /* StringLike */ ? globalStringType :
- t.flags & 296 /* NumberLike */ ? globalNumberType :
- t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= 7 /* ES2020 */) :
- t.flags & 528 /* BooleanLike */ ? globalBooleanType :
- t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) :
- t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType :
- t.flags & 4194304 /* Index */ ? keyofConstraintType :
- t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType :
+ var t = !(type.flags & 465829888 /* TypeFlags.Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType;
+ return ts.getObjectFlags(t) & 32 /* ObjectFlags.Mapped */ ? getApparentTypeOfMappedType(t) :
+ t.flags & 2097152 /* TypeFlags.Intersection */ ? getApparentTypeOfIntersectionType(t) :
+ t.flags & 402653316 /* TypeFlags.StringLike */ ? globalStringType :
+ t.flags & 296 /* TypeFlags.NumberLike */ ? globalNumberType :
+ t.flags & 2112 /* TypeFlags.BigIntLike */ ? getGlobalBigIntType() :
+ t.flags & 528 /* TypeFlags.BooleanLike */ ? globalBooleanType :
+ t.flags & 12288 /* TypeFlags.ESSymbolLike */ ? getGlobalESSymbolType() :
+ t.flags & 67108864 /* TypeFlags.NonPrimitive */ ? emptyObjectType :
+ t.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType :
+ t.flags & 2 /* TypeFlags.Unknown */ && !strictNullChecks ? emptyObjectType :
t;
}
function getReducedApparentType(type) {
@@ -58020,21 +59113,21 @@ var ts;
var singleProp;
var propSet;
var indexTypes;
- var isUnion = containingType.flags & 1048576 /* Union */;
+ var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */;
// Flags we want to propagate to the result if they exist in all source symbols
- var optionalFlag = isUnion ? 0 /* None */ : 16777216 /* Optional */;
- var syntheticFlag = 4 /* SyntheticMethod */;
- var checkFlags = isUnion ? 0 : 8 /* Readonly */;
+ var optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */;
+ var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */;
+ var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */;
var mergedInstantiations = false;
for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) {
var current = _c[_i];
var type = getApparentType(current);
- if (!(isErrorType(type) || type.flags & 131072 /* Never */)) {
+ if (!(isErrorType(type) || type.flags & 131072 /* TypeFlags.Never */)) {
var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment);
var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
if (prop) {
if (isUnion) {
- optionalFlag |= (prop.flags & 16777216 /* Optional */);
+ optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */);
}
else {
optionalFlag &= prop.flags;
@@ -58047,7 +59140,7 @@ var ts;
// If the symbols are instances of one another with identical types - consider the symbols
// equivalent and just use the first one, which thus allows us to avoid eliding private
// members when intersecting a (this-)instantiations of a class with it's raw base or another instance
- if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* True */ : 0 /* False */; }) === -1 /* True */) {
+ if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* Ternary.True */ : 0 /* Ternary.False */; }) === -1 /* Ternary.True */) {
// If we merged instantiations of a generic type, we replicate the symbol parent resetting behavior we used
// to do when we recorded multiple distinct symbols so that we still get, eg, `Array<T>.length` printed
// back and not `Array<string>.length` when we're looking at a `.length` access on a `string[] | number[]`
@@ -58065,41 +59158,41 @@ var ts;
}
}
if (isUnion && isReadonlySymbol(prop)) {
- checkFlags |= 8 /* Readonly */;
+ checkFlags |= 8 /* CheckFlags.Readonly */;
}
else if (!isUnion && !isReadonlySymbol(prop)) {
- checkFlags &= ~8 /* Readonly */;
+ checkFlags &= ~8 /* CheckFlags.Readonly */;
}
- checkFlags |= (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 256 /* ContainsPublic */ : 0) |
- (modifiers & 16 /* Protected */ ? 512 /* ContainsProtected */ : 0) |
- (modifiers & 8 /* Private */ ? 1024 /* ContainsPrivate */ : 0) |
- (modifiers & 32 /* Static */ ? 2048 /* ContainsStatic */ : 0);
+ checkFlags |= (!(modifiers & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) ? 256 /* CheckFlags.ContainsPublic */ : 0) |
+ (modifiers & 16 /* ModifierFlags.Protected */ ? 512 /* CheckFlags.ContainsProtected */ : 0) |
+ (modifiers & 8 /* ModifierFlags.Private */ ? 1024 /* CheckFlags.ContainsPrivate */ : 0) |
+ (modifiers & 32 /* ModifierFlags.Static */ ? 2048 /* CheckFlags.ContainsStatic */ : 0);
if (!isPrototypeProperty(prop)) {
- syntheticFlag = 2 /* SyntheticProperty */;
+ syntheticFlag = 2 /* CheckFlags.SyntheticProperty */;
}
}
else if (isUnion) {
var indexInfo = !isLateBoundName(name) && getApplicableIndexInfoForName(type, name);
if (indexInfo) {
- checkFlags |= 32 /* WritePartial */ | (indexInfo.isReadonly ? 8 /* Readonly */ : 0);
+ checkFlags |= 32 /* CheckFlags.WritePartial */ | (indexInfo.isReadonly ? 8 /* CheckFlags.Readonly */ : 0);
indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type);
}
- else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 4194304 /* ContainsSpread */)) {
- checkFlags |= 32 /* WritePartial */;
+ else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 2097152 /* ObjectFlags.ContainsSpread */)) {
+ checkFlags |= 32 /* CheckFlags.WritePartial */;
indexTypes = ts.append(indexTypes, undefinedType);
}
else {
- checkFlags |= 16 /* ReadPartial */;
+ checkFlags |= 16 /* CheckFlags.ReadPartial */;
}
}
}
}
- if (!singleProp || isUnion && (propSet || checkFlags & 48 /* Partial */) && checkFlags & (1024 /* ContainsPrivate */ | 512 /* ContainsProtected */)) {
+ if (!singleProp || isUnion && (propSet || checkFlags & 48 /* CheckFlags.Partial */) && checkFlags & (1024 /* CheckFlags.ContainsPrivate */ | 512 /* CheckFlags.ContainsProtected */)) {
// No property was found, or, in a union, a property has a private or protected declaration in one
// constituent, but is missing or has a different declaration in another constituent.
return undefined;
}
- if (!propSet && !(checkFlags & 16 /* ReadPartial */) && !indexTypes) {
+ if (!propSet && !(checkFlags & 16 /* CheckFlags.ReadPartial */) && !indexTypes) {
if (mergedInstantiations) {
// No symbol from a union/intersection should have a `.parent` set (since unions/intersections don't act as symbol parents)
// Unless that parent is "reconstituted" from the "first value declaration" on the symbol (which is likely different than its instantiated parent!)
@@ -58141,18 +59234,18 @@ var ts;
writeTypes = ts.append(!writeTypes ? propTypes.slice() : writeTypes, writeType);
}
else if (type !== firstType) {
- checkFlags |= 64 /* HasNonUniformType */;
+ checkFlags |= 64 /* CheckFlags.HasNonUniformType */;
}
- if (isLiteralType(type) || isPatternLiteralType(type)) {
- checkFlags |= 128 /* HasLiteralType */;
+ if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) {
+ checkFlags |= 128 /* CheckFlags.HasLiteralType */;
}
- if (type.flags & 131072 /* Never */) {
- checkFlags |= 131072 /* HasNeverType */;
+ if (type.flags & 131072 /* TypeFlags.Never */ && type !== uniqueLiteralType) {
+ checkFlags |= 131072 /* CheckFlags.HasNeverType */;
}
propTypes.push(type);
}
ts.addRange(propTypes, indexTypes);
- var result = createSymbol(4 /* Property */ | optionalFlag, name, syntheticFlag | checkFlags);
+ var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags);
result.containingType = containingType;
if (!hasNonUniformValueDeclaration && firstValueDeclaration) {
result.valueDeclaration = firstValueDeclaration;
@@ -58165,7 +59258,7 @@ var ts;
result.nameType = nameType;
if (propTypes.length > 2) {
// When `propTypes` has the potential to explode in size when normalized, defer normalization until absolutely needed
- result.checkFlags |= 65536 /* DeferredType */;
+ result.checkFlags |= 65536 /* CheckFlags.DeferredType */;
result.deferralParent = containingType;
result.deferralConstituents = propTypes;
result.deferralWriteConstituents = writeTypes;
@@ -58199,7 +59292,7 @@ var ts;
function getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment) {
var property = getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
// We need to filter out partial properties in union types
- return property && !(ts.getCheckFlags(property) & 16 /* ReadPartial */) ? property : undefined;
+ return property && !(ts.getCheckFlags(property) & 16 /* CheckFlags.ReadPartial */) ? property : undefined;
}
/**
* Return the reduced form of the given type. For a union type, it is a union of the normalized constituent types.
@@ -58208,15 +59301,15 @@ var ts;
* no constituent property has type 'never', but the intersection of the constituent property types is 'never'.
*/
function getReducedType(type) {
- if (type.flags & 1048576 /* Union */ && type.objectFlags & 33554432 /* ContainsIntersections */) {
+ if (type.flags & 1048576 /* TypeFlags.Union */ && type.objectFlags & 16777216 /* ObjectFlags.ContainsIntersections */) {
return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type));
}
- else if (type.flags & 2097152 /* Intersection */) {
- if (!(type.objectFlags & 33554432 /* IsNeverIntersectionComputed */)) {
- type.objectFlags |= 33554432 /* IsNeverIntersectionComputed */ |
- (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 67108864 /* IsNeverIntersection */ : 0);
+ else if (type.flags & 2097152 /* TypeFlags.Intersection */) {
+ if (!(type.objectFlags & 16777216 /* ObjectFlags.IsNeverIntersectionComputed */)) {
+ type.objectFlags |= 16777216 /* ObjectFlags.IsNeverIntersectionComputed */ |
+ (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* ObjectFlags.IsNeverIntersection */ : 0);
}
- return type.objectFlags & 67108864 /* IsNeverIntersection */ ? neverType : type;
+ return type.objectFlags & 33554432 /* ObjectFlags.IsNeverIntersection */ ? neverType : type;
}
return type;
}
@@ -58226,7 +59319,7 @@ var ts;
return unionType;
}
var reduced = getUnionType(reducedTypes);
- if (reduced.flags & 1048576 /* Union */) {
+ if (reduced.flags & 1048576 /* TypeFlags.Union */) {
reduced.resolvedReducedType = reduced;
}
return reduced;
@@ -58237,23 +59330,23 @@ var ts;
function isDiscriminantWithNeverType(prop) {
// Return true for a synthetic non-optional property with non-uniform types, where at least one is
// a literal type and none is never, that reduces to never.
- return !(prop.flags & 16777216 /* Optional */) &&
- (ts.getCheckFlags(prop) & (192 /* Discriminant */ | 131072 /* HasNeverType */)) === 192 /* Discriminant */ &&
- !!(getTypeOfSymbol(prop).flags & 131072 /* Never */);
+ return !(prop.flags & 16777216 /* SymbolFlags.Optional */) &&
+ (ts.getCheckFlags(prop) & (192 /* CheckFlags.Discriminant */ | 131072 /* CheckFlags.HasNeverType */)) === 192 /* CheckFlags.Discriminant */ &&
+ !!(getTypeOfSymbol(prop).flags & 131072 /* TypeFlags.Never */);
}
function isConflictingPrivateProperty(prop) {
// Return true for a synthetic property with multiple declarations, at least one of which is private.
- return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */);
+ return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* CheckFlags.ContainsPrivate */);
}
function elaborateNeverIntersection(errorInfo, type) {
- if (type.flags & 2097152 /* Intersection */ && ts.getObjectFlags(type) & 67108864 /* IsNeverIntersection */) {
+ if (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IsNeverIntersection */) {
var neverProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isDiscriminantWithNeverType);
if (neverProp) {
- return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(neverProp));
+ return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(neverProp));
}
var privateProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isConflictingPrivateProperty);
if (privateProp) {
- return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(privateProp));
+ return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(privateProp));
}
}
return errorInfo;
@@ -58268,7 +59361,7 @@ var ts;
*/
function getPropertyOfType(type, name, skipObjectFunctionPropertyAugment) {
type = getReducedApparentType(type);
- if (type.flags & 524288 /* Object */) {
+ if (type.flags & 524288 /* TypeFlags.Object */) {
var resolved = resolveStructuredTypeMembers(type);
var symbol = resolved.members.get(name);
if (symbol && symbolIsValue(symbol)) {
@@ -58288,15 +59381,15 @@ var ts;
}
return getPropertyOfObjectType(globalObjectType, name);
}
- if (type.flags & 3145728 /* UnionOrIntersection */) {
+ if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) {
return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment);
}
return undefined;
}
function getSignaturesOfStructuredType(type, kind) {
- if (type.flags & 3670016 /* StructuredType */) {
+ if (type.flags & 3670016 /* TypeFlags.StructuredType */) {
var resolved = resolveStructuredTypeMembers(type);
- return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures;
+ return kind === 0 /* SignatureKind.Call */ ? resolved.callSignatures : resolved.constructSignatures;
}
return ts.emptyArray;
}
@@ -58315,8 +59408,8 @@ var ts;
var stringIndexInfo;
var applicableInfo;
var applicableInfos;
- for (var _i = 0, indexInfos_1 = indexInfos; _i < indexInfos_1.length; _i++) {
- var info = indexInfos_1[_i];
+ for (var _i = 0, indexInfos_3 = indexInfos; _i < indexInfos_3.length; _i++) {
+ var info = indexInfos_3[_i];
if (info.keyType === stringType) {
stringIndexInfo = info;
}
@@ -58339,13 +59432,13 @@ var ts;
}
function isApplicableIndexType(source, target) {
// A 'string' index signature applies to types assignable to 'string' or 'number', and a 'number' index
- // signature applies to types assignable to 'number' and numeric string literal types.
+ // signature applies to types assignable to 'number', `${number}` and numeric string literal types.
return isTypeAssignableTo(source, target) ||
target === stringType && isTypeAssignableTo(source, numberType) ||
- target === numberType && !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value);
+ target === numberType && (source === numericStringType || !!(source.flags & 128 /* TypeFlags.StringLiteral */) && ts.isNumericLiteralName(source.value));
}
function getIndexInfosOfStructuredType(type) {
- if (type.flags & 3670016 /* StructuredType */) {
+ if (type.flags & 3670016 /* TypeFlags.StructuredType */) {
var resolved = resolveStructuredTypeMembers(type);
return resolved.indexInfos;
}
@@ -58396,17 +59489,17 @@ var ts;
function isJSDocOptionalParameter(node) {
return ts.isInJSFile(node) && (
// node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType
- node.type && node.type.kind === 314 /* JSDocOptionalType */
+ node.type && node.type.kind === 316 /* SyntaxKind.JSDocOptionalType */
|| ts.getJSDocParameterTags(node).some(function (_a) {
var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression;
- return isBracketed || !!typeExpression && typeExpression.type.kind === 314 /* JSDocOptionalType */;
+ return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */;
}));
}
function tryFindAmbientModule(moduleName, withAugmentations) {
if (ts.isExternalModuleNameRelative(moduleName)) {
return undefined;
}
- var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */);
+ var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* SymbolFlags.ValueModule */);
// merged symbol is module declaration symbol combined with all augmentations
return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol;
}
@@ -58421,7 +59514,7 @@ var ts;
// Only consider syntactic or instantiated parameters as optional, not `void` parameters as this function is used
// in grammar checks and checking for `void` too early results in parameter types widening too early
// and causes some noImplicitAny errors to be lost.
- return parameterIndex >= getMinArgumentCount(signature, 1 /* StrongArityForUntypedJS */ | 2 /* VoidIsNonOptional */);
+ return parameterIndex >= getMinArgumentCount(signature, 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */ | 2 /* MinArgumentCountFlags.VoidIsNonOptional */);
}
var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent);
if (iife) {
@@ -58439,7 +59532,7 @@ var ts;
return false;
}
var isBracketed = node.isBracketed, typeExpression = node.typeExpression;
- return isBracketed || !!typeExpression && typeExpression.type.kind === 314 /* JSDocOptionalType */;
+ return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */;
}
function createTypePredicate(kind, parameterName, parameterIndex, type) {
return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type };
@@ -58488,7 +59581,7 @@ var ts;
var links = getNodeLinks(declaration);
if (!links.resolvedSignature) {
var parameters = [];
- var flags = 0 /* None */;
+ var flags = 0 /* SignatureFlags.None */;
var minArgumentCount = 0;
var thisParameter = void 0;
var hasThisParameter = false;
@@ -58500,7 +59593,7 @@ var ts;
!ts.hasJSDocParameterTags(declaration) &&
!ts.getJSDocType(declaration);
if (isUntypedSignatureInJSFile) {
- flags |= 32 /* IsUntypedSignatureInJSFile */;
+ flags |= 32 /* SignatureFlags.IsUntypedSignatureInJSFile */;
}
// If this is a JSDoc construct signature, then skip the first parameter in the
// parameter list. The first parameter represents the return type of the construct
@@ -58510,19 +59603,19 @@ var ts;
var paramSymbol = param.symbol;
var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type;
// Include parameter symbol instead of property symbol in the signature
- if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) {
- var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* Value */, undefined, undefined, /*isUse*/ false);
+ if (paramSymbol && !!(paramSymbol.flags & 4 /* SymbolFlags.Property */) && !ts.isBindingPattern(param.name)) {
+ var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ false);
paramSymbol = resolvedSymbol;
}
- if (i === 0 && paramSymbol.escapedName === "this" /* This */) {
+ if (i === 0 && paramSymbol.escapedName === "this" /* InternalSymbolName.This */) {
hasThisParameter = true;
thisParameter = param.symbol;
}
else {
parameters.push(paramSymbol);
}
- if (type && type.kind === 195 /* LiteralType */) {
- flags |= 2 /* HasLiteralTypes */;
+ if (type && type.kind === 196 /* SyntaxKind.LiteralType */) {
+ flags |= 2 /* SignatureFlags.HasLiteralTypes */;
}
// Record a new minimum argument count if this is not an optional parameter
var isOptionalParameter_1 = isOptionalJSDocPropertyLikeTag(param) ||
@@ -58534,25 +59627,25 @@ var ts;
}
}
// If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation
- if ((declaration.kind === 171 /* GetAccessor */ || declaration.kind === 172 /* SetAccessor */) &&
+ if ((declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) &&
hasBindableName(declaration) &&
(!hasThisParameter || !thisParameter)) {
- var otherKind = declaration.kind === 171 /* GetAccessor */ ? 172 /* SetAccessor */ : 171 /* GetAccessor */;
+ var otherKind = declaration.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */;
var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind);
if (other) {
thisParameter = getAnnotatedAccessorThisParameter(other);
}
}
- var classType = declaration.kind === 170 /* Constructor */ ?
+ var classType = declaration.kind === 171 /* SyntaxKind.Constructor */ ?
getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol))
: undefined;
var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration);
if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) {
- flags |= 1 /* HasRestParameter */;
+ flags |= 1 /* SignatureFlags.HasRestParameter */;
}
- if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* Abstract */) ||
- ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* Abstract */)) {
- flags |= 4 /* Abstract */;
+ if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */) ||
+ ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* ModifierFlags.Abstract */)) {
+ flags |= 4 /* SignatureFlags.Abstract */;
}
links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters,
/*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgumentCount, flags);
@@ -58574,8 +59667,20 @@ var ts;
var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) {
return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined;
});
- var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 32768 /* RestParameter */);
- syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType;
+ var syntheticArgsSymbol = createSymbol(3 /* SymbolFlags.Variable */, "args", 32768 /* CheckFlags.RestParameter */);
+ if (lastParamVariadicType) {
+ // Parameter has effective annotation, lock in type
+ syntheticArgsSymbol.type = createArrayType(getTypeFromTypeNode(lastParamVariadicType.type));
+ }
+ else {
+ // Parameter has no annotation
+ // By using a `DeferredType` symbol, we allow the type of this rest arg to be overriden by contextual type assignment so long as its type hasn't been
+ // cached by `getTypeOfSymbol` yet.
+ syntheticArgsSymbol.checkFlags |= 65536 /* CheckFlags.DeferredType */;
+ syntheticArgsSymbol.deferralParent = neverType;
+ syntheticArgsSymbol.deferralConstituents = [anyArrayType];
+ syntheticArgsSymbol.deferralWriteConstituents = [anyArrayType];
+ }
if (lastParamVariadicType) {
// Replace the last parameter with a rest parameter.
parameters.pop();
@@ -58604,7 +59709,7 @@ var ts;
function containsArgumentsReference(declaration) {
var links = getNodeLinks(declaration);
if (links.containsArgumentsReference === undefined) {
- if (links.flags & 8192 /* CaptureArguments */) {
+ if (links.flags & 8192 /* NodeCheckFlags.CaptureArguments */) {
links.containsArgumentsReference = true;
}
else {
@@ -58616,18 +59721,18 @@ var ts;
if (!node)
return false;
switch (node.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return node.escapedText === argumentsSymbol.escapedName && getReferencedValueSymbol(node) === argumentsSymbol;
- case 166 /* PropertyDeclaration */:
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- return node.name.kind === 161 /* ComputedPropertyName */
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ return node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */
&& traverse(node.name);
- case 205 /* PropertyAccessExpression */:
- case 206 /* ElementAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
return traverse(node.expression);
- case 294 /* PropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
return traverse(node.initializer);
default:
return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse);
@@ -58699,26 +59804,26 @@ var ts;
function createTypePredicateFromTypePredicateNode(node, signature) {
var parameterName = node.parameterName;
var type = node.type && getTypeFromTypeNode(node.type);
- return parameterName.kind === 191 /* ThisType */ ?
- createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) :
- createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type);
+ return parameterName.kind === 192 /* SyntaxKind.ThisType */ ?
+ createTypePredicate(node.assertsModifier ? 2 /* TypePredicateKind.AssertsThis */ : 0 /* TypePredicateKind.This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) :
+ createTypePredicate(node.assertsModifier ? 3 /* TypePredicateKind.AssertsIdentifier */ : 1 /* TypePredicateKind.Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type);
}
function getUnionOrIntersectionType(types, kind, unionReduction) {
- return kind !== 2097152 /* Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types);
+ return kind !== 2097152 /* TypeFlags.Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types);
}
function getReturnTypeOfSignature(signature) {
if (!signature.resolvedReturnType) {
- if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) {
+ if (!pushTypeResolution(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */)) {
return errorType;
}
var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) :
- signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* Subtype */), signature.mapper) :
+ signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* UnionReduction.Subtype */), signature.mapper) :
getReturnTypeFromAnnotation(signature.declaration) ||
(ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration));
- if (signature.flags & 8 /* IsInnerCallChain */) {
+ if (signature.flags & 8 /* SignatureFlags.IsInnerCallChain */) {
type = addOptionalTypeMarker(type);
}
- else if (signature.flags & 16 /* IsOuterCallChain */) {
+ else if (signature.flags & 16 /* SignatureFlags.IsOuterCallChain */) {
type = getOptionalType(type);
}
if (!popTypeResolution()) {
@@ -58745,7 +59850,7 @@ var ts;
return signature.resolvedReturnType;
}
function getReturnTypeFromAnnotation(declaration) {
- if (declaration.kind === 170 /* Constructor */) {
+ if (declaration.kind === 171 /* SyntaxKind.Constructor */) {
return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol));
}
if (ts.isJSDocConstructSignature(declaration)) {
@@ -58755,12 +59860,12 @@ var ts;
if (typeNode) {
return getTypeFromTypeNode(typeNode);
}
- if (declaration.kind === 171 /* GetAccessor */ && hasBindableName(declaration)) {
+ if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ && hasBindableName(declaration)) {
var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration);
if (jsDocType) {
return jsDocType;
}
- var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 172 /* SetAccessor */);
+ var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 173 /* SyntaxKind.SetAccessor */);
var setterType = getAnnotatedAccessorType(setter);
if (setterType) {
return setterType;
@@ -58769,7 +59874,7 @@ var ts;
return getReturnTypeOfTypeTag(declaration);
}
function isResolvingReturnTypeOfSignature(signature) {
- return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0;
+ return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */) >= 0;
}
function getRestTypeOfSignature(signature) {
return tryGetRestTypeOfSignature(signature) || anyType;
@@ -58855,14 +59960,16 @@ var ts;
return signature;
}
function getOrCreateTypeFromSignature(signature) {
+ var _a;
// There are two ways to declare a construct signature, one is by declaring a class constructor
// using the constructor keyword, and the other is declaring a bare construct signature in an
// object type literal or interface (using the new keyword). Each way of declaring a constructor
// will result in a different declaration kind.
if (!signature.isolatedSignatureType) {
- var kind = signature.declaration ? signature.declaration.kind : 0 /* Unknown */;
- var isConstructor = kind === 170 /* Constructor */ || kind === 174 /* ConstructSignature */ || kind === 179 /* ConstructorType */;
- var type = createObjectType(16 /* Anonymous */);
+ var kind = (_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind;
+ // If declaration is undefined, it is likely to be the signature of the default constructor.
+ var isConstructor = kind === undefined || kind === 171 /* SyntaxKind.Constructor */ || kind === 175 /* SyntaxKind.ConstructSignature */ || kind === 180 /* SyntaxKind.ConstructorType */;
+ var type = createObjectType(16 /* ObjectFlags.Anonymous */);
type.members = emptySymbols;
type.properties = ts.emptyArray;
type.callSignatures = !isConstructor ? [signature] : ts.emptyArray;
@@ -58876,7 +59983,7 @@ var ts;
return symbol.members ? getIndexSymbolFromSymbolTable(symbol.members) : undefined;
}
function getIndexSymbolFromSymbolTable(symbolTable) {
- return symbolTable.get("__index" /* Index */);
+ return symbolTable.get("__index" /* InternalSymbolName.Index */);
}
function createIndexInfo(keyType, type, isReadonly, declaration) {
return { keyType: keyType, type: type, isReadonly: isReadonly, declaration: declaration };
@@ -58887,14 +59994,14 @@ var ts;
}
function getIndexInfosOfIndexSymbol(indexSymbol) {
if (indexSymbol.declarations) {
- var indexInfos_2 = [];
+ var indexInfos_4 = [];
var _loop_14 = function (declaration) {
if (declaration.parameters.length === 1) {
var parameter = declaration.parameters[0];
if (parameter.type) {
forEachType(getTypeFromTypeNode(parameter.type), function (keyType) {
- if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos_2, keyType)) {
- indexInfos_2.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration));
+ if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos_4, keyType)) {
+ indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* ModifierFlags.Readonly */), declaration));
}
});
}
@@ -58904,30 +60011,30 @@ var ts;
var declaration = _a[_i];
_loop_14(declaration);
}
- return indexInfos_2;
+ return indexInfos_4;
}
return ts.emptyArray;
}
function isValidIndexKeyType(type) {
- return !!(type.flags & (4 /* String */ | 8 /* Number */ | 4096 /* ESSymbol */)) || isPatternLiteralType(type) ||
- !!(type.flags & 2097152 /* Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType);
+ return !!(type.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 4096 /* TypeFlags.ESSymbol */)) || isPatternLiteralType(type) ||
+ !!(type.flags & 2097152 /* TypeFlags.Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType);
}
function getConstraintDeclaration(type) {
return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0];
}
- function getInferredTypeParameterConstraint(typeParameter) {
+ function getInferredTypeParameterConstraint(typeParameter, omitTypeReferences) {
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];
- if (declaration.parent.kind === 189 /* InferType */) {
+ if (declaration.parent.kind === 190 /* SyntaxKind.InferType */) {
// When an 'infer T' declaration is immediately contained in a type reference node
// (such as 'Foo<infer T>'), T's constraint is inferred from the constraint of the
// corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are
// present, we form an intersection of the inferred constraint types.
var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1];
- if (grandParent.kind === 177 /* TypeReference */) {
+ if (grandParent.kind === 178 /* SyntaxKind.TypeReference */ && !omitTypeReferences) {
var typeReference = grandParent;
var typeParameters = getTypeParametersForTypeReference(typeReference);
if (typeParameters) {
@@ -58952,27 +60059,27 @@ var ts;
}
// When an 'infer T' declaration is immediately contained in a rest parameter declaration, a rest type
// or a named rest tuple element, we infer an 'unknown[]' constraint.
- else if (grandParent.kind === 163 /* Parameter */ && grandParent.dotDotDotToken ||
- grandParent.kind === 185 /* RestType */ ||
- grandParent.kind === 196 /* NamedTupleMember */ && grandParent.dotDotDotToken) {
+ else if (grandParent.kind === 164 /* SyntaxKind.Parameter */ && grandParent.dotDotDotToken ||
+ grandParent.kind === 186 /* SyntaxKind.RestType */ ||
+ grandParent.kind === 197 /* SyntaxKind.NamedTupleMember */ && grandParent.dotDotDotToken) {
inferences = ts.append(inferences, createArrayType(unknownType));
}
// When an 'infer T' declaration is immediately contained in a string template type, we infer a 'string'
// constraint.
- else if (grandParent.kind === 198 /* TemplateLiteralTypeSpan */) {
+ else if (grandParent.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */) {
inferences = ts.append(inferences, stringType);
}
// When an 'infer T' declaration is in the constraint position of a mapped type, we infer a 'keyof any'
// constraint.
- else if (grandParent.kind === 162 /* TypeParameter */ && grandParent.parent.kind === 194 /* MappedType */) {
+ else if (grandParent.kind === 163 /* SyntaxKind.TypeParameter */ && grandParent.parent.kind === 195 /* SyntaxKind.MappedType */) {
inferences = ts.append(inferences, keyofConstraintType);
}
// When an 'infer T' declaration is the template of a mapped type, and that mapped type is the extends
// clause of a conditional whose check type is also a mapped type, give it a constraint equal to the template
// of the check type's mapped type
- else if (grandParent.kind === 194 /* MappedType */ && grandParent.type &&
- ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 188 /* ConditionalType */ &&
- grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 194 /* MappedType */ &&
+ else if (grandParent.kind === 195 /* SyntaxKind.MappedType */ && grandParent.type &&
+ ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 189 /* SyntaxKind.ConditionalType */ &&
+ grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 195 /* SyntaxKind.MappedType */ &&
grandParent.parent.checkType.type) {
var checkMappedType_1 = grandParent.parent.checkType;
var nodeType = getTypeFromTypeNode(checkMappedType_1.type);
@@ -58997,10 +60104,10 @@ var ts;
}
else {
var type = getTypeFromTypeNode(constraintDeclaration);
- if (type.flags & 1 /* Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed
+ if (type.flags & 1 /* TypeFlags.Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed
// use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was),
// use unknown otherwise
- type = constraintDeclaration.parent.parent.kind === 194 /* MappedType */ ? keyofConstraintType : unknownType;
+ type = constraintDeclaration.parent.parent.kind === 195 /* SyntaxKind.MappedType */ ? keyofConstraintType : unknownType;
}
typeParameter.constraint = type;
}
@@ -59009,7 +60116,7 @@ var ts;
return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint;
}
function getParentSymbolOfTypeParameter(typeParameter) {
- var tp = ts.getDeclarationOfKind(typeParameter.symbol, 162 /* TypeParameter */);
+ var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* SyntaxKind.TypeParameter */);
var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getEffectiveContainerForJSDocTemplateTag(tp.parent) : tp.parent;
return host && getSymbolOfNode(host);
}
@@ -59051,13 +60158,13 @@ var ts;
result |= ts.getObjectFlags(type);
}
}
- return result & 917504 /* PropagatingFlags */;
+ return result & 458752 /* ObjectFlags.PropagatingFlags */;
}
function createTypeReference(target, typeArguments) {
var id = getTypeListId(typeArguments);
var type = target.instantiations.get(id);
if (!type) {
- type = createObjectType(4 /* Reference */, target.symbol);
+ type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol);
target.instantiations.set(id, type);
type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0;
type.target = target;
@@ -59079,7 +60186,7 @@ var ts;
var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
aliasTypeArguments = mapper ? instantiateTypes(localAliasTypeArguments, mapper) : localAliasTypeArguments;
}
- var type = createObjectType(4 /* Reference */, target.symbol);
+ var type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol);
type.target = target;
type.node = node;
type.mapper = mapper;
@@ -59090,13 +60197,13 @@ var ts;
function getTypeArguments(type) {
var _a, _b;
if (!type.resolvedTypeArguments) {
- if (!pushTypeResolution(type, 6 /* ResolvedTypeArguments */)) {
+ if (!pushTypeResolution(type, 6 /* TypeSystemPropertyName.ResolvedTypeArguments */)) {
return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray;
}
var node = type.node;
var typeArguments = !node ? ts.emptyArray :
- node.kind === 177 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) :
- node.kind === 182 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] :
+ node.kind === 178 /* SyntaxKind.TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) :
+ node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] :
ts.map(node.elements, getTypeFromTypeNode);
if (popTypeResolution()) {
type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments;
@@ -59131,14 +60238,14 @@ var ts;
missingAugmentsTag ?
ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag :
ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments;
- var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */);
+ var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */);
error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length);
if (!isJs) {
// TODO: Adopt same permissive behavior in TS as in JS to reduce follow-on editing experience failures (requires editing fillMissingTypeArguments)
return errorType;
}
}
- if (node.kind === 177 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) {
+ if (node.kind === 178 /* SyntaxKind.TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) {
return createDeferredTypeReference(type, node, /*mapper*/ undefined);
}
// In a type reference, the outer type parameters of the referenced class or interface are automatically
@@ -59169,12 +60276,12 @@ var ts;
* declared type. Instantiations are cached using the type identities of the type arguments as the key.
*/
function getTypeFromTypeAliasReference(node, symbol) {
- if (ts.getCheckFlags(symbol) & 1048576 /* Unresolved */) {
+ if (ts.getCheckFlags(symbol) & 1048576 /* CheckFlags.Unresolved */) {
var typeArguments = typeArgumentsFromTypeReferenceNode(node);
var id = getAliasId(symbol, typeArguments);
var errorType_1 = errorTypes.get(id);
if (!errorType_1) {
- errorType_1 = createIntrinsicType(1 /* Any */, "error");
+ errorType_1 = createIntrinsicType(1 /* TypeFlags.Any */, "error");
errorType_1.aliasSymbol = symbol;
errorType_1.aliasTypeArguments = typeArguments;
errorTypes.set(id, errorType_1);
@@ -59209,9 +60316,9 @@ var ts;
}
function getTypeReferenceName(node) {
switch (node.kind) {
- case 177 /* TypeReference */:
+ case 178 /* SyntaxKind.TypeReference */:
return node.typeName;
- case 227 /* ExpressionWithTypeArguments */:
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
// We only support expressions that are simple qualified names. For other
// expressions this produces undefined.
var expr = node.expression;
@@ -59226,18 +60333,18 @@ var ts;
return symbol.parent ? "".concat(getSymbolPath(symbol.parent), ".").concat(symbol.escapedName) : symbol.escapedName;
}
function getUnresolvedSymbolForEntityName(name) {
- var identifier = name.kind === 160 /* QualifiedName */ ? name.right :
- name.kind === 205 /* PropertyAccessExpression */ ? name.name :
+ var identifier = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right :
+ name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? name.name :
name;
var text = identifier.escapedText;
if (text) {
- var parentSymbol = name.kind === 160 /* QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) :
- name.kind === 205 /* PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) :
+ var parentSymbol = name.kind === 161 /* SyntaxKind.QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) :
+ name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) :
undefined;
var path = parentSymbol ? "".concat(getSymbolPath(parentSymbol), ".").concat(text) : text;
var result = unresolvedSymbols.get(path);
if (!result) {
- unresolvedSymbols.set(path, result = createSymbol(524288 /* TypeAlias */, text, 1048576 /* Unresolved */));
+ unresolvedSymbols.set(path, result = createSymbol(524288 /* SymbolFlags.TypeAlias */, text, 1048576 /* CheckFlags.Unresolved */));
result.parent = parentSymbol;
result.declaredType = unresolvedType;
}
@@ -59259,10 +60366,10 @@ var ts;
return errorType;
}
symbol = getExpandoSymbol(symbol) || symbol;
- if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) {
+ if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) {
return getTypeFromClassOrInterfaceReference(node, symbol);
}
- if (symbol.flags & 524288 /* TypeAlias */) {
+ if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) {
return getTypeFromTypeAliasReference(node, symbol);
}
// Get type from reference to named type that cannot be generic (enum or type parameter)
@@ -59270,14 +60377,14 @@ var ts;
if (res) {
return checkNoTypeArguments(node, symbol) ? getRegularTypeOfLiteralType(res) : errorType;
}
- if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) {
+ if (symbol.flags & 111551 /* SymbolFlags.Value */ && isJSDocTypeReference(node)) {
var jsdocType = getTypeFromJSDocValueReference(node, symbol);
if (jsdocType) {
return jsdocType;
}
else {
// Resolve the type reference as a Type for the purpose of reporting errors.
- resolveTypeReferenceName(node, 788968 /* Type */);
+ resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */);
return getTypeOfSymbol(symbol);
}
}
@@ -59293,7 +60400,7 @@ var ts;
var valueType = getTypeOfSymbol(symbol);
var typeType = valueType;
if (symbol.valueDeclaration) {
- var isImportTypeWithQualifier = node.kind === 199 /* ImportType */ && node.qualifier;
+ var isImportTypeWithQualifier = node.kind === 200 /* SyntaxKind.ImportType */ && node.qualifier;
// valueType might not have a symbol, eg, {import('./b').STRING_LITERAL}
if (valueType.symbol && valueType.symbol !== symbol && isImportTypeWithQualifier) {
typeType = getTypeReferenceType(node, valueType.symbol);
@@ -59304,7 +60411,7 @@ var ts;
return links.resolvedJSDocType;
}
function getSubstitutionType(baseType, substitute) {
- if (substitute.flags & 3 /* AnyOrUnknown */ || substitute === baseType) {
+ if (substitute.flags & 3 /* TypeFlags.AnyOrUnknown */ || substitute === baseType) {
return baseType;
}
var id = "".concat(getTypeId(baseType), ">").concat(getTypeId(substitute));
@@ -59312,14 +60419,14 @@ var ts;
if (cached) {
return cached;
}
- var result = createType(33554432 /* Substitution */);
+ var result = createType(33554432 /* TypeFlags.Substitution */);
result.baseType = baseType;
result.substitute = substitute;
substitutionTypes.set(id, result);
return result;
}
function isUnaryTupleTypeNode(node) {
- return node.kind === 183 /* TupleType */ && node.elements.length === 1;
+ return node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 1;
}
function getImpliedConstraint(type, checkNode, extendsNode) {
return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) :
@@ -59329,27 +60436,41 @@ var ts;
function getConditionalFlowTypeOfType(type, node) {
var constraints;
var covariant = true;
- while (node && !ts.isStatement(node) && node.kind !== 318 /* JSDocComment */) {
+ while (node && !ts.isStatement(node) && node.kind !== 320 /* SyntaxKind.JSDoc */) {
var parent = node.parent;
// only consider variance flipped by parameter locations - `keyof` types would usually be considered variance inverting, but
// often get used in indexed accesses where they behave sortof invariantly, but our checking is lax
- if (parent.kind === 163 /* Parameter */) {
+ if (parent.kind === 164 /* SyntaxKind.Parameter */) {
covariant = !covariant;
}
// Always substitute on type parameters, regardless of variance, since even
// in contravariant positions, they may rely on substituted constraints to be valid
- if ((covariant || type.flags & 8650752 /* TypeVariable */) && parent.kind === 188 /* ConditionalType */ && node === parent.trueType) {
+ if ((covariant || type.flags & 8650752 /* TypeFlags.TypeVariable */) && parent.kind === 189 /* SyntaxKind.ConditionalType */ && node === parent.trueType) {
var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType);
if (constraint) {
constraints = ts.append(constraints, constraint);
}
}
+ // Given a homomorphic mapped type { [K in keyof T]: XXX }, where T is constrained to an array or tuple type, in the
+ // template type XXX, K has an added constraint of number | `${number}`.
+ else if (type.flags & 262144 /* TypeFlags.TypeParameter */ && parent.kind === 195 /* SyntaxKind.MappedType */ && node === parent.type) {
+ var mappedType = getTypeFromTypeNode(parent);
+ if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) {
+ var typeParameter = getHomomorphicTypeVariable(mappedType);
+ if (typeParameter) {
+ var constraint = getConstraintOfTypeParameter(typeParameter);
+ if (constraint && everyType(constraint, isArrayOrTupleType)) {
+ constraints = ts.append(constraints, getUnionType([numberType, numericStringType]));
+ }
+ }
+ }
+ }
node = parent;
}
return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
}
function isJSDocTypeReference(node) {
- return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 177 /* TypeReference */ || node.kind === 199 /* ImportType */);
+ return !!(node.flags & 8388608 /* NodeFlags.JSDoc */) && (node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 200 /* SyntaxKind.ImportType */);
}
function checkNoTypeArguments(node, symbol) {
if (node.typeArguments) {
@@ -59405,7 +60526,7 @@ var ts;
}
function getTypeFromJSDocNullableTypeNode(node) {
var type = getTypeFromTypeNode(node.type);
- return strictNullChecks ? getNullableType(type, 65536 /* Null */) : type;
+ return strictNullChecks ? getNullableType(type, 65536 /* TypeFlags.Null */) : type;
}
function getTypeFromTypeReference(node) {
var links = getNodeLinks(node);
@@ -59417,13 +60538,13 @@ var ts;
}
var symbol = void 0;
var type = void 0;
- var meaning = 788968 /* Type */;
+ var meaning = 788968 /* SymbolFlags.Type */;
if (isJSDocTypeReference(node)) {
type = getIntendedTypeFromJSDocTypeReference(node);
if (!type) {
symbol = resolveTypeReferenceName(node, meaning, /*ignoreErrors*/ true);
if (symbol === unknownSymbol) {
- symbol = resolveTypeReferenceName(node, meaning | 111551 /* Value */);
+ symbol = resolveTypeReferenceName(node, meaning | 111551 /* SymbolFlags.Value */);
}
else {
resolveTypeReferenceName(node, meaning); // Resolve again to mark errors, if any
@@ -59452,7 +60573,7 @@ var ts;
// The expression is processed as an identifier expression (section 4.3)
// or property access expression(section 4.10),
// the widened type(section 3.9) of which becomes the result.
- var type = ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName);
+ var type = checkExpressionWithTypeArguments(node);
links.resolvedType = getRegularTypeOfLiteralType(getWidenedType(type));
}
return links.resolvedType;
@@ -59464,9 +60585,9 @@ var ts;
for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) {
var declaration = declarations_3[_i];
switch (declaration.kind) {
- case 256 /* ClassDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 259 /* EnumDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
return declaration;
}
}
@@ -59476,7 +60597,7 @@ var ts;
return arity ? emptyGenericType : emptyObjectType;
}
var type = getDeclaredTypeOfSymbol(symbol);
- if (!(type.flags & 524288 /* Object */)) {
+ if (!(type.flags & 524288 /* TypeFlags.Object */)) {
error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol));
return arity ? emptyGenericType : emptyObjectType;
}
@@ -59487,13 +60608,13 @@ var ts;
return type;
}
function getGlobalValueSymbol(name, reportErrors) {
- return getGlobalSymbol(name, 111551 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined);
+ return getGlobalSymbol(name, 111551 /* SymbolFlags.Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined);
}
function getGlobalTypeSymbol(name, reportErrors) {
- return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined);
+ return getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined);
}
function getGlobalTypeAliasSymbol(name, arity, reportErrors) {
- var symbol = getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined);
+ var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined);
if (symbol) {
// Resolve the declared type of the symbol. This resolves type parameters for the type
// alias so that we can check arity.
@@ -59529,9 +60650,9 @@ var ts;
function getGlobalImportMetaExpressionType() {
if (!deferredGlobalImportMetaExpressionType) {
// Create a synthetic type `ImportMetaExpression { meta: MetaProperty }`
- var symbol = createSymbol(0 /* None */, "ImportMetaExpression");
+ var symbol = createSymbol(0 /* SymbolFlags.None */, "ImportMetaExpression");
var importMetaType = getGlobalImportMetaType();
- var metaPropertySymbol = createSymbol(4 /* Property */, "meta", 8 /* Readonly */);
+ var metaPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "meta", 8 /* CheckFlags.Readonly */);
metaPropertySymbol.parent = symbol;
metaPropertySymbol.type = importMetaType;
var members = ts.createSymbolTable([metaPropertySymbol]);
@@ -59549,8 +60670,8 @@ var ts;
function getGlobalESSymbolConstructorTypeSymbol(reportErrors) {
return deferredGlobalESSymbolConstructorTypeSymbol || (deferredGlobalESSymbolConstructorTypeSymbol = getGlobalTypeSymbol("SymbolConstructor", reportErrors));
}
- function getGlobalESSymbolType(reportErrors) {
- return (deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, reportErrors))) || emptyObjectType;
+ function getGlobalESSymbolType() {
+ return (deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, /*reportErrors*/ false))) || emptyObjectType;
}
function getGlobalPromiseType(reportErrors) {
return (deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", /*arity*/ 1, reportErrors))) || emptyGenericType;
@@ -59596,7 +60717,7 @@ var ts;
}
function getGlobalTypeOrUndefined(name, arity) {
if (arity === void 0) { arity = 0; }
- var symbol = getGlobalSymbol(name, 788968 /* Type */, /*diagnostic*/ undefined);
+ var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, /*diagnostic*/ undefined);
return symbol && getTypeOfGlobalSymbol(symbol, arity);
}
function getGlobalExtractSymbol() {
@@ -59614,8 +60735,8 @@ var ts;
deferredGlobalAwaitedSymbol || (deferredGlobalAwaitedSymbol = getGlobalTypeAliasSymbol("Awaited", /*arity*/ 1, reportErrors) || (reportErrors ? unknownSymbol : undefined));
return deferredGlobalAwaitedSymbol === unknownSymbol ? undefined : deferredGlobalAwaitedSymbol;
}
- function getGlobalBigIntType(reportErrors) {
- return (deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, reportErrors))) || emptyObjectType;
+ function getGlobalBigIntType() {
+ return (deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, /*reportErrors*/ false))) || emptyObjectType;
}
/**
* Instantiates a global type that is generic with some element type, and returns that instantiation.
@@ -59634,20 +60755,20 @@ var ts;
}
function getTupleElementFlags(node) {
switch (node.kind) {
- case 184 /* OptionalType */:
- return 2 /* Optional */;
- case 185 /* RestType */:
+ case 185 /* SyntaxKind.OptionalType */:
+ return 2 /* ElementFlags.Optional */;
+ case 186 /* SyntaxKind.RestType */:
return getRestTypeElementFlags(node);
- case 196 /* NamedTupleMember */:
- return node.questionToken ? 2 /* Optional */ :
+ case 197 /* SyntaxKind.NamedTupleMember */:
+ return node.questionToken ? 2 /* ElementFlags.Optional */ :
node.dotDotDotToken ? getRestTypeElementFlags(node) :
- 1 /* Required */;
+ 1 /* ElementFlags.Required */;
default:
- return 1 /* Required */;
+ return 1 /* ElementFlags.Required */;
}
}
function getRestTypeElementFlags(node) {
- return getArrayElementTypeNode(node.type) ? 4 /* Rest */ : 8 /* Variadic */;
+ return getArrayElementTypeNode(node.type) ? 4 /* ElementFlags.Rest */ : 8 /* ElementFlags.Variadic */;
}
function getArrayOrTupleTargetType(node) {
var readonly = isReadonlyTypeOperator(node.parent);
@@ -59656,14 +60777,14 @@ var ts;
return readonly ? globalReadonlyArrayType : globalArrayType;
}
var elementFlags = ts.map(node.elements, getTupleElementFlags);
- var missingName = ts.some(node.elements, function (e) { return e.kind !== 196 /* NamedTupleMember */; });
+ var missingName = ts.some(node.elements, function (e) { return e.kind !== 197 /* SyntaxKind.NamedTupleMember */; });
return getTupleTargetType(elementFlags, readonly, /*associatedNames*/ missingName ? undefined : node.elements);
}
// Return true if the given type reference node is directly aliased or if it needs to be deferred
// because it is possibly contained in a circular chain of eagerly resolved types.
function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) {
- return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 182 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) :
- node.kind === 183 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) :
+ return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 183 /* SyntaxKind.ArrayType */ ? mayResolveTypeAlias(node.elementType) :
+ node.kind === 184 /* SyntaxKind.TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) :
hasDefaultTypeArguments || ts.some(node.typeArguments, mayResolveTypeAlias));
}
// Return true when the given node is transitively contained in type constructs that eagerly
@@ -59672,18 +60793,18 @@ var ts;
function isResolvedByTypeAlias(node) {
var parent = node.parent;
switch (parent.kind) {
- case 190 /* ParenthesizedType */:
- case 196 /* NamedTupleMember */:
- case 177 /* TypeReference */:
- case 186 /* UnionType */:
- case 187 /* IntersectionType */:
- case 193 /* IndexedAccessType */:
- case 188 /* ConditionalType */:
- case 192 /* TypeOperator */:
- case 182 /* ArrayType */:
- case 183 /* TupleType */:
+ case 191 /* SyntaxKind.ParenthesizedType */:
+ case 197 /* SyntaxKind.NamedTupleMember */:
+ case 178 /* SyntaxKind.TypeReference */:
+ case 187 /* SyntaxKind.UnionType */:
+ case 188 /* SyntaxKind.IntersectionType */:
+ case 194 /* SyntaxKind.IndexedAccessType */:
+ case 189 /* SyntaxKind.ConditionalType */:
+ case 193 /* SyntaxKind.TypeOperator */:
+ case 183 /* SyntaxKind.ArrayType */:
+ case 184 /* SyntaxKind.TupleType */:
return isResolvedByTypeAlias(parent);
- case 258 /* TypeAliasDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
return true;
}
return false;
@@ -59692,28 +60813,28 @@ var ts;
// of a type alias.
function mayResolveTypeAlias(node) {
switch (node.kind) {
- case 177 /* TypeReference */:
- return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* Type */).flags & 524288 /* TypeAlias */);
- case 180 /* TypeQuery */:
+ case 178 /* SyntaxKind.TypeReference */:
+ return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */).flags & 524288 /* SymbolFlags.TypeAlias */);
+ case 181 /* SyntaxKind.TypeQuery */:
return true;
- case 192 /* TypeOperator */:
- return node.operator !== 153 /* UniqueKeyword */ && mayResolveTypeAlias(node.type);
- case 190 /* ParenthesizedType */:
- case 184 /* OptionalType */:
- case 196 /* NamedTupleMember */:
- case 314 /* JSDocOptionalType */:
- case 312 /* JSDocNullableType */:
- case 313 /* JSDocNonNullableType */:
- case 307 /* JSDocTypeExpression */:
+ case 193 /* SyntaxKind.TypeOperator */:
+ return node.operator !== 154 /* SyntaxKind.UniqueKeyword */ && mayResolveTypeAlias(node.type);
+ case 191 /* SyntaxKind.ParenthesizedType */:
+ case 185 /* SyntaxKind.OptionalType */:
+ case 197 /* SyntaxKind.NamedTupleMember */:
+ case 316 /* SyntaxKind.JSDocOptionalType */:
+ case 314 /* SyntaxKind.JSDocNullableType */:
+ case 315 /* SyntaxKind.JSDocNonNullableType */:
+ case 309 /* SyntaxKind.JSDocTypeExpression */:
return mayResolveTypeAlias(node.type);
- case 185 /* RestType */:
- return node.type.kind !== 182 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType);
- case 186 /* UnionType */:
- case 187 /* IntersectionType */:
+ case 186 /* SyntaxKind.RestType */:
+ return node.type.kind !== 183 /* SyntaxKind.ArrayType */ || mayResolveTypeAlias(node.type.elementType);
+ case 187 /* SyntaxKind.UnionType */:
+ case 188 /* SyntaxKind.IntersectionType */:
return ts.some(node.types, mayResolveTypeAlias);
- case 193 /* IndexedAccessType */:
+ case 194 /* SyntaxKind.IndexedAccessType */:
return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType);
- case 188 /* ConditionalType */:
+ case 189 /* SyntaxKind.ConditionalType */:
return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) ||
mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType);
}
@@ -59726,33 +60847,33 @@ var ts;
if (target === emptyGenericType) {
links.resolvedType = emptyObjectType;
}
- else if (!(node.kind === 183 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) {
- links.resolvedType = node.kind === 183 /* TupleType */ && node.elements.length === 0 ? target :
+ else if (!(node.kind === 184 /* SyntaxKind.TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* ElementFlags.Variadic */); })) && isDeferredTypeReferenceNode(node)) {
+ links.resolvedType = node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 0 ? target :
createDeferredTypeReference(target, node, /*mapper*/ undefined);
}
else {
- var elementTypes = node.kind === 182 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode);
+ var elementTypes = node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode);
links.resolvedType = createNormalizedTypeReference(target, elementTypes);
}
}
return links.resolvedType;
}
function isReadonlyTypeOperator(node) {
- return ts.isTypeOperatorNode(node) && node.operator === 144 /* ReadonlyKeyword */;
+ return ts.isTypeOperatorNode(node) && node.operator === 145 /* SyntaxKind.ReadonlyKeyword */;
}
function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) {
if (readonly === void 0) { readonly = false; }
- var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* Required */; }), readonly, namedMemberDeclarations);
+ var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* ElementFlags.Required */; }), readonly, namedMemberDeclarations);
return tupleTarget === emptyGenericType ? emptyObjectType :
elementTypes.length ? createNormalizedTypeReference(tupleTarget, elementTypes) :
tupleTarget;
}
function getTupleTargetType(elementFlags, readonly, namedMemberDeclarations) {
- if (elementFlags.length === 1 && elementFlags[0] & 4 /* Rest */) {
+ if (elementFlags.length === 1 && elementFlags[0] & 4 /* ElementFlags.Rest */) {
// [...X[]] is equivalent to just X[]
return readonly ? globalReadonlyArrayType : globalArrayType;
}
- var key = ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? "#" : f & 2 /* Optional */ ? "?" : f & 4 /* Rest */ ? "." : "*"; }).join() +
+ var key = ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? "#" : f & 2 /* ElementFlags.Optional */ ? "?" : f & 4 /* ElementFlags.Rest */ ? "." : "*"; }).join() +
(readonly ? "R" : "") +
(namedMemberDeclarations && namedMemberDeclarations.length ? "," + ts.map(namedMemberDeclarations, getNodeId).join(",") : "");
var type = tupleTypes.get(key);
@@ -59770,7 +60891,7 @@ var ts;
// is true for each of the synthesized type parameters.
function createTupleTargetType(elementFlags, readonly, namedMemberDeclarations) {
var arity = elementFlags.length;
- var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* Required */ | 8 /* Variadic */)); });
+ var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* ElementFlags.Required */ | 8 /* ElementFlags.Variadic */)); });
var typeParameters;
var properties = [];
var combinedFlags = 0;
@@ -59780,8 +60901,8 @@ var ts;
var typeParameter = typeParameters[i] = createTypeParameter();
var flags = elementFlags[i];
combinedFlags |= flags;
- if (!(combinedFlags & 12 /* Variable */)) {
- var property = createSymbol(4 /* Property */ | (flags & 2 /* Optional */ ? 16777216 /* Optional */ : 0), "" + i, readonly ? 8 /* Readonly */ : 0);
+ if (!(combinedFlags & 12 /* ElementFlags.Variable */)) {
+ var property = createSymbol(4 /* SymbolFlags.Property */ | (flags & 2 /* ElementFlags.Optional */ ? 16777216 /* SymbolFlags.Optional */ : 0), "" + i, readonly ? 8 /* CheckFlags.Readonly */ : 0);
property.tupleLabelDeclaration = namedMemberDeclarations === null || namedMemberDeclarations === void 0 ? void 0 : namedMemberDeclarations[i];
property.type = typeParameter;
properties.push(property);
@@ -59789,8 +60910,8 @@ var ts;
}
}
var fixedLength = properties.length;
- var lengthSymbol = createSymbol(4 /* Property */, "length");
- if (combinedFlags & 12 /* Variable */) {
+ var lengthSymbol = createSymbol(4 /* SymbolFlags.Property */, "length", readonly ? 8 /* CheckFlags.Readonly */ : 0);
+ if (combinedFlags & 12 /* ElementFlags.Variable */) {
lengthSymbol.type = numberType;
}
else {
@@ -59800,7 +60921,7 @@ var ts;
lengthSymbol.type = getUnionType(literalTypes);
}
properties.push(lengthSymbol);
- var type = createObjectType(8 /* Tuple */ | 4 /* Reference */);
+ var type = createObjectType(8 /* ObjectFlags.Tuple */ | 4 /* ObjectFlags.Reference */);
type.typeParameters = typeParameters;
type.outerTypeParameters = undefined;
type.localTypeParameters = typeParameters;
@@ -59818,26 +60939,26 @@ var ts;
type.elementFlags = elementFlags;
type.minLength = minLength;
type.fixedLength = fixedLength;
- type.hasRestElement = !!(combinedFlags & 12 /* Variable */);
+ type.hasRestElement = !!(combinedFlags & 12 /* ElementFlags.Variable */);
type.combinedFlags = combinedFlags;
type.readonly = readonly;
type.labeledElementDeclarations = namedMemberDeclarations;
return type;
}
function createNormalizedTypeReference(target, typeArguments) {
- return target.objectFlags & 8 /* Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments);
+ return target.objectFlags & 8 /* ObjectFlags.Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments);
}
function createNormalizedTupleType(target, elementTypes) {
var _a, _b, _c;
- if (!(target.combinedFlags & 14 /* NonRequired */)) {
+ if (!(target.combinedFlags & 14 /* ElementFlags.NonRequired */)) {
// No need to normalize when we only have regular required elements
return createTypeReference(target, elementTypes);
}
- if (target.combinedFlags & 8 /* Variadic */) {
+ if (target.combinedFlags & 8 /* ElementFlags.Variadic */) {
// Transform [A, ...(X | Y | Z)] into [A, ...X] | [A, ...Y] | [A, ...Z]
- var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* Variadic */ && t.flags & (131072 /* Never */ | 1048576 /* Union */)); });
+ var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* ElementFlags.Variadic */ && t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); });
if (unionIndex_1 >= 0) {
- return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* Variadic */ ? t : unknownType; })) ?
+ return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t : unknownType; })) ?
mapType(elementTypes[unionIndex_1], function (t) { return createNormalizedTupleType(target, ts.replaceElement(elementTypes, unionIndex_1, t)); }) :
errorType;
}
@@ -59856,10 +60977,10 @@ var ts;
var _loop_15 = function (i) {
var type = elementTypes[i];
var flags = target.elementFlags[i];
- if (flags & 8 /* Variadic */) {
- if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) {
+ if (flags & 8 /* ElementFlags.Variadic */) {
+ if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type)) {
// Generic variadic elements stay as they are.
- addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]);
+ addElement(type, 8 /* ElementFlags.Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]);
}
else if (isTupleType(type)) {
var elements = getTypeArguments(type);
@@ -59874,7 +60995,7 @@ var ts;
}
else {
// Treat everything else as an array type and create a rest element.
- addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]);
+ addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* ElementFlags.Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]);
}
}
else {
@@ -59889,12 +61010,12 @@ var ts;
}
// Turn optional elements preceding the last required element into required elements
for (var i = 0; i < lastRequiredIndex; i++) {
- if (expandedFlags[i] & 2 /* Optional */)
- expandedFlags[i] = 1 /* Required */;
+ if (expandedFlags[i] & 2 /* ElementFlags.Optional */)
+ expandedFlags[i] = 1 /* ElementFlags.Required */;
}
if (firstRestIndex >= 0 && firstRestIndex < lastOptionalOrRestIndex) {
// Turn elements between first rest and last optional/rest into a single rest element
- expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; }));
+ expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; }));
expandedTypes.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
expandedFlags.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
expandedDeclarations === null || expandedDeclarations === void 0 ? void 0 : expandedDeclarations.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
@@ -59904,13 +61025,13 @@ var ts;
expandedFlags.length ? createTypeReference(tupleTarget, expandedTypes) :
tupleTarget;
function addElement(type, flags, declaration) {
- if (flags & 1 /* Required */) {
+ if (flags & 1 /* ElementFlags.Required */) {
lastRequiredIndex = expandedFlags.length;
}
- if (flags & 4 /* Rest */ && firstRestIndex < 0) {
+ if (flags & 4 /* ElementFlags.Rest */ && firstRestIndex < 0) {
firstRestIndex = expandedFlags.length;
}
- if (flags & (2 /* Optional */ | 4 /* Rest */)) {
+ if (flags & (2 /* ElementFlags.Optional */ | 4 /* ElementFlags.Rest */)) {
lastOptionalOrRestIndex = expandedFlags.length;
}
expandedTypes.push(type);
@@ -59962,19 +61083,19 @@ var ts;
}
function addTypeToUnion(typeSet, includes, type) {
var flags = type.flags;
- if (flags & 1048576 /* Union */) {
- return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* Union */ : 0), type.types);
+ if (flags & 1048576 /* TypeFlags.Union */) {
+ return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* TypeFlags.Union */ : 0), type.types);
}
// We ignore 'never' types in unions
- if (!(flags & 131072 /* Never */)) {
- includes |= flags & 205258751 /* IncludesMask */;
- if (flags & 465829888 /* Instantiable */)
- includes |= 33554432 /* IncludesInstantiable */;
+ if (!(flags & 131072 /* TypeFlags.Never */)) {
+ includes |= flags & 205258751 /* TypeFlags.IncludesMask */;
+ if (flags & 465829888 /* TypeFlags.Instantiable */)
+ includes |= 33554432 /* TypeFlags.IncludesInstantiable */;
if (type === wildcardType)
- includes |= 8388608 /* IncludesWildcard */;
- if (!strictNullChecks && flags & 98304 /* Nullable */) {
- if (!(ts.getObjectFlags(type) & 131072 /* ContainsWideningType */))
- includes |= 4194304 /* IncludesNonWideningType */;
+ includes |= 8388608 /* TypeFlags.IncludesWildcard */;
+ if (!strictNullChecks && flags & 98304 /* TypeFlags.Nullable */) {
+ if (!(ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */))
+ includes |= 4194304 /* TypeFlags.IncludesNonWideningType */;
}
else {
var len = typeSet.length;
@@ -59996,6 +61117,10 @@ var ts;
return includes;
}
function removeSubtypes(types, hasObjectTypes) {
+ // [] and [T] immediately reduce to [] and [T] respectively
+ if (types.length < 2) {
+ return types;
+ }
var id = getTypeListId(types);
var match = subtypeReductionCache.get(id);
if (match) {
@@ -60004,18 +61129,18 @@ var ts;
// We assume that redundant primitive types have already been removed from the types array and that there
// are no any and unknown types in the array. Thus, the only possible supertypes for primitive types are empty
// object types, and if none of those are present we can exclude primitive types from the subtype check.
- var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); });
+ var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); });
var len = types.length;
var i = len;
var count = 0;
while (i > 0) {
i--;
var source = types[i];
- if (hasEmptyObject || source.flags & 469499904 /* StructuredOrInstantiable */) {
+ if (hasEmptyObject || source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) {
// Find the first property with a unit type, if any. When constituents have a property by the same name
// but of a different unit type, we can quickly disqualify them from subtype checks. This helps subtype
// reduction of large discriminated union types.
- var keyProperty = source.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */) ?
+ var keyProperty = source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ?
ts.find(getPropertiesOfType(source), function (p) { return isUnitType(getTypeOfSymbol(p)); }) :
undefined;
var keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty));
@@ -60029,20 +61154,20 @@ var ts;
// caps union types at 1000 unique object types.
var estimatedCount = (count / (len - i)) * len;
if (estimatedCount > 1000000) {
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) });
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) });
error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
return undefined;
}
}
count++;
- if (keyProperty && target.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
+ if (keyProperty && target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) {
var t = getTypeOfPropertyOfType(target, keyProperty.escapedName);
if (t && isUnitType(t) && getRegularTypeOfLiteralType(t) !== keyPropertyType) {
continue;
}
}
- if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* Class */) ||
- !(ts.getObjectFlags(getTargetType(target)) & 1 /* Class */) ||
+ if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* ObjectFlags.Class */) ||
+ !(ts.getObjectFlags(getTargetType(target)) & 1 /* ObjectFlags.Class */) ||
isTypeDerivedFrom(source, target))) {
ts.orderedRemoveItemAt(types, i);
break;
@@ -60060,11 +61185,11 @@ var ts;
i--;
var t = types[i];
var flags = t.flags;
- var remove = flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 4 /* String */ ||
- flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ ||
- flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ ||
- flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ ||
- reduceVoidUndefined && flags & 32768 /* Undefined */ && includes & 16384 /* Void */ ||
+ var remove = flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && includes & 4 /* TypeFlags.String */ ||
+ flags & 256 /* TypeFlags.NumberLiteral */ && includes & 8 /* TypeFlags.Number */ ||
+ flags & 2048 /* TypeFlags.BigIntLiteral */ && includes & 64 /* TypeFlags.BigInt */ ||
+ flags & 8192 /* TypeFlags.UniqueESSymbol */ && includes & 4096 /* TypeFlags.ESSymbol */ ||
+ reduceVoidUndefined && flags & 32768 /* TypeFlags.Undefined */ && includes & 16384 /* TypeFlags.Void */ ||
isFreshLiteralType(t) && containsType(types, t.regularType);
if (remove) {
ts.orderedRemoveItemAt(types, i);
@@ -60078,7 +61203,7 @@ var ts;
var _loop_16 = function () {
i--;
var t = types[i];
- if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) {
+ if (t.flags & 128 /* TypeFlags.StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) {
ts.orderedRemoveItemAt(types, i);
}
};
@@ -60088,17 +61213,17 @@ var ts;
}
}
function isNamedUnionType(type) {
- return !!(type.flags & 1048576 /* Union */ && (type.aliasSymbol || type.origin));
+ return !!(type.flags & 1048576 /* TypeFlags.Union */ && (type.aliasSymbol || type.origin));
}
function addNamedUnions(namedUnions, types) {
for (var _i = 0, types_11 = types; _i < types_11.length; _i++) {
var t = types_11[_i];
- if (t.flags & 1048576 /* Union */) {
+ if (t.flags & 1048576 /* TypeFlags.Union */) {
var origin = t.origin;
- if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* Union */)) {
+ if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* TypeFlags.Union */)) {
ts.pushIfUnique(namedUnions, t);
}
- else if (origin && origin.flags & 1048576 /* Union */) {
+ else if (origin && origin.flags & 1048576 /* TypeFlags.Union */) {
addNamedUnions(namedUnions, origin.types);
}
}
@@ -60117,7 +61242,7 @@ var ts;
// circularly reference themselves and therefore cannot be subtype reduced during their declaration.
// For example, "type Item = string | (() => Item" is a named type that circularly references itself.
function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments, origin) {
- if (unionReduction === void 0) { unionReduction = 1 /* Literal */; }
+ if (unionReduction === void 0) { unionReduction = 1 /* UnionReduction.Literal */; }
if (types.length === 0) {
return neverType;
}
@@ -60126,37 +61251,37 @@ var ts;
}
var typeSet = [];
var includes = addTypesToUnion(typeSet, 0, types);
- if (unionReduction !== 0 /* None */) {
- if (includes & 3 /* AnyOrUnknown */) {
- return includes & 1 /* Any */ ?
- includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType :
- includes & 65536 /* Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType;
+ if (unionReduction !== 0 /* UnionReduction.None */) {
+ if (includes & 3 /* TypeFlags.AnyOrUnknown */) {
+ return includes & 1 /* TypeFlags.Any */ ?
+ includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType :
+ includes & 65536 /* TypeFlags.Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType;
}
- if (exactOptionalPropertyTypes && includes & 32768 /* Undefined */) {
+ if (exactOptionalPropertyTypes && includes & 32768 /* TypeFlags.Undefined */) {
var missingIndex = ts.binarySearch(typeSet, missingType, getTypeId, ts.compareValues);
if (missingIndex >= 0 && containsType(typeSet, undefinedType)) {
ts.orderedRemoveItemAt(typeSet, missingIndex);
}
}
- if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) {
- removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */));
+ if (includes & (2944 /* TypeFlags.Literal */ | 8192 /* TypeFlags.UniqueESSymbol */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || includes & 16384 /* TypeFlags.Void */ && includes & 32768 /* TypeFlags.Undefined */) {
+ removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* UnionReduction.Subtype */));
}
- if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) {
+ if (includes & 128 /* TypeFlags.StringLiteral */ && includes & 134217728 /* TypeFlags.TemplateLiteral */) {
removeStringLiteralsMatchedByTemplateLiterals(typeSet);
}
- if (unionReduction === 2 /* Subtype */) {
- typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */));
+ if (unionReduction === 2 /* UnionReduction.Subtype */) {
+ typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* TypeFlags.Object */));
if (!typeSet) {
return errorType;
}
}
if (typeSet.length === 0) {
- return includes & 65536 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType :
- includes & 32768 /* Undefined */ ? includes & 4194304 /* IncludesNonWideningType */ ? undefinedType : undefinedWideningType :
+ return includes & 65536 /* TypeFlags.Null */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? nullType : nullWideningType :
+ includes & 32768 /* TypeFlags.Undefined */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? undefinedType : undefinedWideningType :
neverType;
}
}
- if (!origin && includes & 1048576 /* Union */) {
+ if (!origin && includes & 1048576 /* TypeFlags.Union */) {
var namedUnions = [];
addNamedUnions(namedUnions, types);
var reducedTypes = [];
@@ -60180,11 +61305,11 @@ var ts;
var t = namedUnions_1[_a];
insertType(reducedTypes, t);
}
- origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
+ origin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, reducedTypes);
}
}
- var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) |
- (includes & 2097152 /* Intersection */ ? 33554432 /* ContainsIntersections */ : 0);
+ var objectFlags = (includes & 36323363 /* TypeFlags.NotPrimitiveUnion */ ? 0 : 32768 /* ObjectFlags.PrimitiveUnion */) |
+ (includes & 2097152 /* TypeFlags.Intersection */ ? 16777216 /* ObjectFlags.ContainsIntersections */ : 0);
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
}
function getUnionOrIntersectionTypePredicate(signatures, kind) {
@@ -60193,8 +61318,8 @@ var ts;
for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) {
var sig = signatures_6[_i];
var pred = getTypePredicateOfSignature(sig);
- if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) {
- if (kind !== 2097152 /* Intersection */) {
+ if (!pred || pred.kind === 2 /* TypePredicateKind.AssertsThis */ || pred.kind === 3 /* TypePredicateKind.AssertsIdentifier */) {
+ if (kind !== 2097152 /* TypeFlags.Intersection */) {
continue;
}
else {
@@ -60231,20 +61356,20 @@ var ts;
return types[0];
}
var typeKey = !origin ? getTypeListId(types) :
- origin.flags & 1048576 /* Union */ ? "|".concat(getTypeListId(origin.types)) :
- origin.flags & 2097152 /* Intersection */ ? "&".concat(getTypeListId(origin.types)) :
+ origin.flags & 1048576 /* TypeFlags.Union */ ? "|".concat(getTypeListId(origin.types)) :
+ origin.flags & 2097152 /* TypeFlags.Intersection */ ? "&".concat(getTypeListId(origin.types)) :
"#".concat(origin.type.id, "|").concat(getTypeListId(types)); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving
var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments);
var type = unionTypes.get(id);
if (!type) {
- type = createType(1048576 /* Union */);
- type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */);
+ type = createType(1048576 /* TypeFlags.Union */);
+ type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */);
type.types = types;
type.origin = origin;
type.aliasSymbol = aliasSymbol;
type.aliasTypeArguments = aliasTypeArguments;
- if (types.length === 2 && types[0].flags & 512 /* BooleanLiteral */ && types[1].flags & 512 /* BooleanLiteral */) {
- type.flags |= 16 /* Boolean */;
+ if (types.length === 2 && types[0].flags & 512 /* TypeFlags.BooleanLiteral */ && types[1].flags & 512 /* TypeFlags.BooleanLiteral */) {
+ type.flags |= 16 /* TypeFlags.Boolean */;
type.intrinsicName = "boolean";
}
unionTypes.set(id, type);
@@ -60255,41 +61380,41 @@ var ts;
var links = getNodeLinks(node);
if (!links.resolvedType) {
var aliasSymbol = getAliasSymbolForTypeNode(node);
- links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
+ links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* UnionReduction.Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
}
return links.resolvedType;
}
function addTypeToIntersection(typeSet, includes, type) {
var flags = type.flags;
- if (flags & 2097152 /* Intersection */) {
+ if (flags & 2097152 /* TypeFlags.Intersection */) {
return addTypesToIntersection(typeSet, includes, type.types);
}
if (isEmptyAnonymousObjectType(type)) {
- if (!(includes & 16777216 /* IncludesEmptyObject */)) {
- includes |= 16777216 /* IncludesEmptyObject */;
+ if (!(includes & 16777216 /* TypeFlags.IncludesEmptyObject */)) {
+ includes |= 16777216 /* TypeFlags.IncludesEmptyObject */;
typeSet.set(type.id.toString(), type);
}
}
else {
- if (flags & 3 /* AnyOrUnknown */) {
+ if (flags & 3 /* TypeFlags.AnyOrUnknown */) {
if (type === wildcardType)
- includes |= 8388608 /* IncludesWildcard */;
+ includes |= 8388608 /* TypeFlags.IncludesWildcard */;
}
- else if (strictNullChecks || !(flags & 98304 /* Nullable */)) {
+ else if (strictNullChecks || !(flags & 98304 /* TypeFlags.Nullable */)) {
if (exactOptionalPropertyTypes && type === missingType) {
- includes |= 262144 /* IncludesMissingType */;
+ includes |= 262144 /* TypeFlags.IncludesMissingType */;
type = undefinedType;
}
if (!typeSet.has(type.id.toString())) {
- if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) {
+ if (type.flags & 109440 /* TypeFlags.Unit */ && includes & 109440 /* TypeFlags.Unit */) {
// We have seen two distinct unit types which means we should reduce to an
// empty intersection. Adding TypeFlags.NonPrimitive causes that to happen.
- includes |= 67108864 /* NonPrimitive */;
+ includes |= 67108864 /* TypeFlags.NonPrimitive */;
}
typeSet.set(type.id.toString(), type);
}
}
- includes |= flags & 205258751 /* IncludesMask */;
+ includes |= flags & 205258751 /* TypeFlags.IncludesMask */;
}
return includes;
}
@@ -60307,10 +61432,10 @@ var ts;
while (i > 0) {
i--;
var t = types[i];
- var remove = t.flags & 4 /* String */ && includes & 128 /* StringLiteral */ ||
- t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
- t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
- t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */;
+ var remove = t.flags & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ||
+ t.flags & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ ||
+ t.flags & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ ||
+ t.flags & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */;
if (remove) {
ts.orderedRemoveItemAt(types, i);
}
@@ -60323,10 +61448,10 @@ var ts;
for (var _i = 0, unionTypes_1 = unionTypes; _i < unionTypes_1.length; _i++) {
var u = unionTypes_1[_i];
if (!containsType(u.types, type)) {
- var primitive = type.flags & 128 /* StringLiteral */ ? stringType :
- type.flags & 256 /* NumberLiteral */ ? numberType :
- type.flags & 2048 /* BigIntLiteral */ ? bigintType :
- type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType :
+ var primitive = type.flags & 128 /* TypeFlags.StringLiteral */ ? stringType :
+ type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType :
+ type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType :
+ type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType :
undefined;
if (!primitive || !containsType(u.types, primitive)) {
return false;
@@ -60340,11 +61465,11 @@ var ts;
*/
function extractRedundantTemplateLiterals(types) {
var i = types.length;
- var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* StringLiteral */); });
+ var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* TypeFlags.StringLiteral */); });
while (i > 0) {
i--;
var t = types[i];
- if (!(t.flags & 134217728 /* TemplateLiteral */))
+ if (!(t.flags & 134217728 /* TypeFlags.TemplateLiteral */))
continue;
for (var _i = 0, literals_1 = literals; _i < literals_1.length; _i++) {
var t2 = literals_1[_i];
@@ -60361,7 +61486,7 @@ var ts;
return false;
}
function eachIsUnionContaining(types, flag) {
- return ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); });
+ return ts.every(types, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); });
}
function removeFromEach(types, flag) {
for (var i = 0; i < types.length; i++) {
@@ -60373,7 +61498,7 @@ var ts;
// other unions and return true. Otherwise, do nothing and return false.
function intersectUnionsOfPrimitiveTypes(types) {
var unionTypes;
- var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 65536 /* PrimitiveUnion */); });
+ var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */); });
if (index < 0) {
return false;
}
@@ -60382,7 +61507,7 @@ var ts;
// the unionTypes array.
while (i < types.length) {
var t = types[i];
- if (ts.getObjectFlags(t) & 65536 /* PrimitiveUnion */) {
+ if (ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */) {
(unionTypes || (unionTypes = [types[index]])).push(t);
ts.orderedRemoveItemAt(types, i);
}
@@ -60411,12 +61536,12 @@ var ts;
}
}
// Finally replace the first union with the result
- types[index] = getUnionTypeFromSortedList(result, 65536 /* PrimitiveUnion */);
+ types[index] = getUnionTypeFromSortedList(result, 32768 /* ObjectFlags.PrimitiveUnion */);
return true;
}
function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
- var result = createType(2097152 /* Intersection */);
- result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */);
+ var result = createType(2097152 /* TypeFlags.Intersection */);
+ result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */);
result.types = types;
result.aliasSymbol = aliasSymbol;
result.aliasTypeArguments = aliasTypeArguments;
@@ -60445,37 +61570,37 @@ var ts;
// a symbol-like type and a type known to be non-symbol-like, or
// a void-like type and a type known to be non-void-like, or
// a non-primitive type and a type known to be primitive.
- if (includes & 131072 /* Never */) {
+ if (includes & 131072 /* TypeFlags.Never */) {
return ts.contains(typeSet, silentNeverType) ? silentNeverType : neverType;
}
- if (strictNullChecks && includes & 98304 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 16777216 /* IncludesEmptyObject */) ||
- includes & 67108864 /* NonPrimitive */ && includes & (469892092 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) ||
- includes & 402653316 /* StringLike */ && includes & (469892092 /* DisjointDomains */ & ~402653316 /* StringLike */) ||
- includes & 296 /* NumberLike */ && includes & (469892092 /* DisjointDomains */ & ~296 /* NumberLike */) ||
- includes & 2112 /* BigIntLike */ && includes & (469892092 /* DisjointDomains */ & ~2112 /* BigIntLike */) ||
- includes & 12288 /* ESSymbolLike */ && includes & (469892092 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) ||
- includes & 49152 /* VoidLike */ && includes & (469892092 /* DisjointDomains */ & ~49152 /* VoidLike */)) {
+ if (strictNullChecks && includes & 98304 /* TypeFlags.Nullable */ && includes & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 16777216 /* TypeFlags.IncludesEmptyObject */) ||
+ includes & 67108864 /* TypeFlags.NonPrimitive */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~67108864 /* TypeFlags.NonPrimitive */) ||
+ includes & 402653316 /* TypeFlags.StringLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~402653316 /* TypeFlags.StringLike */) ||
+ includes & 296 /* TypeFlags.NumberLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~296 /* TypeFlags.NumberLike */) ||
+ includes & 2112 /* TypeFlags.BigIntLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~2112 /* TypeFlags.BigIntLike */) ||
+ includes & 12288 /* TypeFlags.ESSymbolLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~12288 /* TypeFlags.ESSymbolLike */) ||
+ includes & 49152 /* TypeFlags.VoidLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~49152 /* TypeFlags.VoidLike */)) {
return neverType;
}
- if (includes & 134217728 /* TemplateLiteral */ && includes & 128 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) {
+ if (includes & 134217728 /* TypeFlags.TemplateLiteral */ && includes & 128 /* TypeFlags.StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) {
return neverType;
}
- if (includes & 1 /* Any */) {
- return includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType;
+ if (includes & 1 /* TypeFlags.Any */) {
+ return includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType;
}
- if (!strictNullChecks && includes & 98304 /* Nullable */) {
- return includes & 32768 /* Undefined */ ? undefinedType : nullType;
+ if (!strictNullChecks && includes & 98304 /* TypeFlags.Nullable */) {
+ return includes & 32768 /* TypeFlags.Undefined */ ? undefinedType : nullType;
}
- if (includes & 4 /* String */ && includes & 128 /* StringLiteral */ ||
- includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
- includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
- includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) {
+ if (includes & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ||
+ includes & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ ||
+ includes & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ ||
+ includes & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */) {
removeRedundantPrimitiveTypes(typeSet, includes);
}
- if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) {
+ if (includes & 16777216 /* TypeFlags.IncludesEmptyObject */ && includes & 524288 /* TypeFlags.Object */) {
ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
}
- if (includes & 262144 /* IncludesMissingType */) {
+ if (includes & 262144 /* TypeFlags.IncludesMissingType */) {
typeSet[typeSet.indexOf(undefinedType)] = missingType;
}
if (typeSet.length === 0) {
@@ -60487,21 +61612,21 @@ var ts;
var id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments);
var result = intersectionTypes.get(id);
if (!result) {
- if (includes & 1048576 /* Union */) {
+ if (includes & 1048576 /* TypeFlags.Union */) {
if (intersectUnionsOfPrimitiveTypes(typeSet)) {
// When the intersection creates a reduced set (which might mean that *all* union types have
// disappeared), we restart the operation to get a new set of combined flags. Once we have
// reduced we'll never reduce again, so this occurs at most once.
result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
}
- else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) {
+ else if (eachIsUnionContaining(typeSet, 32768 /* TypeFlags.Undefined */)) {
var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType;
- removeFromEach(typeSet, 32768 /* Undefined */);
- result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
+ removeFromEach(typeSet, 32768 /* TypeFlags.Undefined */);
+ result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments);
}
- else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) {
- removeFromEach(typeSet, 65536 /* Null */);
- result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
+ else if (eachIsUnionContaining(typeSet, 65536 /* TypeFlags.Null */)) {
+ removeFromEach(typeSet, 65536 /* TypeFlags.Null */);
+ result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments);
}
else {
// We are attempting to construct a type of the form X & (A | B) & (C | D). Transform this into a type of
@@ -60513,8 +61638,8 @@ var ts;
var constituents = getCrossProductIntersections(typeSet);
// We attach a denormalized origin type when at least one constituent of the cross-product union is an
// intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions).
- var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
- result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
+ var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* TypeFlags.Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* TypeFlags.Intersection */, typeSet) : undefined;
+ result = getUnionType(constituents, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments, origin);
}
}
else {
@@ -60525,12 +61650,12 @@ var ts;
return result;
}
function getCrossProductUnionSize(types) {
- return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* Union */ ? n * t.types.length : t.flags & 131072 /* Never */ ? 0 : n; }, 1);
+ return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* TypeFlags.Union */ ? n * t.types.length : t.flags & 131072 /* TypeFlags.Never */ ? 0 : n; }, 1);
}
function checkCrossProductUnion(types) {
var size = getCrossProductUnionSize(types);
if (size >= 100000) {
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size });
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size });
error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
return false;
}
@@ -60543,7 +61668,7 @@ var ts;
var constituents = types.slice();
var n = i;
for (var j = types.length - 1; j >= 0; j--) {
- if (types[j].flags & 1048576 /* Union */) {
+ if (types[j].flags & 1048576 /* TypeFlags.Union */) {
var sourceTypes = types[j].types;
var length_5 = sourceTypes.length;
constituents[j] = sourceTypes[n % length_5];
@@ -60551,7 +61676,7 @@ var ts;
}
}
var t = getIntersectionType(constituents);
- if (!(t.flags & 131072 /* Never */))
+ if (!(t.flags & 131072 /* TypeFlags.Never */))
intersections.push(t);
}
return intersections;
@@ -60565,13 +61690,13 @@ var ts;
return links.resolvedType;
}
function createIndexType(type, stringsOnly) {
- var result = createType(4194304 /* Index */);
+ var result = createType(4194304 /* TypeFlags.Index */);
result.type = type;
result.stringsOnly = stringsOnly;
return result;
}
function createOriginIndexType(type) {
- var result = createOriginType(4194304 /* Index */);
+ var result = createOriginType(4194304 /* TypeFlags.Index */);
result.type = type;
return result;
}
@@ -60603,7 +61728,7 @@ var ts;
// so we only eagerly manifest the keys if the constraint is nongeneric
if (!isGenericIndexType(constraintType)) {
var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T'
- forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType);
+ forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType);
}
else {
// we have a generic index and a homomorphic mapping (but a distributive key remapping) - we need to defer the whole `keyof whatever` for later
@@ -60619,8 +61744,8 @@ var ts;
}
// we had to pick apart the constraintType to potentially map/filter it - compare the final resulting list with the original constraintType,
// so we can return the union that preserves aliases/origin data if possible
- var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* Any */ | 4 /* String */)); }) : getUnionType(keyTypes);
- if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) {
+ var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)); }) : getUnionType(keyTypes);
+ if (result.flags & 1048576 /* TypeFlags.Union */ && constraintType.flags & 1048576 /* TypeFlags.Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) {
return constraintType;
}
return result;
@@ -60640,12 +61765,12 @@ var ts;
var typeVariable = getTypeParameterFromMappedType(mappedType);
return isDistributive(getNameTypeFromMappedType(mappedType) || typeVariable);
function isDistributive(type) {
- return type.flags & (3 /* AnyOrUnknown */ | 131068 /* Primitive */ | 131072 /* Never */ | 262144 /* TypeParameter */ | 524288 /* Object */ | 67108864 /* NonPrimitive */) ? true :
- type.flags & 16777216 /* Conditional */ ? type.root.isDistributive && type.checkType === typeVariable :
- type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) ? ts.every(type.types, isDistributive) :
- type.flags & 8388608 /* IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) :
- type.flags & 33554432 /* Substitution */ ? isDistributive(type.substitute) :
- type.flags & 268435456 /* StringMapping */ ? isDistributive(type.type) :
+ return type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */ | 262144 /* TypeFlags.TypeParameter */ | 524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */) ? true :
+ type.flags & 16777216 /* TypeFlags.Conditional */ ? type.root.isDistributive && type.checkType === typeVariable :
+ type.flags & (3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */) ? ts.every(type.types, isDistributive) :
+ type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) :
+ type.flags & 33554432 /* TypeFlags.Substitution */ ? isDistributive(type.substitute) :
+ type.flags & 268435456 /* TypeFlags.StringMapping */ ? isDistributive(type.type) :
false;
}
}
@@ -60657,11 +61782,11 @@ var ts;
getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name));
}
function getLiteralTypeFromProperty(prop, include, includeNonPublic) {
- if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) {
+ if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) {
var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType;
if (!type) {
var name = ts.getNameOfDeclaration(prop.valueDeclaration);
- type = prop.escapedName === "default" /* Default */ ? getStringLiteralType("default") :
+ type = prop.escapedName === "default" /* InternalSymbolName.Default */ ? getStringLiteralType("default") :
name && getLiteralTypeFromPropertyName(name) || (!ts.isKnownSymbol(prop) ? getStringLiteralType(ts.symbolName(prop)) : undefined);
}
if (type && type.flags & include) {
@@ -60671,27 +61796,41 @@ var ts;
return neverType;
}
function isKeyTypeIncluded(keyType, include) {
- return !!(keyType.flags & include || keyType.flags & 2097152 /* Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); }));
+ return !!(keyType.flags & include || keyType.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); }));
}
function getLiteralTypeFromProperties(type, include, includeOrigin) {
- var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined;
+ var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined;
var propertyTypes = ts.map(getPropertiesOfType(type), function (prop) { return getLiteralTypeFromProperty(prop, include); });
var indexKeyTypes = ts.map(getIndexInfosOfType(type), function (info) { return info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ?
- info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType; });
- return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */,
+ info.keyType === stringType && include & 8 /* TypeFlags.Number */ ? stringOrNumberType : info.keyType : neverType; });
+ return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* UnionReduction.Literal */,
/*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin);
}
+ /**
+ * A union type which is reducible upon instantiation (meaning some members are removed under certain instantiations)
+ * must be kept generic, as that instantiation information needs to flow through the type system. By replacing all
+ * type parameters in the union with a special never type that is treated as a literal in `getReducedType`, we can cause the `getReducedType` logic
+ * to reduce the resulting type if possible (since only intersections with conflicting literal-typed properties are reducible).
+ */
+ function isPossiblyReducibleByInstantiation(type) {
+ return ts.some(type.types, function (t) {
+ var uniqueFilled = getUniqueLiteralFilledInstantiation(t);
+ return getReducedType(uniqueFilled) !== uniqueFilled;
+ });
+ }
function getIndexType(type, stringsOnly, noIndexSignatures) {
if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
type = getReducedType(type);
- return type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
- type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
- type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
- ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) :
+ return type.flags & 1048576 /* TypeFlags.Union */ ? isPossiblyReducibleByInstantiation(type)
+ ? getIndexTypeForGenericType(type, stringsOnly)
+ : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
+ type.flags & 2097152 /* TypeFlags.Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
+ type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
+ ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) :
type === wildcardType ? wildcardType :
- type.flags & 2 /* Unknown */ ? neverType :
- type.flags & (1 /* Any */ | 131072 /* Never */) ? keyofConstraintType :
- getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* StringLiteral */ : 402653316 /* StringLike */) | (stringsOnly ? 0 : 296 /* NumberLike */ | 12288 /* ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures);
+ type.flags & 2 /* TypeFlags.Unknown */ ? neverType :
+ type.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */) ? keyofConstraintType :
+ getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* TypeFlags.StringLiteral */ : 402653316 /* TypeFlags.StringLike */) | (stringsOnly ? 0 : 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures);
}
function getExtractStringType(type) {
if (keyofStringsOnly) {
@@ -60702,21 +61841,21 @@ var ts;
}
function getIndexTypeOrString(type) {
var indexType = getExtractStringType(getIndexType(type));
- return indexType.flags & 131072 /* Never */ ? stringType : indexType;
+ return indexType.flags & 131072 /* TypeFlags.Never */ ? stringType : indexType;
}
function getTypeFromTypeOperatorNode(node) {
var links = getNodeLinks(node);
if (!links.resolvedType) {
switch (node.operator) {
- case 140 /* KeyOfKeyword */:
+ case 140 /* SyntaxKind.KeyOfKeyword */:
links.resolvedType = getIndexType(getTypeFromTypeNode(node.type));
break;
- case 153 /* UniqueKeyword */:
- links.resolvedType = node.type.kind === 150 /* SymbolKeyword */
+ case 154 /* SyntaxKind.UniqueKeyword */:
+ links.resolvedType = node.type.kind === 151 /* SyntaxKind.SymbolKeyword */
? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent))
: errorType;
break;
- case 144 /* ReadonlyKeyword */:
+ case 145 /* SyntaxKind.ReadonlyKeyword */:
links.resolvedType = getTypeFromTypeNode(node.type);
break;
default:
@@ -60733,7 +61872,7 @@ var ts;
return links.resolvedType;
}
function getTemplateLiteralType(texts, types) {
- var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* Never */ | 1048576 /* Union */)); });
+ var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); });
if (unionIndex >= 0) {
return checkCrossProductUnion(types) ?
mapType(types[unionIndex], function (t) { return getTemplateLiteralType(texts, ts.replaceElement(types, unionIndex, t)); }) :
@@ -60752,7 +61891,7 @@ var ts;
return getStringLiteralType(text);
}
newTexts.push(text);
- if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* String */); })) {
+ if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) {
return stringType;
}
var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join(""));
@@ -60762,24 +61901,35 @@ var ts;
}
return type;
function addSpans(texts, types) {
+ var isTextsArray = ts.isArray(texts);
for (var i = 0; i < types.length; i++) {
var t = types[i];
- if (t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) {
+ var addText = isTextsArray ? texts[i + 1] : texts;
+ if (t.flags & (2944 /* TypeFlags.Literal */ | 65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */)) {
text += getTemplateStringForType(t) || "";
- text += texts[i + 1];
+ text += addText;
+ if (!isTextsArray)
+ return true;
}
- else if (t.flags & 134217728 /* TemplateLiteral */) {
+ else if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) {
text += t.texts[0];
if (!addSpans(t.texts, t.types))
return false;
- text += texts[i + 1];
+ text += addText;
+ if (!isTextsArray)
+ return true;
}
else if (isGenericIndexType(t) || isPatternLiteralPlaceholderType(t)) {
newTypes.push(t);
newTexts.push(text);
- text = texts[i + 1];
+ text = addText;
}
- else {
+ else if (t.flags & 2097152 /* TypeFlags.Intersection */) {
+ var added = addSpans(texts[i + 1], t.types);
+ if (!added)
+ return false;
+ }
+ else if (isTextsArray) {
return false;
}
}
@@ -60787,30 +61937,30 @@ var ts;
}
}
function getTemplateStringForType(type) {
- return type.flags & 128 /* StringLiteral */ ? type.value :
- type.flags & 256 /* NumberLiteral */ ? "" + type.value :
- type.flags & 2048 /* BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) :
- type.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) ? type.intrinsicName :
+ return type.flags & 128 /* TypeFlags.StringLiteral */ ? type.value :
+ type.flags & 256 /* TypeFlags.NumberLiteral */ ? "" + type.value :
+ type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) :
+ type.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) ? type.intrinsicName :
undefined;
}
function createTemplateLiteralType(texts, types) {
- var type = createType(134217728 /* TemplateLiteral */);
+ var type = createType(134217728 /* TypeFlags.TemplateLiteral */);
type.texts = texts;
type.types = types;
return type;
}
function getStringMappingType(symbol, type) {
- return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
+ return type.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
- type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
+ type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
type;
}
function applyStringMapping(symbol, str) {
switch (intrinsicTypeKinds.get(symbol.escapedName)) {
- case 0 /* Uppercase */: return str.toUpperCase();
- case 1 /* Lowercase */: return str.toLowerCase();
- case 2 /* Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1);
- case 3 /* Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1);
+ case 0 /* IntrinsicTypeKind.Uppercase */: return str.toUpperCase();
+ case 1 /* IntrinsicTypeKind.Lowercase */: return str.toLowerCase();
+ case 2 /* IntrinsicTypeKind.Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1);
+ case 3 /* IntrinsicTypeKind.Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1);
}
return str;
}
@@ -60823,13 +61973,13 @@ var ts;
return result;
}
function createStringMappingType(symbol, type) {
- var result = createType(268435456 /* StringMapping */);
+ var result = createType(268435456 /* TypeFlags.StringMapping */);
result.symbol = symbol;
result.type = type;
return result;
}
function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) {
- var type = createType(8388608 /* IndexedAccess */);
+ var type = createType(8388608 /* TypeFlags.IndexedAccess */);
type.objectType = objectType;
type.indexType = indexType;
type.accessFlags = accessFlags;
@@ -60850,16 +62000,16 @@ var ts;
if (noImplicitAny) {
return false; // Flag is meaningless under `noImplicitAny` mode
}
- if (ts.getObjectFlags(type) & 8192 /* JSLiteral */) {
+ if (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */) {
return true;
}
- if (type.flags & 1048576 /* Union */) {
+ if (type.flags & 1048576 /* TypeFlags.Union */) {
return ts.every(type.types, isJSLiteralType);
}
- if (type.flags & 2097152 /* Intersection */) {
+ if (type.flags & 2097152 /* TypeFlags.Intersection */) {
return ts.some(type.types, isJSLiteralType);
}
- if (type.flags & 465829888 /* Instantiable */) {
+ if (type.flags & 465829888 /* TypeFlags.Instantiable */) {
var constraint = getResolvedBaseConstraint(type);
return constraint !== type && isJSLiteralType(constraint);
}
@@ -60874,26 +62024,26 @@ var ts;
undefined;
}
function isUncalledFunctionReference(node, symbol) {
- if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) {
+ if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) {
var parent = ts.findAncestor(node.parent, function (n) { return !ts.isAccessExpression(n); }) || node.parent;
if (ts.isCallLikeExpression(parent)) {
return ts.isCallOrNewExpression(parent) && ts.isIdentifier(node) && hasMatchingArgument(parent, node);
}
- return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); });
+ return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); });
}
return true;
}
function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, accessNode, accessFlags) {
var _a;
- var accessExpression = accessNode && accessNode.kind === 206 /* ElementAccessExpression */ ? accessNode : undefined;
+ var accessExpression = accessNode && accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode : undefined;
var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode);
if (propName !== undefined) {
- if (accessFlags & 256 /* Contextual */) {
+ if (accessFlags & 256 /* AccessFlags.Contextual */) {
return getTypeOfPropertyOfContextualType(objectType, propName) || anyType;
}
var prop = getPropertyOfType(objectType, propName);
if (prop) {
- if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) {
+ if (accessFlags & 64 /* AccessFlags.ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) {
var deprecatedNode = (_a = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _a !== void 0 ? _a : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode);
addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName);
}
@@ -60903,7 +62053,7 @@ var ts;
error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop));
return undefined;
}
- if (accessFlags & 8 /* CacheSymbol */) {
+ if (accessFlags & 8 /* AccessFlags.CacheSymbol */) {
getNodeLinks(accessNode).resolvedSymbol = prop;
}
if (isThisPropertyAccessInConstructor(accessExpression, prop)) {
@@ -60911,12 +62061,12 @@ var ts;
}
}
var propType = getTypeOfSymbol(prop);
- return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* Definite */ ?
+ return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* AssignmentKind.Definite */ ?
getFlowTypeOfReference(accessExpression, propType) :
propType;
}
if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) {
- if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) {
+ if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* AccessFlags.NoTupleBoundsCheck */)) {
var indexNode = getIndexNodeForAccessExpression(accessNode);
if (isTupleType(objectType)) {
error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName));
@@ -60928,33 +62078,33 @@ var ts;
errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType));
return mapType(objectType, function (t) {
var restType = getRestTypeOfTupleType(t) || undefinedType;
- return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType;
+ return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType;
});
}
}
- if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) {
- if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) {
+ if (!(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */)) {
+ if (objectType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) {
return objectType;
}
// If no index signature is applicable, we default to the string index signature. In effect, this means the string
// index signature applies even when accessing with a symbol-like type.
var indexInfo = getApplicableIndexInfo(objectType, indexType) || getIndexInfoOfType(objectType, stringType);
if (indexInfo) {
- if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo.keyType !== numberType) {
+ if (accessFlags & 2 /* AccessFlags.NoIndexSignatures */ && indexInfo.keyType !== numberType) {
if (accessExpression) {
error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType));
}
return undefined;
}
- if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) {
+ if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) {
var indexNode = getIndexNodeForAccessExpression(accessNode);
error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
- return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
+ return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
}
errorIfWritingToReadonlyIndex(indexInfo);
- return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
+ return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
}
- if (indexType.flags & 131072 /* Never */) {
+ if (indexType.flags & 131072 /* TypeFlags.Never */) {
return neverType;
}
if (isJSLiteralType(objectType)) {
@@ -60962,21 +62112,21 @@ var ts;
}
if (accessExpression && !isConstEnumObjectType(objectType)) {
if (isObjectLiteralType(objectType)) {
- if (noImplicitAny && indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
+ if (noImplicitAny && indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) {
diagnostics.add(ts.createDiagnosticForNode(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)));
return undefinedType;
}
- else if (indexType.flags & (8 /* Number */ | 4 /* String */)) {
+ else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) {
var types = ts.map(objectType.properties, function (property) {
return getTypeOfSymbol(property);
});
return getUnionType(ts.append(types, undefinedType));
}
}
- if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) {
+ if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* SymbolFlags.BlockScoped */)) {
error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
}
- else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* SuppressNoImplicitAnyError */)) {
+ else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* AccessFlags.SuppressNoImplicitAnyError */)) {
if (propName !== undefined && typeHasStaticProperty(propName, objectType)) {
var typeName = typeToString(objectType);
error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead, propName, typeName, typeName + "[" + ts.getTextOfNode(accessExpression.argumentExpression) + "]");
@@ -60998,20 +62148,20 @@ var ts;
}
else {
var errorInfo = void 0;
- if (indexType.flags & 1024 /* EnumLiteral */) {
+ if (indexType.flags & 1024 /* TypeFlags.EnumLiteral */) {
errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType));
}
- else if (indexType.flags & 8192 /* UniqueESSymbol */) {
+ else if (indexType.flags & 8192 /* TypeFlags.UniqueESSymbol */) {
var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression);
errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType));
}
- else if (indexType.flags & 128 /* StringLiteral */) {
+ else if (indexType.flags & 128 /* TypeFlags.StringLiteral */) {
errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
}
- else if (indexType.flags & 256 /* NumberLiteral */) {
+ else if (indexType.flags & 256 /* TypeFlags.NumberLiteral */) {
errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
}
- else if (indexType.flags & (8 /* Number */ | 4 /* String */)) {
+ else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) {
errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType));
}
errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1, typeToString(fullIndexType), typeToString(objectType));
@@ -61028,10 +62178,10 @@ var ts;
}
if (accessNode) {
var indexNode = getIndexNodeForAccessExpression(accessNode);
- if (indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
+ if (indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) {
error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType));
}
- else if (indexType.flags & (4 /* String */ | 8 /* Number */)) {
+ else if (indexType.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) {
error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType));
}
else {
@@ -61049,62 +62199,62 @@ var ts;
}
}
function getIndexNodeForAccessExpression(accessNode) {
- return accessNode.kind === 206 /* ElementAccessExpression */ ? accessNode.argumentExpression :
- accessNode.kind === 193 /* IndexedAccessType */ ? accessNode.indexType :
- accessNode.kind === 161 /* ComputedPropertyName */ ? accessNode.expression :
+ return accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode.argumentExpression :
+ accessNode.kind === 194 /* SyntaxKind.IndexedAccessType */ ? accessNode.indexType :
+ accessNode.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? accessNode.expression :
accessNode;
}
function isPatternLiteralPlaceholderType(type) {
- return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */));
+ return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */));
}
function isPatternLiteralType(type) {
- return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
+ return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
}
function isGenericType(type) {
return !!getGenericObjectFlags(type);
}
function isGenericObjectType(type) {
- return !!(getGenericObjectFlags(type) & 8388608 /* IsGenericObjectType */);
+ return !!(getGenericObjectFlags(type) & 4194304 /* ObjectFlags.IsGenericObjectType */);
}
function isGenericIndexType(type) {
- return !!(getGenericObjectFlags(type) & 16777216 /* IsGenericIndexType */);
+ return !!(getGenericObjectFlags(type) & 8388608 /* ObjectFlags.IsGenericIndexType */);
}
function getGenericObjectFlags(type) {
- if (type.flags & 3145728 /* UnionOrIntersection */) {
- if (!(type.objectFlags & 4194304 /* IsGenericTypeComputed */)) {
- type.objectFlags |= 4194304 /* IsGenericTypeComputed */ |
+ if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) {
+ if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) {
+ type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ |
ts.reduceLeft(type.types, function (flags, t) { return flags | getGenericObjectFlags(t); }, 0);
}
- return type.objectFlags & 25165824 /* IsGenericType */;
+ return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */;
}
- if (type.flags & 33554432 /* Substitution */) {
- if (!(type.objectFlags & 4194304 /* IsGenericTypeComputed */)) {
- type.objectFlags |= 4194304 /* IsGenericTypeComputed */ |
+ if (type.flags & 33554432 /* TypeFlags.Substitution */) {
+ if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) {
+ type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ |
getGenericObjectFlags(type.substitute) | getGenericObjectFlags(type.baseType);
}
- return type.objectFlags & 25165824 /* IsGenericType */;
+ return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */;
}
- return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 8388608 /* IsGenericObjectType */ : 0) |
- (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 16777216 /* IsGenericIndexType */ : 0);
+ return (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* ObjectFlags.IsGenericObjectType */ : 0) |
+ (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* ObjectFlags.IsGenericIndexType */ : 0);
}
function getSimplifiedType(type, writing) {
- return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) :
- type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) :
+ return type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) :
+ type.flags & 16777216 /* TypeFlags.Conditional */ ? getSimplifiedConditionalType(type, writing) :
type;
}
function distributeIndexOverObjectType(objectType, indexType, writing) {
// (T | U)[K] -> T[K] | U[K] (reading)
// (T | U)[K] -> T[K] & U[K] (writing)
// (T & U)[K] -> T[K] & U[K]
- if (objectType.flags & 3145728 /* UnionOrIntersection */) {
+ if (objectType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) {
var types = ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType), writing); });
- return objectType.flags & 2097152 /* Intersection */ || writing ? getIntersectionType(types) : getUnionType(types);
+ return objectType.flags & 2097152 /* TypeFlags.Intersection */ || writing ? getIntersectionType(types) : getUnionType(types);
}
}
function distributeObjectOverIndexType(objectType, indexType, writing) {
// T[A | B] -> T[A] | T[B] (reading)
// T[A | B] -> T[A] & T[B] (writing)
- if (indexType.flags & 1048576 /* Union */) {
+ if (indexType.flags & 1048576 /* TypeFlags.Union */) {
var types = ts.map(indexType.types, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t), writing); });
return writing ? getIntersectionType(types) : getUnionType(types);
}
@@ -61129,7 +62279,7 @@ var ts;
return type[cache] = distributedOverIndex;
}
// Only do the inner distributions if the index can no longer be instantiated to cause index distribution again
- if (!(indexType.flags & 465829888 /* Instantiable */)) {
+ if (!(indexType.flags & 465829888 /* TypeFlags.Instantiable */)) {
// (T | U)[K] -> T[K] | U[K] (reading)
// (T | U)[K] -> T[K] & U[K] (writing)
// (T & U)[K] -> T[K] & U[K]
@@ -61143,17 +62293,20 @@ var ts;
// A generic tuple type indexed by a number exists only when the index type doesn't select a
// fixed element. We simplify to either the combined type of all elements (when the index type
// the actual number type) or to the combined type of all non-fixed elements.
- if (isGenericTupleType(objectType) && indexType.flags & 296 /* NumberLike */) {
- var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing);
+ if (isGenericTupleType(objectType) && indexType.flags & 296 /* TypeFlags.NumberLike */) {
+ var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* TypeFlags.Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing);
if (elementType) {
return type[cache] = elementType;
}
}
- // If the object type is a mapped type { [P in K]: E }, where K is generic, instantiate E using a mapper
- // that substitutes the index type for P. For example, for an index access { [P in K]: Box<T[P]> }[X], we
- // construct the type Box<T[X]>.
+ // If the object type is a mapped type { [P in K]: E }, where K is generic, or { [P in K as N]: E }, where
+ // K is generic and N is assignable to P, instantiate E using a mapper that substitutes the index type for P.
+ // For example, for an index access { [P in K]: Box<T[P]> }[X], we construct the type Box<T[X]>.
if (isGenericMappedType(objectType)) {
- return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); });
+ var nameType = getNameTypeFromMappedType(objectType);
+ if (!nameType || isTypeAssignableTo(nameType, getTypeParameterFromMappedType(objectType))) {
+ return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); });
+ }
}
return type[cache] = type;
}
@@ -61163,19 +62316,19 @@ var ts;
var trueType = getTrueTypeFromConditionalType(type);
var falseType = getFalseTypeFromConditionalType(type);
// Simplifications for types of the form `T extends U ? T : never` and `T extends U ? never : T`.
- if (falseType.flags & 131072 /* Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) {
- if (checkType.flags & 1 /* Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true
+ if (falseType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) {
+ if (checkType.flags & 1 /* TypeFlags.Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true
return getSimplifiedType(trueType, writing);
}
else if (isIntersectionEmpty(checkType, extendsType)) { // Always false
return neverType;
}
}
- else if (trueType.flags & 131072 /* Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) {
- if (!(checkType.flags & 1 /* Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true
+ else if (trueType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) {
+ if (!(checkType.flags & 1 /* TypeFlags.Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true
return neverType;
}
- else if (checkType.flags & 1 /* Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false
+ else if (checkType.flags & 1 /* TypeFlags.Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false
return getSimplifiedType(falseType, writing);
}
}
@@ -61185,7 +62338,7 @@ var ts;
* Invokes union simplification logic to determine if an intersection is considered empty as a union constituent
*/
function isIntersectionEmpty(type1, type2) {
- return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* Never */);
+ return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* TypeFlags.Never */);
}
function substituteIndexedMappedType(objectType, index) {
var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]);
@@ -61193,12 +62346,12 @@ var ts;
return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper);
}
function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) {
- if (accessFlags === void 0) { accessFlags = 0 /* None */; }
+ if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; }
return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType);
}
function indexTypeLessThan(indexType, limit) {
return everyType(indexType, function (t) {
- if (t.flags & 384 /* StringOrNumberLiteral */) {
+ if (t.flags & 384 /* TypeFlags.StringOrNumberLiteral */) {
var propName = getPropertyNameFromType(t);
if (ts.isNumericLiteralName(propName)) {
var index = +propName;
@@ -61209,33 +62362,33 @@ var ts;
});
}
function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) {
- if (accessFlags === void 0) { accessFlags = 0 /* None */; }
+ if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; }
if (objectType === wildcardType || indexType === wildcardType) {
return wildcardType;
}
// If the object type has a string index signature and no other members we know that the result will
// always be the type of that index signature and we can simplify accordingly.
- if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) {
+ if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) {
indexType = stringType;
}
// In noUncheckedIndexedAccess mode, indexed access operations that occur in an expression in a read position and resolve to
// an index signature have 'undefined' included in their type.
- if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* ExpressionPosition */)
- accessFlags |= 1 /* IncludeUndefined */;
+ if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* AccessFlags.ExpressionPosition */)
+ accessFlags |= 1 /* AccessFlags.IncludeUndefined */;
// If the index type is generic, or if the object type is generic and doesn't originate in an expression and
// the operation isn't exclusively indexing the fixed (non-variadic) portion of a tuple type, we are performing
// a higher-order index access where we cannot meaningfully access the properties of the object type. Note that
// for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in an expression. This is to
// preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved
// eagerly using the constraint type of 'this' at the given location.
- if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 193 /* IndexedAccessType */ ?
+ if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 194 /* SyntaxKind.IndexedAccessType */ ?
isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) :
isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) {
- if (objectType.flags & 3 /* AnyOrUnknown */) {
+ if (objectType.flags & 3 /* TypeFlags.AnyOrUnknown */) {
return objectType;
}
// Defer the operation by creating an indexed access type.
- var persistentAccessFlags = accessFlags & 1 /* Persistent */;
+ var persistentAccessFlags = accessFlags & 1 /* AccessFlags.Persistent */;
var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments);
var type = indexedAccessTypes.get(id);
if (!type) {
@@ -61247,12 +62400,12 @@ var ts;
// We treat boolean as different from other unions to improve errors;
// skipping straight to getPropertyTypeForIndexType gives errors with 'boolean' instead of 'true'.
var apparentObjectType = getReducedApparentType(objectType);
- if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 16 /* Boolean */)) {
+ if (indexType.flags & 1048576 /* TypeFlags.Union */ && !(indexType.flags & 16 /* TypeFlags.Boolean */)) {
var propTypes = [];
var wasMissingProp = false;
for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) {
var t = _a[_i];
- var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* SuppressNoImplicitAnyError */ : 0));
+ var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* AccessFlags.SuppressNoImplicitAnyError */ : 0));
if (propType) {
propTypes.push(propType);
}
@@ -61268,11 +62421,11 @@ var ts;
if (wasMissingProp) {
return undefined;
}
- return accessFlags & 4 /* Writing */
+ return accessFlags & 4 /* AccessFlags.Writing */
? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments)
- : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments);
+ : getUnionType(propTypes, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments);
}
- return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */);
+ return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* AccessFlags.CacheSymbol */ | 64 /* AccessFlags.ReportDeprecated */);
}
function getTypeFromIndexedAccessTypeNode(node) {
var links = getNodeLinks(node);
@@ -61280,8 +62433,8 @@ var ts;
var objectType = getTypeFromTypeNode(node.objectType);
var indexType = getTypeFromTypeNode(node.indexType);
var potentialAlias = getAliasSymbolForTypeNode(node);
- var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias));
- links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ &&
+ var resolved = getIndexedAccessType(objectType, indexType, 0 /* AccessFlags.None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias));
+ links.resolvedType = resolved.flags & 8388608 /* TypeFlags.IndexedAccess */ &&
resolved.objectType === objectType &&
resolved.indexType === indexType ?
getConditionalFlowTypeOfType(resolved, node) : resolved;
@@ -61291,7 +62444,7 @@ var ts;
function getTypeFromMappedTypeNode(node) {
var links = getNodeLinks(node);
if (!links.resolvedType) {
- var type = createObjectType(32 /* Mapped */, node.symbol);
+ var type = createObjectType(32 /* ObjectFlags.Mapped */, node.symbol);
type.declaration = node;
type.aliasSymbol = getAliasSymbolForTypeNode(node);
type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol);
@@ -61303,20 +62456,28 @@ var ts;
return links.resolvedType;
}
function getActualTypeVariable(type) {
- if (type.flags & 33554432 /* Substitution */) {
+ if (type.flags & 33554432 /* TypeFlags.Substitution */) {
return type.baseType;
}
- if (type.flags & 8388608 /* IndexedAccess */ && (type.objectType.flags & 33554432 /* Substitution */ ||
- type.indexType.flags & 33554432 /* Substitution */)) {
+ if (type.flags & 8388608 /* TypeFlags.IndexedAccess */ && (type.objectType.flags & 33554432 /* TypeFlags.Substitution */ ||
+ type.indexType.flags & 33554432 /* TypeFlags.Substitution */)) {
return getIndexedAccessType(getActualTypeVariable(type.objectType), getActualTypeVariable(type.indexType));
}
return type;
}
+ function maybeCloneTypeParameter(p) {
+ var constraint = getConstraintOfTypeParameter(p);
+ return constraint && (isGenericObjectType(constraint) || isGenericIndexType(constraint)) ? cloneTypeParameter(p) : p;
+ }
function isTypicalNondistributiveConditional(root) {
return !root.isDistributive && isSingletonTupleType(root.node.checkType) && isSingletonTupleType(root.node.extendsType);
}
function isSingletonTupleType(node) {
- return ts.isTupleTypeNode(node) && ts.length(node.elements) === 1 && !ts.isOptionalTypeNode(node.elements[0]) && !ts.isRestTypeNode(node.elements[0]);
+ return ts.isTupleTypeNode(node) &&
+ ts.length(node.elements) === 1 &&
+ !ts.isOptionalTypeNode(node.elements[0]) &&
+ !ts.isRestTypeNode(node.elements[0]) &&
+ !(ts.isNamedTupleMember(node.elements[0]) && (node.elements[0].questionToken || node.elements[0].dotDotDotToken));
}
/**
* We syntactually check for common nondistributive conditional shapes and unwrap them into
@@ -61330,37 +62491,65 @@ var ts;
var result;
var extraTypes;
var tailCount = 0;
- // We loop here for an immediately nested conditional type in the false position, effectively treating
- // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
- // purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
- // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
- // cases we increment the tail recursion counter and stop after 1000 iterations.
- while (true) {
+ var _loop_18 = function () {
if (tailCount === 1000) {
error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
result = errorType;
- break;
+ return "break";
}
var isUnwrapped = isTypicalNondistributiveConditional(root);
var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper);
var checkTypeInstantiable = isGenericType(checkType);
var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper);
if (checkType === wildcardType || extendsType === wildcardType) {
- return wildcardType;
+ return { value: wildcardType };
}
var combinedMapper = void 0;
if (root.inferTypeParameters) {
- var context = createInferenceContext(root.inferTypeParameters, /*signature*/ undefined, 0 /* None */);
- if (!checkTypeInstantiable) {
+ // When we're looking at making an inference for an infer type, when we get its constraint, it'll automagically be
+ // instantiated with the context, so it doesn't need the mapper for the inference contex - however the constraint
+ // may refer to another _root_, _uncloned_ `infer` type parameter [1], or to something mapped by `mapper` [2].
+ // [1] Eg, if we have `Foo<T, U extends T>` and `Foo<number, infer B>` - `B` is constrained to `T`, which, in turn, has been instantiated
+ // as `number`
+ // Conversely, if we have `Foo<infer A, infer B>`, `B` is still constrained to `T` and `T` is instantiated as `A`
+ // [2] Eg, if we have `Foo<T, U extends T>` and `Foo<Q, infer B>` where `Q` is mapped by `mapper` into `number` - `B` is constrained to `T`
+ // which is in turn instantiated as `Q`, which is in turn instantiated as `number`.
+ // So we need to:
+ // * Clone the type parameters so their constraints can be instantiated in the context of `mapper` (otherwise theyd only get inference context information)
+ // * Set the clones to both map the conditional's enclosing `mapper` and the original params
+ // * instantiate the extends type with the clones
+ // * incorporate all of the component mappers into the combined mapper for the true and false members
+ // This means we have three mappers that need applying:
+ // * The original `mapper` used to create this conditional
+ // * The mapper that maps the old root type parameter to the clone (`freshMapper`)
+ // * The mapper that maps the clone to its inference result (`context.mapper`)
+ var freshParams = ts.sameMap(root.inferTypeParameters, maybeCloneTypeParameter);
+ var freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : undefined;
+ var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* InferenceFlags.None */);
+ if (freshMapper) {
+ var freshCombinedMapper = combineTypeMappers(mapper, freshMapper);
+ for (var _i = 0, freshParams_1 = freshParams; _i < freshParams_1.length; _i++) {
+ var p = freshParams_1[_i];
+ if (root.inferTypeParameters.indexOf(p) === -1) {
+ p.mapper = freshCombinedMapper;
+ }
+ }
+ }
+ // We skip inference of the possible `infer` types unles the `extendsType` _is_ an infer type
+ // if it was, it's trivial to say that extendsType = checkType, however such a pattern is used to
+ // "reset" the type being build up during constraint calculation and avoid making an apparently "infinite" constraint
+ // so in those cases we refain from performing inference and retain the uninfered type parameter
+ if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
// We don't want inferences from constraints as they may cause us to eagerly resolve the
// conditional type instead of deferring resolution. Also, we always want strict function
// types rules (i.e. proper contravariance) for inferences.
- inferTypes(context.inferences, checkType, extendsType, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
+ inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */);
}
+ var innerMapper = combineTypeMappers(freshMapper, context.mapper);
// It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the
// those type parameters are used in type references (see getInferredTypeParameterConstraint). For
// that reason we need context.mapper to be first in the combined mapper. See #42636 for examples.
- combinedMapper = mapper ? combineTypeMappers(context.mapper, mapper) : context.mapper;
+ combinedMapper = mapper ? combineTypeMappers(innerMapper, mapper) : innerMapper;
}
// Instantiate the extends type including inferences for 'infer T' type parameters
var inferredExtendsType = combinedMapper ? instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), combinedMapper) : extendsType;
@@ -61370,44 +62559,44 @@ var ts;
// types with type parameters mapped to the wildcard type, the most permissive instantiations
// possible (the wildcard type is assignable to and from all types). If those are not related,
// then no instantiations will be and we can just return the false branch type.
- if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && ((checkType.flags & 1 /* Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
+ if (!(inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */) && ((checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
// Return union of trueType and falseType for 'any' since it matches anything
- if (checkType.flags & 1 /* Any */ && !isUnwrapped) {
+ if (checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) {
(extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
}
// If falseType is an immediately nested conditional type that isn't distributive or has an
// identical checkType, switch to that type and loop.
var falseType_1 = getTypeFromTypeNode(root.node.falseType);
- if (falseType_1.flags & 16777216 /* Conditional */) {
+ if (falseType_1.flags & 16777216 /* TypeFlags.Conditional */) {
var newRoot = falseType_1.root;
if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
root = newRoot;
- continue;
+ return "continue";
}
if (canTailRecurse(falseType_1, mapper)) {
- continue;
+ return "continue";
}
}
result = instantiateType(falseType_1, mapper);
- break;
+ return "break";
}
// Return trueType for a definitely true extends check. We check instantiations of the two
// types with type parameters mapped to their restrictive form, i.e. a form of the type parameter
// that has no constraint. This ensures that, for example, the type
// type Foo<T extends { x: any }> = T extends { x: string } ? string : number
// doesn't immediately resolve to 'string' instead of being deferred.
- if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) {
+ if (inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) {
var trueType_1 = getTypeFromTypeNode(root.node.trueType);
var trueMapper = combinedMapper || mapper;
if (canTailRecurse(trueType_1, trueMapper)) {
- continue;
+ return "continue";
}
result = instantiateType(trueType_1, trueMapper);
- break;
+ return "break";
}
}
// Return a deferred type for a check that is neither definitely true nor definitely false
- result = createType(16777216 /* Conditional */);
+ result = createType(16777216 /* TypeFlags.Conditional */);
result.root = root;
result.checkType = instantiateType(root.checkType, mapper);
result.extendsType = instantiateType(root.extendsType, mapper);
@@ -61415,7 +62604,19 @@ var ts;
result.combinedMapper = combinedMapper;
result.aliasSymbol = aliasSymbol || root.aliasSymbol;
result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
- break;
+ return "break";
+ };
+ // We loop here for an immediately nested conditional type in the false position, effectively treating
+ // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
+ // purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
+ // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
+ // cases we increment the tail recursion counter and stop after 1000 iterations.
+ while (true) {
+ var state_5 = _loop_18();
+ if (typeof state_5 === "object")
+ return state_5.value;
+ if (state_5 === "break")
+ break;
}
return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
// We tail-recurse for generic conditional types that (a) have not already been evaluated and cached, and
@@ -61423,14 +62624,14 @@ var ts;
// type. Note that recursion is possible only through aliased conditional types, so we only increment the tail
// recursion counter for those.
function canTailRecurse(newType, newMapper) {
- if (newType.flags & 16777216 /* Conditional */ && newMapper) {
+ if (newType.flags & 16777216 /* TypeFlags.Conditional */ && newMapper) {
var newRoot = newType.root;
if (newRoot.outerTypeParameters) {
var typeParamMapper_1 = combineTypeMappers(newType.mapper, newMapper);
var typeArguments = ts.map(newRoot.outerTypeParameters, function (t) { return getMappedType(t, typeParamMapper_1); });
var newRootMapper = createTypeMapper(newRoot.outerTypeParameters, typeArguments);
var newCheckType = newRoot.isDistributive ? getMappedType(newRoot.checkType, newRootMapper) : undefined;
- if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* Union */ | 131072 /* Never */))) {
+ if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */))) {
root = newRoot;
mapper = newRootMapper;
aliasSymbol = undefined;
@@ -61458,7 +62659,7 @@ var ts;
var result;
if (node.locals) {
node.locals.forEach(function (symbol) {
- if (symbol.flags & 262144 /* TypeParameter */) {
+ if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) {
result = ts.append(result, getDeclaredTypeOfSymbol(symbol));
}
});
@@ -61481,7 +62682,7 @@ var ts;
node: node,
checkType: checkType,
extendsType: getTypeFromTypeNode(node.extendsType),
- isDistributive: !!(checkType.flags & 262144 /* TypeParameter */),
+ isDistributive: !!(checkType.flags & 262144 /* TypeFlags.TypeParameter */),
inferTypeParameters: getInferTypeParameters(node),
outerTypeParameters: outerTypeParameters,
instantiations: undefined,
@@ -61524,7 +62725,7 @@ var ts;
links.resolvedSymbol = unknownSymbol;
return links.resolvedType = errorType;
}
- var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 4194304 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */;
+ var targetMeaning = node.isTypeOf ? 111551 /* SymbolFlags.Value */ : node.flags & 8388608 /* NodeFlags.JSDoc */ ? 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ : 788968 /* SymbolFlags.Type */;
// TODO: Future work: support unions/generics/whatever via a deferred import-type
var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal);
if (!innerModuleSymbol) {
@@ -61537,7 +62738,7 @@ var ts;
var currentNamespace = moduleSymbol;
var current = void 0;
while (current = nameStack.shift()) {
- var meaning = nameStack.length ? 1920 /* Namespace */ : targetMeaning;
+ var meaning = nameStack.length ? 1920 /* SymbolFlags.Namespace */ : targetMeaning;
// typeof a.b.c is normally resolved using `checkExpression` which in turn defers to `checkQualifiedName`
// That, in turn, ultimately uses `getPropertyOfType` on the type of the symbol, which differs slightly from
// the `exports` lookup process that only looks up namespace members which is used for most type references
@@ -61560,7 +62761,7 @@ var ts;
links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning);
}
else {
- var errorMessage = targetMeaning === 111551 /* Value */
+ var errorMessage = targetMeaning === 111551 /* SymbolFlags.Value */
? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here
: ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0;
error(node, errorMessage, node.argument.literal.text);
@@ -61574,7 +62775,7 @@ var ts;
function resolveImportSymbolType(node, links, symbol, meaning) {
var resolvedSymbol = resolveSymbol(symbol);
links.resolvedSymbol = resolvedSymbol;
- if (meaning === 111551 /* Value */) {
+ if (meaning === 111551 /* SymbolFlags.Value */) {
return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias
}
else {
@@ -61590,7 +62791,7 @@ var ts;
links.resolvedType = emptyTypeLiteralType;
}
else {
- var type = createObjectType(16 /* Anonymous */, node.symbol);
+ var type = createObjectType(16 /* ObjectFlags.Anonymous */, node.symbol);
type.aliasSymbol = aliasSymbol;
type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
if (ts.isJSDocTypeLiteral(node) && node.isArrayType) {
@@ -61603,7 +62804,7 @@ var ts;
}
function getAliasSymbolForTypeNode(node) {
var host = node.parent;
- while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 144 /* ReadonlyKeyword */) {
+ while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 145 /* SyntaxKind.ReadonlyKeyword */) {
host = host.parent;
}
return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined;
@@ -61612,13 +62813,13 @@ var ts;
return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined;
}
function isNonGenericObjectType(type) {
- return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type);
+ return !!(type.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(type);
}
function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) {
- return isEmptyObjectType(type) || !!(type.flags & (65536 /* Null */ | 32768 /* Undefined */ | 528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */));
+ return isEmptyObjectType(type) || !!(type.flags & (65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */ | 528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */));
}
function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) {
- if (!(type.flags & 1048576 /* Union */)) {
+ if (!(type.flags & 1048576 /* TypeFlags.Union */)) {
return type;
}
if (ts.every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) {
@@ -61638,13 +62839,13 @@ var ts;
var members = ts.createSymbolTable();
for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
var prop = _a[_i];
- if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) {
+ if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) {
// do nothing, skip privates
}
else if (isSpreadableProperty(prop)) {
- var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */);
- var flags = 4 /* Property */ | 16777216 /* Optional */;
- var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0));
+ var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */);
+ var flags = 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */;
+ var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0));
result.type = isSetonlyAccessor ? undefinedType : addOptionality(getTypeOfSymbol(prop), /*isProperty*/ true);
result.declarations = prop.declarations;
result.nameType = getSymbolLinks(prop).nameType;
@@ -61653,7 +62854,7 @@ var ts;
}
}
var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(type));
- spread.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */;
+ spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */;
return spread;
}
}
@@ -61663,31 +62864,31 @@ var ts;
* and right = the new element to be spread.
*/
function getSpreadType(left, right, symbol, objectFlags, readonly) {
- if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) {
+ if (left.flags & 1 /* TypeFlags.Any */ || right.flags & 1 /* TypeFlags.Any */) {
return anyType;
}
- if (left.flags & 2 /* Unknown */ || right.flags & 2 /* Unknown */) {
+ if (left.flags & 2 /* TypeFlags.Unknown */ || right.flags & 2 /* TypeFlags.Unknown */) {
return unknownType;
}
- if (left.flags & 131072 /* Never */) {
+ if (left.flags & 131072 /* TypeFlags.Never */) {
return right;
}
- if (right.flags & 131072 /* Never */) {
+ if (right.flags & 131072 /* TypeFlags.Never */) {
return left;
}
left = tryMergeUnionOfObjectTypeAndEmptyObject(left, readonly);
- if (left.flags & 1048576 /* Union */) {
+ if (left.flags & 1048576 /* TypeFlags.Union */) {
return checkCrossProductUnion([left, right])
? mapType(left, function (t) { return getSpreadType(t, right, symbol, objectFlags, readonly); })
: errorType;
}
right = tryMergeUnionOfObjectTypeAndEmptyObject(right, readonly);
- if (right.flags & 1048576 /* Union */) {
+ if (right.flags & 1048576 /* TypeFlags.Union */) {
return checkCrossProductUnion([left, right])
? mapType(right, function (t) { return getSpreadType(left, t, symbol, objectFlags, readonly); })
: errorType;
}
- if (right.flags & (528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) {
+ if (right.flags & (528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)) {
return left;
}
if (isGenericObjectType(left) || isGenericObjectType(right)) {
@@ -61697,7 +62898,7 @@ var ts;
// When the left type is an intersection, we may need to merge the last constituent of the
// intersection with the right type. For example when the left type is 'T & { a: string }'
// and the right type is '{ b: string }' we produce 'T & { a: string, b: string }'.
- if (left.flags & 2097152 /* Intersection */) {
+ if (left.flags & 2097152 /* TypeFlags.Intersection */) {
var types = left.types;
var lastLeft = types[types.length - 1];
if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) {
@@ -61711,7 +62912,7 @@ var ts;
var indexInfos = left === emptyObjectType ? getIndexInfosOfType(right) : getUnionIndexInfos([left, right]);
for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) {
var rightProp = _a[_i];
- if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* Private */ | 16 /* Protected */)) {
+ if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) {
skippedPrivateMembers.add(rightProp.escapedName);
}
else if (isSpreadableProperty(rightProp)) {
@@ -61726,11 +62927,11 @@ var ts;
if (members.has(leftProp.escapedName)) {
var rightProp = members.get(leftProp.escapedName);
var rightType = getTypeOfSymbol(rightProp);
- if (rightProp.flags & 16777216 /* Optional */) {
+ if (rightProp.flags & 16777216 /* SymbolFlags.Optional */) {
var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations);
- var flags = 4 /* Property */ | (leftProp.flags & 16777216 /* Optional */);
+ var flags = 4 /* SymbolFlags.Property */ | (leftProp.flags & 16777216 /* SymbolFlags.Optional */);
var result = createSymbol(flags, leftProp.escapedName);
- result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* Subtype */);
+ result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* UnionReduction.Subtype */);
result.leftSpread = leftProp;
result.rightSpread = rightProp;
result.declarations = declarations;
@@ -61743,23 +62944,23 @@ var ts;
}
}
var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(indexInfos, function (info) { return getIndexInfoWithReadonly(info, readonly); }));
- spread.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */ | 4194304 /* ContainsSpread */ | objectFlags;
+ spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */ | 2097152 /* ObjectFlags.ContainsSpread */ | objectFlags;
return spread;
}
/** We approximate own properties as non-methods plus methods that are inside the object literal */
function isSpreadableProperty(prop) {
var _a;
return !ts.some(prop.declarations, ts.isPrivateIdentifierClassElementDeclaration) &&
- (!(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) ||
+ (!(prop.flags & (8192 /* SymbolFlags.Method */ | 32768 /* SymbolFlags.GetAccessor */ | 65536 /* SymbolFlags.SetAccessor */)) ||
!((_a = prop.declarations) === null || _a === void 0 ? void 0 : _a.some(function (decl) { return ts.isClassLike(decl.parent); })));
}
function getSpreadSymbol(prop, readonly) {
- var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */);
+ var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */);
if (!isSetonlyAccessor && readonly === isReadonlySymbol(prop)) {
return prop;
}
- var flags = 4 /* Property */ | (prop.flags & 16777216 /* Optional */);
- var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0));
+ var flags = 4 /* SymbolFlags.Property */ | (prop.flags & 16777216 /* SymbolFlags.Optional */);
+ var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0));
result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop);
result.declarations = prop.declarations;
result.nameType = getSymbolLinks(prop).nameType;
@@ -61777,7 +62978,7 @@ var ts;
return type;
}
function getFreshTypeOfLiteralType(type) {
- if (type.flags & 2944 /* Literal */) {
+ if (type.flags & 2944 /* TypeFlags.Literal */) {
if (!type.freshType) {
var freshType = createLiteralType(type.flags, type.value, type.symbol, type);
freshType.freshType = freshType;
@@ -61788,39 +62989,39 @@ var ts;
return type;
}
function getRegularTypeOfLiteralType(type) {
- return type.flags & 2944 /* Literal */ ? type.regularType :
- type.flags & 1048576 /* Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) :
+ return type.flags & 2944 /* TypeFlags.Literal */ ? type.regularType :
+ type.flags & 1048576 /* TypeFlags.Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) :
type;
}
function isFreshLiteralType(type) {
- return !!(type.flags & 2944 /* Literal */) && type.freshType === type;
+ return !!(type.flags & 2944 /* TypeFlags.Literal */) && type.freshType === type;
}
function getStringLiteralType(value) {
var type;
return stringLiteralTypes.get(value) ||
- (stringLiteralTypes.set(value, type = createLiteralType(128 /* StringLiteral */, value)), type);
+ (stringLiteralTypes.set(value, type = createLiteralType(128 /* TypeFlags.StringLiteral */, value)), type);
}
function getNumberLiteralType(value) {
var type;
return numberLiteralTypes.get(value) ||
- (numberLiteralTypes.set(value, type = createLiteralType(256 /* NumberLiteral */, value)), type);
+ (numberLiteralTypes.set(value, type = createLiteralType(256 /* TypeFlags.NumberLiteral */, value)), type);
}
function getBigIntLiteralType(value) {
var type;
var key = ts.pseudoBigIntToString(value);
return bigIntLiteralTypes.get(key) ||
- (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* BigIntLiteral */, value)), type);
+ (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* TypeFlags.BigIntLiteral */, value)), type);
}
function getEnumLiteralType(value, enumId, symbol) {
var type;
var qualifier = typeof value === "string" ? "@" : "#";
var key = enumId + qualifier + value;
- var flags = 1024 /* EnumLiteral */ | (typeof value === "string" ? 128 /* StringLiteral */ : 256 /* NumberLiteral */);
+ var flags = 1024 /* TypeFlags.EnumLiteral */ | (typeof value === "string" ? 128 /* TypeFlags.StringLiteral */ : 256 /* TypeFlags.NumberLiteral */);
return enumLiteralTypes.get(key) ||
(enumLiteralTypes.set(key, type = createLiteralType(flags, value, symbol)), type);
}
function getTypeFromLiteralTypeNode(node) {
- if (node.literal.kind === 104 /* NullKeyword */) {
+ if (node.literal.kind === 104 /* SyntaxKind.NullKeyword */) {
return nullType;
}
var links = getNodeLinks(node);
@@ -61830,36 +63031,38 @@ var ts;
return links.resolvedType;
}
function createUniqueESSymbolType(symbol) {
- var type = createType(8192 /* UniqueESSymbol */);
+ var type = createType(8192 /* TypeFlags.UniqueESSymbol */);
type.symbol = symbol;
type.escapedName = "__@".concat(type.symbol.escapedName, "@").concat(getSymbolId(type.symbol));
return type;
}
function getESSymbolLikeTypeForNode(node) {
if (ts.isValidESSymbolDeclaration(node)) {
- var symbol = getSymbolOfNode(node);
- var links = getSymbolLinks(symbol);
- return links.uniqueESSymbolType || (links.uniqueESSymbolType = createUniqueESSymbolType(symbol));
+ var symbol = ts.isCommonJsExportPropertyAssignment(node) ? getSymbolOfNode(node.left) : getSymbolOfNode(node);
+ if (symbol) {
+ var links = getSymbolLinks(symbol);
+ return links.uniqueESSymbolType || (links.uniqueESSymbolType = createUniqueESSymbolType(symbol));
+ }
}
return esSymbolType;
}
function getThisType(node) {
var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false);
var parent = container && container.parent;
- if (parent && (ts.isClassLike(parent) || parent.kind === 257 /* InterfaceDeclaration */)) {
+ if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */)) {
if (!ts.isStatic(container) &&
(!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) {
return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType;
}
}
// inside x.prototype = { ... }
- if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) {
+ if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) {
return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType;
}
// /** @return {this} */
// x.prototype.m = function() { ... }
- var host = node.flags & 4194304 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined;
- if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) {
+ var host = node.flags & 8388608 /* NodeFlags.JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined;
+ if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) {
return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType;
}
// inside constructor function C() { ... }
@@ -61881,17 +63084,17 @@ var ts;
}
function getArrayElementTypeNode(node) {
switch (node.kind) {
- case 190 /* ParenthesizedType */:
+ case 191 /* SyntaxKind.ParenthesizedType */:
return getArrayElementTypeNode(node.type);
- case 183 /* TupleType */:
+ case 184 /* SyntaxKind.TupleType */:
if (node.elements.length === 1) {
node = node.elements[0];
- if (node.kind === 185 /* RestType */ || node.kind === 196 /* NamedTupleMember */ && node.dotDotDotToken) {
+ if (node.kind === 186 /* SyntaxKind.RestType */ || node.kind === 197 /* SyntaxKind.NamedTupleMember */ && node.dotDotDotToken) {
return getArrayElementTypeNode(node.type);
}
}
break;
- case 182 /* ArrayType */:
+ case 183 /* SyntaxKind.ArrayType */:
return node.elementType;
}
return undefined;
@@ -61907,99 +63110,99 @@ var ts;
}
function getTypeFromTypeNodeWorker(node) {
switch (node.kind) {
- case 130 /* AnyKeyword */:
- case 310 /* JSDocAllType */:
- case 311 /* JSDocUnknownType */:
+ case 130 /* SyntaxKind.AnyKeyword */:
+ case 312 /* SyntaxKind.JSDocAllType */:
+ case 313 /* SyntaxKind.JSDocUnknownType */:
return anyType;
- case 154 /* UnknownKeyword */:
+ case 155 /* SyntaxKind.UnknownKeyword */:
return unknownType;
- case 149 /* StringKeyword */:
+ case 150 /* SyntaxKind.StringKeyword */:
return stringType;
- case 146 /* NumberKeyword */:
+ case 147 /* SyntaxKind.NumberKeyword */:
return numberType;
- case 157 /* BigIntKeyword */:
+ case 158 /* SyntaxKind.BigIntKeyword */:
return bigintType;
- case 133 /* BooleanKeyword */:
+ case 133 /* SyntaxKind.BooleanKeyword */:
return booleanType;
- case 150 /* SymbolKeyword */:
+ case 151 /* SyntaxKind.SymbolKeyword */:
return esSymbolType;
- case 114 /* VoidKeyword */:
+ case 114 /* SyntaxKind.VoidKeyword */:
return voidType;
- case 152 /* UndefinedKeyword */:
+ case 153 /* SyntaxKind.UndefinedKeyword */:
return undefinedType;
- case 104 /* NullKeyword */:
+ case 104 /* SyntaxKind.NullKeyword */:
// TODO(rbuckton): `NullKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service.
return nullType;
- case 143 /* NeverKeyword */:
+ case 143 /* SyntaxKind.NeverKeyword */:
return neverType;
- case 147 /* ObjectKeyword */:
- return node.flags & 131072 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType;
- case 138 /* IntrinsicKeyword */:
+ case 148 /* SyntaxKind.ObjectKeyword */:
+ return node.flags & 262144 /* NodeFlags.JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType;
+ case 138 /* SyntaxKind.IntrinsicKeyword */:
return intrinsicMarkerType;
- case 191 /* ThisType */:
- case 108 /* ThisKeyword */:
+ case 192 /* SyntaxKind.ThisType */:
+ case 108 /* SyntaxKind.ThisKeyword */:
// TODO(rbuckton): `ThisKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service and because of `isPartOfTypeNode`.
return getTypeFromThisTypeNode(node);
- case 195 /* LiteralType */:
+ case 196 /* SyntaxKind.LiteralType */:
return getTypeFromLiteralTypeNode(node);
- case 177 /* TypeReference */:
+ case 178 /* SyntaxKind.TypeReference */:
return getTypeFromTypeReference(node);
- case 176 /* TypePredicate */:
+ case 177 /* SyntaxKind.TypePredicate */:
return node.assertsModifier ? voidType : booleanType;
- case 227 /* ExpressionWithTypeArguments */:
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
return getTypeFromTypeReference(node);
- case 180 /* TypeQuery */:
+ case 181 /* SyntaxKind.TypeQuery */:
return getTypeFromTypeQueryNode(node);
- case 182 /* ArrayType */:
- case 183 /* TupleType */:
+ case 183 /* SyntaxKind.ArrayType */:
+ case 184 /* SyntaxKind.TupleType */:
return getTypeFromArrayOrTupleTypeNode(node);
- case 184 /* OptionalType */:
+ case 185 /* SyntaxKind.OptionalType */:
return getTypeFromOptionalTypeNode(node);
- case 186 /* UnionType */:
+ case 187 /* SyntaxKind.UnionType */:
return getTypeFromUnionTypeNode(node);
- case 187 /* IntersectionType */:
+ case 188 /* SyntaxKind.IntersectionType */:
return getTypeFromIntersectionTypeNode(node);
- case 312 /* JSDocNullableType */:
+ case 314 /* SyntaxKind.JSDocNullableType */:
return getTypeFromJSDocNullableTypeNode(node);
- case 314 /* JSDocOptionalType */:
+ case 316 /* SyntaxKind.JSDocOptionalType */:
return addOptionality(getTypeFromTypeNode(node.type));
- case 196 /* NamedTupleMember */:
+ case 197 /* SyntaxKind.NamedTupleMember */:
return getTypeFromNamedTupleTypeNode(node);
- case 190 /* ParenthesizedType */:
- case 313 /* JSDocNonNullableType */:
- case 307 /* JSDocTypeExpression */:
+ case 191 /* SyntaxKind.ParenthesizedType */:
+ case 315 /* SyntaxKind.JSDocNonNullableType */:
+ case 309 /* SyntaxKind.JSDocTypeExpression */:
return getTypeFromTypeNode(node.type);
- case 185 /* RestType */:
+ case 186 /* SyntaxKind.RestType */:
return getTypeFromRestTypeNode(node);
- case 316 /* JSDocVariadicType */:
+ case 318 /* SyntaxKind.JSDocVariadicType */:
return getTypeFromJSDocVariadicType(node);
- case 178 /* FunctionType */:
- case 179 /* ConstructorType */:
- case 181 /* TypeLiteral */:
- case 320 /* JSDocTypeLiteral */:
- case 315 /* JSDocFunctionType */:
- case 321 /* JSDocSignature */:
+ case 179 /* SyntaxKind.FunctionType */:
+ case 180 /* SyntaxKind.ConstructorType */:
+ case 182 /* SyntaxKind.TypeLiteral */:
+ case 322 /* SyntaxKind.JSDocTypeLiteral */:
+ case 317 /* SyntaxKind.JSDocFunctionType */:
+ case 323 /* SyntaxKind.JSDocSignature */:
return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
- case 192 /* TypeOperator */:
+ case 193 /* SyntaxKind.TypeOperator */:
return getTypeFromTypeOperatorNode(node);
- case 193 /* IndexedAccessType */:
+ case 194 /* SyntaxKind.IndexedAccessType */:
return getTypeFromIndexedAccessTypeNode(node);
- case 194 /* MappedType */:
+ case 195 /* SyntaxKind.MappedType */:
return getTypeFromMappedTypeNode(node);
- case 188 /* ConditionalType */:
+ case 189 /* SyntaxKind.ConditionalType */:
return getTypeFromConditionalTypeNode(node);
- case 189 /* InferType */:
+ case 190 /* SyntaxKind.InferType */:
return getTypeFromInferTypeNode(node);
- case 197 /* TemplateLiteralType */:
+ case 198 /* SyntaxKind.TemplateLiteralType */:
return getTypeFromTemplateTypeNode(node);
- case 199 /* ImportType */:
+ case 200 /* SyntaxKind.ImportType */:
return getTypeFromImportTypeNode(node);
// This function assumes that an identifier, qualified name, or property access expression is a type expression
// Callers should first ensure this by calling `isPartOfTypeNode`
// TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s.
- case 79 /* Identifier */:
- case 160 /* QualifiedName */:
- case 205 /* PropertyAccessExpression */:
+ case 79 /* SyntaxKind.Identifier */:
+ case 161 /* SyntaxKind.QualifiedName */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
var symbol = getSymbolAtLocation(node);
return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
default:
@@ -62037,9 +63240,9 @@ var ts;
}
function getMappedType(type, mapper) {
switch (mapper.kind) {
- case 0 /* Simple */:
+ case 0 /* TypeMapKind.Simple */:
return type === mapper.source ? mapper.target : type;
- case 1 /* Array */:
+ case 1 /* TypeMapKind.Array */:
var sources = mapper.sources;
var targets = mapper.targets;
for (var i = 0; i < sources.length; i++) {
@@ -62048,22 +63251,22 @@ var ts;
}
}
return type;
- case 2 /* Function */:
+ case 2 /* TypeMapKind.Function */:
return mapper.func(type);
- case 3 /* Composite */:
- case 4 /* Merged */:
+ case 3 /* TypeMapKind.Composite */:
+ case 4 /* TypeMapKind.Merged */:
var t1 = getMappedType(type, mapper.mapper1);
- return t1 !== type && mapper.kind === 3 /* Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2);
+ return t1 !== type && mapper.kind === 3 /* TypeMapKind.Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2);
}
}
function makeUnaryTypeMapper(source, target) {
- return { kind: 0 /* Simple */, source: source, target: target };
+ return { kind: 0 /* TypeMapKind.Simple */, source: source, target: target };
}
function makeArrayTypeMapper(sources, targets) {
- return { kind: 1 /* Array */, sources: sources, targets: targets };
+ return { kind: 1 /* TypeMapKind.Array */, sources: sources, targets: targets };
}
function makeFunctionTypeMapper(func) {
- return { kind: 2 /* Function */, func: func };
+ return { kind: 2 /* TypeMapKind.Function */, func: func };
}
function makeCompositeTypeMapper(kind, mapper1, mapper2) {
return { kind: kind, mapper1: mapper1, mapper2: mapper2 };
@@ -62079,16 +63282,16 @@ var ts;
return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; });
}
function combineTypeMappers(mapper1, mapper2) {
- return mapper1 ? makeCompositeTypeMapper(3 /* Composite */, mapper1, mapper2) : mapper2;
+ return mapper1 ? makeCompositeTypeMapper(3 /* TypeMapKind.Composite */, mapper1, mapper2) : mapper2;
}
function mergeTypeMappers(mapper1, mapper2) {
- return mapper1 ? makeCompositeTypeMapper(4 /* Merged */, mapper1, mapper2) : mapper2;
+ return mapper1 ? makeCompositeTypeMapper(4 /* TypeMapKind.Merged */, mapper1, mapper2) : mapper2;
}
function prependTypeMapping(source, target, mapper) {
- return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, makeUnaryTypeMapper(source, target), mapper);
+ return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* TypeMapKind.Merged */, makeUnaryTypeMapper(source, target), mapper);
}
function appendTypeMapping(mapper, source, target) {
- return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, mapper, makeUnaryTypeMapper(source, target));
+ return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* TypeMapKind.Merged */, mapper, makeUnaryTypeMapper(source, target));
}
function getRestrictiveTypeParameter(tp) {
return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol),
@@ -62121,7 +63324,7 @@ var ts;
// See GH#17600.
var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol),
/*resolvedReturnType*/ undefined,
- /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* PropagatingFlags */);
+ /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* SignatureFlags.PropagatingFlags */);
result.target = signature;
result.mapper = mapper;
return result;
@@ -62133,7 +63336,7 @@ var ts;
// be affected by instantiation, simply return the symbol itself.
return symbol;
}
- if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) {
+ if (ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) {
// If symbol being instantiated is itself a instantiation, fetch the original target and combine the
// type mappers. This ensures that original type identities are properly preserved and that aliases
// always reference a non-aliases.
@@ -62142,7 +63345,7 @@ var ts;
}
// Keep the flags from the symbol we're instantiating. Mark that is instantiated, and
// also transient so that we can just store data on it directly.
- var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | ts.getCheckFlags(symbol) & (8 /* Readonly */ | 4096 /* Late */ | 16384 /* OptionalParameter */ | 32768 /* RestParameter */));
+ var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* CheckFlags.Instantiated */ | ts.getCheckFlags(symbol) & (8 /* CheckFlags.Readonly */ | 4096 /* CheckFlags.Late */ | 16384 /* CheckFlags.OptionalParameter */ | 32768 /* CheckFlags.RestParameter */));
result.declarations = symbol.declarations;
result.parent = symbol.parent;
result.target = symbol;
@@ -62156,10 +63359,12 @@ var ts;
return result;
}
function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
- var declaration = type.objectFlags & 4 /* Reference */ ? type.node : type.symbol.declarations[0];
+ var declaration = type.objectFlags & 4 /* ObjectFlags.Reference */ ? type.node :
+ type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */ ? type.node :
+ type.symbol.declarations[0];
var links = getNodeLinks(declaration);
- var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType :
- type.objectFlags & 64 /* Instantiated */ ? type.target : type;
+ var target = type.objectFlags & 4 /* ObjectFlags.Reference */ ? links.resolvedType :
+ type.objectFlags & 64 /* ObjectFlags.Instantiated */ ? type.target : type;
var typeParameters = links.outerTypeParameters;
if (!typeParameters) {
// The first time an anonymous type is instantiated we compute and store a list of the type
@@ -62172,8 +63377,8 @@ var ts;
outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters);
}
typeParameters = outerTypeParameters || ts.emptyArray;
- var allDeclarations_1 = type.objectFlags & 4 /* Reference */ ? [declaration] : type.symbol.declarations;
- typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ?
+ var allDeclarations_1 = type.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) ? [declaration] : type.symbol.declarations;
+ typeParameters = (target.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) || target.symbol.flags & 8192 /* SymbolFlags.Method */ || target.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) && !target.aliasTypeArguments ?
ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) :
typeParameters;
links.outerTypeParameters = typeParameters;
@@ -62194,8 +63399,8 @@ var ts;
var result = target.instantiations.get(id);
if (!result) {
var newMapper = createTypeMapper(typeParameters, typeArguments);
- result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) :
- target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) :
+ result = target.objectFlags & 4 /* ObjectFlags.Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) :
+ target.objectFlags & 32 /* ObjectFlags.Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) :
instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
target.instantiations.set(id, result);
}
@@ -62204,8 +63409,8 @@ var ts;
return type;
}
function maybeTypeParameterReference(node) {
- return !(node.parent.kind === 177 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName ||
- node.parent.kind === 199 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier);
+ return !(node.parent.kind === 178 /* SyntaxKind.TypeReference */ && node.parent.typeArguments && node === node.parent.typeName ||
+ node.parent.kind === 200 /* SyntaxKind.ImportType */ && node.parent.typeArguments && node === node.parent.qualifier);
}
function isTypeParameterPossiblyReferenced(tp, node) {
// If the type parameter doesn't have exactly one declaration, if there are invening statement blocks
@@ -62214,7 +63419,7 @@ var ts;
if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) {
var container = tp.symbol.declarations[0].parent;
for (var n = node; n !== container; n = n.parent) {
- if (!n || n.kind === 234 /* Block */ || n.kind === 188 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) {
+ if (!n || n.kind === 235 /* SyntaxKind.Block */ || n.kind === 189 /* SyntaxKind.ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) {
return true;
}
}
@@ -62223,15 +63428,15 @@ var ts;
return true;
function containsReference(node) {
switch (node.kind) {
- case 191 /* ThisType */:
+ case 192 /* SyntaxKind.ThisType */:
return !!tp.isThisType;
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) &&
getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality
- case 180 /* TypeQuery */:
+ case 181 /* SyntaxKind.TypeQuery */:
return true;
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
return !node.type && !!node.body ||
ts.some(node.typeParameters, containsReference) ||
ts.some(node.parameters, containsReference) ||
@@ -62242,9 +63447,9 @@ var ts;
}
function getHomomorphicTypeVariable(type) {
var constraintType = getConstraintTypeFromMappedType(type);
- if (constraintType.flags & 4194304 /* Index */) {
+ if (constraintType.flags & 4194304 /* TypeFlags.Index */) {
var typeVariable = getActualTypeVariable(constraintType.type);
- if (typeVariable.flags & 262144 /* TypeParameter */) {
+ if (typeVariable.flags & 262144 /* TypeFlags.TypeParameter */) {
return typeVariable;
}
}
@@ -62266,11 +63471,11 @@ var ts;
var mappedTypeVariable = instantiateType(typeVariable, mapper);
if (typeVariable !== mappedTypeVariable) {
return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) {
- if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
+ if (t.flags & (3 /* TypeFlags.AnyOrUnknown */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && t !== wildcardType && !isErrorType(t)) {
if (!type.declaration.nameType) {
var constraint = void 0;
- if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 &&
- (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
+ if (isArrayType(t) || t.flags & 1 /* TypeFlags.Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */) < 0 &&
+ (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
}
if (isGenericTupleType(t)) {
@@ -62290,7 +63495,7 @@ var ts;
return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments);
}
function getModifiedReadonlyState(state, modifiers) {
- return modifiers & 1 /* IncludeReadonly */ ? true : modifiers & 2 /* ExcludeReadonly */ ? false : state;
+ return modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? true : modifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */ ? false : state;
}
function instantiateMappedGenericTupleType(tupleType, mappedType, typeVariable, mapper) {
// When a tuple type is generic (i.e. when it contains variadic elements), we want to eagerly map the
@@ -62299,14 +63504,14 @@ var ts;
// normalization to resolve the non-generic parts of the resulting tuple.
var elementFlags = tupleType.target.elementFlags;
var elementTypes = ts.map(getTypeArguments(tupleType), function (t, i) {
- var singleton = elementFlags[i] & 8 /* Variadic */ ? t :
- elementFlags[i] & 4 /* Rest */ ? createArrayType(t) :
+ var singleton = elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t :
+ elementFlags[i] & 4 /* ElementFlags.Rest */ ? createArrayType(t) :
createTupleType([t], [elementFlags[i]]);
// The singleton is never a generic tuple type, so it is safe to recurse here.
return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper));
});
var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, getMappedTypeModifiers(mappedType));
- return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* Variadic */; }), newReadonly);
+ return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* ElementFlags.Variadic */; }), newReadonly);
}
function instantiateMappedArrayType(arrayType, mappedType, mapper) {
var elementType = instantiateMappedTypeTemplate(mappedType, numberType, /*isOptional*/ true, mapper);
@@ -62316,11 +63521,11 @@ var ts;
function instantiateMappedTupleType(tupleType, mappedType, mapper) {
var elementFlags = tupleType.target.elementFlags;
var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) {
- return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* Optional */), mapper);
+ return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* ElementFlags.Optional */), mapper);
});
var modifiers = getMappedTypeModifiers(mappedType);
- var newTupleModifiers = modifiers & 4 /* IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? 2 /* Optional */ : f; }) :
- modifiers & 8 /* ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) :
+ var newTupleModifiers = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? 2 /* ElementFlags.Optional */ : f; }) :
+ modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) :
elementFlags;
var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers);
return ts.contains(elementTypes, errorType) ? errorType :
@@ -62330,13 +63535,13 @@ var ts;
var templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key);
var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper);
var modifiers = getMappedTypeModifiers(type);
- return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) :
- strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) :
+ return strictNullChecks && modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) :
+ strictNullChecks && modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */) :
propType;
}
function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) {
- var result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol);
- if (type.objectFlags & 32 /* Mapped */) {
+ var result = createObjectType(type.objectFlags | 64 /* ObjectFlags.Instantiated */, type.symbol);
+ if (type.objectFlags & 32 /* ObjectFlags.Mapped */) {
result.declaration = type.declaration;
// C.f. instantiateSignature
var origTypeParameter = getTypeParameterFromMappedType(type);
@@ -62345,6 +63550,9 @@ var ts;
mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper);
freshTypeParameter.mapper = mapper;
}
+ if (type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */) {
+ result.node = type.node;
+ }
result.target = type;
result.mapper = mapper;
result.aliasSymbol = aliasSymbol || type.aliasSymbol;
@@ -62367,8 +63575,8 @@ var ts;
// Distributive conditional types are distributed over union types. For example, when the
// distributive conditional type T extends U ? X : Y is instantiated with A | B for T, the
// result is (A extends U ? X : Y) | (B extends U ? X : Y).
- result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ?
- mapTypeWithAlias(distributionType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments) :
+ result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ?
+ mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments) :
getConditionalType(root, newMapper_1, aliasSymbol, aliasTypeArguments);
root.instantiations.set(id, result);
}
@@ -62387,7 +63595,7 @@ var ts;
// We have reached 100 recursive type instantiations, or 5M type instantiations caused by the same statement
// or expression. There is a very high likelyhood we're dealing with a combination of infinite generic types
// that perpetually generate new type identities, so we stop the recursion here by yielding the error type.
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount });
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount });
error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
return errorType;
}
@@ -62400,62 +63608,62 @@ var ts;
}
function instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments) {
var flags = type.flags;
- if (flags & 262144 /* TypeParameter */) {
+ if (flags & 262144 /* TypeFlags.TypeParameter */) {
return getMappedType(type, mapper);
}
- if (flags & 524288 /* Object */) {
+ if (flags & 524288 /* TypeFlags.Object */) {
var objectFlags = type.objectFlags;
- if (objectFlags & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */)) {
- if (objectFlags & 4 /* Reference */ && !type.node) {
+ if (objectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) {
+ if (objectFlags & 4 /* ObjectFlags.Reference */ && !type.node) {
var resolvedTypeArguments = type.resolvedTypeArguments;
var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper);
return newTypeArguments !== resolvedTypeArguments ? createNormalizedTypeReference(type.target, newTypeArguments) : type;
}
- if (objectFlags & 1024 /* ReverseMapped */) {
+ if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) {
return instantiateReverseMappedType(type, mapper);
}
return getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments);
}
return type;
}
- if (flags & 3145728 /* UnionOrIntersection */) {
- var origin = type.flags & 1048576 /* Union */ ? type.origin : undefined;
- var types = origin && origin.flags & 3145728 /* UnionOrIntersection */ ? origin.types : type.types;
+ if (flags & 3145728 /* TypeFlags.UnionOrIntersection */) {
+ var origin = type.flags & 1048576 /* TypeFlags.Union */ ? type.origin : undefined;
+ var types = origin && origin.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? origin.types : type.types;
var newTypes = instantiateTypes(types, mapper);
if (newTypes === types && aliasSymbol === type.aliasSymbol) {
return type;
}
var newAliasSymbol = aliasSymbol || type.aliasSymbol;
var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
- return flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ?
+ return flags & 2097152 /* TypeFlags.Intersection */ || origin && origin.flags & 2097152 /* TypeFlags.Intersection */ ?
getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) :
- getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments);
+ getUnionType(newTypes, 1 /* UnionReduction.Literal */, newAliasSymbol, newAliasTypeArguments);
}
- if (flags & 4194304 /* Index */) {
+ if (flags & 4194304 /* TypeFlags.Index */) {
return getIndexType(instantiateType(type.type, mapper));
}
- if (flags & 134217728 /* TemplateLiteral */) {
+ if (flags & 134217728 /* TypeFlags.TemplateLiteral */) {
return getTemplateLiteralType(type.texts, instantiateTypes(type.types, mapper));
}
- if (flags & 268435456 /* StringMapping */) {
+ if (flags & 268435456 /* TypeFlags.StringMapping */) {
return getStringMappingType(type.symbol, instantiateType(type.type, mapper));
}
- if (flags & 8388608 /* IndexedAccess */) {
+ if (flags & 8388608 /* TypeFlags.IndexedAccess */) {
var newAliasSymbol = aliasSymbol || type.aliasSymbol;
var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments);
}
- if (flags & 16777216 /* Conditional */) {
+ if (flags & 16777216 /* TypeFlags.Conditional */) {
return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments);
}
- if (flags & 33554432 /* Substitution */) {
+ if (flags & 33554432 /* TypeFlags.Substitution */) {
var maybeVariable = instantiateType(type.baseType, mapper);
- if (maybeVariable.flags & 8650752 /* TypeVariable */) {
+ if (maybeVariable.flags & 8650752 /* TypeFlags.TypeVariable */) {
return getSubstitutionType(maybeVariable, instantiateType(type.substitute, mapper));
}
else {
var sub = instantiateType(type.substitute, mapper);
- if (sub.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) {
+ if (sub.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) {
return maybeVariable;
}
return sub;
@@ -62465,11 +63673,11 @@ var ts;
}
function instantiateReverseMappedType(type, mapper) {
var innerMappedType = instantiateType(type.mappedType, mapper);
- if (!(ts.getObjectFlags(innerMappedType) & 32 /* Mapped */)) {
+ if (!(ts.getObjectFlags(innerMappedType) & 32 /* ObjectFlags.Mapped */)) {
return type;
}
var innerIndexType = instantiateType(type.constraintType, mapper);
- if (!(innerIndexType.flags & 4194304 /* Index */)) {
+ if (!(innerIndexType.flags & 4194304 /* TypeFlags.Index */)) {
return type;
}
var instantiated = inferTypeForHomomorphicMappedType(instantiateType(type.source, mapper), innerMappedType, innerIndexType);
@@ -62478,12 +63686,16 @@ var ts;
}
return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable
}
+ function getUniqueLiteralFilledInstantiation(type) {
+ return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type :
+ type.uniqueLiteralFilledInstantiation || (type.uniqueLiteralFilledInstantiation = instantiateType(type, uniqueLiteralMapper));
+ }
function getPermissiveInstantiation(type) {
- return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type :
+ return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type :
type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper));
}
function getRestrictiveInstantiation(type) {
- if (type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */)) {
+ if (type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) {
return type;
}
if (type.restrictiveInstantiation) {
@@ -62504,35 +63716,35 @@ var ts;
// Returns true if the given expression contains (at any level of nesting) a function or arrow expression
// that is subject to contextual typing.
function isContextSensitive(node) {
- ts.Debug.assert(node.kind !== 168 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node));
+ ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node));
switch (node.kind) {
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
- case 168 /* MethodDeclaration */:
- case 255 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type
return isContextSensitiveFunctionLikeDeclaration(node);
- case 204 /* ObjectLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
return ts.some(node.properties, isContextSensitive);
- case 203 /* ArrayLiteralExpression */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
return ts.some(node.elements, isContextSensitive);
- case 221 /* ConditionalExpression */:
+ case 222 /* SyntaxKind.ConditionalExpression */:
return isContextSensitive(node.whenTrue) ||
isContextSensitive(node.whenFalse);
- case 220 /* BinaryExpression */:
- return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) &&
+ case 221 /* SyntaxKind.BinaryExpression */:
+ return (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) &&
(isContextSensitive(node.left) || isContextSensitive(node.right));
- case 294 /* PropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
return isContextSensitive(node.initializer);
- case 211 /* ParenthesizedExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
return isContextSensitive(node.expression);
- case 285 /* JsxAttributes */:
+ case 286 /* SyntaxKind.JsxAttributes */:
return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive);
- case 284 /* JsxAttribute */: {
+ case 285 /* SyntaxKind.JsxAttribute */: {
// If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive.
var initializer = node.initializer;
return !!initializer && isContextSensitive(initializer);
}
- case 287 /* JsxExpression */: {
+ case 288 /* SyntaxKind.JsxExpression */: {
// It is possible to that node.expression is undefined (e.g <div x={} />)
var expression = node.expression;
return !!expression && isContextSensitive(expression);
@@ -62546,17 +63758,17 @@ var ts;
}
function hasContextSensitiveReturnExpression(node) {
// TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value.
- return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 234 /* Block */ && isContextSensitive(node.body);
+ return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* SyntaxKind.Block */ && isContextSensitive(node.body);
}
function isContextSensitiveFunctionOrObjectLiteralMethod(func) {
return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
isContextSensitiveFunctionLikeDeclaration(func);
}
function getTypeWithoutSignatures(type) {
- if (type.flags & 524288 /* Object */) {
+ if (type.flags & 524288 /* TypeFlags.Object */) {
var resolved = resolveStructuredTypeMembers(type);
if (resolved.constructSignatures.length || resolved.callSignatures.length) {
- var result = createObjectType(16 /* Anonymous */, type.symbol);
+ var result = createObjectType(16 /* ObjectFlags.Anonymous */, type.symbol);
result.members = resolved.members;
result.properties = resolved.properties;
result.callSignatures = ts.emptyArray;
@@ -62565,7 +63777,7 @@ var ts;
return result;
}
}
- else if (type.flags & 2097152 /* Intersection */) {
+ else if (type.flags & 2097152 /* TypeFlags.Intersection */) {
return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures));
}
return type;
@@ -62575,13 +63787,13 @@ var ts;
return isTypeRelatedTo(source, target, identityRelation);
}
function compareTypesIdentical(source, target) {
- return isTypeRelatedTo(source, target, identityRelation) ? -1 /* True */ : 0 /* False */;
+ return isTypeRelatedTo(source, target, identityRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */;
}
function compareTypesAssignable(source, target) {
- return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* True */ : 0 /* False */;
+ return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */;
}
function compareTypesSubtypeOf(source, target) {
- return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* True */ : 0 /* False */;
+ return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */;
}
function isTypeSubtypeOf(source, target) {
return isTypeRelatedTo(source, target, subtypeRelation);
@@ -62598,11 +63810,11 @@ var ts;
// Note that this check ignores type parameters and only considers the
// inheritance hierarchy.
function isTypeDerivedFrom(source, target) {
- return source.flags & 1048576 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) :
- target.flags & 1048576 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) :
- source.flags & 58982400 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) :
- target === globalObjectType ? !!(source.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */)) :
- target === globalFunctionType ? !!(source.flags & 524288 /* Object */) && isFunctionObjectType(source) :
+ return source.flags & 1048576 /* TypeFlags.Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) :
+ target.flags & 1048576 /* TypeFlags.Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) :
+ source.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) :
+ target === globalObjectType ? !!(source.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */)) :
+ target === globalFunctionType ? !!(source.flags & 524288 /* TypeFlags.Object */) && isFunctionObjectType(source) :
hasBaseType(source, getTargetType(target)) || (isArrayType(target) && !isReadonlyArrayType(target) && isTypeDerivedFrom(source, globalReadonlyArrayType));
}
/**
@@ -62640,7 +63852,7 @@ var ts;
return false;
}
function isOrHasGenericConditional(type) {
- return !!(type.flags & 16777216 /* Conditional */ || (type.flags & 2097152 /* Intersection */ && ts.some(type.types, isOrHasGenericConditional)));
+ return !!(type.flags & 16777216 /* TypeFlags.Conditional */ || (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(type.types, isOrHasGenericConditional)));
}
function elaborateError(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) {
if (!node || isOrHasGenericConditional(target))
@@ -62650,35 +63862,35 @@ var ts;
return true;
}
switch (node.kind) {
- case 287 /* JsxExpression */:
- case 211 /* ParenthesizedExpression */:
+ case 288 /* SyntaxKind.JsxExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer);
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
switch (node.operatorToken.kind) {
- case 63 /* EqualsToken */:
- case 27 /* CommaToken */:
+ case 63 /* SyntaxKind.EqualsToken */:
+ case 27 /* SyntaxKind.CommaToken */:
return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer);
}
break;
- case 204 /* ObjectLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer);
- case 203 /* ArrayLiteralExpression */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer);
- case 285 /* JsxAttributes */:
+ case 286 /* SyntaxKind.JsxAttributes */:
return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer);
- case 213 /* ArrowFunction */:
+ case 214 /* SyntaxKind.ArrowFunction */:
return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer);
}
return false;
}
function elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) {
- var callSignatures = getSignaturesOfType(source, 0 /* Call */);
- var constructSignatures = getSignaturesOfType(source, 1 /* Construct */);
+ var callSignatures = getSignaturesOfType(source, 0 /* SignatureKind.Call */);
+ var constructSignatures = getSignaturesOfType(source, 1 /* SignatureKind.Construct */);
for (var _i = 0, _a = [constructSignatures, callSignatures]; _i < _a.length; _i++) {
var signatures = _a[_i];
if (ts.some(signatures, function (s) {
var returnType = getReturnTypeOfSignature(s);
- return !(returnType.flags & (1 /* Any */ | 131072 /* Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined);
+ return !(returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined);
})) {
var resultObj = errorOutputContainer || {};
checkTypeAssignableTo(source, target, node, headMessage, containingMessageChain, resultObj);
@@ -62702,7 +63914,7 @@ var ts;
if (!sourceSig) {
return false;
}
- var targetSignatures = getSignaturesOfType(target, 0 /* Call */);
+ var targetSignatures = getSignaturesOfType(target, 0 /* SignatureKind.Call */);
if (!ts.length(targetSignatures)) {
return false;
}
@@ -62720,7 +63932,7 @@ var ts;
if (target.symbol && ts.length(target.symbol.declarations)) {
ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_the_return_type_of_this_signature));
}
- if ((ts.getFunctionFlags(node) & 2 /* Async */) === 0
+ if ((ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */) === 0
// exclude cases where source itself is promisy - this way we don't make a suggestion when relating
// an IPromise and a Promise that are slightly different
&& !getTypeOfPropertyOfType(sourceReturn, "then")
@@ -62737,7 +63949,7 @@ var ts;
if (idx) {
return idx;
}
- if (target.flags & 1048576 /* Union */) {
+ if (target.flags & 1048576 /* TypeFlags.Union */) {
var best = getBestMatchingType(source, target);
if (best) {
return getIndexedAccessTypeOrUndefined(best, nameType);
@@ -62747,7 +63959,7 @@ var ts;
function checkExpressionForMutableLocationWithContextualType(next, sourcePropType) {
next.contextualType = sourcePropType;
try {
- return checkExpressionForMutableLocation(next, 1 /* Contextual */, sourcePropType);
+ return checkExpressionForMutableLocation(next, 1 /* CheckMode.Contextual */, sourcePropType);
}
finally {
next.contextualType = undefined;
@@ -62764,7 +63976,7 @@ var ts;
for (var status = iterator.next(); !status.done; status = iterator.next()) {
var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage;
var targetPropType = getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType);
- if (!targetPropType || targetPropType.flags & 8388608 /* IndexedAccess */)
+ if (!targetPropType || targetPropType.flags & 8388608 /* TypeFlags.IndexedAccess */)
continue; // Don't elaborate on indexes on generic variables
var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType);
if (!sourcePropType)
@@ -62784,8 +63996,8 @@ var ts;
resultObj.errors = [diag];
}
else {
- var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* Optional */);
- var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* Optional */);
+ var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */);
+ var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */);
targetPropType = removeMissingType(targetPropType, targetIsOptional);
sourcePropType = removeMissingType(sourcePropType, targetIsOptional && sourceIsOptional);
var result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj);
@@ -62809,7 +64021,7 @@ var ts;
if (!issuedElaboration && (targetProp && ts.length(targetProp.declarations) || target.symbol && ts.length(target.symbol.declarations))) {
var targetNode = targetProp && ts.length(targetProp.declarations) ? targetProp.declarations[0] : target.symbol.declarations[0];
if (!ts.getSourceFileOfNode(targetNode).hasNoDefaultLib) {
- ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target)));
+ ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target)));
}
}
}
@@ -62875,18 +64087,18 @@ var ts;
}
function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) {
switch (child.kind) {
- case 287 /* JsxExpression */:
+ case 288 /* SyntaxKind.JsxExpression */:
// child is of the type of the expression
return { errorNode: child, innerExpression: child.expression, nameType: nameType };
- case 11 /* JsxText */:
+ case 11 /* SyntaxKind.JsxText */:
if (child.containsOnlyTriviaWhiteSpaces) {
break; // Whitespace only jsx text isn't real jsx text
}
// child is a string
return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() };
- case 277 /* JsxElement */:
- case 278 /* JsxSelfClosingElement */:
- case 281 /* JsxFragment */:
+ case 278 /* SyntaxKind.JsxElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
+ case 282 /* SyntaxKind.JsxFragment */:
// child is of type JSX.Element
return { errorNode: child, innerExpression: child, nameType: nameType };
default:
@@ -62911,7 +64123,7 @@ var ts;
var nonArrayLikeTargetParts = filterType(childrenTargetType, function (t) { return !isArrayOrTupleLikeType(t); });
if (moreThanOneRealChildren) {
if (arrayLikeTargetParts !== neverType) {
- var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* Normal */));
+ var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* CheckMode.Normal */));
var children = generateJsxChildren(containingElement, getInvalidTextualChildDiagnostic);
result = elaborateElementwise(children, realSource, arrayLikeTargetParts, relation, containingMessageChain, errorOutputContainer) || result;
}
@@ -62993,7 +64205,7 @@ var ts;
});
}
function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) {
- if (target.flags & 131068 /* Primitive */)
+ if (target.flags & 131068 /* TypeFlags.Primitive */)
return false;
if (isTupleLikeType(source)) {
return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer);
@@ -63003,7 +64215,7 @@ var ts;
var oldContext = node.contextualType;
node.contextualType = target;
try {
- var tupleizedType = checkArrayLiteral(node, 1 /* Contextual */, /*forceTuple*/ true);
+ var tupleizedType = checkArrayLiteral(node, 1 /* CheckMode.Contextual */, /*forceTuple*/ true);
node.contextualType = oldContext;
if (isTupleLikeType(tupleizedType)) {
return elaborateElementwise(generateLimitedTupleElements(node, target), tupleizedType, target, relation, containingMessageChain, errorOutputContainer);
@@ -63028,17 +64240,17 @@ var ts;
prop = _a[_i];
if (ts.isSpreadAssignment(prop))
return [3 /*break*/, 7];
- type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* StringOrNumberLiteralOrUnique */);
- if (!type || (type.flags & 131072 /* Never */)) {
+ type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */);
+ if (!type || (type.flags & 131072 /* TypeFlags.Never */)) {
return [3 /*break*/, 7];
}
_b = prop.kind;
switch (_b) {
- case 172 /* SetAccessor */: return [3 /*break*/, 2];
- case 171 /* GetAccessor */: return [3 /*break*/, 2];
- case 168 /* MethodDeclaration */: return [3 /*break*/, 2];
- case 295 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2];
- case 294 /* PropertyAssignment */: return [3 /*break*/, 4];
+ case 173 /* SyntaxKind.SetAccessor */: return [3 /*break*/, 2];
+ case 172 /* SyntaxKind.GetAccessor */: return [3 /*break*/, 2];
+ case 169 /* SyntaxKind.MethodDeclaration */: return [3 /*break*/, 2];
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return [3 /*break*/, 2];
+ case 296 /* SyntaxKind.PropertyAssignment */: return [3 /*break*/, 4];
}
return [3 /*break*/, 6];
case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }];
@@ -63060,7 +64272,7 @@ var ts;
});
}
function elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) {
- if (target.flags & 131068 /* Primitive */)
+ if (target.flags & 131068 /* TypeFlags.Primitive */)
return false;
return elaborateElementwise(generateObjectLiteralElements(node), source, target, relation, containingMessageChain, errorOutputContainer);
}
@@ -63072,8 +64284,8 @@ var ts;
return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain);
}
function isSignatureAssignableTo(source, target, ignoreReturnTypes) {
- return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* IgnoreReturnTypes */ : 0, /*reportErrors*/ false,
- /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* False */;
+ return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* SignatureCheckMode.IgnoreReturnTypes */ : 0, /*reportErrors*/ false,
+ /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* Ternary.False */;
}
/**
* Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any`
@@ -63089,16 +64301,16 @@ var ts;
function compareSignaturesRelated(source, target, checkMode, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) {
// TODO (drosen): De-duplicate code between related functions.
if (source === target) {
- return -1 /* True */;
+ return -1 /* Ternary.True */;
}
if (isAnySignature(target)) {
- return -1 /* True */;
+ return -1 /* Ternary.True */;
}
var targetCount = getParameterCount(target);
var sourceHasMoreParameters = !hasEffectiveRestParameter(target) &&
- (checkMode & 8 /* StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount);
+ (checkMode & 8 /* SignatureCheckMode.StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount);
if (sourceHasMoreParameters) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
if (source.typeParameters && source.typeParameters !== target.typeParameters) {
target = getCanonicalSignature(target);
@@ -63110,14 +64322,10 @@ var ts;
if (sourceRestType || targetRestType) {
void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers);
}
- if (sourceRestType && targetRestType && sourceCount !== targetCount) {
- // We're not able to relate misaligned complex rest parameters
- return 0 /* False */;
- }
- var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */;
- var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 168 /* MethodDeclaration */ &&
- kind !== 167 /* MethodSignature */ && kind !== 170 /* Constructor */;
- var result = -1 /* True */;
+ var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */;
+ var strictVariance = !(checkMode & 3 /* SignatureCheckMode.Callback */) && strictFunctionTypes && kind !== 169 /* SyntaxKind.MethodDeclaration */ &&
+ kind !== 168 /* SyntaxKind.MethodSignature */ && kind !== 171 /* SyntaxKind.Constructor */;
+ var result = -1 /* Ternary.True */;
var sourceThisType = getThisTypeOfSignature(source);
if (sourceThisType && sourceThisType !== voidType) {
var targetThisType = getThisTypeOfSignature(target);
@@ -63129,7 +64337,7 @@ var ts;
if (reportErrors) {
errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible);
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
result &= related;
}
@@ -63148,33 +64356,33 @@ var ts;
// similar to return values, callback parameters are output positions. This means that a Promise<T>,
// where T is used only in callback parameter positions, will be co-variant (as opposed to bi-variant)
// with respect to T.
- var sourceSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType));
- var targetSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType));
+ var sourceSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType));
+ var targetSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType));
var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) &&
- (getFalsyFlags(sourceType) & 98304 /* Nullable */) === (getFalsyFlags(targetType) & 98304 /* Nullable */);
+ (getFalsyFlags(sourceType) & 98304 /* TypeFlags.Nullable */) === (getFalsyFlags(targetType) & 98304 /* TypeFlags.Nullable */);
var related = callbacks ?
- compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* StrictArity */) | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) :
- !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors);
+ compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* SignatureCheckMode.StrictArity */) | (strictVariance ? 2 /* SignatureCheckMode.StrictCallback */ : 1 /* SignatureCheckMode.BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) :
+ !(checkMode & 3 /* SignatureCheckMode.Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors);
// With strict arity, (x: number | undefined) => void is a subtype of (x?: number | undefined) => void
- if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) {
- related = 0 /* False */;
+ if (related && checkMode & 8 /* SignatureCheckMode.StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) {
+ related = 0 /* Ternary.False */;
}
if (!related) {
if (reportErrors) {
errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i)));
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
result &= related;
}
}
- if (!(checkMode & 4 /* IgnoreReturnTypes */)) {
+ if (!(checkMode & 4 /* SignatureCheckMode.IgnoreReturnTypes */)) {
// If a signature resolution is already in-flight, skip issuing a circularity error
// here and just use the `any` type directly
var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType
: target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(target.declaration.symbol))
: getReturnTypeOfSignature(target);
- if (targetReturnType === voidType) {
+ if (targetReturnType === voidType || targetReturnType === anyType) {
return result;
}
var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType
@@ -63191,14 +64399,14 @@ var ts;
if (reportErrors) {
errorReporter(ts.Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source));
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
}
else {
// When relating callback signatures, we still need to relate return types bi-variantly as otherwise
// the containing type wouldn't be co-variant. For example, interface Foo<T> { add(cb: () => T): void }
// wouldn't be co-variant for T without this rule.
- result &= checkMode & 1 /* BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) ||
+ result &= checkMode & 1 /* SignatureCheckMode.BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) ||
compareTypes(sourceReturnType, targetReturnType, reportErrors);
if (!result && reportErrors && incompatibleErrorReporter) {
incompatibleErrorReporter(sourceReturnType, targetReturnType);
@@ -63213,21 +64421,21 @@ var ts;
errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard);
errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
- if (source.kind === 1 /* Identifier */ || source.kind === 3 /* AssertsIdentifier */) {
+ if (source.kind === 1 /* TypePredicateKind.Identifier */ || source.kind === 3 /* TypePredicateKind.AssertsIdentifier */) {
if (source.parameterIndex !== target.parameterIndex) {
if (reportErrors) {
errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName);
errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
}
- var related = source.type === target.type ? -1 /* True */ :
+ var related = source.type === target.type ? -1 /* Ternary.True */ :
source.type && target.type ? compareTypes(source.type, target.type, reportErrors) :
- 0 /* False */;
- if (related === 0 /* False */ && reportErrors) {
+ 0 /* Ternary.False */;
+ if (related === 0 /* Ternary.False */ && reportErrors) {
errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
}
return related;
@@ -63253,19 +64461,19 @@ var ts;
t.indexInfos.length === 0;
}
function isEmptyObjectType(type) {
- return type.flags & 524288 /* Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) :
- type.flags & 67108864 /* NonPrimitive */ ? true :
- type.flags & 1048576 /* Union */ ? ts.some(type.types, isEmptyObjectType) :
- type.flags & 2097152 /* Intersection */ ? ts.every(type.types, isEmptyObjectType) :
+ return type.flags & 524288 /* TypeFlags.Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) :
+ type.flags & 67108864 /* TypeFlags.NonPrimitive */ ? true :
+ type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, isEmptyObjectType) :
+ type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.every(type.types, isEmptyObjectType) :
false;
}
function isEmptyAnonymousObjectType(type) {
- return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) ||
- type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0));
+ return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && (type.members && isEmptyResolvedType(type) ||
+ type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0));
}
function isStringIndexSignatureOnlyType(type) {
- return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) ||
- type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) ||
+ return type.flags & 524288 /* TypeFlags.Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) ||
+ type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) ||
false;
}
function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) {
@@ -63274,81 +64482,83 @@ var ts;
}
var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol);
var entry = enumRelation.get(id);
- if (entry !== undefined && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) {
- return !!(entry & 1 /* Succeeded */);
+ if (entry !== undefined && !(!(entry & 4 /* RelationComparisonResult.Reported */) && entry & 2 /* RelationComparisonResult.Failed */ && errorReporter)) {
+ return !!(entry & 1 /* RelationComparisonResult.Succeeded */);
}
- if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) {
- enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */);
+ if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* SymbolFlags.RegularEnum */) || !(targetSymbol.flags & 256 /* SymbolFlags.RegularEnum */)) {
+ enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */);
return false;
}
var targetEnumType = getTypeOfSymbol(targetSymbol);
for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(sourceSymbol)); _i < _a.length; _i++) {
var property = _a[_i];
- if (property.flags & 8 /* EnumMember */) {
+ if (property.flags & 8 /* SymbolFlags.EnumMember */) {
var targetProperty = getPropertyOfType(targetEnumType, property.escapedName);
- if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) {
+ if (!targetProperty || !(targetProperty.flags & 8 /* SymbolFlags.EnumMember */)) {
if (errorReporter) {
- errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */));
- enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */);
+ errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */));
+ enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */);
}
else {
- enumRelation.set(id, 2 /* Failed */);
+ enumRelation.set(id, 2 /* RelationComparisonResult.Failed */);
}
return false;
}
}
}
- enumRelation.set(id, 1 /* Succeeded */);
+ enumRelation.set(id, 1 /* RelationComparisonResult.Succeeded */);
return true;
}
function isSimpleTypeRelatedTo(source, target, relation, errorReporter) {
var s = source.flags;
var t = target.flags;
- if (t & 3 /* AnyOrUnknown */ || s & 131072 /* Never */ || source === wildcardType)
+ if (t & 3 /* TypeFlags.AnyOrUnknown */ || s & 131072 /* TypeFlags.Never */ || source === wildcardType)
return true;
- if (t & 131072 /* Never */)
+ if (t & 131072 /* TypeFlags.Never */)
return false;
- if (s & 402653316 /* StringLike */ && t & 4 /* String */)
+ if (s & 402653316 /* TypeFlags.StringLike */ && t & 4 /* TypeFlags.String */)
return true;
- if (s & 128 /* StringLiteral */ && s & 1024 /* EnumLiteral */ &&
- t & 128 /* StringLiteral */ && !(t & 1024 /* EnumLiteral */) &&
+ if (s & 128 /* TypeFlags.StringLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ &&
+ t & 128 /* TypeFlags.StringLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) &&
source.value === target.value)
return true;
- if (s & 296 /* NumberLike */ && t & 8 /* Number */)
+ if (s & 296 /* TypeFlags.NumberLike */ && t & 8 /* TypeFlags.Number */)
return true;
- if (s & 256 /* NumberLiteral */ && s & 1024 /* EnumLiteral */ &&
- t & 256 /* NumberLiteral */ && !(t & 1024 /* EnumLiteral */) &&
+ if (s & 256 /* TypeFlags.NumberLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ &&
+ t & 256 /* TypeFlags.NumberLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) &&
source.value === target.value)
return true;
- if (s & 2112 /* BigIntLike */ && t & 64 /* BigInt */)
+ if (s & 2112 /* TypeFlags.BigIntLike */ && t & 64 /* TypeFlags.BigInt */)
return true;
- if (s & 528 /* BooleanLike */ && t & 16 /* Boolean */)
+ if (s & 528 /* TypeFlags.BooleanLike */ && t & 16 /* TypeFlags.Boolean */)
return true;
- if (s & 12288 /* ESSymbolLike */ && t & 4096 /* ESSymbol */)
+ if (s & 12288 /* TypeFlags.ESSymbolLike */ && t & 4096 /* TypeFlags.ESSymbol */)
return true;
- if (s & 32 /* Enum */ && t & 32 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter))
+ if (s & 32 /* TypeFlags.Enum */ && t & 32 /* TypeFlags.Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter))
return true;
- if (s & 1024 /* EnumLiteral */ && t & 1024 /* EnumLiteral */) {
- if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter))
+ if (s & 1024 /* TypeFlags.EnumLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */) {
+ if (s & 1048576 /* TypeFlags.Union */ && t & 1048576 /* TypeFlags.Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter))
return true;
- if (s & 2944 /* Literal */ && t & 2944 /* Literal */ &&
+ if (s & 2944 /* TypeFlags.Literal */ && t & 2944 /* TypeFlags.Literal */ &&
source.value === target.value &&
isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter))
return true;
}
- if (s & 32768 /* Undefined */ && (!strictNullChecks || t & (32768 /* Undefined */ | 16384 /* Void */)))
+ // In non-strictNullChecks mode, `undefined` and `null` are assignable to anything except `never`.
+ // Since unions and intersections may reduce to `never`, we exclude them here.
+ if (s & 32768 /* TypeFlags.Undefined */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & (32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */)))
return true;
- if (s & 65536 /* Null */ && (!strictNullChecks || t & 65536 /* Null */))
+ if (s & 65536 /* TypeFlags.Null */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & 65536 /* TypeFlags.Null */))
return true;
- if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */)
+ if (s & 524288 /* TypeFlags.Object */ && t & 67108864 /* TypeFlags.NonPrimitive */)
return true;
if (relation === assignableRelation || relation === comparableRelation) {
- if (s & 1 /* Any */)
+ if (s & 1 /* TypeFlags.Any */)
return true;
// Type number or any numeric literal type is assignable to any numeric enum type or any
// numeric enum literal type. This rule exists for backwards compatibility reasons because
// bit-flag enum types sometimes look like literal enum types with numeric literal values.
- if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */))
+ if (s & (8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) && !(s & 1024 /* TypeFlags.EnumLiteral */) && (t & 32 /* TypeFlags.Enum */ || relation === assignableRelation && t & 256 /* TypeFlags.NumberLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */))
return true;
}
return false;
@@ -63364,37 +64574,38 @@ var ts;
return true;
}
if (relation !== identityRelation) {
- if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) {
+ if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) {
return true;
}
}
- else {
+ else if (!((source.flags | target.flags) & (3145728 /* TypeFlags.UnionOrIntersection */ | 8388608 /* TypeFlags.IndexedAccess */ | 16777216 /* TypeFlags.Conditional */ | 33554432 /* TypeFlags.Substitution */))) {
+ // We have excluded types that may simplify to other forms, so types must have identical flags
if (source.flags !== target.flags)
return false;
- if (source.flags & 67358815 /* Singleton */)
+ if (source.flags & 67358815 /* TypeFlags.Singleton */)
return true;
}
- if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
- var related = relation.get(getRelationKey(source, target, 0 /* None */, relation, /*ignoreConstraints*/ false));
+ if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) {
+ var related = relation.get(getRelationKey(source, target, 0 /* IntersectionState.None */, relation, /*ignoreConstraints*/ false));
if (related !== undefined) {
- return !!(related & 1 /* Succeeded */);
+ return !!(related & 1 /* RelationComparisonResult.Succeeded */);
}
}
- if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) {
+ if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) {
return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined);
}
return false;
}
function isIgnoredJsxProperty(source, sourceProp) {
- return ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName);
+ return ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName);
}
function getNormalizedType(type, writing) {
while (true) {
var t = isFreshLiteralType(type) ? type.regularType :
- ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) :
- type.flags & 3145728 /* UnionOrIntersection */ ? getReducedType(type) :
- type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute :
- type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) :
+ ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) :
+ type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getReducedType(type) :
+ type.flags & 33554432 /* TypeFlags.Substitution */ ? writing ? type.baseType : type.substitute :
+ type.flags & 25165824 /* TypeFlags.Simplifiable */ ? getSimplifiedType(type, writing) :
type;
t = getSingleBaseForNonAugmentingSubtype(t) || t;
if (t === type)
@@ -63423,19 +64634,19 @@ var ts;
var maybeCount = 0;
var sourceDepth = 0;
var targetDepth = 0;
- var expandingFlags = 0 /* None */;
+ var expandingFlags = 0 /* ExpandingFlags.None */;
var overflow = false;
var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid
var lastSkippedInfo;
var incompatibleStack;
var inPropertyCheck = false;
ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
- var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage);
+ var result = isRelatedTo(source, target, 3 /* RecursionFlags.Both */, /*reportErrors*/ !!errorNode, headMessage);
if (incompatibleStack) {
reportIncompatibleStack();
}
if (overflow) {
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth });
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth });
var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
if (errorOutputContainer) {
(errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
@@ -63473,10 +64684,10 @@ var ts;
diagnostics.add(diag);
}
}
- if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* False */) {
+ if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* Ternary.False */) {
ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error.");
}
- return result !== 0 /* False */;
+ return result !== 0 /* Ternary.False */;
function resetErrorInfo(saved) {
errorInfo = saved.errorInfo;
lastSkippedInfo = saved.lastSkippedInfo;
@@ -63632,7 +64843,7 @@ var ts;
ts.Debug.assert(!isTypeAssignableTo(generalizedSource, target), "generalized source shouldn't be assignable");
generalizedSourceType = getTypeNameForErrorDisplay(generalizedSource);
}
- if (target.flags & 262144 /* TypeParameter */) {
+ if (target.flags & 262144 /* TypeFlags.TypeParameter */ && target !== markerSuperType && target !== markerSubType) {
var constraint = getBaseConstraintOfType(target);
var needsOriginalSource = void 0;
if (constraint && (isTypeAssignableTo(generalizedSource, constraint) || (needsOriginalSource = isTypeAssignableTo(source, constraint)))) {
@@ -63654,7 +64865,7 @@ var ts;
message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties;
}
else {
- if (source.flags & 128 /* StringLiteral */ && target.flags & 1048576 /* Union */) {
+ if (source.flags & 128 /* TypeFlags.StringLiteral */ && target.flags & 1048576 /* TypeFlags.Union */) {
var suggestedType = getSuggestedTypeForNonexistentStringLiteralType(source, target);
if (suggestedType) {
reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Did_you_mean_2, generalizedSourceType, targetType, typeToString(suggestedType));
@@ -63677,7 +64888,7 @@ var ts;
if ((globalStringType === source && stringType === target) ||
(globalNumberType === source && numberType === target) ||
(globalBooleanType === source && booleanType === target) ||
- (getGlobalESSymbolType(/*reportErrors*/ false) === source && esSymbolType === target)) {
+ (getGlobalESSymbolType() === source && esSymbolType === target)) {
reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType);
}
}
@@ -63702,7 +64913,7 @@ var ts;
}
return false;
}
- return isTupleType(target) || isArrayType(target);
+ return isArrayOrTupleType(target);
}
if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) {
if (reportErrors) {
@@ -63716,7 +64927,7 @@ var ts;
return true;
}
function isRelatedToWorker(source, target, reportErrors) {
- return isRelatedTo(source, target, 3 /* Both */, reportErrors);
+ return isRelatedTo(source, target, 3 /* RecursionFlags.Both */, reportErrors);
}
/**
* Compare two types and return
@@ -63725,19 +64936,19 @@ var ts;
* * Ternary.False if they are not related.
*/
function isRelatedTo(originalSource, originalTarget, recursionFlags, reportErrors, headMessage, intersectionState) {
- if (recursionFlags === void 0) { recursionFlags = 3 /* Both */; }
+ if (recursionFlags === void 0) { recursionFlags = 3 /* RecursionFlags.Both */; }
if (reportErrors === void 0) { reportErrors = false; }
- if (intersectionState === void 0) { intersectionState = 0 /* None */; }
+ if (intersectionState === void 0) { intersectionState = 0 /* IntersectionState.None */; }
// Before normalization: if `source` is type an object type, and `target` is primitive,
// skip all the checks we don't need and just return `isSimpleTypeRelatedTo` result
- if (originalSource.flags & 524288 /* Object */ && originalTarget.flags & 131068 /* Primitive */) {
+ if (originalSource.flags & 524288 /* TypeFlags.Object */ && originalTarget.flags & 131068 /* TypeFlags.Primitive */) {
if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) {
- return -1 /* True */;
+ return -1 /* Ternary.True */;
}
if (reportErrors) {
reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage);
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
// Normalize the source and target types: Turn fresh literal types into regular literal types,
// turn deferred type references into regular type references, simplify indexed access and
@@ -63746,73 +64957,73 @@ var ts;
var source = getNormalizedType(originalSource, /*writing*/ false);
var target = getNormalizedType(originalTarget, /*writing*/ true);
if (source === target)
- return -1 /* True */;
+ return -1 /* Ternary.True */;
if (relation === identityRelation) {
if (source.flags !== target.flags)
- return 0 /* False */;
- if (source.flags & 67358815 /* Singleton */)
- return -1 /* True */;
+ return 0 /* Ternary.False */;
+ if (source.flags & 67358815 /* TypeFlags.Singleton */)
+ return -1 /* Ternary.True */;
traceUnionsOrIntersectionsTooLarge(source, target);
- return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
+ return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* IntersectionState.None */, recursionFlags);
}
// We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common,
// and otherwise, for type parameters in large unions, causes us to need to compare the union to itself,
// as we break down the _target_ union first, _then_ get the source constraint - so for every
// member of the target, we attempt to find a match in the source. This avoids that in cases where
// the target is exactly the constraint.
- if (source.flags & 262144 /* TypeParameter */ && getConstraintOfType(source) === target) {
- return -1 /* True */;
+ if (source.flags & 262144 /* TypeFlags.TypeParameter */ && getConstraintOfType(source) === target) {
+ return -1 /* Ternary.True */;
}
// See if we're relating a definitely non-nullable type to a union that includes null and/or undefined
// plus a single non-nullable type. If so, remove null and/or undefined from the target type.
- if (source.flags & 470302716 /* DefinitelyNonNullable */ && target.flags & 1048576 /* Union */) {
+ if (source.flags & 470302716 /* TypeFlags.DefinitelyNonNullable */ && target.flags & 1048576 /* TypeFlags.Union */) {
var types = target.types;
- var candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] :
- types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] :
+ var candidate = types.length === 2 && types[0].flags & 98304 /* TypeFlags.Nullable */ ? types[1] :
+ types.length === 3 && types[0].flags & 98304 /* TypeFlags.Nullable */ && types[1].flags & 98304 /* TypeFlags.Nullable */ ? types[2] :
undefined;
- if (candidate && !(candidate.flags & 98304 /* Nullable */)) {
+ if (candidate && !(candidate.flags & 98304 /* TypeFlags.Nullable */)) {
target = getNormalizedType(candidate, /*writing*/ true);
if (source === target)
- return -1 /* True */;
+ return -1 /* Ternary.True */;
}
}
- if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) ||
+ if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) ||
isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined))
- return -1 /* True */;
- if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) {
- var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384 /* FreshLiteral */);
+ return -1 /* Ternary.True */;
+ if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) {
+ var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* IntersectionState.Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 8192 /* ObjectFlags.FreshLiteral */);
if (isPerformingExcessPropertyChecks) {
if (hasExcessProperties(source, target, reportErrors)) {
if (reportErrors) {
reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target);
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
}
- var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) &&
- source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType &&
- target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) &&
+ var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* IntersectionState.Target */) &&
+ source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType &&
+ target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) &&
(getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
- var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */);
+ var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */);
if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
if (reportErrors) {
var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source);
var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
- var calls = getSignaturesOfType(source, 0 /* Call */);
- var constructs = getSignaturesOfType(source, 1 /* Construct */);
- if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) ||
- constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) {
+ var calls = getSignaturesOfType(source, 0 /* SignatureKind.Call */);
+ var constructs = getSignaturesOfType(source, 1 /* SignatureKind.Construct */);
+ if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false) ||
+ constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) {
reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
}
else {
reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString);
}
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
traceUnionsOrIntersectionsTooLarge(source, target);
- var skipCaching = source.flags & 1048576 /* Union */ && source.types.length < 4 && !(target.flags & 1048576 /* Union */) ||
- target.flags & 1048576 /* Union */ && target.types.length < 4 && !(source.flags & 469499904 /* StructuredOrInstantiable */);
+ var skipCaching = source.flags & 1048576 /* TypeFlags.Union */ && source.types.length < 4 && !(target.flags & 1048576 /* TypeFlags.Union */) ||
+ target.flags & 1048576 /* TypeFlags.Union */ && target.types.length < 4 && !(source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */);
var result_7 = skipCaching ?
unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
@@ -63831,10 +65042,10 @@ var ts;
//
// We suppress recursive intersection property checks because they can generate lots of work when relating
// recursive intersections that are structurally similar but not exactly identical. See #37854.
- if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
- isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 524288 /* NonInferrableType */); }))) {
+ if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
+ isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* TypeFlags.Intersection */ && getApparentType(source).flags & 3670016 /* TypeFlags.StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* ObjectFlags.NonInferrableType */); }))) {
inPropertyCheck = true;
- result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
+ result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* IntersectionState.PropertyCheck */, recursionFlags);
inPropertyCheck = false;
}
if (result_7) {
@@ -63844,7 +65055,7 @@ var ts;
if (reportErrors) {
reportErrorResults(originalSource, originalTarget, source, target, headMessage);
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
@@ -63855,20 +65066,20 @@ var ts;
if (maybeSuppress) {
overrideNextErrorInfo--;
}
- if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
+ if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) {
var currentError = errorInfo;
tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ true);
if (errorInfo !== currentError) {
maybeSuppress = !!errorInfo;
}
}
- if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) {
+ if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 131068 /* TypeFlags.Primitive */) {
tryElaborateErrorsForPrimitivesAndObjects(source, target);
}
- else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) {
+ else if (source.symbol && source.flags & 524288 /* TypeFlags.Object */ && globalObjectType === source) {
reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
}
- else if (ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && target.flags & 2097152 /* Intersection */) {
+ else if (ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && target.flags & 2097152 /* TypeFlags.Intersection */) {
var targetTypes = target.types;
var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
@@ -63892,17 +65103,17 @@ var ts;
if (!ts.tracing) {
return;
}
- if ((source.flags & 3145728 /* UnionOrIntersection */) && (target.flags & 3145728 /* UnionOrIntersection */)) {
+ if ((source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) && (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */)) {
var sourceUnionOrIntersection = source;
var targetUnionOrIntersection = target;
- if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 65536 /* PrimitiveUnion */) {
+ if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 32768 /* ObjectFlags.PrimitiveUnion */) {
// There's a fast path for comparing primitive unions
return;
}
var sourceSize = sourceUnionOrIntersection.types.length;
var targetSize = targetUnionOrIntersection.types.length;
if (sourceSize * targetSize > 1E6) {
- ts.tracing.instant("checkTypes" /* CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", {
+ ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", {
sourceId: source.id,
sourceSize: sourceSize,
targetId: target.id,
@@ -63917,7 +65128,7 @@ var ts;
var appendPropType = function (propTypes, type) {
var _a;
type = getApparentType(type);
- var prop = type.flags & 3145728 /* UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name);
+ var prop = type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name);
var propType = prop && getTypeOfSymbol(prop) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || undefinedType;
return ts.append(propTypes, propType);
};
@@ -63925,21 +65136,21 @@ var ts;
}
function hasExcessProperties(source, target, reportErrors) {
var _a;
- if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 8192 /* JSLiteral */) {
+ if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 4096 /* ObjectFlags.JSLiteral */) {
return false; // Disable excess property checks on JS literals to simulate having an implicit "index signature" - but only outside of noImplicitAny
}
- var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */);
+ var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */);
if ((relation === assignableRelation || relation === comparableRelation) &&
(isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) {
return false;
}
var reducedTarget = target;
var checkTypes;
- if (target.flags & 1048576 /* Union */) {
+ if (target.flags & 1048576 /* TypeFlags.Union */) {
reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
- checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget];
+ checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget];
}
- var _loop_18 = function (prop) {
+ var _loop_19 = function (prop) {
if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
if (reportErrors) {
@@ -63992,7 +65203,7 @@ var ts;
}
return { value: true };
}
- if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* Both */, reportErrors)) {
+ if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* RecursionFlags.Both */, reportErrors)) {
if (reportErrors) {
reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop));
}
@@ -64002,9 +65213,9 @@ var ts;
};
for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
var prop = _b[_i];
- var state_5 = _loop_18(prop);
- if (typeof state_5 === "object")
- return state_5.value;
+ var state_6 = _loop_19(prop);
+ if (typeof state_6 === "object")
+ return state_6.value;
}
return false;
}
@@ -64015,28 +65226,28 @@ var ts;
// Note that these checks are specifically ordered to produce correct results. In particular,
// we need to deconstruct unions before intersections (because unions are always at the top),
// and we need to handle "each" relations before "some" relations for the same kind of type.
- if (source.flags & 1048576 /* Union */) {
+ if (source.flags & 1048576 /* TypeFlags.Union */) {
return relation === comparableRelation ?
- someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState) :
- eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState);
+ someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState) :
+ eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState);
}
- if (target.flags & 1048576 /* Union */) {
- return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */));
+ if (target.flags & 1048576 /* TypeFlags.Union */) {
+ return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */) && !(target.flags & 131068 /* TypeFlags.Primitive */));
}
- if (target.flags & 2097152 /* Intersection */) {
- return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */);
+ if (target.flags & 2097152 /* TypeFlags.Intersection */) {
+ return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* IntersectionState.Target */);
}
// Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
// constraints of all non-primitive types in the source into a new intersection. We do this because the
// intersection may further constrain the constraints of the non-primitive types. For example, given a type
// parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't
// appear to be comparable to '2'.
- if (relation === comparableRelation && target.flags & 131068 /* Primitive */) {
+ if (relation === comparableRelation && target.flags & 131068 /* TypeFlags.Primitive */) {
var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
if (constraints !== source.types) {
source = getIntersectionType(constraints);
- if (!(source.flags & 2097152 /* Intersection */)) {
- return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
+ if (!(source.flags & 2097152 /* TypeFlags.Intersection */)) {
+ return isRelatedTo(source, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false);
}
}
}
@@ -64044,16 +65255,16 @@ var ts;
// Don't report errors though. Elaborating on whether a source constituent is related to the target is
// not actually useful and leads to some confusing error messages. Instead, we rely on the caller
// checking whether the full intersection viewed as an object is related to the target.
- return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */);
+ return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* IntersectionState.Source */);
}
function eachTypeRelatedToSomeType(source, target) {
- var result = -1 /* True */;
+ var result = -1 /* Ternary.True */;
var sourceTypes = source.types;
for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) {
var sourceType = sourceTypes_1[_i];
var related = typeRelatedToSomeType(sourceType, target, /*reportErrors*/ false);
if (!related) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
result &= related;
}
@@ -64061,13 +65272,13 @@ var ts;
}
function typeRelatedToSomeType(source, target, reportErrors) {
var targetTypes = target.types;
- if (target.flags & 1048576 /* Union */) {
+ if (target.flags & 1048576 /* TypeFlags.Union */) {
if (containsType(targetTypes, source)) {
- return -1 /* True */;
+ return -1 /* Ternary.True */;
}
var match = getMatchingUnionConstituentForType(target, source);
if (match) {
- var related = isRelatedTo(source, match, 2 /* Target */, /*reportErrors*/ false);
+ var related = isRelatedTo(source, match, 2 /* RecursionFlags.Target */, /*reportErrors*/ false);
if (related) {
return related;
}
@@ -64075,7 +65286,7 @@ var ts;
}
for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) {
var type = targetTypes_1[_i];
- var related = isRelatedTo(source, type, 2 /* Target */, /*reportErrors*/ false);
+ var related = isRelatedTo(source, type, 2 /* RecursionFlags.Target */, /*reportErrors*/ false);
if (related) {
return related;
}
@@ -64084,19 +65295,19 @@ var ts;
// Elaborate only if we can find a best matching type in the target union
var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
if (bestMatchingType) {
- isRelatedTo(source, bestMatchingType, 2 /* Target */, /*reportErrors*/ true);
+ isRelatedTo(source, bestMatchingType, 2 /* RecursionFlags.Target */, /*reportErrors*/ true);
}
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
function typeRelatedToEachType(source, target, reportErrors, intersectionState) {
- var result = -1 /* True */;
+ var result = -1 /* Ternary.True */;
var targetTypes = target.types;
for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) {
var targetType = targetTypes_2[_i];
- var related = isRelatedTo(source, targetType, 2 /* Target */, reportErrors, /*headMessage*/ undefined, intersectionState);
+ var related = isRelatedTo(source, targetType, 2 /* RecursionFlags.Target */, reportErrors, /*headMessage*/ undefined, intersectionState);
if (!related) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
result &= related;
}
@@ -64104,50 +65315,50 @@ var ts;
}
function someTypeRelatedToType(source, target, reportErrors, intersectionState) {
var sourceTypes = source.types;
- if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) {
- return -1 /* True */;
+ if (source.flags & 1048576 /* TypeFlags.Union */ && containsType(sourceTypes, target)) {
+ return -1 /* Ternary.True */;
}
var len = sourceTypes.length;
for (var i = 0; i < len; i++) {
- var related = isRelatedTo(sourceTypes[i], target, 1 /* Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState);
+ var related = isRelatedTo(sourceTypes[i], target, 1 /* RecursionFlags.Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState);
if (related) {
return related;
}
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
function getUndefinedStrippedTargetIfNeeded(source, target) {
// As a builtin type, `undefined` is a very low type ID - making it almsot always first, making this a very fast check to see
// if we need to strip `undefined` from the target
- if (source.flags & 1048576 /* Union */ && target.flags & 1048576 /* Union */ &&
- !(source.types[0].flags & 32768 /* Undefined */) && target.types[0].flags & 32768 /* Undefined */) {
- return extractTypesOfKind(target, ~32768 /* Undefined */);
+ if (source.flags & 1048576 /* TypeFlags.Union */ && target.flags & 1048576 /* TypeFlags.Union */ &&
+ !(source.types[0].flags & 32768 /* TypeFlags.Undefined */) && target.types[0].flags & 32768 /* TypeFlags.Undefined */) {
+ return extractTypesOfKind(target, ~32768 /* TypeFlags.Undefined */);
}
return target;
}
function eachTypeRelatedToType(source, target, reportErrors, intersectionState) {
- var result = -1 /* True */;
+ var result = -1 /* Ternary.True */;
var sourceTypes = source.types;
// We strip `undefined` from the target if the `source` trivially doesn't contain it for our correspondence-checking fastpath
// since `undefined` is frequently added by optionality and would otherwise spoil a potentially useful correspondence
var undefinedStrippedTarget = getUndefinedStrippedTargetIfNeeded(source, target);
for (var i = 0; i < sourceTypes.length; i++) {
var sourceType = sourceTypes[i];
- if (undefinedStrippedTarget.flags & 1048576 /* Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) {
+ if (undefinedStrippedTarget.flags & 1048576 /* TypeFlags.Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) {
// many unions are mappings of one another; in such cases, simply comparing members at the same index can shortcut the comparison
// such unions will have identical lengths, and their corresponding elements will match up. Another common scenario is where a large
// union has a union of objects intersected with it. In such cases, if the input was, eg `("a" | "b" | "c") & (string | boolean | {} | {whatever})`,
// the result will have the structure `"a" | "b" | "c" | "a" & {} | "b" & {} | "c" & {} | "a" & {whatever} | "b" & {whatever} | "c" & {whatever}`
// - the resulting union has a length which is a multiple of the original union, and the elements correspond modulo the length of the original union
- var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
+ var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* RecursionFlags.Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
if (related_1) {
result &= related_1;
continue;
}
}
- var related = isRelatedTo(sourceType, target, 1 /* Source */, reportErrors, /*headMessage*/ undefined, intersectionState);
+ var related = isRelatedTo(sourceType, target, 1 /* RecursionFlags.Source */, reportErrors, /*headMessage*/ undefined, intersectionState);
if (!related) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
result &= related;
}
@@ -64158,54 +65369,54 @@ var ts;
if (targets === void 0) { targets = ts.emptyArray; }
if (variances === void 0) { variances = ts.emptyArray; }
if (sources.length !== targets.length && relation === identityRelation) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
var length = sources.length <= targets.length ? sources.length : targets.length;
- var result = -1 /* True */;
+ var result = -1 /* Ternary.True */;
for (var i = 0; i < length; i++) {
// When variance information isn't available we default to covariance. This happens
// in the process of computing variance information for recursive types and when
// comparing 'this' type arguments.
- var varianceFlags = i < variances.length ? variances[i] : 1 /* Covariant */;
- var variance = varianceFlags & 7 /* VarianceMask */;
+ var varianceFlags = i < variances.length ? variances[i] : 1 /* VarianceFlags.Covariant */;
+ var variance = varianceFlags & 7 /* VarianceFlags.VarianceMask */;
// We ignore arguments for independent type parameters (because they're never witnessed).
- if (variance !== 4 /* Independent */) {
+ if (variance !== 4 /* VarianceFlags.Independent */) {
var s = sources[i];
var t = targets[i];
- var related = -1 /* True */;
- if (varianceFlags & 8 /* Unmeasurable */) {
+ var related = -1 /* Ternary.True */;
+ if (varianceFlags & 8 /* VarianceFlags.Unmeasurable */) {
// Even an `Unmeasurable` variance works out without a structural check if the source and target are _identical_.
// We can't simply assume invariance, because `Unmeasurable` marks nonlinear relations, for example, a relation tained by
// the `-?` modifier in a mapped type (where, no matter how the inputs are related, the outputs still might not be)
- related = relation === identityRelation ? isRelatedTo(s, t, 3 /* Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t);
+ related = relation === identityRelation ? isRelatedTo(s, t, 3 /* RecursionFlags.Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t);
}
- else if (variance === 1 /* Covariant */) {
- related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
+ else if (variance === 1 /* VarianceFlags.Covariant */) {
+ related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
}
- else if (variance === 2 /* Contravariant */) {
- related = isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
+ else if (variance === 2 /* VarianceFlags.Contravariant */) {
+ related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
}
- else if (variance === 3 /* Bivariant */) {
+ else if (variance === 3 /* VarianceFlags.Bivariant */) {
// In the bivariant case we first compare contravariantly without reporting
// errors. Then, if that doesn't succeed, we compare covariantly with error
// reporting. Thus, error elaboration will be based on the the covariant check,
// which is generally easier to reason about.
- related = isRelatedTo(t, s, 3 /* Both */, /*reportErrors*/ false);
+ related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, /*reportErrors*/ false);
if (!related) {
- related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
+ related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
}
}
else {
// In the invariant case we first compare covariantly, and only when that
// succeeds do we proceed to compare contravariantly. Thus, error elaboration
// will typically be based on the covariant check.
- related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
+ related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
if (related) {
- related &= isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
+ related &= isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
}
}
if (!related) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
result &= related;
}
@@ -64219,28 +65430,28 @@ var ts;
// and issue an error. Otherwise, actually compare the structure of the two types.
function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags) {
if (overflow) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
- var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* InPropertyCheck */ : 0);
+ var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* IntersectionState.InPropertyCheck */ : 0);
var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
var entry = relation.get(id);
if (entry !== undefined) {
- if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) {
+ if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) {
// We are elaborating errors and the cached result is an unreported failure. The result will be reported
// as a failure, and should be updated as a reported failure by the bottom of this function.
}
else {
if (outofbandVarianceMarkerHandler) {
// We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component
- var saved = entry & 24 /* ReportsMask */;
- if (saved & 8 /* ReportsUnmeasurable */) {
+ var saved = entry & 24 /* RelationComparisonResult.ReportsMask */;
+ if (saved & 8 /* RelationComparisonResult.ReportsUnmeasurable */) {
instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers));
}
- if (saved & 16 /* ReportsUnreliable */) {
+ if (saved & 16 /* RelationComparisonResult.ReportsUnreliable */) {
instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
}
}
- return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */;
+ return entry & 1 /* RelationComparisonResult.Succeeded */ ? -1 /* Ternary.True */ : 0 /* Ternary.False */;
}
}
if (!maybeKeys) {
@@ -64256,42 +65467,42 @@ var ts;
for (var i = 0; i < maybeCount; i++) {
// If source and target are already being compared, consider them related with assumptions
if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) {
- return 3 /* Maybe */;
+ return 3 /* Ternary.Maybe */;
}
}
if (sourceDepth === 100 || targetDepth === 100) {
overflow = true;
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
}
var maybeStart = maybeCount;
maybeKeys[maybeCount] = id;
maybeCount++;
var saveExpandingFlags = expandingFlags;
- if (recursionFlags & 1 /* Source */) {
+ if (recursionFlags & 1 /* RecursionFlags.Source */) {
sourceStack[sourceDepth] = source;
sourceDepth++;
- if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth))
- expandingFlags |= 1 /* Source */;
+ if (!(expandingFlags & 1 /* ExpandingFlags.Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth))
+ expandingFlags |= 1 /* ExpandingFlags.Source */;
}
- if (recursionFlags & 2 /* Target */) {
+ if (recursionFlags & 2 /* RecursionFlags.Target */) {
targetStack[targetDepth] = target;
targetDepth++;
- if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth))
- expandingFlags |= 2 /* Target */;
+ if (!(expandingFlags & 2 /* ExpandingFlags.Target */) && isDeeplyNestedType(target, targetStack, targetDepth))
+ expandingFlags |= 2 /* ExpandingFlags.Target */;
}
var originalHandler;
var propagatingVarianceFlags = 0;
if (outofbandVarianceMarkerHandler) {
originalHandler = outofbandVarianceMarkerHandler;
outofbandVarianceMarkerHandler = function (onlyUnreliable) {
- propagatingVarianceFlags |= onlyUnreliable ? 16 /* ReportsUnreliable */ : 8 /* ReportsUnmeasurable */;
+ propagatingVarianceFlags |= onlyUnreliable ? 16 /* RelationComparisonResult.ReportsUnreliable */ : 8 /* RelationComparisonResult.ReportsUnmeasurable */;
return originalHandler(onlyUnreliable);
};
}
var result;
- if (expandingFlags === 3 /* Both */) {
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", {
+ if (expandingFlags === 3 /* ExpandingFlags.Both */) {
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", {
sourceId: source.id,
sourceIdStack: sourceStack.map(function (t) { return t.id; }),
targetId: target.id,
@@ -64299,30 +65510,30 @@ var ts;
depth: sourceDepth,
targetDepth: targetDepth
});
- result = 3 /* Maybe */;
+ result = 3 /* Ternary.Maybe */;
}
else {
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState);
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
}
if (outofbandVarianceMarkerHandler) {
outofbandVarianceMarkerHandler = originalHandler;
}
- if (recursionFlags & 1 /* Source */) {
+ if (recursionFlags & 1 /* RecursionFlags.Source */) {
sourceDepth--;
}
- if (recursionFlags & 2 /* Target */) {
+ if (recursionFlags & 2 /* RecursionFlags.Target */) {
targetDepth--;
}
expandingFlags = saveExpandingFlags;
if (result) {
- if (result === -1 /* True */ || (sourceDepth === 0 && targetDepth === 0)) {
- if (result === -1 /* True */ || result === 3 /* Maybe */) {
+ if (result === -1 /* Ternary.True */ || (sourceDepth === 0 && targetDepth === 0)) {
+ if (result === -1 /* Ternary.True */ || result === 3 /* Ternary.Maybe */) {
// If result is definitely true, record all maybe keys as having succeeded. Also, record Ternary.Maybe
// results as having succeeded once we reach depth 0, but never record Ternary.Unknown results.
for (var i = maybeStart; i < maybeCount; i++) {
- relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags);
+ relation.set(maybeKeys[i], 1 /* RelationComparisonResult.Succeeded */ | propagatingVarianceFlags);
}
}
maybeCount = maybeStart;
@@ -64331,14 +65542,14 @@ var ts;
else {
// A false result goes straight into global cache (when something is false under
// assumptions it will also be false without assumptions)
- relation.set(id, (reportErrors ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags);
+ relation.set(id, (reportErrors ? 4 /* RelationComparisonResult.Reported */ : 0) | 2 /* RelationComparisonResult.Failed */ | propagatingVarianceFlags);
maybeCount = maybeStart;
}
return result;
}
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
- if (intersectionState & 4 /* PropertyCheck */) {
- return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */);
+ if (intersectionState & 4 /* IntersectionState.PropertyCheck */) {
+ return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
}
var result;
var originalErrorInfo;
@@ -64348,29 +65559,29 @@ var ts;
var targetFlags = target.flags;
if (relation === identityRelation) {
// We've already checked that source.flags and target.flags are identical
- if (sourceFlags & 3145728 /* UnionOrIntersection */) {
+ if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */) {
var result_8 = eachTypeRelatedToSomeType(source, target);
if (result_8) {
result_8 &= eachTypeRelatedToSomeType(target, source);
}
return result_8;
}
- if (sourceFlags & 4194304 /* Index */) {
- return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false);
+ if (sourceFlags & 4194304 /* TypeFlags.Index */) {
+ return isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false);
}
- if (sourceFlags & 8388608 /* IndexedAccess */) {
- if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) {
- if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) {
+ if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) {
+ if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) {
+ if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) {
return result;
}
}
}
- if (sourceFlags & 16777216 /* Conditional */) {
+ if (sourceFlags & 16777216 /* TypeFlags.Conditional */) {
if (source.root.isDistributive === target.root.isDistributive) {
- if (result = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) {
- if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) {
- if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
- if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
+ if (result = isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) {
+ if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) {
+ if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) {
+ if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) {
return result;
}
}
@@ -64378,18 +65589,18 @@ var ts;
}
}
}
- if (sourceFlags & 33554432 /* Substitution */) {
- return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false);
+ if (sourceFlags & 33554432 /* TypeFlags.Substitution */) {
+ return isRelatedTo(source.substitute, target.substitute, 3 /* RecursionFlags.Both */, /*reportErrors*/ false);
}
- if (!(sourceFlags & 524288 /* Object */)) {
- return 0 /* False */;
+ if (!(sourceFlags & 524288 /* TypeFlags.Object */)) {
+ return 0 /* Ternary.False */;
}
}
- else if (sourceFlags & 3145728 /* UnionOrIntersection */ || targetFlags & 3145728 /* UnionOrIntersection */) {
+ else if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */ || targetFlags & 3145728 /* TypeFlags.UnionOrIntersection */) {
if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) {
return result;
}
- if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) {
+ if (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */) {
// The combined constraint of an intersection type is the intersection of the constraints of
// the constituents. When an intersection type contains instantiable types with union type
// constraints, there are situations where we need to examine the combined constraint. One is
@@ -64403,10 +65614,10 @@ var ts;
// needs to have its constraint hoisted into an intersection with said type parameter, this way
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
- var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
+ var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */));
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
- if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
+ if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
resetErrorInfo(saveErrorInfo);
return result;
}
@@ -64418,21 +65629,20 @@ var ts;
// Source is an intersection, target is an object (e.g. { a } & { b } <=> { a, b }).
// Source is an intersection, target is a union (e.g. { a } & { b: boolean } <=> { a, b: true } | { a, b: false }).
// Source is an intersection, target instantiable (e.g. string & { tag } <=> T["a"] constrained to string & { tag }).
- if (!(sourceFlags & 465829888 /* Instantiable */ ||
- sourceFlags & 524288 /* Object */ && targetFlags & 1048576 /* Union */ ||
- sourceFlags & 2097152 /* Intersection */ && targetFlags & (524288 /* Object */ | 1048576 /* Union */ | 465829888 /* Instantiable */))) {
- return 0 /* False */;
+ if (!(sourceFlags & 465829888 /* TypeFlags.Instantiable */ ||
+ sourceFlags & 524288 /* TypeFlags.Object */ && targetFlags & 1048576 /* TypeFlags.Union */ ||
+ sourceFlags & 2097152 /* TypeFlags.Intersection */ && targetFlags & (524288 /* TypeFlags.Object */ | 1048576 /* TypeFlags.Union */ | 465829888 /* TypeFlags.Instantiable */))) {
+ return 0 /* Ternary.False */;
}
}
// We limit alias variance probing to only object and conditional types since their alias behavior
// is more predictable than other, interned types, which may or may not have an alias depending on
// the order in which things were checked.
- if (sourceFlags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol &&
- source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
- !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) {
+ if (sourceFlags & (524288 /* TypeFlags.Object */ | 16777216 /* TypeFlags.Conditional */) && source.aliasSymbol && source.aliasTypeArguments &&
+ source.aliasSymbol === target.aliasSymbol && !(isMarkerType(source) || isMarkerType(target))) {
var variances = getAliasVariances(source.aliasSymbol);
if (variances === ts.emptyArray) {
- return 1 /* Unknown */;
+ return 1 /* Ternary.Unknown */;
}
var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState);
if (varianceResult !== undefined) {
@@ -64441,34 +65651,34 @@ var ts;
}
// For a generic type T and a type U that is assignable to T, [...U] is assignable to T, U is assignable to readonly [...T],
// and U is assignable to [...T] when U is constrained to a mutable array or tuple type.
- if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* Source */)) ||
- isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) {
+ if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* RecursionFlags.Source */)) ||
+ isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* RecursionFlags.Target */))) {
return result;
}
- if (targetFlags & 262144 /* TypeParameter */) {
+ if (targetFlags & 262144 /* TypeFlags.TypeParameter */) {
// A source type { [P in Q]: X } is related to a target type T if keyof T is related to Q and X is related to T[Q].
- if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) {
- if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) {
+ if (ts.getObjectFlags(source) & 32 /* ObjectFlags.Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* RecursionFlags.Both */)) {
+ if (!(getMappedTypeModifiers(source) & 4 /* MappedTypeModifiers.IncludeOptional */)) {
var templateType = getTemplateTypeFromMappedType(source);
var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source));
- if (result = isRelatedTo(templateType, indexedAccessType, 3 /* Both */, reportErrors)) {
+ if (result = isRelatedTo(templateType, indexedAccessType, 3 /* RecursionFlags.Both */, reportErrors)) {
return result;
}
}
}
}
- else if (targetFlags & 4194304 /* Index */) {
+ else if (targetFlags & 4194304 /* TypeFlags.Index */) {
var targetType_1 = target.type;
// A keyof S is related to a keyof T if T is related to S.
- if (sourceFlags & 4194304 /* Index */) {
- if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) {
+ if (sourceFlags & 4194304 /* TypeFlags.Index */) {
+ if (result = isRelatedTo(targetType_1, source.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) {
return result;
}
}
if (isTupleType(targetType_1)) {
// An index type can have a tuple type target when the tuple type contains variadic elements.
// Check if the source is related to the known keys of the tuple type.
- if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* Target */, reportErrors)) {
+ if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* RecursionFlags.Target */, reportErrors)) {
return result;
}
}
@@ -64481,8 +65691,8 @@ var ts;
// false positives. For example, given 'T extends { [K in keyof T]: string }',
// 'keyof T' has itself as its constraint and produces a Ternary.Maybe when
// related to other types.
- if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* Target */, reportErrors) === -1 /* True */) {
- return -1 /* True */;
+ if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) {
+ return -1 /* Ternary.True */;
}
}
else if (isGenericMappedType(targetType_1)) {
@@ -64497,7 +65707,7 @@ var ts;
// missing from the `constraintType` which will otherwise be mapped in the object
var modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType_1));
var mappedKeys_1 = [];
- forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */,
+ forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */,
/*stringsOnly*/ false, function (t) { return void mappedKeys_1.push(instantiateType(nameType_1, appendTypeMapping(targetType_1.mapper, getTypeParameterFromMappedType(targetType_1), t))); });
// We still need to include the non-apparent (and thus still generic) keys in the target side of the comparison (in case they're in the source side)
targetKeys = getUnionType(__spreadArray(__spreadArray([], mappedKeys_1, true), [nameType_1], false));
@@ -64505,18 +65715,18 @@ var ts;
else {
targetKeys = nameType_1 || constraintType;
}
- if (isRelatedTo(source, targetKeys, 2 /* Target */, reportErrors) === -1 /* True */) {
- return -1 /* True */;
+ if (isRelatedTo(source, targetKeys, 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) {
+ return -1 /* Ternary.True */;
}
}
}
}
- else if (targetFlags & 8388608 /* IndexedAccess */) {
- if (sourceFlags & 8388608 /* IndexedAccess */) {
+ else if (targetFlags & 8388608 /* TypeFlags.IndexedAccess */) {
+ if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) {
// Relate components directly before falling back to constraint relationships
// A type S[K] is related to a type T[J] if S is related to T and K is related to J.
- if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) {
- result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors);
+ if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, reportErrors)) {
+ result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, reportErrors);
}
if (result) {
resetErrorInfo(saveErrorInfo);
@@ -64534,14 +65744,14 @@ var ts;
var baseObjectType = getBaseConstraintOfType(objectType) || objectType;
var baseIndexType = getBaseConstraintOfType(indexType) || indexType;
if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) {
- var accessFlags = 4 /* Writing */ | (baseObjectType !== objectType ? 2 /* NoIndexSignatures */ : 0);
+ var accessFlags = 4 /* AccessFlags.Writing */ | (baseObjectType !== objectType ? 2 /* AccessFlags.NoIndexSignatures */ : 0);
var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, accessFlags);
if (constraint) {
if (reportErrors && originalErrorInfo) {
// create a new chain for the constraint error
resetErrorInfo(saveErrorInfo);
}
- if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors)) {
+ if (result = isRelatedTo(source, constraint, 2 /* RecursionFlags.Target */, reportErrors)) {
return result;
}
// prefer the shorter chain of the constraint comparison chain, and the direct comparison chain
@@ -64560,12 +65770,12 @@ var ts;
var keysRemapped = !!target.declaration.nameType;
var templateType = getTemplateTypeFromMappedType(target);
var modifiers = getMappedTypeModifiers(target);
- if (!(modifiers & 8 /* ExcludeOptional */)) {
+ if (!(modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */)) {
// If the mapped type has shape `{ [P in Q]: T[P] }`,
// source `S` is related to target if `T` = `S`, i.e. `S` is related to `{ [P in Q]: S[P] }`.
- if (!keysRemapped && templateType.flags & 8388608 /* IndexedAccess */ && templateType.objectType === source &&
+ if (!keysRemapped && templateType.flags & 8388608 /* TypeFlags.IndexedAccess */ && templateType.objectType === source &&
templateType.indexType === getTypeParameterFromMappedType(target)) {
- return -1 /* True */;
+ return -1 /* Ternary.True */;
}
if (!isGenericMappedType(source)) {
// If target has shape `{ [P in Q as R]: T}`, then its keys have type `R`.
@@ -64573,22 +65783,22 @@ var ts;
var targetKeys = keysRemapped ? getNameTypeFromMappedType(target) : getConstraintTypeFromMappedType(target);
// Type of the keys of source type `S`, i.e. `keyof S`.
var sourceKeys = getIndexType(source, /*stringsOnly*/ undefined, /*noIndexSignatures*/ true);
- var includeOptional = modifiers & 4 /* IncludeOptional */;
+ var includeOptional = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */;
var filteredByApplicability = includeOptional ? intersectTypes(targetKeys, sourceKeys) : undefined;
// A source type `S` is related to a target type `{ [P in Q]: T }` if `Q` is related to `keyof S` and `S[Q]` is related to `T`.
// A source type `S` is related to a target type `{ [P in Q as R]: T }` if `R` is related to `keyof S` and `S[R]` is related to `T.
// A source type `S` is related to a target type `{ [P in Q]?: T }` if some constituent `Q'` of `Q` is related to `keyof S` and `S[Q']` is related to `T`.
// A source type `S` is related to a target type `{ [P in Q as R]?: T }` if some constituent `R'` of `R` is related to `keyof S` and `S[R']` is related to `T`.
if (includeOptional
- ? !(filteredByApplicability.flags & 131072 /* Never */)
- : isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) {
+ ? !(filteredByApplicability.flags & 131072 /* TypeFlags.Never */)
+ : isRelatedTo(targetKeys, sourceKeys, 3 /* RecursionFlags.Both */)) {
var templateType_1 = getTemplateTypeFromMappedType(target);
var typeParameter = getTypeParameterFromMappedType(target);
// Fastpath: When the template type has the form `Obj[P]` where `P` is the mapped type parameter, directly compare source `S` with `Obj`
// to avoid creating the (potentially very large) number of new intermediate types made by manufacturing `S[P]`.
- var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* Nullable */);
- if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) {
- if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* Target */, reportErrors)) {
+ var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* TypeFlags.Nullable */);
+ if (!keysRemapped && nonNullComponent.flags & 8388608 /* TypeFlags.IndexedAccess */ && nonNullComponent.indexType === typeParameter) {
+ if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* RecursionFlags.Target */, reportErrors)) {
return result;
}
}
@@ -64608,7 +65818,7 @@ var ts;
: typeParameter;
var indexedAccessType = getIndexedAccessType(source, indexingType);
// Compare `S[indexingType]` to `T`, where `T` is the type of a property of the target type.
- if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* Both */, reportErrors)) {
+ if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* RecursionFlags.Both */, reportErrors)) {
return result;
}
}
@@ -64618,12 +65828,12 @@ var ts;
}
}
}
- else if (targetFlags & 16777216 /* Conditional */) {
+ else if (targetFlags & 16777216 /* TypeFlags.Conditional */) {
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
// conditional type and bail out with a Ternary.Maybe result.
if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
resetErrorInfo(saveErrorInfo);
- return 3 /* Maybe */;
+ return 3 /* Ternary.Maybe */;
}
var c = target;
// We check for a relationship to a conditional type target only when the conditional type has no
@@ -64634,8 +65844,8 @@ var ts;
var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType));
var skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType));
// TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't)
- if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) {
- result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false);
+ if (result = skipTrue ? -1 /* Ternary.True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false)) {
+ result &= skipFalse ? -1 /* Ternary.True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false);
if (result) {
resetErrorInfo(saveErrorInfo);
return result;
@@ -64643,37 +65853,37 @@ var ts;
}
}
}
- else if (targetFlags & 134217728 /* TemplateLiteral */) {
- if (sourceFlags & 134217728 /* TemplateLiteral */) {
+ else if (targetFlags & 134217728 /* TypeFlags.TemplateLiteral */) {
+ if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */) {
if (relation === comparableRelation) {
- return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */;
+ return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* Ternary.False */ : -1 /* Ternary.True */;
}
// Report unreliable variance for type variables referenced in template literal type placeholders.
// For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string.
instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
}
if (isTypeMatchedByTemplateLiteralType(source, target)) {
- return -1 /* True */;
+ return -1 /* Ternary.True */;
}
}
- if (sourceFlags & 8650752 /* TypeVariable */) {
+ if (sourceFlags & 8650752 /* TypeFlags.TypeVariable */) {
// IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
- if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
+ if (!(sourceFlags & 8388608 /* TypeFlags.IndexedAccess */ && targetFlags & 8388608 /* TypeFlags.IndexedAccess */)) {
var constraint = getConstraintOfType(source);
- if (!constraint || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
+ if (!constraint || (sourceFlags & 262144 /* TypeFlags.TypeParameter */ && constraint.flags & 1 /* TypeFlags.Any */)) {
// A type variable with no constraint is not related to the non-primitive object type.
- if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
+ if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* TypeFlags.NonPrimitive */), 3 /* RecursionFlags.Both */)) {
resetErrorInfo(saveErrorInfo);
return result;
}
}
// hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed
- else if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
+ else if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
resetErrorInfo(saveErrorInfo);
return result;
}
// slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
- else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
+ else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* RecursionFlags.Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeFlags.TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
resetErrorInfo(saveErrorInfo);
return result;
}
@@ -64682,7 +65892,7 @@ var ts;
// substituted for P. We also want to explore type { [P in K]: E }[C], where C is the constraint of X.
var indexConstraint = getConstraintOfType(source.indexType);
if (indexConstraint) {
- if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) {
+ if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* RecursionFlags.Source */, reportErrors)) {
resetErrorInfo(saveErrorInfo);
return result;
}
@@ -64690,44 +65900,44 @@ var ts;
}
}
}
- else if (sourceFlags & 4194304 /* Index */) {
- if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
+ else if (sourceFlags & 4194304 /* TypeFlags.Index */) {
+ if (result = isRelatedTo(keyofConstraintType, target, 1 /* RecursionFlags.Source */, reportErrors)) {
resetErrorInfo(saveErrorInfo);
return result;
}
}
- else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
- if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
+ else if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */ && !(targetFlags & 524288 /* TypeFlags.Object */)) {
+ if (!(targetFlags & 134217728 /* TypeFlags.TemplateLiteral */)) {
var constraint = getBaseConstraintOfType(source);
- if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
+ if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) {
resetErrorInfo(saveErrorInfo);
return result;
}
}
}
- else if (sourceFlags & 268435456 /* StringMapping */) {
- if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
- if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
+ else if (sourceFlags & 268435456 /* TypeFlags.StringMapping */) {
+ if (targetFlags & 268435456 /* TypeFlags.StringMapping */ && source.symbol === target.symbol) {
+ if (result = isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, reportErrors)) {
resetErrorInfo(saveErrorInfo);
return result;
}
}
else {
var constraint = getBaseConstraintOfType(source);
- if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
+ if (constraint && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) {
resetErrorInfo(saveErrorInfo);
return result;
}
}
}
- else if (sourceFlags & 16777216 /* Conditional */) {
+ else if (sourceFlags & 16777216 /* TypeFlags.Conditional */) {
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
// conditional type and bail out with a Ternary.Maybe result.
if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
resetErrorInfo(saveErrorInfo);
- return 3 /* Maybe */;
+ return 3 /* Ternary.Maybe */;
}
- if (targetFlags & 16777216 /* Conditional */) {
+ if (targetFlags & 16777216 /* TypeFlags.Conditional */) {
// Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
// one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
// and Y1 is related to Y2.
@@ -64736,15 +65946,15 @@ var ts;
var mapper = void 0;
if (sourceParams) {
// If the source has infer type parameters, we instantiate them in the context of the target
- var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedToWorker);
- inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
+ var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* InferenceFlags.None */, isRelatedToWorker);
+ inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */);
sourceExtends = instantiateType(sourceExtends, ctx.mapper);
mapper = ctx.mapper;
}
if (isTypeIdenticalTo(sourceExtends, target.extendsType) &&
- (isRelatedTo(source.checkType, target.checkType, 3 /* Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* Both */))) {
- if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* Both */, reportErrors)) {
- result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors);
+ (isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* RecursionFlags.Both */))) {
+ if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors)) {
+ result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors);
}
if (result) {
resetErrorInfo(saveErrorInfo);
@@ -64757,7 +65967,7 @@ var ts;
// more assignments than are desirable (since it maps the source check type to its constraint, it loses information)
var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined;
if (distributiveConstraint) {
- if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) {
+ if (result = isRelatedTo(distributiveConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) {
resetErrorInfo(saveErrorInfo);
return result;
}
@@ -64767,7 +65977,7 @@ var ts;
// when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!).
var defaultConstraint = getDefaultConstraintOfConditionalType(source);
if (defaultConstraint) {
- if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) {
+ if (result = isRelatedTo(defaultConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) {
resetErrorInfo(saveErrorInfo);
return result;
}
@@ -64776,7 +65986,7 @@ var ts;
else {
// An empty object type is related to any mapped type that includes a '?' modifier.
if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target) && isEmptyObjectType(source)) {
- return -1 /* True */;
+ return -1 /* Ternary.True */;
}
if (isGenericMappedType(target)) {
if (isGenericMappedType(source)) {
@@ -64785,18 +65995,23 @@ var ts;
return result;
}
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
- var sourceIsPrimitive = !!(sourceFlags & 131068 /* Primitive */);
+ var sourceIsPrimitive = !!(sourceFlags & 131068 /* TypeFlags.Primitive */);
if (relation !== identityRelation) {
source = getApparentType(source);
sourceFlags = source.flags;
}
else if (isGenericMappedType(source)) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
- if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target &&
- !isTupleType(source) && !(ts.getObjectFlags(source) & 4096 /* MarkerType */ || ts.getObjectFlags(target) & 4096 /* MarkerType */)) {
+ if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && source.target === target.target &&
+ !isTupleType(source) && !(isMarkerType(source) || isMarkerType(target))) {
+ // When strictNullChecks is disabled, the element type of the empty array literal is undefinedWideningType,
+ // and an empty array literal wouldn't be assignable to a `never[]` without this check.
+ if (isEmptyArrayLiteralType(source)) {
+ return -1 /* Ternary.True */;
+ }
// We have type references to the same generic type, and the type references are not marker
// type references (which are intended by be compared structurally). Obtain the variance
// information for the type parameters and relate the type arguments accordingly.
@@ -64805,41 +66020,41 @@ var ts;
// effectively means we measure variance only from type parameter occurrences that aren't nested in
// recursive instantiations of the generic type.
if (variances === ts.emptyArray) {
- return 1 /* Unknown */;
+ return 1 /* Ternary.Unknown */;
}
var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, intersectionState);
if (varianceResult !== undefined) {
return varianceResult;
}
}
- else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
+ else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
if (relation !== identityRelation) {
- return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors);
+ return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* RecursionFlags.Both */, reportErrors);
}
else {
// By flags alone, we know that the `target` is a readonly array while the source is a normal array or tuple
// or `target` is an array and source is a tuple - in both cases the types cannot be identical, by construction
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
}
// Consider a fresh empty object literal type "closed" under the subtype relationship - this way `{} <- {[idx: string]: any} <- fresh({})`
// and not `{} <- fresh({}) <- {[idx: string]: any}`
- else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 16384 /* FreshLiteral */ && !isEmptyObjectType(source)) {
- return 0 /* False */;
+ else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 8192 /* ObjectFlags.FreshLiteral */ && !isEmptyObjectType(source)) {
+ return 0 /* Ternary.False */;
}
// Even if relationship doesn't hold for unions, intersections, or generic type references,
// it may hold in a structural comparison.
// In a check of the form X = A & B, we will have previously checked if A relates to X or B relates
// to X. Failing both of those we want to check if the aggregation of A and B's members structurally
// relates to X. Thus, we include intersection types on the source side here.
- if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 524288 /* Object */) {
+ if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 524288 /* TypeFlags.Object */) {
// Report structural errors only if we haven't reported any errors yet
var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive;
result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, intersectionState);
if (result) {
- result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors);
+ result &= signaturesRelatedTo(source, target, 0 /* SignatureKind.Call */, reportStructuralErrors);
if (result) {
- result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportStructuralErrors);
+ result &= signaturesRelatedTo(source, target, 1 /* SignatureKind.Construct */, reportStructuralErrors);
if (result) {
result &= indexSignaturesRelatedTo(source, target, sourceIsPrimitive, reportStructuralErrors, intersectionState);
}
@@ -64856,9 +66071,9 @@ var ts;
// there exists a constituent of T for every combination of the discriminants of S
// with respect to T. We do not report errors here, as we will use the existing
// error result from checking each constituent of the union.
- if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 1048576 /* Union */) {
- var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */);
- if (objectOnlyTarget.flags & 1048576 /* Union */) {
+ if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 1048576 /* TypeFlags.Union */) {
+ var objectOnlyTarget = extractTypesOfKind(target, 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 33554432 /* TypeFlags.Substitution */);
+ if (objectOnlyTarget.flags & 1048576 /* TypeFlags.Union */) {
var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
if (result_9) {
return result_9;
@@ -64866,7 +66081,7 @@ var ts;
}
}
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
function countMessageChainBreadth(info) {
if (!info)
return 0;
@@ -64876,7 +66091,7 @@ var ts;
if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) {
return result;
}
- if (ts.some(variances, function (v) { return !!(v & 24 /* AllowsStructuralFallback */); })) {
+ if (ts.some(variances, function (v) { return !!(v & 24 /* VarianceFlags.AllowsStructuralFallback */); })) {
// If some type parameter was `Unmeasurable` or `Unreliable`, and we couldn't pass by assuming it was identical, then we
// have to allow a structural fallback check
// We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially
@@ -64903,8 +66118,8 @@ var ts;
// reveal the reason).
// We can switch on `reportErrors` here, since varianceCheckFailed guarantees we return `False`,
// we can return `False` early here to skip calculating the structural error message we don't need.
- if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceMask */) === 0 /* Invariant */; }))) {
- return 0 /* False */;
+ if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceFlags.VarianceMask */) === 0 /* VarianceFlags.Invariant */; }))) {
+ return 0 /* Ternary.False */;
}
// We remember the original error information so we can restore it in case the structural
// comparison unexpectedly succeeds. This can happen when the structural comparison result
@@ -64936,14 +66151,14 @@ var ts;
var result_10;
var targetConstraint = getConstraintTypeFromMappedType(target);
var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers));
- if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) {
+ if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* RecursionFlags.Both */, reportErrors)) {
var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]);
if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) {
- return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors);
+ return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* RecursionFlags.Both */, reportErrors);
}
}
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
function typeRelatedToDiscriminatedType(source, target) {
// 1. Generate the combinations of discriminant properties & types 'source' can satisfy.
@@ -64958,7 +66173,7 @@ var ts;
var sourceProperties = getPropertiesOfType(source);
var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
if (!sourcePropertiesFiltered)
- return 0 /* False */;
+ return 0 /* Ternary.False */;
// Though we could compute the number of combinations as we generate
// the matrix, this would incur additional memory overhead due to
// array allocations. To reduce this overhead, we first compute
@@ -64970,8 +66185,8 @@ var ts;
numCombinations *= countTypes(getNonMissingTypeOfSymbol(sourceProperty));
if (numCombinations > 25) {
// We've reached the complexity limit.
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations });
- return 0 /* False */;
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations });
+ return 0 /* Ternary.False */;
}
}
// Compute the set of types for each discriminant property.
@@ -64980,7 +66195,7 @@ var ts;
for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
var sourceProperty = sourcePropertiesFiltered[i];
var sourcePropertyType = getNonMissingTypeOfSymbol(sourceProperty);
- sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* Union */
+ sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* TypeFlags.Union */
? sourcePropertyType.types
: [sourcePropertyType];
excludedProperties.add(sourceProperty.escapedName);
@@ -64989,11 +66204,11 @@ var ts;
// constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
var matchingTypes = [];
- var _loop_19 = function (combination) {
+ var _loop_20 = function (combination) {
var hasMatch = false;
outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
var type = _d[_c];
- var _loop_20 = function (i) {
+ var _loop_21 = function (i) {
var sourceProperty = sourcePropertiesFiltered[i];
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
if (!targetProperty)
@@ -65001,7 +66216,7 @@ var ts;
if (sourceProperty === targetProperty)
return "continue";
// We compare the source property to the target in the context of a single discriminant type.
- var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation);
+ var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* IntersectionState.None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation);
// If the target property could not be found, or if the properties were not related,
// then this constituent is not a match.
if (!related) {
@@ -65009,8 +66224,8 @@ var ts;
}
};
for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
- var state_7 = _loop_20(i);
- switch (state_7) {
+ var state_8 = _loop_21(i);
+ switch (state_8) {
case "continue-outer": continue outer;
}
}
@@ -65018,30 +66233,30 @@ var ts;
hasMatch = true;
}
if (!hasMatch) {
- return { value: 0 /* False */ };
+ return { value: 0 /* Ternary.False */ };
}
};
for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
var combination = discriminantCombinations_1[_a];
- var state_6 = _loop_19(combination);
- if (typeof state_6 === "object")
- return state_6.value;
+ var state_7 = _loop_20(combination);
+ if (typeof state_7 === "object")
+ return state_7.value;
}
// Compare the remaining non-discriminant properties of each match.
- var result = -1 /* True */;
+ var result = -1 /* Ternary.True */;
for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) {
var type = matchingTypes_1[_b];
- result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* None */);
+ result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* IntersectionState.None */);
if (result) {
- result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false);
+ result &= signaturesRelatedTo(source, type, 0 /* SignatureKind.Call */, /*reportStructuralErrors*/ false);
if (result) {
- result &= signaturesRelatedTo(source, type, 1 /* Construct */, /*reportStructuralErrors*/ false);
+ result &= signaturesRelatedTo(source, type, 1 /* SignatureKind.Construct */, /*reportStructuralErrors*/ false);
if (result && !(isTupleType(source) && isTupleType(type))) {
// Comparing numeric index types when both `source` and `type` are tuples is unnecessary as the
// element types should be sufficiently covered by `propertiesRelatedTo`. It also causes problems
// with index type assignability as the types for the excluded discriminants are still included
// in the index type.
- result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* None */);
+ result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* IntersectionState.None */);
}
}
}
@@ -65068,40 +66283,50 @@ var ts;
return result || properties;
}
function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) {
- var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */);
+ var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */);
var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional);
var effectiveSource = getTypeOfSourceProperty(sourceProp);
- return isRelatedTo(effectiveSource, effectiveTarget, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
+ return isRelatedTo(effectiveSource, effectiveTarget, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
}
function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) {
var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp);
var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp);
- if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) {
+ if (sourcePropFlags & 8 /* ModifierFlags.Private */ || targetPropFlags & 8 /* ModifierFlags.Private */) {
if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) {
if (reportErrors) {
- if (sourcePropFlags & 8 /* Private */ && targetPropFlags & 8 /* Private */) {
+ if (sourcePropFlags & 8 /* ModifierFlags.Private */ && targetPropFlags & 8 /* ModifierFlags.Private */) {
reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp));
}
else {
- reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* Private */ ? source : target), typeToString(sourcePropFlags & 8 /* Private */ ? target : source));
+ reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? source : target), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? target : source));
}
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
}
- else if (targetPropFlags & 16 /* Protected */) {
+ else if (targetPropFlags & 16 /* ModifierFlags.Protected */) {
if (!isValidOverrideOf(sourceProp, targetProp)) {
if (reportErrors) {
reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target));
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
}
- else if (sourcePropFlags & 16 /* Protected */) {
+ else if (sourcePropFlags & 16 /* ModifierFlags.Protected */) {
if (reportErrors) {
reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target));
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
+ }
+ // Ensure {readonly a: whatever} is not a subtype of {a: whatever},
+ // while {a: whatever} is a subtype of {readonly a: whatever}.
+ // This ensures the subtype relationship is ordered, and preventing declaration order
+ // from deciding which type "wins" in union subtype reduction.
+ // They're still assignable to one another, since `readonly` doesn't affect assignability.
+ // This is only applied during the strictSubtypeRelation -- currently used in subtype reduction
+ if (relation === strictSubtypeRelation &&
+ isReadonlySymbol(sourceProp) && !isReadonlySymbol(targetProp)) {
+ return 0 /* Ternary.False */;
}
// If the target comes from a partial union prop, allow `undefined` in the target type
var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState);
@@ -65109,10 +66334,10 @@ var ts;
if (reportErrors) {
reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp));
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
// When checking for comparability, be more lenient with optional properties.
- if (!skipOptional && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) {
+ if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
// TypeScript 1.0 spec (April 2014): 3.8.3
// S is a subtype of a type T, and T is a supertype of S if ...
// S' and T are object types and, for each member M in T..
@@ -65123,7 +66348,7 @@ var ts;
if (reportErrors) {
reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target));
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
return related;
}
@@ -65134,7 +66359,7 @@ var ts;
&& ts.isNamedDeclaration(unmatchedProperty.valueDeclaration)
&& ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name)
&& source.symbol
- && source.symbol.flags & 32 /* Class */) {
+ && source.symbol.flags & 32 /* SymbolFlags.Class */) {
var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText;
var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription);
if (symbolTableKey && getPropertyOfType(source, symbolTableKey)) {
@@ -65176,29 +66401,29 @@ var ts;
if (relation === identityRelation) {
return propertiesIdenticalTo(source, target, excludedProperties);
}
- var result = -1 /* True */;
+ var result = -1 /* Ternary.True */;
if (isTupleType(target)) {
- if (isArrayType(source) || isTupleType(source)) {
+ if (isArrayOrTupleType(source)) {
if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
var sourceArity = getTypeReferenceArity(source);
var targetArity = getTypeReferenceArity(target);
- var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* Rest */ : 4 /* Rest */;
- var targetRestFlag = target.target.combinedFlags & 4 /* Rest */;
+ var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* ElementFlags.Rest */ : 4 /* ElementFlags.Rest */;
+ var targetRestFlag = target.target.combinedFlags & 4 /* ElementFlags.Rest */;
var sourceMinLength = isTupleType(source) ? source.target.minLength : 0;
var targetMinLength = target.target.minLength;
if (!sourceRestFlag && sourceArity < targetMinLength) {
if (reportErrors) {
reportError(ts.Diagnostics.Source_has_0_element_s_but_target_requires_1, sourceArity, targetMinLength);
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
if (!targetRestFlag && targetArity < sourceMinLength) {
if (reportErrors) {
reportError(ts.Diagnostics.Source_has_0_element_s_but_target_allows_only_1, sourceMinLength, targetArity);
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
if (!targetRestFlag && (sourceRestFlag || targetArity < sourceArity)) {
if (reportErrors) {
@@ -65209,38 +66434,38 @@ var ts;
reportError(ts.Diagnostics.Target_allows_only_0_element_s_but_source_may_have_more, targetArity);
}
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
var sourceTypeArguments = getTypeArguments(source);
var targetTypeArguments = getTypeArguments(target);
- var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* NonRest */) : 0, getStartElementCount(target.target, 11 /* NonRest */));
- var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* NonRest */) : 0);
+ var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, getStartElementCount(target.target, 11 /* ElementFlags.NonRest */));
+ var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* ElementFlags.NonRest */) : 0);
var canExcludeDiscriminants = !!excludedProperties;
for (var i = 0; i < targetArity; i++) {
var sourceIndex = i < targetArity - endCount ? i : i + sourceArity - targetArity;
- var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* Rest */;
+ var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* ElementFlags.Rest */;
var targetFlags = target.target.elementFlags[i];
- if (targetFlags & 8 /* Variadic */ && !(sourceFlags & 8 /* Variadic */)) {
+ if (targetFlags & 8 /* ElementFlags.Variadic */ && !(sourceFlags & 8 /* ElementFlags.Variadic */)) {
if (reportErrors) {
reportError(ts.Diagnostics.Source_provides_no_match_for_variadic_element_at_position_0_in_target, i);
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
- if (sourceFlags & 8 /* Variadic */ && !(targetFlags & 12 /* Variable */)) {
+ if (sourceFlags & 8 /* ElementFlags.Variadic */ && !(targetFlags & 12 /* ElementFlags.Variable */)) {
if (reportErrors) {
reportError(ts.Diagnostics.Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target, sourceIndex, i);
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
- if (targetFlags & 1 /* Required */ && !(sourceFlags & 1 /* Required */)) {
+ if (targetFlags & 1 /* ElementFlags.Required */ && !(sourceFlags & 1 /* ElementFlags.Required */)) {
if (reportErrors) {
reportError(ts.Diagnostics.Source_provides_no_match_for_required_element_at_position_0_in_target, i);
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
// We can only exclude discriminant properties if we have not yet encountered a variable-length element.
if (canExcludeDiscriminants) {
- if (sourceFlags & 12 /* Variable */ || targetFlags & 12 /* Variable */) {
+ if (sourceFlags & 12 /* ElementFlags.Variable */ || targetFlags & 12 /* ElementFlags.Variable */) {
canExcludeDiscriminants = false;
}
if (canExcludeDiscriminants && (excludedProperties === null || excludedProperties === void 0 ? void 0 : excludedProperties.has(("" + i)))) {
@@ -65248,12 +66473,12 @@ var ts;
}
}
var sourceType = !isTupleType(source) ? sourceTypeArguments[0] :
- i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* Optional */)) :
+ i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* ElementFlags.Optional */)) :
getElementTypeOfSliceOfTupleType(source, startCount, endCount) || neverType;
var targetType = targetTypeArguments[i];
- var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) :
- removeMissingType(targetType, !!(targetFlags & 2 /* Optional */));
- var related = isRelatedTo(sourceType, targetCheckType, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
+ var targetCheckType = sourceFlags & 8 /* ElementFlags.Variadic */ && targetFlags & 4 /* ElementFlags.Rest */ ? createArrayType(targetType) :
+ removeMissingType(targetType, !!(targetFlags & 2 /* ElementFlags.Optional */));
+ var related = isRelatedTo(sourceType, targetCheckType, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
if (!related) {
if (reportErrors && (targetArity > 1 || sourceArity > 1)) {
if (i < startCount || i >= targetArity - endCount || sourceArity - startCount - endCount === 1) {
@@ -65263,34 +66488,34 @@ var ts;
reportIncompatibleError(ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target, startCount, sourceArity - endCount - 1, i);
}
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
result &= related;
}
return result;
}
- if (target.target.combinedFlags & 12 /* Variable */) {
- return 0 /* False */;
+ if (target.target.combinedFlags & 12 /* ElementFlags.Variable */) {
+ return 0 /* Ternary.False */;
}
}
var requireOptionalProperties = (relation === subtypeRelation || relation === strictSubtypeRelation) && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source);
var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties, /*matchDiscriminantProperties*/ false);
if (unmatchedProperty) {
- if (reportErrors) {
+ if (reportErrors && shouldReportUnmatchedPropertyError(source, target)) {
reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties);
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
if (isObjectLiteralType(target)) {
for (var _i = 0, _a = excludeProperties(getPropertiesOfType(source), excludedProperties); _i < _a.length; _i++) {
var sourceProp = _a[_i];
if (!getPropertyOfObjectType(target, sourceProp.escapedName)) {
var sourceType = getTypeOfSymbol(sourceProp);
- if (!(sourceType.flags & 32768 /* Undefined */)) {
+ if (!(sourceType.flags & 32768 /* TypeFlags.Undefined */)) {
if (reportErrors) {
reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target));
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
}
}
@@ -65302,12 +66527,12 @@ var ts;
for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) {
var targetProp = _c[_b];
var name = targetProp.escapedName;
- if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) {
+ if (!(targetProp.flags & 4194304 /* SymbolFlags.Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) {
var sourceProp = getPropertyOfType(source, name);
if (sourceProp && sourceProp !== targetProp) {
var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation);
if (!related) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
result &= related;
}
@@ -65316,24 +66541,24 @@ var ts;
return result;
}
function propertiesIdenticalTo(source, target, excludedProperties) {
- if (!(source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */)) {
- return 0 /* False */;
+ if (!(source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */)) {
+ return 0 /* Ternary.False */;
}
var sourceProperties = excludeProperties(getPropertiesOfObjectType(source), excludedProperties);
var targetProperties = excludeProperties(getPropertiesOfObjectType(target), excludedProperties);
if (sourceProperties.length !== targetProperties.length) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
- var result = -1 /* True */;
+ var result = -1 /* Ternary.True */;
for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) {
var sourceProp = sourceProperties_1[_i];
var targetProp = getPropertyOfObjectType(target, sourceProp.escapedName);
if (!targetProp) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
var related = compareProperties(sourceProp, targetProp, isRelatedTo);
if (!related) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
result &= related;
}
@@ -65345,17 +66570,17 @@ var ts;
return signaturesIdenticalTo(source, target, kind);
}
if (target === anyFunctionType || source === anyFunctionType) {
- return -1 /* True */;
+ return -1 /* Ternary.True */;
}
var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration);
var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration);
- var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* Construct */) ?
- 0 /* Call */ : kind);
- var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* Construct */) ?
- 0 /* Call */ : kind);
- if (kind === 1 /* Construct */ && sourceSignatures.length && targetSignatures.length) {
- var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* Abstract */);
- var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* Abstract */);
+ var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ?
+ 0 /* SignatureKind.Call */ : kind);
+ var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ?
+ 0 /* SignatureKind.Call */ : kind);
+ if (kind === 1 /* SignatureKind.Construct */ && sourceSignatures.length && targetSignatures.length) {
+ var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* SignatureFlags.Abstract */);
+ var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* SignatureFlags.Abstract */);
if (sourceIsAbstract && !targetIsAbstract) {
// An abstract constructor type is not assignable to a non-abstract constructor type
// as it would otherwise be possible to new an abstract class. Note that the assignability
@@ -65364,18 +66589,18 @@ var ts;
if (reportErrors) {
reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type);
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
}
- var result = -1 /* True */;
- var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
+ var result = -1 /* Ternary.True */;
+ var incompatibleReporter = kind === 1 /* SignatureKind.Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
var sourceObjectFlags = ts.getObjectFlags(source);
var targetObjectFlags = ts.getObjectFlags(target);
- if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol ||
- sourceObjectFlags & 4 /* Reference */ && targetObjectFlags & 4 /* Reference */ && source.target === target.target) {
+ if (sourceObjectFlags & 64 /* ObjectFlags.Instantiated */ && targetObjectFlags & 64 /* ObjectFlags.Instantiated */ && source.symbol === target.symbol ||
+ sourceObjectFlags & 4 /* ObjectFlags.Reference */ && targetObjectFlags & 4 /* ObjectFlags.Reference */ && source.target === target.target) {
// We have instantiations of the same anonymous type (which typically will be the type of a
// method). Simply do a pairwise comparison of the signatures in the two signature lists instead
// of the much more expensive N * M comparison matrix we explore below. We erase type parameters
@@ -65383,7 +66608,7 @@ var ts;
for (var i = 0; i < targetSignatures.length; i++) {
var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i]));
if (!related) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
result &= related;
}
@@ -65398,10 +66623,10 @@ var ts;
var sourceSignature = ts.first(sourceSignatures);
var targetSignature = ts.first(targetSignatures);
result = signatureRelatedTo(sourceSignature, targetSignature, eraseGenerics, reportErrors, incompatibleReporter(sourceSignature, targetSignature));
- if (!result && reportErrors && kind === 1 /* Construct */ && (sourceObjectFlags & targetObjectFlags) &&
- (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 170 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 170 /* Constructor */)) {
+ if (!result && reportErrors && kind === 1 /* SignatureKind.Construct */ && (sourceObjectFlags & targetObjectFlags) &&
+ (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* SyntaxKind.Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 171 /* SyntaxKind.Constructor */)) {
var constructSignatureToString = function (signature) {
- return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* WriteArrowStyleSignature */, kind);
+ return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* TypeFormatFlags.WriteArrowStyleSignature */, kind);
};
reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, constructSignatureToString(sourceSignature), constructSignatureToString(targetSignature));
reportError(ts.Diagnostics.Types_of_construct_signatures_are_incompatible);
@@ -65427,11 +66652,24 @@ var ts;
if (shouldElaborateErrors) {
reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind));
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
}
return result;
}
+ function shouldReportUnmatchedPropertyError(source, target) {
+ var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* SignatureKind.Call */);
+ var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* SignatureKind.Construct */);
+ var typeProperties = getPropertiesOfObjectType(source);
+ if ((typeCallSignatures.length || typeConstructSignatures.length) && !typeProperties.length) {
+ if ((getSignaturesOfType(target, 0 /* SignatureKind.Call */).length && typeCallSignatures.length) ||
+ (getSignaturesOfType(target, 1 /* SignatureKind.Construct */).length && typeConstructSignatures.length)) {
+ return true; // target has similar signature kinds to source, still focus on the unmatched property
+ }
+ return false;
+ }
+ return true;
+ }
function reportIncompatibleCallSignatureReturn(siga, sigb) {
if (siga.parameters.length === 0 && sigb.parameters.length === 0) {
return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); };
@@ -65448,45 +66686,45 @@ var ts;
* See signatureAssignableTo, compareSignaturesIdentical
*/
function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) {
- return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers));
+ return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* SignatureCheckMode.StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers));
}
function signaturesIdenticalTo(source, target, kind) {
var sourceSignatures = getSignaturesOfType(source, kind);
var targetSignatures = getSignaturesOfType(target, kind);
if (sourceSignatures.length !== targetSignatures.length) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
- var result = -1 /* True */;
+ var result = -1 /* Ternary.True */;
for (var i = 0; i < sourceSignatures.length; i++) {
var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, isRelatedTo);
if (!related) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
result &= related;
}
return result;
}
function membersRelatedToIndexInfo(source, targetInfo, reportErrors) {
- var result = -1 /* True */;
+ var result = -1 /* Ternary.True */;
var keyType = targetInfo.keyType;
- var props = source.flags & 2097152 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source);
+ var props = source.flags & 2097152 /* TypeFlags.Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source);
for (var _i = 0, props_2 = props; _i < props_2.length; _i++) {
var prop = props_2[_i];
// Skip over ignored JSX and symbol-named members
if (isIgnoredJsxProperty(source, prop)) {
continue;
}
- if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), keyType)) {
+ if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), keyType)) {
var propType = getNonMissingTypeOfSymbol(prop);
- var type = exactOptionalPropertyTypes || propType.flags & 32768 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */)
+ var type = exactOptionalPropertyTypes || propType.flags & 32768 /* TypeFlags.Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* SymbolFlags.Optional */)
? propType
- : getTypeWithFacts(propType, 524288 /* NEUndefined */);
- var related = isRelatedTo(type, targetInfo.type, 3 /* Both */, reportErrors);
+ : getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */);
+ var related = isRelatedTo(type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors);
if (!related) {
if (reportErrors) {
reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop));
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
result &= related;
}
@@ -65496,7 +66734,7 @@ var ts;
if (isApplicableIndexType(info.keyType, keyType)) {
var related = indexInfoRelatedTo(info, targetInfo, reportErrors);
if (!related) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
result &= related;
}
@@ -65504,7 +66742,7 @@ var ts;
return result;
}
function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors) {
- var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */, reportErrors);
+ var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors);
if (!related && reportErrors) {
if (sourceInfo.keyType === targetInfo.keyType) {
reportError(ts.Diagnostics._0_index_signatures_are_incompatible, typeToString(sourceInfo.keyType));
@@ -65521,14 +66759,14 @@ var ts;
}
var indexInfos = getIndexInfosOfType(target);
var targetHasStringIndex = ts.some(indexInfos, function (info) { return info.keyType === stringType; });
- var result = -1 /* True */;
- for (var _i = 0, indexInfos_3 = indexInfos; _i < indexInfos_3.length; _i++) {
- var targetInfo = indexInfos_3[_i];
- var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ :
- isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* Both */, reportErrors) :
+ var result = -1 /* Ternary.True */;
+ for (var _i = 0, indexInfos_5 = indexInfos; _i < indexInfos_5.length; _i++) {
+ var targetInfo = indexInfos_5[_i];
+ var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* TypeFlags.Any */ ? -1 /* Ternary.True */ :
+ isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors) :
typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState);
if (!related) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
result &= related;
}
@@ -65539,46 +66777,46 @@ var ts;
if (sourceInfo) {
return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors);
}
- if (!(intersectionState & 1 /* Source */) && isObjectTypeWithInferableIndex(source)) {
+ if (!(intersectionState & 1 /* IntersectionState.Source */) && isObjectTypeWithInferableIndex(source)) {
// Intersection constituents are never considered to have an inferred index signature
return membersRelatedToIndexInfo(source, targetInfo, reportErrors);
}
if (reportErrors) {
reportError(ts.Diagnostics.Index_signature_for_type_0_is_missing_in_type_1, typeToString(targetInfo.keyType), typeToString(source));
}
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
function indexSignaturesIdenticalTo(source, target) {
var sourceInfos = getIndexInfosOfType(source);
var targetInfos = getIndexInfosOfType(target);
if (sourceInfos.length !== targetInfos.length) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
for (var _i = 0, targetInfos_1 = targetInfos; _i < targetInfos_1.length; _i++) {
var targetInfo = targetInfos_1[_i];
var sourceInfo = getIndexInfoOfType(source, targetInfo.keyType);
- if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) {
- return 0 /* False */;
+ if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) {
+ return 0 /* Ternary.False */;
}
}
- return -1 /* True */;
+ return -1 /* Ternary.True */;
}
function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) {
if (!sourceSignature.declaration || !targetSignature.declaration) {
return true;
}
- var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* NonPublicAccessibilityModifier */);
- var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* NonPublicAccessibilityModifier */);
+ var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */);
+ var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */);
// A public, protected and private signature is assignable to a private signature.
- if (targetAccessibility === 8 /* Private */) {
+ if (targetAccessibility === 8 /* ModifierFlags.Private */) {
return true;
}
// A public and protected signature is assignable to a protected signature.
- if (targetAccessibility === 16 /* Protected */ && sourceAccessibility !== 8 /* Private */) {
+ if (targetAccessibility === 16 /* ModifierFlags.Protected */ && sourceAccessibility !== 8 /* ModifierFlags.Private */) {
return true;
}
// Only a public signature is assignable to public signature.
- if (targetAccessibility !== 16 /* Protected */ && !sourceAccessibility) {
+ if (targetAccessibility !== 16 /* ModifierFlags.Protected */ && !sourceAccessibility) {
return true;
}
if (reportErrors) {
@@ -65591,19 +66829,19 @@ var ts;
// Okay, yes, 'boolean' is a union of 'true | false', but that's not useful
// in error reporting scenarios. If you need to use this function but that detail matters,
// feel free to add a flag.
- if (type.flags & 16 /* Boolean */) {
+ if (type.flags & 16 /* TypeFlags.Boolean */) {
return false;
}
- if (type.flags & 3145728 /* UnionOrIntersection */) {
+ if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) {
return !!ts.forEach(type.types, typeCouldHaveTopLevelSingletonTypes);
}
- if (type.flags & 465829888 /* Instantiable */) {
+ if (type.flags & 465829888 /* TypeFlags.Instantiable */) {
var constraint = getConstraintOfType(type);
if (constraint && constraint !== type) {
return typeCouldHaveTopLevelSingletonTypes(constraint);
}
}
- return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */);
+ return isUnitType(type) || !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */);
}
function getExactOptionalUnassignableProperties(source, target) {
if (isTupleType(source) && isTupleType(target))
@@ -65612,7 +66850,7 @@ var ts;
.filter(function (targetProp) { return isExactOptionalPropertyMismatch(getTypeOfPropertyOfType(source, targetProp.escapedName), getTypeOfSymbol(targetProp)); });
}
function isExactOptionalPropertyMismatch(source, target) {
- return !!source && !!target && maybeTypeOfKind(source, 32768 /* Undefined */) && !!containsMissingType(target);
+ return !!source && !!target && maybeTypeOfKind(source, 32768 /* TypeFlags.Undefined */) && !!containsMissingType(target);
}
function getExactOptionalProperties(type) {
return getPropertiesOfType(type).filter(function (targetProp) { return containsMissingType(getTypeOfSymbol(targetProp)); });
@@ -65632,7 +66870,7 @@ var ts;
for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) {
var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1];
var targetProp = getUnionOrIntersectionProperty(target, propertyName);
- if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* ReadPartial */) {
+ if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* CheckFlags.ReadPartial */) {
continue;
}
var i = 0;
@@ -65667,12 +66905,12 @@ var ts;
* and no required properties, call/construct signatures or index signatures
*/
function isWeakType(type) {
- if (type.flags & 524288 /* Object */) {
+ if (type.flags & 524288 /* TypeFlags.Object */) {
var resolved = resolveStructuredTypeMembers(type);
return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && resolved.indexInfos.length === 0 &&
- resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* Optional */); });
+ resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* SymbolFlags.Optional */); });
}
- if (type.flags & 2097152 /* Intersection */) {
+ if (type.flags & 2097152 /* TypeFlags.Intersection */) {
return ts.every(type.types, isWeakType);
}
return false;
@@ -65686,99 +66924,110 @@ var ts;
}
return false;
}
- // Return a type reference where the source type parameter is replaced with the target marker
- // type, and flag the result as a marker type reference.
- function getMarkerTypeReference(type, source, target) {
- var result = createTypeReference(type, ts.map(type.typeParameters, function (t) { return t === source ? target : t; }));
- result.objectFlags |= 4096 /* MarkerType */;
- return result;
+ function getVariances(type) {
+ // Arrays and tuples are known to be covariant, no need to spend time computing this.
+ return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* ObjectFlags.Tuple */ ?
+ arrayVariances :
+ getVariancesWorker(type.symbol, type.typeParameters);
}
function getAliasVariances(symbol) {
- var links = getSymbolLinks(symbol);
- return getVariancesWorker(links.typeParameters, links, function (_links, param, marker) {
- var type = getTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters, makeUnaryTypeMapper(param, marker)));
- type.aliasTypeArgumentsContainsMarker = true;
- return type;
- });
+ return getVariancesWorker(symbol, getSymbolLinks(symbol).typeParameters);
}
// Return an array containing the variance of each type parameter. The variance is effectively
// a digest of the type comparisons that occur for each type argument when instantiations of the
// generic type are structurally compared. We infer the variance information by comparing
// instantiations of the generic type for type arguments with known relations. The function
// returns the emptyArray singleton when invoked recursively for the given generic type.
- function getVariancesWorker(typeParameters, cache, createMarkerType) {
- var _a, _b, _c;
+ function getVariancesWorker(symbol, typeParameters) {
if (typeParameters === void 0) { typeParameters = ts.emptyArray; }
- var variances = cache.variances;
- if (!variances) {
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: (_c = (_a = cache.id) !== null && _a !== void 0 ? _a : (_b = cache.declaredType) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1 });
- // The emptyArray singleton is used to signal a recursive invocation.
- cache.variances = ts.emptyArray;
- variances = [];
- var _loop_21 = function (tp) {
- var unmeasurable = false;
- var unreliable = false;
- var oldHandler = outofbandVarianceMarkerHandler;
- outofbandVarianceMarkerHandler = function (onlyUnreliable) { return onlyUnreliable ? unreliable = true : unmeasurable = true; };
- // We first compare instantiations where the type parameter is replaced with
- // marker types that have a known subtype relationship. From this we can infer
- // invariance, covariance, contravariance or bivariance.
- var typeWithSuper = createMarkerType(cache, tp, markerSuperType);
- var typeWithSub = createMarkerType(cache, tp, markerSubType);
- var variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* Covariant */ : 0) |
- (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* Contravariant */ : 0);
- // If the instantiations appear to be related bivariantly it may be because the
- // type parameter is independent (i.e. it isn't witnessed anywhere in the generic
- // type). To determine this we compare instantiations where the type parameter is
- // replaced with marker types that are known to be unrelated.
- if (variance === 3 /* Bivariant */ && isTypeAssignableTo(createMarkerType(cache, tp, markerOtherType), typeWithSuper)) {
- variance = 4 /* Independent */;
- }
- outofbandVarianceMarkerHandler = oldHandler;
- if (unmeasurable || unreliable) {
- if (unmeasurable) {
- variance |= 8 /* Unmeasurable */;
- }
- if (unreliable) {
- variance |= 16 /* Unreliable */;
+ var links = getSymbolLinks(symbol);
+ if (!links.variances) {
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
+ links.variances = ts.emptyArray;
+ var variances = [];
+ var _loop_22 = function (tp) {
+ var modifiers = getVarianceModifiers(tp);
+ var variance = modifiers & 65536 /* ModifierFlags.Out */ ?
+ modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ :
+ modifiers & 32768 /* ModifierFlags.In */ ? 2 /* VarianceFlags.Contravariant */ : undefined;
+ if (variance === undefined) {
+ var unmeasurable_1 = false;
+ var unreliable_1 = false;
+ var oldHandler = outofbandVarianceMarkerHandler;
+ outofbandVarianceMarkerHandler = function (onlyUnreliable) { return onlyUnreliable ? unreliable_1 = true : unmeasurable_1 = true; };
+ // We first compare instantiations where the type parameter is replaced with
+ // marker types that have a known subtype relationship. From this we can infer
+ // invariance, covariance, contravariance or bivariance.
+ var typeWithSuper = createMarkerType(symbol, tp, markerSuperType);
+ var typeWithSub = createMarkerType(symbol, tp, markerSubType);
+ variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* VarianceFlags.Covariant */ : 0) |
+ (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* VarianceFlags.Contravariant */ : 0);
+ // If the instantiations appear to be related bivariantly it may be because the
+ // type parameter is independent (i.e. it isn't witnessed anywhere in the generic
+ // type). To determine this we compare instantiations where the type parameter is
+ // replaced with marker types that are known to be unrelated.
+ if (variance === 3 /* VarianceFlags.Bivariant */ && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) {
+ variance = 4 /* VarianceFlags.Independent */;
+ }
+ outofbandVarianceMarkerHandler = oldHandler;
+ if (unmeasurable_1 || unreliable_1) {
+ if (unmeasurable_1) {
+ variance |= 8 /* VarianceFlags.Unmeasurable */;
+ }
+ if (unreliable_1) {
+ variance |= 16 /* VarianceFlags.Unreliable */;
+ }
}
}
variances.push(variance);
};
for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) {
var tp = typeParameters_1[_i];
- _loop_21(tp);
+ _loop_22(tp);
}
- cache.variances = variances;
+ links.variances = variances;
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
}
- return variances;
+ return links.variances;
}
- function getVariances(type) {
- // Arrays and tuples are known to be covariant, no need to spend time computing this.
- if (type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* Tuple */) {
- return arrayVariances;
+ function createMarkerType(symbol, source, target) {
+ var mapper = makeUnaryTypeMapper(source, target);
+ var type = getDeclaredTypeOfSymbol(symbol);
+ if (isErrorType(type)) {
+ return type;
}
- return getVariancesWorker(type.typeParameters, type, getMarkerTypeReference);
+ var result = symbol.flags & 524288 /* SymbolFlags.TypeAlias */ ?
+ getTypeAliasInstantiation(symbol, instantiateTypes(getSymbolLinks(symbol).typeParameters, mapper)) :
+ createTypeReference(type, instantiateTypes(type.typeParameters, mapper));
+ markerTypes.add(getTypeId(result));
+ return result;
+ }
+ function isMarkerType(type) {
+ return markerTypes.has(getTypeId(type));
+ }
+ function getVarianceModifiers(tp) {
+ var _a, _b;
+ return (ts.some((_a = tp.symbol) === null || _a === void 0 ? void 0 : _a.declarations, function (d) { return ts.hasSyntacticModifier(d, 32768 /* ModifierFlags.In */); }) ? 32768 /* ModifierFlags.In */ : 0) |
+ (ts.some((_b = tp.symbol) === null || _b === void 0 ? void 0 : _b.declarations, function (d) { return ts.hasSyntacticModifier(d, 65536 /* ModifierFlags.Out */); }) ? 65536 /* ModifierFlags.Out */ : 0);
}
// Return true if the given type reference has a 'void' type argument for a covariant type parameter.
// See comment at call in recursiveTypeRelatedTo for when this case matters.
function hasCovariantVoidArgument(typeArguments, variances) {
for (var i = 0; i < variances.length; i++) {
- if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags & 16384 /* Void */) {
+ if ((variances[i] & 7 /* VarianceFlags.VarianceMask */) === 1 /* VarianceFlags.Covariant */ && typeArguments[i].flags & 16384 /* TypeFlags.Void */) {
return true;
}
}
return false;
}
function isUnconstrainedTypeParameter(type) {
- return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type);
+ return type.flags & 262144 /* TypeFlags.TypeParameter */ && !getConstraintOfTypeParameter(type);
}
function isNonDeferredTypeReference(type) {
- return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node;
+ return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && !type.node;
}
function isTypeReferenceWithGenericArguments(type) {
- return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); });
+ return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeFlags.TypeParameter */) || isTypeReferenceWithGenericArguments(t); });
}
function getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) {
var typeParameters = [];
@@ -65793,7 +67042,7 @@ var ts;
var result = "" + type.target.id;
for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) {
var t = _a[_i];
- if (t.flags & 262144 /* TypeParameter */) {
+ if (t.flags & 262144 /* TypeFlags.TypeParameter */) {
if (ignoreConstraints || isUnconstrainedTypeParameter(t)) {
var index = typeParameters.indexOf(t);
if (index < 0) {
@@ -65834,7 +67083,7 @@ var ts;
// Invoke the callback for each underlying property symbol of the given symbol and return the first
// value that isn't undefined.
function forEachProperty(prop, callback) {
- if (ts.getCheckFlags(prop) & 6 /* Synthetic */) {
+ if (ts.getCheckFlags(prop) & 6 /* CheckFlags.Synthetic */) {
for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) {
var t = _a[_i];
var p = getPropertyOfType(t, prop.escapedName);
@@ -65849,7 +67098,7 @@ var ts;
}
// Return the declaring class type of a property or undefined if property not declared in class
function getDeclaringClass(prop) {
- return prop.parent && prop.parent.flags & 32 /* Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined;
+ return prop.parent && prop.parent.flags & 32 /* SymbolFlags.Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined;
}
// Return the inherited type of the given property or undefined if property doesn't exist in a base class.
function getTypeOfPropertyInBaseClass(property) {
@@ -65867,13 +67116,13 @@ var ts;
}
// Return true if source property is a valid override of protected parts of target property.
function isValidOverrideOf(sourceProp, targetProp) {
- return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* Protected */ ?
+ return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* ModifierFlags.Protected */ ?
!isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; });
}
// Return true if the given class derives from each of the declaring classes of the protected
// constituents of the given property.
function isClassDerivedFromDeclaringClasses(checkClass, prop, writing) {
- return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* Protected */ ?
+ return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* ModifierFlags.Protected */ ?
!hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass;
}
// Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons
@@ -65891,12 +67140,12 @@ var ts;
function isDeeplyNestedType(type, stack, depth, maxDepth) {
if (maxDepth === void 0) { maxDepth = 3; }
if (depth >= maxDepth) {
- var identity_1 = getRecursionIdentity(type);
+ var identity_2 = getRecursionIdentity(type);
var count = 0;
var lastTypeId = 0;
for (var i = 0; i < depth; i++) {
var t = stack[i];
- if (getRecursionIdentity(t) === identity_1) {
+ if (getRecursionIdentity(t) === identity_2) {
// We only count occurrences with a higher type id than the previous occurrence, since higher
// type ids are an indicator of newer instantiations caused by recursion.
if (t.id >= lastTypeId) {
@@ -65919,14 +67168,14 @@ var ts;
// reference the type have a recursion identity that differs from the object identity.
function getRecursionIdentity(type) {
// Object and array literals are known not to contain recursive references and don't need a recursion identity.
- if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) {
- if (ts.getObjectFlags(type) && 4 /* Reference */ && type.node) {
+ if (type.flags & 524288 /* TypeFlags.Object */ && !isObjectOrArrayLiteralType(type)) {
+ if (ts.getObjectFlags(type) && 4 /* ObjectFlags.Reference */ && type.node) {
// Deferred type references are tracked through their associated AST node. This gives us finer
// granularity than using their associated target because each manifest type reference has a
// unique AST node.
return type.node;
}
- if (type.symbol && !(ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) {
+ if (type.symbol && !(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol.flags & 32 /* SymbolFlags.Class */)) {
// We track all object types that have an associated symbol (representing the origin of the type), but
// exclude the static side of classes from this check since it shares its symbol with the instance side.
return type.symbol;
@@ -65936,49 +67185,49 @@ var ts;
return type.target;
}
}
- if (type.flags & 262144 /* TypeParameter */) {
+ if (type.flags & 262144 /* TypeFlags.TypeParameter */) {
return type.symbol;
}
- if (type.flags & 8388608 /* IndexedAccess */) {
+ if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) {
// Identity is the leftmost object type in a chain of indexed accesses, eg, in A[P][Q] it is A
do {
type = type.objectType;
- } while (type.flags & 8388608 /* IndexedAccess */);
+ } while (type.flags & 8388608 /* TypeFlags.IndexedAccess */);
return type;
}
- if (type.flags & 16777216 /* Conditional */) {
+ if (type.flags & 16777216 /* TypeFlags.Conditional */) {
// The root object represents the origin of the conditional type
return type.root;
}
return type;
}
function isPropertyIdenticalTo(sourceProp, targetProp) {
- return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */;
+ return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* Ternary.False */;
}
function compareProperties(sourceProp, targetProp, compareTypes) {
// Two members are considered identical when
// - they are public properties with identical names, optionality, and types,
// - they are private or protected properties originating in the same declaration and having identical types
if (sourceProp === targetProp) {
- return -1 /* True */;
+ return -1 /* Ternary.True */;
}
- var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* NonPublicAccessibilityModifier */;
- var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* NonPublicAccessibilityModifier */;
+ var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */;
+ var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */;
if (sourcePropAccessibility !== targetPropAccessibility) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
if (sourcePropAccessibility) {
if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
}
else {
- if ((sourceProp.flags & 16777216 /* Optional */) !== (targetProp.flags & 16777216 /* Optional */)) {
- return 0 /* False */;
+ if ((sourceProp.flags & 16777216 /* SymbolFlags.Optional */) !== (targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
+ return 0 /* Ternary.False */;
}
}
if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
}
@@ -66009,14 +67258,14 @@ var ts;
function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes) {
// TODO (drosen): De-duplicate code between related functions.
if (source === target) {
- return -1 /* True */;
+ return -1 /* Ternary.True */;
}
if (!(isMatchingSignature(source, target, partialMatch))) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
// Check that the two signatures have the same number of type parameters.
if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
// Check that type parameter constraints and defaults match. If they do, instantiate the source
// signature with the type parameters of the target signature and continue the comparison.
@@ -66027,12 +67276,12 @@ var ts;
var t = target.typeParameters[i];
if (!(s === t || compareTypes(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) &&
compareTypes(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
}
source = instantiateSignature(source, mapper, /*eraseTypeParameters*/ true);
}
- var result = -1 /* True */;
+ var result = -1 /* Ternary.True */;
if (!ignoreThisTypes) {
var sourceThisType = getThisTypeOfSignature(source);
if (sourceThisType) {
@@ -66040,7 +67289,7 @@ var ts;
if (targetThisType) {
var related = compareTypes(sourceThisType, targetThisType);
if (!related) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
result &= related;
}
@@ -66052,7 +67301,7 @@ var ts;
var t = getTypeAtPosition(target, i);
var related = compareTypes(t, s);
if (!related) {
- return 0 /* False */;
+ return 0 /* Ternary.False */;
}
result &= related;
}
@@ -66066,10 +67315,10 @@ var ts;
return result;
}
function compareTypePredicatesIdentical(source, target, compareTypes) {
- return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ :
- source.type === target.type ? -1 /* True */ :
+ return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* Ternary.False */ :
+ source.type === target.type ? -1 /* Ternary.True */ :
source.type && target.type ? compareTypes(source.type, target.type) :
- 0 /* False */;
+ 0 /* Ternary.False */;
}
function literalTypesWithSameBaseType(types) {
var commonBaseType;
@@ -66100,20 +67349,23 @@ var ts;
if (!strictNullChecks) {
return getSupertypeOrUnion(types);
}
- var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); });
+ var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* TypeFlags.Nullable */); });
return primaryTypes.length ?
- getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* Nullable */) :
- getUnionType(types, 2 /* Subtype */);
+ getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* TypeFlags.Nullable */) :
+ getUnionType(types, 2 /* UnionReduction.Subtype */);
}
// Return the leftmost type for which no type to the right is a subtype.
function getCommonSubtype(types) {
return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; });
}
function isArrayType(type) {
- return !!(ts.getObjectFlags(type) & 4 /* Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType);
+ return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType);
}
function isReadonlyArrayType(type) {
- return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType;
+ return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && type.target === globalReadonlyArrayType;
+ }
+ function isArrayOrTupleType(type) {
+ return isArrayType(type) || isTupleType(type);
}
function isMutableArrayOrTuple(type) {
return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly;
@@ -66124,22 +67376,22 @@ var ts;
function isArrayLikeType(type) {
// A type is array-like if it is a reference to the global Array or global ReadonlyArray type,
// or if it is not the undefined or null type and if it is assignable to ReadonlyArray<any>
- return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType);
+ return isArrayType(type) || !(type.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType);
}
function getSingleBaseForNonAugmentingSubtype(type) {
- if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) {
+ if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ObjectFlags.ClassOrInterface */)) {
return undefined;
}
- if (ts.getObjectFlags(type) & 33554432 /* IdenticalBaseTypeCalculated */) {
- return ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined;
+ if (ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */) {
+ return ts.getObjectFlags(type) & 67108864 /* ObjectFlags.IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined;
}
- type.objectFlags |= 33554432 /* IdenticalBaseTypeCalculated */;
+ type.objectFlags |= 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */;
var target = type.target;
- if (ts.getObjectFlags(target) & 1 /* Class */) {
+ if (ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) {
var baseTypeNode = getBaseTypeNodeOfClass(target);
// A base type expression may circularly reference the class itself (e.g. as an argument to function call), so we only
// check for base types specified as simple qualified names.
- if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* Identifier */ && baseTypeNode.expression.kind !== 205 /* PropertyAccessExpression */) {
+ if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* SyntaxKind.Identifier */ && baseTypeNode.expression.kind !== 206 /* SyntaxKind.PropertyAccessExpression */) {
return undefined;
}
}
@@ -66154,7 +67406,7 @@ var ts;
if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) {
instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type)));
}
- type.objectFlags |= 67108864 /* IdenticalBaseTypeExists */;
+ type.objectFlags |= 67108864 /* ObjectFlags.IdenticalBaseTypeExists */;
return type.cachedEquivalentBaseType = instantiatedBase;
}
function isEmptyLiteralType(type) {
@@ -66181,44 +67433,44 @@ var ts;
return undefined;
}
function isNeitherUnitTypeNorNever(type) {
- return !(type.flags & (109440 /* Unit */ | 131072 /* Never */));
+ return !(type.flags & (109440 /* TypeFlags.Unit */ | 131072 /* TypeFlags.Never */));
}
function isUnitType(type) {
- return !!(type.flags & 109440 /* Unit */);
+ return !!(type.flags & 109440 /* TypeFlags.Unit */);
}
function isUnitLikeType(type) {
- return type.flags & 2097152 /* Intersection */ ? ts.some(type.types, isUnitType) :
- !!(type.flags & 109440 /* Unit */);
+ return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(type.types, isUnitType) :
+ !!(type.flags & 109440 /* TypeFlags.Unit */);
}
function extractUnitType(type) {
- return type.flags & 2097152 /* Intersection */ ? ts.find(type.types, isUnitType) || type : type;
+ return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type;
}
function isLiteralType(type) {
- return type.flags & 16 /* Boolean */ ? true :
- type.flags & 1048576 /* Union */ ? type.flags & 1024 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) :
+ return type.flags & 16 /* TypeFlags.Boolean */ ? true :
+ type.flags & 1048576 /* TypeFlags.Union */ ? type.flags & 1024 /* TypeFlags.EnumLiteral */ ? true : ts.every(type.types, isUnitType) :
isUnitType(type);
}
function getBaseTypeOfLiteralType(type) {
- return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) :
- type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? stringType :
- type.flags & 256 /* NumberLiteral */ ? numberType :
- type.flags & 2048 /* BigIntLiteral */ ? bigintType :
- type.flags & 512 /* BooleanLiteral */ ? booleanType :
- type.flags & 1048576 /* Union */ ? mapType(type, getBaseTypeOfLiteralType) :
+ return type.flags & 1024 /* TypeFlags.EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) :
+ type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? stringType :
+ type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType :
+ type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType :
+ type.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType :
+ type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getBaseTypeOfLiteralType) :
type;
}
function getWidenedLiteralType(type) {
- return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) :
- type.flags & 128 /* StringLiteral */ && isFreshLiteralType(type) ? stringType :
- type.flags & 256 /* NumberLiteral */ && isFreshLiteralType(type) ? numberType :
- type.flags & 2048 /* BigIntLiteral */ && isFreshLiteralType(type) ? bigintType :
- type.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(type) ? booleanType :
- type.flags & 1048576 /* Union */ ? mapType(type, getWidenedLiteralType) :
+ return type.flags & 1024 /* TypeFlags.EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) :
+ type.flags & 128 /* TypeFlags.StringLiteral */ && isFreshLiteralType(type) ? stringType :
+ type.flags & 256 /* TypeFlags.NumberLiteral */ && isFreshLiteralType(type) ? numberType :
+ type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isFreshLiteralType(type) ? bigintType :
+ type.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(type) ? booleanType :
+ type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedLiteralType) :
type;
}
function getWidenedUniqueESSymbolType(type) {
- return type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType :
- type.flags & 1048576 /* Union */ ? mapType(type, getWidenedUniqueESSymbolType) :
+ return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType :
+ type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedUniqueESSymbolType) :
type;
}
function getWidenedLiteralLikeTypeForContextualType(type, contextualType) {
@@ -66249,10 +67501,10 @@ var ts;
* Prefer using isTupleLikeType() unless the use of `elementTypes`/`getTypeArguments` is required.
*/
function isTupleType(type) {
- return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */);
+ return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target.objectFlags & 8 /* ObjectFlags.Tuple */);
}
function isGenericTupleType(type) {
- return isTupleType(type) && !!(type.target.combinedFlags & 8 /* Variadic */);
+ return isTupleType(type) && !!(type.target.combinedFlags & 8 /* ElementFlags.Variadic */);
}
function isSingleElementGenericTupleType(type) {
return isGenericTupleType(type) && type.target.elementFlags.length === 1;
@@ -66273,7 +67525,7 @@ var ts;
var elementTypes = [];
for (var i = index; i < length; i++) {
var t = typeArguments[i];
- elementTypes.push(type.target.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t);
+ elementTypes.push(type.target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t);
}
return writing ? getIntersectionType(elementTypes) : getUnionType(elementTypes);
}
@@ -66281,7 +67533,7 @@ var ts;
}
function isTupleTypeStructureMatching(t1, t2) {
return getTypeReferenceArity(t1) === getTypeReferenceArity(t2) &&
- ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* Variable */) === (t2.target.elementFlags[i] & 12 /* Variable */); });
+ ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* ElementFlags.Variable */) === (t2.target.elementFlags[i] & 12 /* ElementFlags.Variable */); });
}
function isZeroBigInt(_a) {
var value = _a.value;
@@ -66299,31 +67551,31 @@ var ts;
// flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns
// no flags for all other types (including non-falsy literal types).
function getFalsyFlags(type) {
- return type.flags & 1048576 /* Union */ ? getFalsyFlagsOfTypes(type.types) :
- type.flags & 128 /* StringLiteral */ ? type.value === "" ? 128 /* StringLiteral */ : 0 :
- type.flags & 256 /* NumberLiteral */ ? type.value === 0 ? 256 /* NumberLiteral */ : 0 :
- type.flags & 2048 /* BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* BigIntLiteral */ : 0 :
- type.flags & 512 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* BooleanLiteral */ : 0 :
- type.flags & 117724 /* PossiblyFalsy */;
+ return type.flags & 1048576 /* TypeFlags.Union */ ? getFalsyFlagsOfTypes(type.types) :
+ type.flags & 128 /* TypeFlags.StringLiteral */ ? type.value === "" ? 128 /* TypeFlags.StringLiteral */ : 0 :
+ type.flags & 256 /* TypeFlags.NumberLiteral */ ? type.value === 0 ? 256 /* TypeFlags.NumberLiteral */ : 0 :
+ type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? isZeroBigInt(type) ? 2048 /* TypeFlags.BigIntLiteral */ : 0 :
+ type.flags & 512 /* TypeFlags.BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 512 /* TypeFlags.BooleanLiteral */ : 0 :
+ type.flags & 117724 /* TypeFlags.PossiblyFalsy */;
}
function removeDefinitelyFalsyTypes(type) {
- return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ?
- filterType(type, function (t) { return !(getFalsyFlags(t) & 117632 /* DefinitelyFalsy */); }) :
+ return getFalsyFlags(type) & 117632 /* TypeFlags.DefinitelyFalsy */ ?
+ filterType(type, function (t) { return !(getFalsyFlags(t) & 117632 /* TypeFlags.DefinitelyFalsy */); }) :
type;
}
function extractDefinitelyFalsyTypes(type) {
return mapType(type, getDefinitelyFalsyPartOfType);
}
function getDefinitelyFalsyPartOfType(type) {
- return type.flags & 4 /* String */ ? emptyStringType :
- type.flags & 8 /* Number */ ? zeroType :
- type.flags & 64 /* BigInt */ ? zeroBigIntType :
+ return type.flags & 4 /* TypeFlags.String */ ? emptyStringType :
+ type.flags & 8 /* TypeFlags.Number */ ? zeroType :
+ type.flags & 64 /* TypeFlags.BigInt */ ? zeroBigIntType :
type === regularFalseType ||
type === falseType ||
- type.flags & (16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */ | 3 /* AnyOrUnknown */) ||
- type.flags & 128 /* StringLiteral */ && type.value === "" ||
- type.flags & 256 /* NumberLiteral */ && type.value === 0 ||
- type.flags & 2048 /* BigIntLiteral */ && isZeroBigInt(type) ? type :
+ type.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */ | 3 /* TypeFlags.AnyOrUnknown */) ||
+ type.flags & 128 /* TypeFlags.StringLiteral */ && type.value === "" ||
+ type.flags & 256 /* TypeFlags.NumberLiteral */ && type.value === 0 ||
+ type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isZeroBigInt(type) ? type :
neverType;
}
/**
@@ -66332,24 +67584,24 @@ var ts;
* @param flags - Either TypeFlags.Undefined or TypeFlags.Null, or both
*/
function getNullableType(type, flags) {
- var missing = (flags & ~type.flags) & (32768 /* Undefined */ | 65536 /* Null */);
+ var missing = (flags & ~type.flags) & (32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */);
return missing === 0 ? type :
- missing === 32768 /* Undefined */ ? getUnionType([type, undefinedType]) :
- missing === 65536 /* Null */ ? getUnionType([type, nullType]) :
+ missing === 32768 /* TypeFlags.Undefined */ ? getUnionType([type, undefinedType]) :
+ missing === 65536 /* TypeFlags.Null */ ? getUnionType([type, nullType]) :
getUnionType([type, undefinedType, nullType]);
}
function getOptionalType(type, isProperty) {
if (isProperty === void 0) { isProperty = false; }
ts.Debug.assert(strictNullChecks);
- return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]);
+ return type.flags & 32768 /* TypeFlags.Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]);
}
function getGlobalNonNullableTypeInstantiation(type) {
// First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
// 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
// that isn't eliminated by a NonNullable<T> instantiation.
- var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
+ var reducedType = getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */);
if (!deferredGlobalNonNullableTypeAlias) {
- deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol;
+ deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* SymbolFlags.TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol;
}
// If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
@@ -66377,10 +67629,10 @@ var ts;
return exactOptionalPropertyTypes && isOptional ? removeType(type, missingType) : type;
}
function containsMissingType(type) {
- return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* Union */ && containsType(type.types, missingType));
+ return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, missingType));
}
function removeMissingOrUndefinedType(type) {
- return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* NEUndefined */);
+ return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */);
}
/**
* Is source potentially coercible to target type under `==`.
@@ -66403,23 +67655,23 @@ var ts;
* @param target
*/
function isCoercibleUnderDoubleEquals(source, target) {
- return ((source.flags & (8 /* Number */ | 4 /* String */ | 512 /* BooleanLiteral */)) !== 0)
- && ((target.flags & (8 /* Number */ | 4 /* String */ | 16 /* Boolean */)) !== 0);
+ return ((source.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 512 /* TypeFlags.BooleanLiteral */)) !== 0)
+ && ((target.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 16 /* TypeFlags.Boolean */)) !== 0);
}
/**
* Return true if type was inferred from an object literal, written as an object type literal, or is the shape of a module
* with no call or construct signatures.
*/
function isObjectTypeWithInferableIndex(type) {
- return type.flags & 2097152 /* Intersection */
+ return type.flags & 2097152 /* TypeFlags.Intersection */
? ts.every(type.types, isObjectTypeWithInferableIndex)
: !!(type.symbol
- && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0
- && !(type.symbol.flags & 32 /* Class */)
- && !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
+ && (type.symbol.flags & (4096 /* SymbolFlags.ObjectLiteral */ | 2048 /* SymbolFlags.TypeLiteral */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) !== 0
+ && !(type.symbol.flags & 32 /* SymbolFlags.Class */)
+ && !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ObjectFlags.ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
}
function createSymbolWithType(source, type) {
- var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */);
+ var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* CheckFlags.Readonly */);
symbol.declarations = source.declarations;
symbol.parent = source.parent;
symbol.type = type;
@@ -66449,7 +67701,7 @@ var ts;
* Leave signatures alone since they are not subject to the check.
*/
function getRegularTypeOfObjectLiteral(type) {
- if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 16384 /* FreshLiteral */)) {
+ if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 8192 /* ObjectFlags.FreshLiteral */)) {
return type;
}
var regularType = type.regularType;
@@ -66460,7 +67712,7 @@ var ts;
var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral);
var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.indexInfos);
regularNew.flags = resolved.flags;
- regularNew.objectFlags |= resolved.objectFlags & ~16384 /* FreshLiteral */;
+ regularNew.objectFlags |= resolved.objectFlags & ~8192 /* ObjectFlags.FreshLiteral */;
type.regularType = regularNew;
return regularNew;
}
@@ -66490,7 +67742,7 @@ var ts;
var names = new ts.Map();
for (var _i = 0, _a = getSiblingsOfContext(context); _i < _a.length; _i++) {
var t = _a[_i];
- if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 4194304 /* ContainsSpread */)) {
+ if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 2097152 /* ObjectFlags.ContainsSpread */)) {
for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) {
var prop = _c[_b];
names.set(prop.escapedName, prop);
@@ -66502,7 +67754,7 @@ var ts;
return context.resolvedProperties;
}
function getWidenedProperty(prop, context) {
- if (!(prop.flags & 4 /* Property */)) {
+ if (!(prop.flags & 4 /* SymbolFlags.Property */)) {
// Since get accessors already widen their return value there is no need to
// widen accessor based properties here.
return prop;
@@ -66518,7 +67770,7 @@ var ts;
return cached;
}
var result = createSymbolWithType(prop, missingType);
- result.flags |= 16777216 /* Optional */;
+ result.flags |= 16777216 /* SymbolFlags.Optional */;
undefinedProperties.set(prop.escapedName, result);
return result;
}
@@ -66537,36 +67789,36 @@ var ts;
}
}
var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(getIndexInfosOfType(type), function (info) { return createIndexInfo(info.keyType, getWidenedType(info.type), info.isReadonly); }));
- result.objectFlags |= (ts.getObjectFlags(type) & (8192 /* JSLiteral */ | 524288 /* NonInferrableType */)); // Retain js literal flag through widening
+ result.objectFlags |= (ts.getObjectFlags(type) & (4096 /* ObjectFlags.JSLiteral */ | 262144 /* ObjectFlags.NonInferrableType */)); // Retain js literal flag through widening
return result;
}
function getWidenedType(type) {
return getWidenedTypeWithContext(type, /*context*/ undefined);
}
function getWidenedTypeWithContext(type, context) {
- if (ts.getObjectFlags(type) & 393216 /* RequiresWidening */) {
+ if (ts.getObjectFlags(type) & 196608 /* ObjectFlags.RequiresWidening */) {
if (context === undefined && type.widened) {
return type.widened;
}
var result = void 0;
- if (type.flags & (1 /* Any */ | 98304 /* Nullable */)) {
+ if (type.flags & (1 /* TypeFlags.Any */ | 98304 /* TypeFlags.Nullable */)) {
result = anyType;
}
else if (isObjectLiteralType(type)) {
result = getWidenedTypeOfObjectLiteral(type, context);
}
- else if (type.flags & 1048576 /* Union */) {
+ else if (type.flags & 1048576 /* TypeFlags.Union */) {
var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types);
- var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); });
+ var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* TypeFlags.Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); });
// Widening an empty object literal transitions from a highly restrictive type to
// a highly inclusive one. For that reason we perform subtype reduction here if the
// union includes empty object types (e.g. reducing {} | string to just {}).
- result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */);
+ result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */);
}
- else if (type.flags & 2097152 /* Intersection */) {
+ else if (type.flags & 2097152 /* TypeFlags.Intersection */) {
result = getIntersectionType(ts.sameMap(type.types, getWidenedType));
}
- else if (isArrayType(type) || isTupleType(type)) {
+ else if (isArrayOrTupleType(type)) {
result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType));
}
if (result && context === undefined) {
@@ -66589,8 +67841,8 @@ var ts;
*/
function reportWideningErrorsInType(type) {
var errorReported = false;
- if (ts.getObjectFlags(type) & 131072 /* ContainsWideningType */) {
- if (type.flags & 1048576 /* Union */) {
+ if (ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */) {
+ if (type.flags & 1048576 /* TypeFlags.Union */) {
if (ts.some(type.types, isEmptyObjectType)) {
errorReported = true;
}
@@ -66603,7 +67855,7 @@ var ts;
}
}
}
- if (isArrayType(type) || isTupleType(type)) {
+ if (isArrayOrTupleType(type)) {
for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) {
var t = _c[_b];
if (reportWideningErrorsInType(t)) {
@@ -66615,7 +67867,7 @@ var ts;
for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) {
var p = _e[_d];
var t = getTypeOfSymbol(p);
- if (ts.getObjectFlags(t) & 131072 /* ContainsWideningType */) {
+ if (ts.getObjectFlags(t) & 65536 /* ObjectFlags.ContainsWideningType */) {
if (!reportWideningErrorsInType(t)) {
error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t)));
}
@@ -66634,17 +67886,17 @@ var ts;
}
var diagnostic;
switch (declaration.kind) {
- case 220 /* BinaryExpression */:
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
+ case 221 /* SyntaxKind.BinaryExpression */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
diagnostic = noImplicitAny ? ts.Diagnostics.Member_0_implicitly_has_an_1_type : ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage;
break;
- case 163 /* Parameter */:
+ case 164 /* SyntaxKind.Parameter */:
var param = declaration;
if (ts.isIdentifier(param.name) &&
(ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) &&
param.parent.parameters.indexOf(param) > -1 &&
- (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) ||
+ (resolveName(param, param.name.escapedText, 788968 /* SymbolFlags.Type */, undefined, param.name.escapedText, /*isUse*/ true) ||
param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) {
var newName = "arg" + param.parent.parameters.indexOf(param);
var typeName = ts.declarationNameToString(param.name) + (param.dotDotDotToken ? "[]" : "");
@@ -66655,25 +67907,25 @@ var ts;
noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage :
noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage;
break;
- case 202 /* BindingElement */:
+ case 203 /* SyntaxKind.BindingElement */:
diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type;
if (!noImplicitAny) {
// Don't issue a suggestion for binding elements since the codefix doesn't yet support them.
return;
}
break;
- case 315 /* JSDocFunctionType */:
+ case 317 /* SyntaxKind.JSDocFunctionType */:
error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString);
return;
- case 255 /* FunctionDeclaration */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
if (noImplicitAny && !declaration.name) {
- if (wideningKind === 3 /* GeneratorYield */) {
+ if (wideningKind === 3 /* WideningKind.GeneratorYield */) {
error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString);
}
else {
@@ -66682,10 +67934,10 @@ var ts;
return;
}
diagnostic = !noImplicitAny ? ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage :
- wideningKind === 3 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type :
+ wideningKind === 3 /* WideningKind.GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type :
ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type;
break;
- case 194 /* MappedType */:
+ case 195 /* SyntaxKind.MappedType */:
if (noImplicitAny) {
error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type);
}
@@ -66696,12 +67948,14 @@ var ts;
errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString);
}
function reportErrorsFromWidening(declaration, type, wideningKind) {
- if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 131072 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) {
- // Report implicit any error within type if possible, otherwise report error on declaration
- if (!reportWideningErrorsInType(type)) {
- reportImplicitAny(declaration, type, wideningKind);
+ addLazyDiagnostic(function () {
+ if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) {
+ // Report implicit any error within type if possible, otherwise report error on declaration
+ if (!reportWideningErrorsInType(type)) {
+ reportImplicitAny(declaration, type, wideningKind);
+ }
}
- }
+ });
}
function applyToParameterTypes(source, target, callback) {
var sourceCount = getParameterCount(source);
@@ -66758,6 +68012,9 @@ var ts;
var inference = inferences[i];
if (t === inference.typeParameter) {
if (fix && !inference.isFixed) {
+ // Before we commit to a particular inference (and thus lock out any further inferences),
+ // we infer from any intra-expression inference sites we have collected.
+ inferFromIntraExpressionSites(context);
clearCachedInferences(inferences);
inference.isFixed = true;
}
@@ -66774,6 +68031,37 @@ var ts;
}
}
}
+ function addIntraExpressionInferenceSite(context, node, type) {
+ var _a;
+ ((_a = context.intraExpressionInferenceSites) !== null && _a !== void 0 ? _a : (context.intraExpressionInferenceSites = [])).push({ node: node, type: type });
+ }
+ // We collect intra-expression inference sites within object and array literals to handle cases where
+ // inferred types flow between context sensitive element expressions. For example:
+ //
+ // declare function foo<T>(arg: [(n: number) => T, (x: T) => void]): void;
+ // foo([_a => 0, n => n.toFixed()]);
+ //
+ // Above, both arrow functions in the tuple argument are context sensitive, thus both are omitted from the
+ // pass that collects inferences from the non-context sensitive parts of the arguments. In the subsequent
+ // pass where nothing is omitted, we need to commit to an inference for T in order to contextually type the
+ // parameter in the second arrow function, but we want to first infer from the return type of the first
+ // arrow function. This happens automatically when the arrow functions are discrete arguments (because we
+ // infer from each argument before processing the next), but when the arrow functions are elements of an
+ // object or array literal, we need to perform intra-expression inferences early.
+ function inferFromIntraExpressionSites(context) {
+ if (context.intraExpressionInferenceSites) {
+ for (var _i = 0, _a = context.intraExpressionInferenceSites; _i < _a.length; _i++) {
+ var _b = _a[_i], node = _b.node, type = _b.type;
+ var contextualType = node.kind === 169 /* SyntaxKind.MethodDeclaration */ ?
+ getContextualTypeForObjectLiteralMethod(node, 2 /* ContextFlags.NoConstraints */) :
+ getContextualType(node, 2 /* ContextFlags.NoConstraints */);
+ if (contextualType) {
+ inferTypes(context.inferences, type, contextualType);
+ }
+ }
+ context.intraExpressionInferenceSites = undefined;
+ }
+ }
function createInferenceInfo(typeParameter) {
return {
typeParameter: typeParameter,
@@ -66812,40 +68100,40 @@ var ts;
// results for union and intersection types for performance reasons.
function couldContainTypeVariables(type) {
var objectFlags = ts.getObjectFlags(type);
- if (objectFlags & 1048576 /* CouldContainTypeVariablesComputed */) {
- return !!(objectFlags & 2097152 /* CouldContainTypeVariables */);
+ if (objectFlags & 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */) {
+ return !!(objectFlags & 1048576 /* ObjectFlags.CouldContainTypeVariables */);
}
- var result = !!(type.flags & 465829888 /* Instantiable */ ||
- type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) ||
- objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations ||
- objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 8388608 /* ObjectRestType */)) ||
- type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables));
- if (type.flags & 3899393 /* ObjectFlagsType */) {
- type.objectFlags |= 1048576 /* CouldContainTypeVariablesComputed */ | (result ? 2097152 /* CouldContainTypeVariables */ : 0);
+ var result = !!(type.flags & 465829888 /* TypeFlags.Instantiable */ ||
+ type.flags & 524288 /* TypeFlags.Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* ObjectFlags.Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) ||
+ objectFlags & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && type.symbol.declarations ||
+ objectFlags & (32 /* ObjectFlags.Mapped */ | 1024 /* ObjectFlags.ReverseMapped */ | 4194304 /* ObjectFlags.ObjectRestType */ | 8388608 /* ObjectFlags.InstantiationExpressionType */)) ||
+ type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && !(type.flags & 1024 /* TypeFlags.EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables));
+ if (type.flags & 3899393 /* TypeFlags.ObjectFlagsType */) {
+ type.objectFlags |= 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */ | (result ? 1048576 /* ObjectFlags.CouldContainTypeVariables */ : 0);
}
return result;
}
function isNonGenericTopLevelType(type) {
if (type.aliasSymbol && !type.aliasTypeArguments) {
- var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 258 /* TypeAliasDeclaration */);
- return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 303 /* SourceFile */ ? true : n.kind === 260 /* ModuleDeclaration */ ? false : "quit"; }));
+ var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* SyntaxKind.TypeAliasDeclaration */);
+ return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 305 /* SyntaxKind.SourceFile */ ? true : n.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? false : "quit"; }));
}
return false;
}
function isTypeParameterAtTopLevel(type, typeParameter) {
return !!(type === typeParameter ||
- type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) ||
- type.flags & 16777216 /* Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter));
+ type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) ||
+ type.flags & 16777216 /* TypeFlags.Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter));
}
/** Create an object with properties named in the string literal type. Every property has type `any` */
function createEmptyObjectTypeFromStringLiteral(type) {
var members = ts.createSymbolTable();
forEachType(type, function (t) {
- if (!(t.flags & 128 /* StringLiteral */)) {
+ if (!(t.flags & 128 /* TypeFlags.StringLiteral */)) {
return;
}
var name = ts.escapeLeadingUnderscores(t.value);
- var literalProp = createSymbol(4 /* Property */, name);
+ var literalProp = createSymbol(4 /* SymbolFlags.Property */, name);
literalProp.type = anyType;
if (t.symbol) {
literalProp.declarations = t.symbol.declarations;
@@ -66853,7 +68141,7 @@ var ts;
}
members.set(name, literalProp);
});
- var indexInfos = type.flags & 4 /* String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray;
+ var indexInfos = type.flags & 4 /* TypeFlags.String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray;
return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfos);
}
/**
@@ -66881,7 +68169,7 @@ var ts;
// literal { a: 123, b: x => true } is marked non-inferable because it contains a context sensitive
// arrow function, but is considered partially inferable because property 'a' has an inferable type.
function isPartiallyInferableType(type) {
- return !(ts.getObjectFlags(type) & 524288 /* NonInferrableType */) ||
+ return !(ts.getObjectFlags(type) & 262144 /* ObjectFlags.NonInferrableType */) ||
isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }) ||
isTupleType(type) && ts.some(getTypeArguments(type), isPartiallyInferableType);
}
@@ -66898,14 +68186,14 @@ var ts;
}
if (isTupleType(source)) {
var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); });
- var elementFlags = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ?
- ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) :
+ var elementFlags = getMappedTypeModifiers(target) & 4 /* MappedTypeModifiers.IncludeOptional */ ?
+ ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) :
source.target.elementFlags;
return createTupleType(elementTypes, elementFlags, source.target.readonly, source.target.labeledElementDeclarations);
}
// For all other object types we infer a new object type where the reverse mapping has been
// applied to the type of each property.
- var reversed = createObjectType(1024 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined);
+ var reversed = createObjectType(1024 /* ObjectFlags.ReverseMapped */ | 16 /* ObjectFlags.Anonymous */, /*symbol*/ undefined);
reversed.source = source;
reversed.mappedType = target;
reversed.constraintType = constraint;
@@ -66940,7 +68228,7 @@ var ts;
if (isStaticPrivateIdentifierProperty(targetProp)) {
return [3 /*break*/, 5];
}
- if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */))) return [3 /*break*/, 5];
+ if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* SymbolFlags.Optional */ || ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */))) return [3 /*break*/, 5];
sourceProp = getPropertyOfType(source, targetProp.escapedName);
if (!!sourceProp) return [3 /*break*/, 3];
return [4 /*yield*/, targetProp];
@@ -66950,9 +68238,9 @@ var ts;
case 3:
if (!matchDiscriminantProperties) return [3 /*break*/, 5];
targetType = getTypeOfSymbol(targetProp);
- if (!(targetType.flags & 109440 /* Unit */)) return [3 /*break*/, 5];
+ if (!(targetType.flags & 109440 /* TypeFlags.Unit */)) return [3 /*break*/, 5];
sourceType = getTypeOfSymbol(sourceProp);
- if (!!(sourceType.flags & 1 /* Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5];
+ if (!!(sourceType.flags & 1 /* TypeFlags.Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5];
return [4 /*yield*/, targetProp];
case 4:
_a.sent();
@@ -66970,7 +68258,7 @@ var ts;
return result.value;
}
function tupleTypesDefinitelyUnrelated(source, target) {
- return !(target.target.combinedFlags & 8 /* Variadic */) && target.target.minLength > source.target.minLength ||
+ return !(target.target.combinedFlags & 8 /* ElementFlags.Variadic */) && target.target.minLength > source.target.minLength ||
!target.target.hasRestElement && (source.target.hasRestElement || target.target.fixedLength < source.target.fixedLength);
}
function typesDefinitelyUnrelated(source, target) {
@@ -66981,7 +68269,7 @@ var ts;
!!getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false, /*matchDiscriminantProperties*/ false);
}
function getTypeFromInference(inference) {
- return inference.candidates ? getUnionType(inference.candidates, 2 /* Subtype */) :
+ return inference.candidates ? getUnionType(inference.candidates, 2 /* UnionReduction.Subtype */) :
inference.contraCandidates ? getIntersectionType(inference.contraCandidates) :
undefined;
}
@@ -67003,12 +68291,12 @@ var ts;
sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
}
function isValidBigIntString(s) {
- var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false);
+ var scanner = ts.createScanner(99 /* ScriptTarget.ESNext */, /*skipTrivia*/ false);
var success = true;
scanner.setOnError(function () { return success = false; });
scanner.setText(s + "n");
var result = scanner.scan();
- if (result === 40 /* MinusToken */) {
+ if (result === 40 /* SyntaxKind.MinusToken */) {
result = scanner.scan();
}
var flags = scanner.getTokenFlags();
@@ -67017,27 +68305,27 @@ var ts;
// * a bigint can be scanned, and that when it is scanned, it is
// * the full length of the input string (so the scanner is one character beyond the augmented input length)
// * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input)
- return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */);
+ return success && result === 9 /* SyntaxKind.BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* TokenFlags.ContainsSeparator */);
}
function isValidTypeForTemplateLiteralPlaceholder(source, target) {
- if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
+ if (source === target || target.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)) {
return true;
}
- if (source.flags & 128 /* StringLiteral */) {
+ if (source.flags & 128 /* TypeFlags.StringLiteral */) {
var value = source.value;
- return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) ||
- target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) ||
- target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
+ return !!(target.flags & 8 /* TypeFlags.Number */ && value !== "" && isFinite(+value) ||
+ target.flags & 64 /* TypeFlags.BigInt */ && value !== "" && isValidBigIntString(value) ||
+ target.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) && value === target.intrinsicName);
}
- if (source.flags & 134217728 /* TemplateLiteral */) {
+ if (source.flags & 134217728 /* TypeFlags.TemplateLiteral */) {
var texts = source.texts;
return texts.length === 2 && texts[0] === "" && texts[1] === "" && isTypeAssignableTo(source.types[0], target);
}
return isTypeAssignableTo(source, target);
}
function inferTypesFromTemplateLiteralType(source, target) {
- return source.flags & 128 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) :
- source.flags & 134217728 /* TemplateLiteral */ ?
+ return source.flags & 128 /* TypeFlags.StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) :
+ source.flags & 134217728 /* TypeFlags.TemplateLiteral */ ?
ts.arraysEqual(source.texts, target.texts) ? ts.map(source.types, getStringLikeTypeForType) :
inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) :
undefined;
@@ -67047,7 +68335,7 @@ var ts;
return !!inferences && ts.every(inferences, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); });
}
function getStringLikeTypeForType(type) {
- return type.flags & (1 /* Any */ | 402653316 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]);
+ return type.flags & (1 /* TypeFlags.Any */ | 402653316 /* TypeFlags.StringLike */) ? type : getTemplateLiteralType(["", ""], [type]);
}
// This function infers from the text parts and type parts of a source literal to a target template literal. The number
// of text parts is always one more than the number of type parts, and a source string literal is treated as a source
@@ -67129,12 +68417,12 @@ var ts;
if (contravariant === void 0) { contravariant = false; }
var bivariant = false;
var propagationType;
- var inferencePriority = 2048 /* MaxValue */;
+ var inferencePriority = 2048 /* InferencePriority.MaxValue */;
var allowComplexConstraintInference = true;
var visited;
var sourceStack;
var targetStack;
- var expandingFlags = 0 /* None */;
+ var expandingFlags = 0 /* ExpandingFlags.None */;
inferFromTypes(originalSource, originalTarget);
function inferFromTypes(source, target) {
if (!couldContainTypeVariables(target)) {
@@ -67156,7 +68444,7 @@ var ts;
inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol));
return;
}
- if (source === target && source.flags & 3145728 /* UnionOrIntersection */) {
+ if (source === target && source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) {
// When source and target are the same union or intersection type, just relate each constituent
// type to itself.
for (var _i = 0, _a = source.types; _i < _a.length; _i++) {
@@ -67165,10 +68453,10 @@ var ts;
}
return;
}
- if (target.flags & 1048576 /* Union */) {
+ if (target.flags & 1048576 /* TypeFlags.Union */) {
// First, infer between identically matching source and target constituents and remove the
// matching types.
- var _b = inferFromMatchingTypes(source.flags & 1048576 /* Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1];
+ var _b = inferFromMatchingTypes(source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1];
// Next, infer between closely matching source and target constituents and remove
// the matching types. Types closely match when they are instantiations of the same
// object type or instantiations of the same type alias.
@@ -67183,21 +68471,21 @@ var ts;
// inferring a type parameter constraint. Instead, make a lower priority inference from
// the full source to whatever remains in the target. For example, when inferring from
// string to 'string | T', make a lower priority inference of string for T.
- inferWithPriority(source, target, 1 /* NakedTypeVariable */);
+ inferWithPriority(source, target, 1 /* InferencePriority.NakedTypeVariable */);
return;
}
source = getUnionType(sources);
}
- else if (target.flags & 2097152 /* Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) {
+ else if (target.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) {
// We reduce intersection types only when they contain naked type parameters. For example, when
// inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and
// infer { extra: any } for T. But when inferring to 'string[] & Iterable<T>' we want to keep the
// string[] on the source side and infer string for T.
// Likewise, we consider a homomorphic mapped type constrainted to the target type parameter as similar to a "naked type variable"
// in such scenarios.
- if (!(source.flags & 1048576 /* Union */)) {
+ if (!(source.flags & 1048576 /* TypeFlags.Union */)) {
// Infer between identically matching source and target constituents and remove the matching types.
- var _d = inferFromMatchingTypes(source.flags & 2097152 /* Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1];
+ var _d = inferFromMatchingTypes(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1];
if (sources.length === 0 || targets.length === 0) {
return;
}
@@ -67205,10 +68493,10 @@ var ts;
target = getIntersectionType(targets);
}
}
- else if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) {
+ else if (target.flags & (8388608 /* TypeFlags.IndexedAccess */ | 33554432 /* TypeFlags.Substitution */)) {
target = getActualTypeVariable(target);
}
- if (target.flags & 8650752 /* TypeVariable */) {
+ if (target.flags & 8650752 /* TypeFlags.TypeVariable */) {
// If target is a type parameter, make an inference, unless the source type contains
// the anyFunctionType (the wildcard type that's used to avoid contextually typing functions).
// Because the anyFunctionType is internal, it should not be exposed to the user by adding
@@ -67216,12 +68504,12 @@ var ts;
// not contain anyFunctionType when we come back to this argument for its second round
// of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard
// when constructing types from type parameters that had no inference candidates).
- if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
+ if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* InferencePriority.ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
return;
}
var inference = getInferenceInfoForType(target);
if (inference) {
- if (ts.getObjectFlags(source) & 524288 /* NonInferrableType */) {
+ if (ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */) {
return;
}
if (!inference.isFixed) {
@@ -67246,7 +68534,7 @@ var ts;
clearCachedInferences(inferences);
}
}
- if (!(priority & 128 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) {
+ if (!(priority & 128 /* InferencePriority.ReturnType */) && target.flags & 262144 /* TypeFlags.TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) {
inference.topLevel = false;
clearCachedInferences(inferences);
}
@@ -67259,11 +68547,11 @@ var ts;
if (simplified !== target) {
inferFromTypes(source, simplified);
}
- else if (target.flags & 8388608 /* IndexedAccess */) {
+ else if (target.flags & 8388608 /* TypeFlags.IndexedAccess */) {
var indexType = getSimplifiedType(target.indexType, /*writing*/ false);
// Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider
// that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can.
- if (indexType.flags & 465829888 /* Instantiable */) {
+ if (indexType.flags & 465829888 /* TypeFlags.Instantiable */) {
var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false);
if (simplified_1 && simplified_1 !== target) {
inferFromTypes(source, simplified_1);
@@ -67271,45 +68559,45 @@ var ts;
}
}
}
- if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) &&
+ if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) &&
!(source.node && target.node)) {
// If source and target are references to the same generic type, infer from type arguments
inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
}
- else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) {
+ else if (source.flags & 4194304 /* TypeFlags.Index */ && target.flags & 4194304 /* TypeFlags.Index */) {
contravariant = !contravariant;
inferFromTypes(source.type, target.type);
contravariant = !contravariant;
}
- else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) {
+ else if ((isLiteralType(source) || source.flags & 4 /* TypeFlags.String */) && target.flags & 4194304 /* TypeFlags.Index */) {
var empty = createEmptyObjectTypeFromStringLiteral(source);
contravariant = !contravariant;
- inferWithPriority(empty, target.type, 256 /* LiteralKeyof */);
+ inferWithPriority(empty, target.type, 256 /* InferencePriority.LiteralKeyof */);
contravariant = !contravariant;
}
- else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) {
+ else if (source.flags & 8388608 /* TypeFlags.IndexedAccess */ && target.flags & 8388608 /* TypeFlags.IndexedAccess */) {
inferFromTypes(source.objectType, target.objectType);
inferFromTypes(source.indexType, target.indexType);
}
- else if (source.flags & 268435456 /* StringMapping */ && target.flags & 268435456 /* StringMapping */) {
+ else if (source.flags & 268435456 /* TypeFlags.StringMapping */ && target.flags & 268435456 /* TypeFlags.StringMapping */) {
if (source.symbol === target.symbol) {
inferFromTypes(source.type, target.type);
}
}
- else if (source.flags & 33554432 /* Substitution */) {
+ else if (source.flags & 33554432 /* TypeFlags.Substitution */) {
inferFromTypes(source.baseType, target);
var oldPriority = priority;
- priority |= 4 /* SubstituteSource */;
+ priority |= 4 /* InferencePriority.SubstituteSource */;
inferFromTypes(source.substitute, target); // Make substitute inference at a lower priority
priority = oldPriority;
}
- else if (target.flags & 16777216 /* Conditional */) {
+ else if (target.flags & 16777216 /* TypeFlags.Conditional */) {
invokeOnce(source, target, inferToConditionalType);
}
- else if (target.flags & 3145728 /* UnionOrIntersection */) {
+ else if (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */) {
inferToMultipleTypes(source, target.types, target.flags);
}
- else if (source.flags & 1048576 /* Union */) {
+ else if (source.flags & 1048576 /* TypeFlags.Union */) {
// Source is a union or intersection type, infer from each constituent type
var sourceTypes = source.types;
for (var _e = 0, sourceTypes_2 = sourceTypes; _e < sourceTypes_2.length; _e++) {
@@ -67317,17 +68605,17 @@ var ts;
inferFromTypes(sourceType, target);
}
}
- else if (target.flags & 134217728 /* TemplateLiteral */) {
+ else if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) {
inferToTemplateLiteralType(source, target);
}
else {
source = getReducedType(source);
- if (!(priority & 512 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) {
+ if (!(priority & 512 /* InferencePriority.NoConstraints */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 465829888 /* TypeFlags.Instantiable */))) {
var apparentSource = getApparentType(source);
// getApparentType can return _any_ type, since an indexed access or conditional may simplify to any other type.
// If that occurs and it doesn't simplify to an object or intersection, we'll need to restart `inferFromTypes`
// with the simplified source.
- if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* Intersection */))) {
+ if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */))) {
// TODO: The `allowComplexConstraintInference` flag is a hack! This forbids inference from complex constraints within constraints!
// This isn't required algorithmically, but rather is used to lower the memory burden caused by performing inference
// that is _too good_ in projects with complicated constraints (eg, fp-ts). In such cases, if we did not limit ourselves
@@ -67340,7 +68628,7 @@ var ts;
}
source = apparentSource;
}
- if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */)) {
+ if (source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) {
invokeOnce(source, target, inferFromObjectTypes);
}
}
@@ -67358,19 +68646,19 @@ var ts;
inferencePriority = Math.min(inferencePriority, status);
return;
}
- (visited || (visited = new ts.Map())).set(key, -1 /* Circularity */);
+ (visited || (visited = new ts.Map())).set(key, -1 /* InferencePriority.Circularity */);
var saveInferencePriority = inferencePriority;
- inferencePriority = 2048 /* MaxValue */;
+ inferencePriority = 2048 /* InferencePriority.MaxValue */;
// We stop inferring and report a circularity if we encounter duplicate recursion identities on both
// the source side and the target side.
var saveExpandingFlags = expandingFlags;
var sourceIdentity = getRecursionIdentity(source);
var targetIdentity = getRecursionIdentity(target);
if (ts.contains(sourceStack, sourceIdentity))
- expandingFlags |= 1 /* Source */;
+ expandingFlags |= 1 /* ExpandingFlags.Source */;
if (ts.contains(targetStack, targetIdentity))
- expandingFlags |= 2 /* Target */;
- if (expandingFlags !== 3 /* Both */) {
+ expandingFlags |= 2 /* ExpandingFlags.Target */;
+ if (expandingFlags !== 3 /* ExpandingFlags.Both */) {
(sourceStack || (sourceStack = [])).push(sourceIdentity);
(targetStack || (targetStack = [])).push(targetIdentity);
action(source, target);
@@ -67378,7 +68666,7 @@ var ts;
sourceStack.pop();
}
else {
- inferencePriority = -1 /* Circularity */;
+ inferencePriority = -1 /* InferencePriority.Circularity */;
}
expandingFlags = saveExpandingFlags;
visited.set(key, inferencePriority);
@@ -67406,7 +68694,7 @@ var ts;
function inferFromTypeArguments(sourceTypes, targetTypes, variances) {
var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length;
for (var i = 0; i < count; i++) {
- if (i < variances.length && (variances[i] & 7 /* VarianceMask */) === 2 /* Contravariant */) {
+ if (i < variances.length && (variances[i] & 7 /* VarianceFlags.VarianceMask */) === 2 /* VarianceFlags.Contravariant */) {
inferFromContravariantTypes(sourceTypes[i], targetTypes[i]);
}
else {
@@ -67415,7 +68703,7 @@ var ts;
}
}
function inferFromContravariantTypes(source, target) {
- if (strictFunctionTypes || priority & 1024 /* AlwaysStrict */) {
+ if (strictFunctionTypes || priority & 1024 /* InferencePriority.AlwaysStrict */) {
contravariant = !contravariant;
inferFromTypes(source, target);
contravariant = !contravariant;
@@ -67425,7 +68713,7 @@ var ts;
}
}
function getInferenceInfoForType(type) {
- if (type.flags & 8650752 /* TypeVariable */) {
+ if (type.flags & 8650752 /* TypeFlags.TypeVariable */) {
for (var _i = 0, inferences_2 = inferences; _i < inferences_2.length; _i++) {
var inference = inferences_2[_i];
if (type === inference.typeParameter) {
@@ -67439,7 +68727,7 @@ var ts;
var typeVariable;
for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
var type = types_15[_i];
- var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); });
+ var t = type.flags & 2097152 /* TypeFlags.Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); });
if (!t || typeVariable && t !== typeVariable) {
return undefined;
}
@@ -67449,9 +68737,9 @@ var ts;
}
function inferToMultipleTypes(source, targets, targetFlags) {
var typeVariableCount = 0;
- if (targetFlags & 1048576 /* Union */) {
+ if (targetFlags & 1048576 /* TypeFlags.Union */) {
var nakedTypeVariable = void 0;
- var sources = source.flags & 1048576 /* Union */ ? source.types : [source];
+ var sources = source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source];
var matched_1 = new Array(sources.length);
var inferenceCircularity = false;
// First infer to types that are not naked type variables. For each source type we
@@ -67467,11 +68755,11 @@ var ts;
else {
for (var i = 0; i < sources.length; i++) {
var saveInferencePriority = inferencePriority;
- inferencePriority = 2048 /* MaxValue */;
+ inferencePriority = 2048 /* InferencePriority.MaxValue */;
inferFromTypes(sources[i], t);
if (inferencePriority === priority)
matched_1[i] = true;
- inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* Circularity */;
+ inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* InferencePriority.Circularity */;
inferencePriority = Math.min(inferencePriority, saveInferencePriority);
}
}
@@ -67482,7 +68770,7 @@ var ts;
// 'A | B' to 'T & (X | Y)' where we want to infer 'A | B' for T.
var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets);
if (intersectionTypeVariable) {
- inferWithPriority(source, intersectionTypeVariable, 1 /* NakedTypeVariable */);
+ inferWithPriority(source, intersectionTypeVariable, 1 /* InferencePriority.NakedTypeVariable */);
}
return;
}
@@ -67516,17 +68804,17 @@ var ts;
// less specific. For example, when inferring from Promise<string> to T | Promise<T>,
// we want to infer string for T, not Promise<string> | string. For intersection types
// we only infer to single naked type variables.
- if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) {
+ if (targetFlags & 2097152 /* TypeFlags.Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) {
for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) {
var t = targets_4[_b];
if (getInferenceInfoForType(t)) {
- inferWithPriority(source, t, 1 /* NakedTypeVariable */);
+ inferWithPriority(source, t, 1 /* InferencePriority.NakedTypeVariable */);
}
}
}
}
function inferToMappedType(source, target, constraintType) {
- if (constraintType.flags & 1048576 /* Union */) {
+ if (constraintType.flags & 1048576 /* TypeFlags.Union */) {
var result = false;
for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) {
var type = _a[_i];
@@ -67534,7 +68822,7 @@ var ts;
}
return result;
}
- if (constraintType.flags & 4194304 /* Index */) {
+ if (constraintType.flags & 4194304 /* TypeFlags.Index */) {
// We're inferring from some source type S to a homomorphic mapped type { [P in keyof T]: X },
// where T is a type variable. Use inferTypeForHomomorphicMappedType to infer a suitable source
// type and then make a secondary inference from that type to T. We make a secondary inference
@@ -67546,17 +68834,17 @@ var ts;
// We assign a lower priority to inferences made from types containing non-inferrable
// types because we may only have a partial result (i.e. we may have failed to make
// reverse inferences for some properties).
- inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 524288 /* NonInferrableType */ ?
- 16 /* PartialHomomorphicMappedType */ :
- 8 /* HomomorphicMappedType */);
+ inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */ ?
+ 16 /* InferencePriority.PartialHomomorphicMappedType */ :
+ 8 /* InferencePriority.HomomorphicMappedType */);
}
}
return true;
}
- if (constraintType.flags & 262144 /* TypeParameter */) {
+ if (constraintType.flags & 262144 /* TypeFlags.TypeParameter */) {
// We're inferring from some source type S to a mapped type { [P in K]: X }, where K is a type
// parameter. First infer from 'keyof S' to K.
- inferWithPriority(getIndexType(source), constraintType, 32 /* MappedTypeConstraint */);
+ inferWithPriority(getIndexType(source), constraintType, 32 /* InferencePriority.MappedTypeConstraint */);
// If K is constrained to a type C, also infer to C. Thus, for a mapped type { [P in K]: X },
// where K extends keyof T, we make the same inferences as for a homomorphic mapped type
// { [P in keyof T]: X }. This enables us to make meaningful inferences when the target is a
@@ -67575,7 +68863,7 @@ var ts;
return false;
}
function inferToConditionalType(source, target) {
- if (source.flags & 16777216 /* Conditional */) {
+ if (source.flags & 16777216 /* TypeFlags.Conditional */) {
inferFromTypes(source.checkType, target.checkType);
inferFromTypes(source.extendsType, target.extendsType);
inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target));
@@ -67583,7 +68871,7 @@ var ts;
}
else {
var savePriority = priority;
- priority |= contravariant ? 64 /* ContravariantConditional */ : 0;
+ priority |= contravariant ? 64 /* InferencePriority.ContravariantConditional */ : 0;
var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)];
inferToMultipleTypes(source, targetTypes, target.flags);
priority = savePriority;
@@ -67605,7 +68893,7 @@ var ts;
}
}
function inferFromObjectTypes(source, target) {
- if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) {
+ if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) {
// If source and target are references to the same generic type, infer from type arguments
inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
return;
@@ -67620,7 +68908,7 @@ var ts;
if (sourceNameType && targetNameType)
inferFromTypes(sourceNameType, targetNameType);
}
- if (ts.getObjectFlags(target) & 32 /* Mapped */ && !target.declaration.nameType) {
+ if (ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */ && !target.declaration.nameType) {
var constraintType = getConstraintTypeFromMappedType(target);
if (inferToMappedType(source, target, constraintType)) {
return;
@@ -67628,7 +68916,7 @@ var ts;
}
// Infer from the members of source and target only if the two types are possibly related
if (!typesDefinitelyUnrelated(source, target)) {
- if (isArrayType(source) || isTupleType(source)) {
+ if (isArrayOrTupleType(source)) {
if (isTupleType(target)) {
var sourceArity = getTypeReferenceArity(source);
var targetArity = getTypeReferenceArity(target);
@@ -67643,21 +68931,21 @@ var ts;
return;
}
var startLength = isTupleType(source) ? Math.min(source.target.fixedLength, target.target.fixedLength) : 0;
- var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* Fixed */) : 0);
+ var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* ElementFlags.Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* ElementFlags.Fixed */) : 0);
// Infer between starting fixed elements.
for (var i = 0; i < startLength; i++) {
inferFromTypes(getTypeArguments(source)[i], elementTypes[i]);
}
- if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* Rest */) {
+ if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* ElementFlags.Rest */) {
// Single rest element remains in source, infer from that to every element in target
var restType = getTypeArguments(source)[startLength];
for (var i = startLength; i < targetArity - endLength; i++) {
- inferFromTypes(elementFlags[i] & 8 /* Variadic */ ? createArrayType(restType) : restType, elementTypes[i]);
+ inferFromTypes(elementFlags[i] & 8 /* ElementFlags.Variadic */ ? createArrayType(restType) : restType, elementTypes[i]);
}
}
else {
var middleLength = targetArity - startLength - endLength;
- if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* Variadic */ && isTupleType(source)) {
+ if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* ElementFlags.Variadic */ && isTupleType(source)) {
// Middle of target is [...T, ...U] and source is tuple type
var targetInfo = getInferenceInfoForType(elementTypes[startLength]);
if (targetInfo && targetInfo.impliedArity !== undefined) {
@@ -67666,14 +68954,14 @@ var ts;
inferFromTypes(sliceTupleType(source, startLength + targetInfo.impliedArity, endLength), elementTypes[startLength + 1]);
}
}
- else if (middleLength === 1 && elementFlags[startLength] & 8 /* Variadic */) {
+ else if (middleLength === 1 && elementFlags[startLength] & 8 /* ElementFlags.Variadic */) {
// Middle of target is exactly one variadic element. Infer the slice between the fixed parts in the source.
// If target ends in optional element(s), make a lower priority a speculative inference.
- var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* Optional */;
+ var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* ElementFlags.Optional */;
var sourceSlice = isTupleType(source) ? sliceTupleType(source, startLength, endLength) : createArrayType(getTypeArguments(source)[0]);
- inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* SpeculativeTuple */ : 0);
+ inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* InferencePriority.SpeculativeTuple */ : 0);
}
- else if (middleLength === 1 && elementFlags[startLength] & 4 /* Rest */) {
+ else if (middleLength === 1 && elementFlags[startLength] & 4 /* ElementFlags.Rest */) {
// Middle of target is exactly one rest element. If middle of source is not empty, infer union of middle element types.
var restType = isTupleType(source) ? getElementTypeOfSliceOfTupleType(source, startLength, endLength) : getTypeArguments(source)[0];
if (restType) {
@@ -67693,8 +68981,8 @@ var ts;
}
}
inferFromProperties(source, target);
- inferFromSignatures(source, target, 0 /* Call */);
- inferFromSignatures(source, target, 1 /* Construct */);
+ inferFromSignatures(source, target, 0 /* SignatureKind.Call */);
+ inferFromSignatures(source, target, 1 /* SignatureKind.Construct */);
inferFromIndexTypes(source, target);
}
}
@@ -67703,7 +68991,7 @@ var ts;
for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) {
var targetProp = properties_3[_i];
var sourceProp = getPropertyOfType(source, targetProp.escapedName);
- if (sourceProp) {
+ if (sourceProp && !ts.some(sourceProp.declarations, hasSkipDirectInferenceFlag)) {
inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
}
}
@@ -67714,7 +69002,7 @@ var ts;
var sourceLen = sourceSignatures.length;
var targetLen = targetSignatures.length;
var len = sourceLen < targetLen ? sourceLen : targetLen;
- var skipParameters = !!(ts.getObjectFlags(source) & 524288 /* NonInferrableType */);
+ var skipParameters = !!(ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */);
for (var i = 0; i < len; i++) {
inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters);
}
@@ -67722,9 +69010,9 @@ var ts;
function inferFromSignature(source, target, skipParameters) {
if (!skipParameters) {
var saveBivariant = bivariant;
- var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */;
+ var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */;
// Once we descend into a bivariant signature we remain bivariant for all nested inferences
- bivariant = bivariant || kind === 168 /* MethodDeclaration */ || kind === 167 /* MethodSignature */ || kind === 170 /* Constructor */;
+ bivariant = bivariant || kind === 169 /* SyntaxKind.MethodDeclaration */ || kind === 168 /* SyntaxKind.MethodSignature */ || kind === 171 /* SyntaxKind.Constructor */;
applyToParameterTypes(source, target, inferFromContravariantTypes);
bivariant = saveBivariant;
}
@@ -67732,17 +69020,17 @@ var ts;
}
function inferFromIndexTypes(source, target) {
// Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables
- var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0;
+ var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */) ? 8 /* InferencePriority.HomomorphicMappedType */ : 0;
var indexInfos = getIndexInfosOfType(target);
if (isObjectTypeWithInferableIndex(source)) {
- for (var _i = 0, indexInfos_4 = indexInfos; _i < indexInfos_4.length; _i++) {
- var targetInfo = indexInfos_4[_i];
+ for (var _i = 0, indexInfos_6 = indexInfos; _i < indexInfos_6.length; _i++) {
+ var targetInfo = indexInfos_6[_i];
var propTypes = [];
for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) {
var prop = _b[_a];
- if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), targetInfo.keyType)) {
+ if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), targetInfo.keyType)) {
var propType = getTypeOfSymbol(prop);
- propTypes.push(prop.flags & 16777216 /* Optional */ ? removeMissingOrUndefinedType(propType) : propType);
+ propTypes.push(prop.flags & 16777216 /* SymbolFlags.Optional */ ? removeMissingOrUndefinedType(propType) : propType);
}
}
for (var _c = 0, _d = getIndexInfosOfType(source); _c < _d.length; _c++) {
@@ -67756,8 +69044,8 @@ var ts;
}
}
}
- for (var _e = 0, indexInfos_5 = indexInfos; _e < indexInfos_5.length; _e++) {
- var targetInfo = indexInfos_5[_e];
+ for (var _e = 0, indexInfos_7 = indexInfos; _e < indexInfos_7.length; _e++) {
+ var targetInfo = indexInfos_7[_e];
var sourceInfo = getApplicableIndexInfo(source, targetInfo.keyType);
if (sourceInfo) {
inferWithPriority(sourceInfo.type, targetInfo.type, priority);
@@ -67767,34 +69055,34 @@ var ts;
}
function isTypeOrBaseIdenticalTo(s, t) {
return exactOptionalPropertyTypes && t === missingType ? s === t :
- (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */));
+ (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* TypeFlags.String */ && s.flags & 128 /* TypeFlags.StringLiteral */ || t.flags & 8 /* TypeFlags.Number */ && s.flags & 256 /* TypeFlags.NumberLiteral */));
}
function isTypeCloselyMatchedBy(s, t) {
- return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol ||
+ return !!(s.flags & 524288 /* TypeFlags.Object */ && t.flags & 524288 /* TypeFlags.Object */ && s.symbol && s.symbol === t.symbol ||
s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol);
}
function hasPrimitiveConstraint(type) {
var constraint = getConstraintOfTypeParameter(type);
- return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */);
+ return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* TypeFlags.Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */);
}
function isObjectLiteralType(type) {
- return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */);
+ return !!(ts.getObjectFlags(type) & 128 /* ObjectFlags.ObjectLiteral */);
}
function isObjectOrArrayLiteralType(type) {
- return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 32768 /* ArrayLiteral */));
+ return !!(ts.getObjectFlags(type) & (128 /* ObjectFlags.ObjectLiteral */ | 16384 /* ObjectFlags.ArrayLiteral */));
}
function unionObjectAndArrayLiteralCandidates(candidates) {
if (candidates.length > 1) {
var objectLiterals = ts.filter(candidates, isObjectOrArrayLiteralType);
if (objectLiterals.length) {
- var literalsType = getUnionType(objectLiterals, 2 /* Subtype */);
+ var literalsType = getUnionType(objectLiterals, 2 /* UnionReduction.Subtype */);
return ts.concatenate(ts.filter(candidates, function (t) { return !isObjectOrArrayLiteralType(t); }), [literalsType]);
}
}
return candidates;
}
function getContravariantInference(inference) {
- return inference.priority & 416 /* PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates);
+ return inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates);
}
function getCovariantInference(inference, signature) {
// Extract all object and array literal types and replace them with a single widened and normalized type.
@@ -67811,8 +69099,8 @@ var ts;
candidates;
// If all inferences were made from a position that implies a combined result, infer a union type.
// Otherwise, infer a common supertype.
- var unwidenedType = inference.priority & 416 /* PriorityImpliesCombination */ ?
- getUnionType(baseCandidates, 2 /* Subtype */) :
+ var unwidenedType = inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ?
+ getUnionType(baseCandidates, 2 /* UnionReduction.Subtype */) :
getCommonSupertype(baseCandidates);
return getWidenedType(unwidenedType);
}
@@ -67826,14 +69114,14 @@ var ts;
if (inference.contraCandidates) {
// If we have both co- and contra-variant inferences, we prefer the contra-variant inference
// unless the co-variant inference is a subtype of some contra-variant inference and not 'never'.
- inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* Never */) &&
+ inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* TypeFlags.Never */) &&
ts.some(inference.contraCandidates, function (t) { return isTypeSubtypeOf(inferredCovariantType_1, t); }) ?
inferredCovariantType_1 : getContravariantInference(inference);
}
else if (inferredCovariantType_1) {
inferredType = inferredCovariantType_1;
}
- else if (context.flags & 1 /* NoDefault */) {
+ else if (context.flags & 1 /* InferenceFlags.NoDefault */) {
// We use silentNeverType as the wildcard that signals no inferences.
inferredType = silentNeverType;
}
@@ -67854,7 +69142,7 @@ var ts;
else {
inferredType = getTypeFromInference(inference);
}
- inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* AnyDefault */));
+ inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* InferenceFlags.AnyDefault */));
var constraint = getConstraintOfTypeParameter(inference.typeParameter);
if (constraint) {
var instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
@@ -67924,7 +69212,7 @@ var ts;
}
// falls through
default:
- if (node.parent.kind === 295 /* ShorthandPropertyAssignment */) {
+ if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) {
return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer;
}
else {
@@ -67936,7 +69224,7 @@ var ts;
var links = getNodeLinks(node);
if (!links.resolvedSymbol) {
links.resolvedSymbol = !ts.nodeIsMissing(node) &&
- resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node),
+ resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node),
/*excludeGlobals*/ false) || unknownSymbol;
}
return links.resolvedSymbol;
@@ -67945,7 +69233,7 @@ var ts;
// TypeScript 1.0 spec (April 2014): 3.6.3
// A type query consists of the keyword typeof followed by an expression.
// The expression is restricted to a single identifier or a sequence of identifiers separated by periods
- return !!ts.findAncestor(node, function (n) { return n.kind === 180 /* TypeQuery */ ? true : n.kind === 79 /* Identifier */ || n.kind === 160 /* QualifiedName */ ? false : "quit"; });
+ return !!ts.findAncestor(node, function (n) { return n.kind === 181 /* SyntaxKind.TypeQuery */ ? true : n.kind === 79 /* SyntaxKind.Identifier */ || n.kind === 161 /* SyntaxKind.QualifiedName */ ? false : "quit"; });
}
// Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers
// separated by dots). The key consists of the id of the symbol referenced by the
@@ -67953,22 +69241,22 @@ var ts;
// The result is undefined if the reference isn't a dotted name.
function getFlowCacheKey(node, declaredType, initialType, flowContainer) {
switch (node.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
if (!ts.isThisInTypeQuery(node)) {
var symbol = getResolvedSymbol(node);
return symbol !== unknownSymbol ? "".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType), "|").concat(getSymbolId(symbol)) : undefined;
}
// falls through
- case 108 /* ThisKeyword */:
+ case 108 /* SyntaxKind.ThisKeyword */:
return "0|".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType));
- case 229 /* NonNullExpression */:
- case 211 /* ParenthesizedExpression */:
+ case 230 /* SyntaxKind.NonNullExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
- case 160 /* QualifiedName */:
+ case 161 /* SyntaxKind.QualifiedName */:
var left = getFlowCacheKey(node.left, declaredType, initialType, flowContainer);
return left && left + "." + node.right.escapedText;
- case 205 /* PropertyAccessExpression */:
- case 206 /* ElementAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
var propName = getAccessedPropertyName(node);
if (propName !== undefined) {
var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
@@ -67979,53 +69267,91 @@ var ts;
}
function isMatchingReference(source, target) {
switch (target.kind) {
- case 211 /* ParenthesizedExpression */:
- case 229 /* NonNullExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
+ case 230 /* SyntaxKind.NonNullExpression */:
return isMatchingReference(source, target.expression);
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) ||
- (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source, target.right));
+ (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source, target.right));
}
switch (source.kind) {
- case 230 /* MetaProperty */:
- return target.kind === 230 /* MetaProperty */
+ case 231 /* SyntaxKind.MetaProperty */:
+ return target.kind === 231 /* SyntaxKind.MetaProperty */
&& source.keywordToken === target.keywordToken
&& source.name.escapedText === target.name.escapedText;
- case 79 /* Identifier */:
- case 80 /* PrivateIdentifier */:
+ case 79 /* SyntaxKind.Identifier */:
+ case 80 /* SyntaxKind.PrivateIdentifier */:
return ts.isThisInTypeQuery(source) ?
- target.kind === 108 /* ThisKeyword */ :
- target.kind === 79 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) ||
- (target.kind === 253 /* VariableDeclaration */ || target.kind === 202 /* BindingElement */) &&
+ target.kind === 108 /* SyntaxKind.ThisKeyword */ :
+ target.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) ||
+ (target.kind === 254 /* SyntaxKind.VariableDeclaration */ || target.kind === 203 /* SyntaxKind.BindingElement */) &&
getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target);
- case 108 /* ThisKeyword */:
- return target.kind === 108 /* ThisKeyword */;
- case 106 /* SuperKeyword */:
- return target.kind === 106 /* SuperKeyword */;
- case 229 /* NonNullExpression */:
- case 211 /* ParenthesizedExpression */:
+ case 108 /* SyntaxKind.ThisKeyword */:
+ return target.kind === 108 /* SyntaxKind.ThisKeyword */;
+ case 106 /* SyntaxKind.SuperKeyword */:
+ return target.kind === 106 /* SyntaxKind.SuperKeyword */;
+ case 230 /* SyntaxKind.NonNullExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
return isMatchingReference(source.expression, target);
- case 205 /* PropertyAccessExpression */:
- case 206 /* ElementAccessExpression */:
- return ts.isAccessExpression(target) &&
- getAccessedPropertyName(source) === getAccessedPropertyName(target) &&
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
+ var sourcePropertyName = getAccessedPropertyName(source);
+ var targetPropertyName = ts.isAccessExpression(target) ? getAccessedPropertyName(target) : undefined;
+ return sourcePropertyName !== undefined && targetPropertyName !== undefined && targetPropertyName === sourcePropertyName &&
isMatchingReference(source.expression, target.expression);
- case 160 /* QualifiedName */:
+ case 161 /* SyntaxKind.QualifiedName */:
return ts.isAccessExpression(target) &&
source.right.escapedText === getAccessedPropertyName(target) &&
isMatchingReference(source.left, target.expression);
- case 220 /* BinaryExpression */:
- return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source.right, target));
+ case 221 /* SyntaxKind.BinaryExpression */:
+ return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source.right, target));
}
return false;
}
function getAccessedPropertyName(access) {
- var propertyName;
- return access.kind === 205 /* PropertyAccessExpression */ ? access.name.escapedText :
- access.kind === 206 /* ElementAccessExpression */ && ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) :
- access.kind === 202 /* BindingElement */ && (propertyName = getDestructuringPropertyName(access)) ? ts.escapeLeadingUnderscores(propertyName) :
- access.kind === 163 /* Parameter */ ? ("" + access.parent.parameters.indexOf(access)) :
- undefined;
+ if (ts.isPropertyAccessExpression(access)) {
+ return access.name.escapedText;
+ }
+ if (ts.isElementAccessExpression(access)) {
+ return tryGetElementAccessExpressionName(access);
+ }
+ if (ts.isBindingElement(access)) {
+ var name = getDestructuringPropertyName(access);
+ return name ? ts.escapeLeadingUnderscores(name) : undefined;
+ }
+ if (ts.isParameter(access)) {
+ return ("" + access.parent.parameters.indexOf(access));
+ }
+ return undefined;
+ }
+ function tryGetNameFromType(type) {
+ return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? type.escapedName :
+ type.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined;
+ }
+ function tryGetElementAccessExpressionName(node) {
+ if (ts.isStringOrNumericLiteralLike(node.argumentExpression)) {
+ return ts.escapeLeadingUnderscores(node.argumentExpression.text);
+ }
+ if (ts.isEntityNameExpression(node.argumentExpression)) {
+ var symbol = resolveEntityName(node.argumentExpression, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true);
+ if (!symbol || !isConstVariable(symbol))
+ return undefined;
+ var declaration = symbol.valueDeclaration;
+ if (declaration === undefined)
+ return undefined;
+ var type = tryGetTypeFromEffectiveTypeNode(declaration);
+ if (type) {
+ var name = tryGetNameFromType(type);
+ if (name !== undefined) {
+ return name;
+ }
+ }
+ if (ts.hasOnlyExpressionInitializer(declaration)) {
+ var initializer = ts.getEffectiveInitializer(declaration);
+ return initializer && tryGetNameFromType(getTypeOfExpression(initializer));
+ }
+ }
+ return undefined;
}
function containsMatchingReference(source, target) {
while (ts.isAccessExpression(source)) {
@@ -68046,12 +69372,12 @@ var ts;
return false;
}
function isDiscriminantProperty(type, name) {
- if (type && type.flags & 1048576 /* Union */) {
+ if (type && type.flags & 1048576 /* TypeFlags.Union */) {
var prop = getUnionOrIntersectionProperty(type, name);
- if (prop && ts.getCheckFlags(prop) & 2 /* SyntheticProperty */) {
+ if (prop && ts.getCheckFlags(prop) & 2 /* CheckFlags.SyntheticProperty */) {
if (prop.isDiscriminantProperty === undefined) {
prop.isDiscriminantProperty =
- (prop.checkFlags & 192 /* Discriminant */) === 192 /* Discriminant */ &&
+ (prop.checkFlags & 192 /* CheckFlags.Discriminant */) === 192 /* CheckFlags.Discriminant */ &&
!isGenericType(getTypeOfSymbol(prop));
}
return !!prop.isDiscriminantProperty;
@@ -68080,8 +69406,8 @@ var ts;
function mapTypesByKeyProperty(types, name) {
var map = new ts.Map();
var count = 0;
- var _loop_22 = function (type) {
- if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
+ var _loop_23 = function (type) {
+ if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) {
var discriminant = getTypeOfPropertyOfType(type, name);
if (discriminant) {
if (!isLiteralType(discriminant)) {
@@ -68106,9 +69432,9 @@ var ts;
};
for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
var type = types_16[_i];
- var state_8 = _loop_22(type);
- if (typeof state_8 === "object")
- return state_8.value;
+ var state_9 = _loop_23(type);
+ if (typeof state_9 === "object")
+ return state_9.value;
}
return count >= 10 && count * 2 >= types.length ? map : undefined;
}
@@ -68117,15 +69443,15 @@ var ts;
function getKeyPropertyName(unionType) {
var types = unionType.types;
// We only construct maps for unions with many non-primitive constituents.
- if (types.length < 10 || ts.getObjectFlags(unionType) & 65536 /* PrimitiveUnion */ ||
- ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */)); }) < 10) {
+ if (types.length < 10 || ts.getObjectFlags(unionType) & 32768 /* ObjectFlags.PrimitiveUnion */ ||
+ ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)); }) < 10) {
return undefined;
}
if (unionType.keyPropertyName === undefined) {
// The candidate key property name is the name of the first property with a unit type in one of the
// constituent types.
var keyPropertyName = ts.forEach(types, function (t) {
- return t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) ?
+ return t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ?
ts.forEach(getPropertiesOfType(t), function (p) { return isUnitType(getTypeOfSymbol(p)) ? p.escapedName : undefined; }) :
undefined;
});
@@ -68149,7 +69475,7 @@ var ts;
}
function getMatchingUnionConstituentForObjectLiteral(unionType, node) {
var keyPropertyName = getKeyPropertyName(unionType);
- var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 294 /* PropertyAssignment */ &&
+ var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ &&
p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); });
var propType = propNode && getContextFreeTypeOfExpression(propNode.initializer);
return propType && getConstituentTypeForKeyType(unionType, propType);
@@ -68166,7 +69492,7 @@ var ts;
}
}
}
- if (expression.expression.kind === 205 /* PropertyAccessExpression */ &&
+ if (expression.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ &&
isOrContainsMatchingReference(reference, expression.expression.expression)) {
return true;
}
@@ -68180,7 +69506,7 @@ var ts;
return flow.id;
}
function typeMaybeAssignableTo(source, target) {
- if (!(source.flags & 1048576 /* Union */)) {
+ if (!(source.flags & 1048576 /* TypeFlags.Union */)) {
return isTypeAssignableTo(source, target);
}
for (var _i = 0, _a = source.types; _i < _a.length; _i++) {
@@ -68196,11 +69522,11 @@ var ts;
// we remove type string.
function getAssignmentReducedType(declaredType, assignedType) {
if (declaredType !== assignedType) {
- if (assignedType.flags & 131072 /* Never */) {
+ if (assignedType.flags & 131072 /* TypeFlags.Never */) {
return assignedType;
}
var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
- if (assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType)) {
+ if (assignedType.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(assignedType)) {
reducedType = mapType(reducedType, getFreshTypeOfLiteralType); // Ensure that if the assignment is a fresh type, that we narrow to fresh types
}
// Our crude heuristic produces an invalid result in some cases: see GH#26130.
@@ -68223,93 +69549,93 @@ var ts;
function getTypeFacts(type, ignoreObjects) {
if (ignoreObjects === void 0) { ignoreObjects = false; }
var flags = type.flags;
- if (flags & 4 /* String */) {
- return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */;
+ if (flags & 4 /* TypeFlags.String */) {
+ return strictNullChecks ? 16317953 /* TypeFacts.StringStrictFacts */ : 16776705 /* TypeFacts.StringFacts */;
}
- if (flags & 128 /* StringLiteral */) {
+ if (flags & 128 /* TypeFlags.StringLiteral */) {
var isEmpty = type.value === "";
return strictNullChecks ?
- isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ :
- isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */;
+ isEmpty ? 12123649 /* TypeFacts.EmptyStringStrictFacts */ : 7929345 /* TypeFacts.NonEmptyStringStrictFacts */ :
+ isEmpty ? 12582401 /* TypeFacts.EmptyStringFacts */ : 16776705 /* TypeFacts.NonEmptyStringFacts */;
}
- if (flags & (8 /* Number */ | 32 /* Enum */)) {
- return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */;
+ if (flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */)) {
+ return strictNullChecks ? 16317698 /* TypeFacts.NumberStrictFacts */ : 16776450 /* TypeFacts.NumberFacts */;
}
- if (flags & 256 /* NumberLiteral */) {
+ if (flags & 256 /* TypeFlags.NumberLiteral */) {
var isZero = type.value === 0;
return strictNullChecks ?
- isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ :
- isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */;
+ isZero ? 12123394 /* TypeFacts.ZeroNumberStrictFacts */ : 7929090 /* TypeFacts.NonZeroNumberStrictFacts */ :
+ isZero ? 12582146 /* TypeFacts.ZeroNumberFacts */ : 16776450 /* TypeFacts.NonZeroNumberFacts */;
}
- if (flags & 64 /* BigInt */) {
- return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */;
+ if (flags & 64 /* TypeFlags.BigInt */) {
+ return strictNullChecks ? 16317188 /* TypeFacts.BigIntStrictFacts */ : 16775940 /* TypeFacts.BigIntFacts */;
}
- if (flags & 2048 /* BigIntLiteral */) {
+ if (flags & 2048 /* TypeFlags.BigIntLiteral */) {
var isZero = isZeroBigInt(type);
return strictNullChecks ?
- isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ :
- isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */;
+ isZero ? 12122884 /* TypeFacts.ZeroBigIntStrictFacts */ : 7928580 /* TypeFacts.NonZeroBigIntStrictFacts */ :
+ isZero ? 12581636 /* TypeFacts.ZeroBigIntFacts */ : 16775940 /* TypeFacts.NonZeroBigIntFacts */;
}
- if (flags & 16 /* Boolean */) {
- return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */;
+ if (flags & 16 /* TypeFlags.Boolean */) {
+ return strictNullChecks ? 16316168 /* TypeFacts.BooleanStrictFacts */ : 16774920 /* TypeFacts.BooleanFacts */;
}
- if (flags & 528 /* BooleanLike */) {
+ if (flags & 528 /* TypeFlags.BooleanLike */) {
return strictNullChecks ?
- (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ :
- (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
+ (type === falseType || type === regularFalseType) ? 12121864 /* TypeFacts.FalseStrictFacts */ : 7927560 /* TypeFacts.TrueStrictFacts */ :
+ (type === falseType || type === regularFalseType) ? 12580616 /* TypeFacts.FalseFacts */ : 16774920 /* TypeFacts.TrueFacts */;
}
- if (flags & 524288 /* Object */) {
+ if (flags & 524288 /* TypeFlags.Object */) {
if (ignoreObjects) {
- return 16768959 /* AndFactsMask */; // This is the identity element for computing type facts of intersection.
+ return 16768959 /* TypeFacts.AndFactsMask */; // This is the identity element for computing type facts of intersection.
}
- return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ?
- strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ :
+ return ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && isEmptyObjectType(type) ?
+ strictNullChecks ? 16318463 /* TypeFacts.EmptyObjectStrictFacts */ : 16777215 /* TypeFacts.EmptyObjectFacts */ :
isFunctionObjectType(type) ?
- strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728000 /* FunctionFacts */ :
- strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */;
+ strictNullChecks ? 7880640 /* TypeFacts.FunctionStrictFacts */ : 16728000 /* TypeFacts.FunctionFacts */ :
+ strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */;
}
- if (flags & (16384 /* Void */ | 32768 /* Undefined */)) {
- return 9830144 /* UndefinedFacts */;
+ if (flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */)) {
+ return 9830144 /* TypeFacts.UndefinedFacts */;
}
- if (flags & 65536 /* Null */) {
- return 9363232 /* NullFacts */;
+ if (flags & 65536 /* TypeFlags.Null */) {
+ return 9363232 /* TypeFacts.NullFacts */;
}
- if (flags & 12288 /* ESSymbolLike */) {
- return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */;
+ if (flags & 12288 /* TypeFlags.ESSymbolLike */) {
+ return strictNullChecks ? 7925520 /* TypeFacts.SymbolStrictFacts */ : 16772880 /* TypeFacts.SymbolFacts */;
}
- if (flags & 67108864 /* NonPrimitive */) {
- return strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */;
+ if (flags & 67108864 /* TypeFlags.NonPrimitive */) {
+ return strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */;
}
- if (flags & 131072 /* Never */) {
- return 0 /* None */;
+ if (flags & 131072 /* TypeFlags.Never */) {
+ return 0 /* TypeFacts.None */;
}
- if (flags & 465829888 /* Instantiable */) {
+ if (flags & 465829888 /* TypeFlags.Instantiable */) {
return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType, ignoreObjects) :
- strictNullChecks ? 7929345 /* NonEmptyStringStrictFacts */ : 16776705 /* NonEmptyStringFacts */;
+ strictNullChecks ? 7929345 /* TypeFacts.NonEmptyStringStrictFacts */ : 16776705 /* TypeFacts.NonEmptyStringFacts */;
}
- if (flags & 1048576 /* Union */) {
- return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0 /* None */);
+ if (flags & 1048576 /* TypeFlags.Union */) {
+ return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0 /* TypeFacts.None */);
}
- if (flags & 2097152 /* Intersection */) {
+ if (flags & 2097152 /* TypeFlags.Intersection */) {
// When an intersection contains a primitive type we ignore object type constituents as they are
// presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type.
- ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */));
+ ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* TypeFlags.Primitive */));
return getIntersectionTypeFacts(type, ignoreObjects);
}
- return 16777215 /* All */;
+ return 16777215 /* TypeFacts.All */;
}
function getIntersectionTypeFacts(type, ignoreObjects) {
// When computing the type facts of an intersection type, certain type facts are computed as `and`
// and others are computed as `or`.
- var oredFacts = 0 /* None */;
- var andedFacts = 16777215 /* All */;
+ var oredFacts = 0 /* TypeFacts.None */;
+ var andedFacts = 16777215 /* TypeFacts.All */;
for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
var t = _a[_i];
var f = getTypeFacts(t, ignoreObjects);
oredFacts |= f;
andedFacts &= f;
}
- return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 16768959 /* AndFactsMask */;
+ return oredFacts & 8256 /* TypeFacts.OrFactsMask */ | andedFacts & 16768959 /* TypeFacts.AndFactsMask */;
}
function getTypeWithFacts(type, include) {
return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
@@ -68329,7 +69655,7 @@ var ts;
}
function getTypeOfDestructuredArrayElement(type, index) {
return everyType(type, isTupleLikeType) && getTupleElementType(type, index) ||
- includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined)) ||
+ includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined)) ||
errorType;
}
function includeUndefinedInIndexSignature(type) {
@@ -68340,18 +69666,18 @@ var ts;
type;
}
function getTypeOfDestructuredSpreadExpression(type) {
- return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType);
+ return createArrayType(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType);
}
function getAssignedTypeOfBinaryExpression(node) {
- var isDestructuringDefaultAssignment = node.parent.kind === 203 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) ||
- node.parent.kind === 294 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent);
+ var isDestructuringDefaultAssignment = node.parent.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) ||
+ node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent);
return isDestructuringDefaultAssignment ?
getTypeWithDefault(getAssignedType(node), node.right) :
getTypeOfExpression(node.right);
}
function isDestructuringAssignmentTarget(parent) {
- return parent.parent.kind === 220 /* BinaryExpression */ && parent.parent.left === parent ||
- parent.parent.kind === 243 /* ForOfStatement */ && parent.parent.initializer === parent;
+ return parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.parent.left === parent ||
+ parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */ && parent.parent.initializer === parent;
}
function getAssignedTypeOfArrayLiteralElement(node, element) {
return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element));
@@ -68368,21 +69694,21 @@ var ts;
function getAssignedType(node) {
var parent = node.parent;
switch (parent.kind) {
- case 242 /* ForInStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
return stringType;
- case 243 /* ForOfStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
return checkRightHandSideOfForOf(parent) || errorType;
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return getAssignedTypeOfBinaryExpression(parent);
- case 214 /* DeleteExpression */:
+ case 215 /* SyntaxKind.DeleteExpression */:
return undefinedType;
- case 203 /* ArrayLiteralExpression */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
return getAssignedTypeOfArrayLiteralElement(parent, node);
- case 224 /* SpreadElement */:
+ case 225 /* SyntaxKind.SpreadElement */:
return getAssignedTypeOfSpreadExpression(parent);
- case 294 /* PropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
return getAssignedTypeOfPropertyAssignment(parent);
- case 295 /* ShorthandPropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
return getAssignedTypeOfShorthandPropertyAssignment(parent);
}
return errorType;
@@ -68390,7 +69716,7 @@ var ts;
function getInitialTypeOfBindingElement(node) {
var pattern = node.parent;
var parentType = getInitialType(pattern.parent);
- var type = pattern.kind === 200 /* ObjectBindingPattern */ ?
+ var type = pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ?
getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) :
!node.dotDotDotToken ?
getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) :
@@ -68408,37 +69734,37 @@ var ts;
if (node.initializer) {
return getTypeOfInitializer(node.initializer);
}
- if (node.parent.parent.kind === 242 /* ForInStatement */) {
+ if (node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) {
return stringType;
}
- if (node.parent.parent.kind === 243 /* ForOfStatement */) {
+ if (node.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) {
return checkRightHandSideOfForOf(node.parent.parent) || errorType;
}
return errorType;
}
function getInitialType(node) {
- return node.kind === 253 /* VariableDeclaration */ ?
+ return node.kind === 254 /* SyntaxKind.VariableDeclaration */ ?
getInitialTypeOfVariableDeclaration(node) :
getInitialTypeOfBindingElement(node);
}
function isEmptyArrayAssignment(node) {
- return node.kind === 253 /* VariableDeclaration */ && node.initializer &&
+ return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.initializer &&
isEmptyArrayLiteral(node.initializer) ||
- node.kind !== 202 /* BindingElement */ && node.parent.kind === 220 /* BinaryExpression */ &&
+ node.kind !== 203 /* SyntaxKind.BindingElement */ && node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ &&
isEmptyArrayLiteral(node.parent.right);
}
function getReferenceCandidate(node) {
switch (node.kind) {
- case 211 /* ParenthesizedExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
return getReferenceCandidate(node.expression);
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
switch (node.operatorToken.kind) {
- case 63 /* EqualsToken */:
- case 75 /* BarBarEqualsToken */:
- case 76 /* AmpersandAmpersandEqualsToken */:
- case 77 /* QuestionQuestionEqualsToken */:
+ case 63 /* SyntaxKind.EqualsToken */:
+ case 75 /* SyntaxKind.BarBarEqualsToken */:
+ case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */:
+ case 77 /* SyntaxKind.QuestionQuestionEqualsToken */:
return getReferenceCandidate(node.left);
- case 27 /* CommaToken */:
+ case 27 /* SyntaxKind.CommaToken */:
return getReferenceCandidate(node.right);
}
}
@@ -68446,13 +69772,13 @@ var ts;
}
function getReferenceRoot(node) {
var parent = node.parent;
- return parent.kind === 211 /* ParenthesizedExpression */ ||
- parent.kind === 220 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */ && parent.left === node ||
- parent.kind === 220 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ?
+ return parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */ ||
+ parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && parent.left === node ||
+ parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && parent.right === node ?
getReferenceRoot(parent) : node;
}
function getTypeOfSwitchClause(clause) {
- if (clause.kind === 288 /* CaseClause */) {
+ if (clause.kind === 289 /* SyntaxKind.CaseClause */) {
return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression));
}
return neverType;
@@ -68472,7 +69798,7 @@ var ts;
var witnesses = [];
for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) {
var clause = _a[_i];
- if (clause.kind === 288 /* CaseClause */) {
+ if (clause.kind === 289 /* SyntaxKind.CaseClause */) {
if (ts.isStringLiteralLike(clause.expression)) {
witnesses.push(clause.expression.text);
continue;
@@ -68485,13 +69811,13 @@ var ts;
return witnesses;
}
function eachTypeContainedIn(source, types) {
- return source.flags & 1048576 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source);
+ return source.flags & 1048576 /* TypeFlags.Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source);
}
function isTypeSubsetOf(source, target) {
- return source === target || target.flags & 1048576 /* Union */ && isTypeSubsetOfUnion(source, target);
+ return source === target || target.flags & 1048576 /* TypeFlags.Union */ && isTypeSubsetOfUnion(source, target);
}
function isTypeSubsetOfUnion(source, target) {
- if (source.flags & 1048576 /* Union */) {
+ if (source.flags & 1048576 /* TypeFlags.Union */) {
for (var _i = 0, _a = source.types; _i < _a.length; _i++) {
var t = _a[_i];
if (!containsType(target.types, t)) {
@@ -68500,25 +69826,25 @@ var ts;
}
return true;
}
- if (source.flags & 1024 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) {
+ if (source.flags & 1024 /* TypeFlags.EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) {
return true;
}
return containsType(target.types, source);
}
function forEachType(type, f) {
- return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type);
+ return type.flags & 1048576 /* TypeFlags.Union */ ? ts.forEach(type.types, f) : f(type);
}
function someType(type, f) {
- return type.flags & 1048576 /* Union */ ? ts.some(type.types, f) : f(type);
+ return type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, f) : f(type);
}
function everyType(type, f) {
- return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type);
+ return type.flags & 1048576 /* TypeFlags.Union */ ? ts.every(type.types, f) : f(type);
}
function everyContainedType(type, f) {
- return type.flags & 3145728 /* UnionOrIntersection */ ? ts.every(type.types, f) : f(type);
+ return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? ts.every(type.types, f) : f(type);
}
function filterType(type, f) {
- if (type.flags & 1048576 /* Union */) {
+ if (type.flags & 1048576 /* TypeFlags.Union */) {
var types = type.types;
var filtered = ts.filter(types, f);
if (filtered === types) {
@@ -68526,45 +69852,45 @@ var ts;
}
var origin = type.origin;
var newOrigin = void 0;
- if (origin && origin.flags & 1048576 /* Union */) {
+ if (origin && origin.flags & 1048576 /* TypeFlags.Union */) {
// If the origin type is a (denormalized) union type, filter its non-union constituents. If that ends
// up removing a smaller number of types than in the normalized constituent set (meaning some of the
// filtered types are within nested unions in the origin), then we can't construct a new origin type.
// Otherwise, if we have exactly one type left in the origin set, return that as the filtered type.
// Otherwise, construct a new filtered origin type.
var originTypes = origin.types;
- var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* Union */) || f(t); });
+ var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) || f(t); });
if (originTypes.length - originFiltered.length === types.length - filtered.length) {
if (originFiltered.length === 1) {
return originFiltered[0];
}
- newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered);
+ newOrigin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, originFiltered);
}
}
return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin);
}
- return type.flags & 131072 /* Never */ || f(type) ? type : neverType;
+ return type.flags & 131072 /* TypeFlags.Never */ || f(type) ? type : neverType;
}
function removeType(type, targetType) {
return filterType(type, function (t) { return t !== targetType; });
}
function countTypes(type) {
- return type.flags & 1048576 /* Union */ ? type.types.length : 1;
+ return type.flags & 1048576 /* TypeFlags.Union */ ? type.types.length : 1;
}
function mapType(type, mapper, noReductions) {
- if (type.flags & 131072 /* Never */) {
+ if (type.flags & 131072 /* TypeFlags.Never */) {
return type;
}
- if (!(type.flags & 1048576 /* Union */)) {
+ if (!(type.flags & 1048576 /* TypeFlags.Union */)) {
return mapper(type);
}
var origin = type.origin;
- var types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types;
+ var types = origin && origin.flags & 1048576 /* TypeFlags.Union */ ? 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];
- var mapped = t.flags & 1048576 /* Union */ ? mapType(t, mapper, noReductions) : mapper(t);
+ var mapped = t.flags & 1048576 /* TypeFlags.Union */ ? mapType(t, mapper, noReductions) : mapper(t);
changed || (changed = t !== mapped);
if (mapped) {
if (!mappedTypes) {
@@ -68575,11 +69901,11 @@ var ts;
}
}
}
- return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type;
+ return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* UnionReduction.None */ : 1 /* UnionReduction.Literal */) : type;
}
function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
- return type.flags & 1048576 /* Union */ && aliasSymbol ?
- getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) :
+ return type.flags & 1048576 /* TypeFlags.Union */ && aliasSymbol ?
+ getUnionType(ts.map(type.types, mapper), 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments) :
mapType(type, mapper);
}
function extractTypesOfKind(type, kind) {
@@ -68591,13 +69917,13 @@ var ts;
// true intersection because it is more costly and, when applied to union types, generates a large number of
// types we don't actually care about.
function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) {
- if (maybeTypeOfKind(typeWithPrimitives, 4 /* String */ | 134217728 /* TemplateLiteral */ | 8 /* Number */ | 64 /* BigInt */) &&
- maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 256 /* NumberLiteral */ | 2048 /* BigIntLiteral */)) {
+ if (maybeTypeOfKind(typeWithPrimitives, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */) &&
+ maybeTypeOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 256 /* TypeFlags.NumberLiteral */ | 2048 /* TypeFlags.BigIntLiteral */)) {
return mapType(typeWithPrimitives, function (t) {
- return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) :
- isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* String */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* StringLiteral */) :
- t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) :
- t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t;
+ return t.flags & 4 /* TypeFlags.String */ ? extractTypesOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) :
+ isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */) :
+ t.flags & 8 /* TypeFlags.Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) :
+ t.flags & 64 /* TypeFlags.BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* TypeFlags.BigInt */ | 2048 /* TypeFlags.BigIntLiteral */) : t;
});
}
return typeWithPrimitives;
@@ -68609,14 +69935,14 @@ var ts;
return flowType.flags === 0 ? flowType.type : flowType;
}
function createFlowType(type, incomplete) {
- return incomplete ? { flags: 0, type: type.flags & 131072 /* Never */ ? silentNeverType : type } : type;
+ return incomplete ? { flags: 0, type: type.flags & 131072 /* TypeFlags.Never */ ? silentNeverType : type } : type;
}
// An evolving array type tracks the element types that have so far been seen in an
// 'x.push(value)' or 'x[n] = value' operation along the control flow graph. Evolving
// array types are ultimately converted into manifest array types (using getFinalArrayType)
// and never escape the getFlowTypeOfReference function.
function createEvolvingArrayType(elementType) {
- var result = createObjectType(256 /* EvolvingArray */);
+ var result = createObjectType(256 /* ObjectFlags.EvolvingArray */);
result.elementType = elementType;
return result;
}
@@ -68631,10 +69957,10 @@ var ts;
return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType]));
}
function createFinalArrayType(elementType) {
- return elementType.flags & 131072 /* Never */ ?
+ return elementType.flags & 131072 /* TypeFlags.Never */ ?
autoArrayType :
- createArrayType(elementType.flags & 1048576 /* Union */ ?
- getUnionType(elementType.types, 2 /* Subtype */) :
+ createArrayType(elementType.flags & 1048576 /* TypeFlags.Union */ ?
+ getUnionType(elementType.types, 2 /* UnionReduction.Subtype */) :
elementType);
}
// We perform subtype reduction upon obtaining the final array type from an evolving array type.
@@ -68642,17 +69968,17 @@ var ts;
return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType));
}
function finalizeEvolvingArrayType(type) {
- return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? getFinalArrayType(type) : type;
+ return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? getFinalArrayType(type) : type;
}
function getElementTypeOfEvolvingArrayType(type) {
- return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? type.elementType : neverType;
+ return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? type.elementType : neverType;
}
function isEvolvingArrayTypeList(types) {
var hasEvolvingArrayType = false;
for (var _i = 0, types_18 = types; _i < types_18.length; _i++) {
var t = types_18[_i];
- if (!(t.flags & 131072 /* Never */)) {
- if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) {
+ if (!(t.flags & 131072 /* TypeFlags.Never */)) {
+ if (!(ts.getObjectFlags(t) & 256 /* ObjectFlags.EvolvingArray */)) {
return false;
}
hasEvolvingArrayType = true;
@@ -68666,16 +69992,16 @@ var ts;
var root = getReferenceRoot(node);
var parent = root.parent;
var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" ||
- parent.parent.kind === 207 /* CallExpression */
+ parent.parent.kind === 208 /* SyntaxKind.CallExpression */
&& ts.isIdentifier(parent.name)
&& ts.isPushOrUnshiftIdentifier(parent.name));
- var isElementAssignment = parent.kind === 206 /* ElementAccessExpression */ &&
+ var isElementAssignment = parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ &&
parent.expression === root &&
- parent.parent.kind === 220 /* BinaryExpression */ &&
- parent.parent.operatorToken.kind === 63 /* EqualsToken */ &&
+ parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ &&
+ parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ &&
parent.parent.left === parent &&
!ts.isAssignmentTarget(parent.parent) &&
- isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */);
+ isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* TypeFlags.NumberLike */);
return isLengthPushOrUnshift || isElementAssignment;
}
function isDeclarationWithExplicitTypeAnnotation(node) {
@@ -68684,11 +70010,11 @@ var ts;
ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer));
}
function getExplicitTypeOfSymbol(symbol, diagnostic) {
- if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) {
+ if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 512 /* SymbolFlags.ValueModule */)) {
return getTypeOfSymbol(symbol);
}
- if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) {
- if (ts.getCheckFlags(symbol) & 262144 /* Mapped */) {
+ if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) {
+ if (ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */) {
var origin = symbol.syntheticOrigin;
if (origin && getExplicitTypeOfSymbol(origin)) {
return getTypeOfSymbol(symbol);
@@ -68699,11 +70025,11 @@ var ts;
if (isDeclarationWithExplicitTypeAnnotation(declaration)) {
return getTypeOfSymbol(symbol);
}
- if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForOfStatement */) {
+ if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) {
var statement = declaration.parent.parent;
var expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined);
if (expressionType) {
- var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */;
+ var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */;
return checkIteratedTypeOrElementType(use, expressionType, undefinedType, /*errorNode*/ undefined);
}
}
@@ -68718,16 +70044,16 @@ var ts;
// parameter symbols with declarations that have explicit type annotations. Such references are
// resolvable with no possibility of triggering circularities in control flow analysis.
function getTypeOfDottedName(node, diagnostic) {
- if (!(node.flags & 16777216 /* InWithStatement */)) {
+ if (!(node.flags & 33554432 /* NodeFlags.InWithStatement */)) {
switch (node.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node));
- return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic);
- case 108 /* ThisKeyword */:
+ return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol, diagnostic);
+ case 108 /* SyntaxKind.ThisKeyword */:
return getExplicitThisType(node);
- case 106 /* SuperKeyword */:
+ case 106 /* SyntaxKind.SuperKeyword */:
return checkSuperExpression(node);
- case 205 /* PropertyAccessExpression */: {
+ case 206 /* SyntaxKind.PropertyAccessExpression */: {
var type = getTypeOfDottedName(node.expression, diagnostic);
if (type) {
var name = node.name;
@@ -68745,7 +70071,7 @@ var ts;
}
return undefined;
}
- case 211 /* ParenthesizedExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
return getTypeOfDottedName(node.expression, diagnostic);
}
}
@@ -68759,10 +70085,10 @@ var ts;
// circularities in control flow analysis, we use getTypeOfDottedName when resolving the call
// target expression of an assertion.
var funcType = void 0;
- if (node.parent.kind === 237 /* ExpressionStatement */) {
+ if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */) {
funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined);
}
- else if (node.expression.kind !== 106 /* SuperKeyword */) {
+ else if (node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) {
if (ts.isOptionalChain(node)) {
funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression);
}
@@ -68770,7 +70096,7 @@ var ts;
funcType = checkNonNullExpression(node.expression);
}
}
- var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* Call */);
+ var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* SignatureKind.Call */);
var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] :
ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) :
undefined;
@@ -68780,10 +70106,10 @@ var ts;
}
function hasTypePredicateOrNeverReturnType(signature) {
return !!(getTypePredicateOfSignature(signature) ||
- signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* Never */);
+ signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* TypeFlags.Never */);
}
function getTypePredicateArgument(predicate, callExpression) {
- if (predicate.kind === 1 /* Identifier */ || predicate.kind === 3 /* AssertsIdentifier */) {
+ if (predicate.kind === 1 /* TypePredicateKind.Identifier */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */) {
return callExpression.arguments[predicate.parameterIndex];
}
var invokedExpression = ts.skipParentheses(callExpression.expression);
@@ -68803,8 +70129,8 @@ var ts;
}
function isFalseExpression(expr) {
var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true);
- return node.kind === 95 /* FalseKeyword */ || node.kind === 220 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) ||
- node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right));
+ return node.kind === 95 /* SyntaxKind.FalseKeyword */ || node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) ||
+ node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right));
}
function isReachableFlowNodeWorker(flow, noCacheCheck) {
while (true) {
@@ -68812,7 +70138,7 @@ var ts;
return lastFlowNodeReachable;
}
var flags = flow.flags;
- if (flags & 4096 /* Shared */) {
+ if (flags & 4096 /* FlowFlags.Shared */) {
if (!noCacheCheck) {
var id = getFlowNodeId(flow);
var reachable = flowNodeReachable[id];
@@ -68820,30 +70146,30 @@ var ts;
}
noCacheCheck = false;
}
- if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */)) {
+ if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */)) {
flow = flow.antecedent;
}
- else if (flags & 512 /* Call */) {
+ else if (flags & 512 /* FlowFlags.Call */) {
var signature = getEffectsSignature(flow.node);
if (signature) {
var predicate = getTypePredicateOfSignature(signature);
- if (predicate && predicate.kind === 3 /* AssertsIdentifier */ && !predicate.type) {
+ if (predicate && predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && !predicate.type) {
var predicateArgument = flow.node.arguments[predicate.parameterIndex];
if (predicateArgument && isFalseExpression(predicateArgument)) {
return false;
}
}
- if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) {
+ if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) {
return false;
}
}
flow = flow.antecedent;
}
- else if (flags & 4 /* BranchLabel */) {
+ else if (flags & 4 /* FlowFlags.BranchLabel */) {
// A branching point is reachable if any branch is reachable.
return ts.some(flow.antecedents, function (f) { return isReachableFlowNodeWorker(f, /*noCacheCheck*/ false); });
}
- else if (flags & 8 /* LoopLabel */) {
+ else if (flags & 8 /* FlowFlags.LoopLabel */) {
var antecedents = flow.antecedents;
if (antecedents === undefined || antecedents.length === 0) {
return false;
@@ -68851,7 +70177,7 @@ var ts;
// A loop is reachable if the control flow path that leads to the top is reachable.
flow = antecedents[0];
}
- else if (flags & 128 /* SwitchClause */) {
+ else if (flags & 128 /* FlowFlags.SwitchClause */) {
// The control flow path representing an unmatched value in a switch statement with
// no default clause is unreachable if the switch statement is exhaustive.
if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) {
@@ -68859,7 +70185,7 @@ var ts;
}
flow = flow.antecedent;
}
- else if (flags & 1024 /* ReduceLabel */) {
+ else if (flags & 1024 /* FlowFlags.ReduceLabel */) {
// Cache is unreliable once we start adjusting labels
lastFlowNode = undefined;
var target = flow.target;
@@ -68870,7 +70196,7 @@ var ts;
return result;
}
else {
- return !(flags & 1 /* Unreachable */);
+ return !(flags & 1 /* FlowFlags.Unreachable */);
}
}
}
@@ -68879,7 +70205,7 @@ var ts;
function isPostSuperFlowNode(flow, noCacheCheck) {
while (true) {
var flags = flow.flags;
- if (flags & 4096 /* Shared */) {
+ if (flags & 4096 /* FlowFlags.Shared */) {
if (!noCacheCheck) {
var id = getFlowNodeId(flow);
var postSuper = flowNodePostSuper[id];
@@ -68887,24 +70213,24 @@ var ts;
}
noCacheCheck = false;
}
- if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 128 /* SwitchClause */)) {
+ if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */ | 128 /* FlowFlags.SwitchClause */)) {
flow = flow.antecedent;
}
- else if (flags & 512 /* Call */) {
- if (flow.node.expression.kind === 106 /* SuperKeyword */) {
+ else if (flags & 512 /* FlowFlags.Call */) {
+ if (flow.node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) {
return true;
}
flow = flow.antecedent;
}
- else if (flags & 4 /* BranchLabel */) {
+ else if (flags & 4 /* FlowFlags.BranchLabel */) {
// A branching point is post-super if every branch is post-super.
return ts.every(flow.antecedents, function (f) { return isPostSuperFlowNode(f, /*noCacheCheck*/ false); });
}
- else if (flags & 8 /* LoopLabel */) {
+ else if (flags & 8 /* FlowFlags.LoopLabel */) {
// A loop is post-super if the control flow path that leads to the top is post-super.
flow = flow.antecedents[0];
}
- else if (flags & 1024 /* ReduceLabel */) {
+ else if (flags & 1024 /* FlowFlags.ReduceLabel */) {
var target = flow.target;
var saveAntecedents = target.antecedents;
target.antecedents = flow.antecedents;
@@ -68914,18 +70240,18 @@ var ts;
}
else {
// Unreachable nodes are considered post-super to silence errors
- return !!(flags & 1 /* Unreachable */);
+ return !!(flags & 1 /* FlowFlags.Unreachable */);
}
}
}
function isConstantReference(node) {
switch (node.kind) {
- case 79 /* Identifier */: {
+ case 79 /* SyntaxKind.Identifier */: {
var symbol = getResolvedSymbol(node);
return isConstVariable(symbol) || ts.isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol);
}
- case 205 /* PropertyAccessExpression */:
- case 206 /* ElementAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
// The resolvedSymbol property is initialized by checkPropertyAccess or checkElementAccess before we get here.
return isConstantReference(node.expression) && isReadonlySymbol(getNodeLinks(node).resolvedSymbol || unknownSymbol);
}
@@ -68951,8 +70277,8 @@ var ts;
// we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations
// on empty arrays are possible without implicit any errors and new element types can be inferred without
// type mismatch errors.
- var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType);
- if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 229 /* NonNullExpression */ && !(resultType.flags & 131072 /* Never */) && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) {
+ var resultType = ts.getObjectFlags(evolvedType) & 256 /* ObjectFlags.EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType);
+ if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 230 /* SyntaxKind.NonNullExpression */ && !(resultType.flags & 131072 /* TypeFlags.Never */) && getTypeWithFacts(resultType, 2097152 /* TypeFacts.NEUndefinedOrNull */).flags & 131072 /* TypeFlags.Never */) {
return declaredType;
}
// The non-null unknown type should never escape control flow analysis.
@@ -68968,7 +70294,7 @@ var ts;
if (flowDepth === 2000) {
// We have made 2000 recursive invocations. To avoid overflowing the call stack we report an error
// and disable further control flow analysis in the containing function or module body.
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id });
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id });
flowAnalysisDisabled = true;
reportFlowControlError(reference);
return errorType;
@@ -68977,7 +70303,7 @@ var ts;
var sharedFlow;
while (true) {
var flags = flow.flags;
- if (flags & 4096 /* Shared */) {
+ if (flags & 4096 /* FlowFlags.Shared */) {
// We cache results of flow type resolution for shared nodes that were previously visited in
// the same getFlowTypeOfReference invocation. A node is considered shared when it is the
// antecedent of more than one node.
@@ -68990,56 +70316,56 @@ var ts;
sharedFlow = flow;
}
var type = void 0;
- if (flags & 16 /* Assignment */) {
+ if (flags & 16 /* FlowFlags.Assignment */) {
type = getTypeAtFlowAssignment(flow);
if (!type) {
flow = flow.antecedent;
continue;
}
}
- else if (flags & 512 /* Call */) {
+ else if (flags & 512 /* FlowFlags.Call */) {
type = getTypeAtFlowCall(flow);
if (!type) {
flow = flow.antecedent;
continue;
}
}
- else if (flags & 96 /* Condition */) {
+ else if (flags & 96 /* FlowFlags.Condition */) {
type = getTypeAtFlowCondition(flow);
}
- else if (flags & 128 /* SwitchClause */) {
+ else if (flags & 128 /* FlowFlags.SwitchClause */) {
type = getTypeAtSwitchClause(flow);
}
- else if (flags & 12 /* Label */) {
+ else if (flags & 12 /* FlowFlags.Label */) {
if (flow.antecedents.length === 1) {
flow = flow.antecedents[0];
continue;
}
- type = flags & 4 /* BranchLabel */ ?
+ type = flags & 4 /* FlowFlags.BranchLabel */ ?
getTypeAtFlowBranchLabel(flow) :
getTypeAtFlowLoopLabel(flow);
}
- else if (flags & 256 /* ArrayMutation */) {
+ else if (flags & 256 /* FlowFlags.ArrayMutation */) {
type = getTypeAtFlowArrayMutation(flow);
if (!type) {
flow = flow.antecedent;
continue;
}
}
- else if (flags & 1024 /* ReduceLabel */) {
+ else if (flags & 1024 /* FlowFlags.ReduceLabel */) {
var target = flow.target;
var saveAntecedents = target.antecedents;
target.antecedents = flow.antecedents;
type = getTypeAtFlowNode(flow.antecedent);
target.antecedents = saveAntecedents;
}
- else if (flags & 2 /* Start */) {
+ else if (flags & 2 /* FlowFlags.Start */) {
// Check if we should continue with the control flow of the containing function.
var container = flow.node;
if (container && container !== flowContainer &&
- reference.kind !== 205 /* PropertyAccessExpression */ &&
- reference.kind !== 206 /* ElementAccessExpression */ &&
- reference.kind !== 108 /* ThisKeyword */) {
+ reference.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ &&
+ reference.kind !== 207 /* SyntaxKind.ElementAccessExpression */ &&
+ reference.kind !== 108 /* SyntaxKind.ThisKeyword */) {
flow = container.flowNode;
continue;
}
@@ -69063,7 +70389,7 @@ var ts;
}
function getInitialOrAssignedType(flow) {
var node = flow.node;
- return getNarrowableTypeForReference(node.kind === 253 /* VariableDeclaration */ || node.kind === 202 /* BindingElement */ ?
+ return getNarrowableTypeForReference(node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */ ?
getInitialType(node) :
getAssignedType(node), reference);
}
@@ -69075,7 +70401,7 @@ var ts;
if (!isReachableFlowNode(flow)) {
return unreachableNeverType;
}
- if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) {
+ if (ts.getAssignmentTargetKind(node) === 2 /* AssignmentKind.Compound */) {
var flowType = getTypeAtFlowNode(flow.antecedent);
return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType));
}
@@ -69086,7 +70412,7 @@ var ts;
var assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow));
return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType;
}
- if (declaredType.flags & 1048576 /* Union */) {
+ if (declaredType.flags & 1048576 /* TypeFlags.Union */) {
return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow));
}
return declaredType;
@@ -69103,14 +70429,14 @@ var ts;
// in which case we continue control flow analysis back to the function's declaration
if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) {
var init = ts.getDeclaredExpandoInitializer(node);
- if (init && (init.kind === 212 /* FunctionExpression */ || init.kind === 213 /* ArrowFunction */)) {
+ if (init && (init.kind === 213 /* SyntaxKind.FunctionExpression */ || init.kind === 214 /* SyntaxKind.ArrowFunction */)) {
return getTypeAtFlowNode(flow.antecedent);
}
}
return declaredType;
}
// for (const _ in ref) acts as a nonnull on ref
- if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 242 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) {
+ if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) {
return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent)));
}
// Assignment doesn't affect reference
@@ -69118,14 +70444,14 @@ var ts;
}
function narrowTypeByAssertion(type, expr) {
var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true);
- if (node.kind === 95 /* FalseKeyword */) {
+ if (node.kind === 95 /* SyntaxKind.FalseKeyword */) {
return unreachableNeverType;
}
- if (node.kind === 220 /* BinaryExpression */) {
- if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) {
+ if (node.kind === 221 /* SyntaxKind.BinaryExpression */) {
+ if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) {
return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right);
}
- if (node.operatorToken.kind === 56 /* BarBarToken */) {
+ if (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) {
return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]);
}
}
@@ -69135,15 +70461,15 @@ var ts;
var signature = getEffectsSignature(flow.node);
if (signature) {
var predicate = getTypePredicateOfSignature(signature);
- if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) {
+ if (predicate && (predicate.kind === 2 /* TypePredicateKind.AssertsThis */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */)) {
var flowType = getTypeAtFlowNode(flow.antecedent);
var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType));
var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) :
- predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) :
+ predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) :
type;
return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType));
}
- if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) {
+ if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) {
return unreachableNeverType;
}
}
@@ -69152,15 +70478,15 @@ var ts;
function getTypeAtFlowArrayMutation(flow) {
if (declaredType === autoType || declaredType === autoArrayType) {
var node = flow.node;
- var expr = node.kind === 207 /* CallExpression */ ?
+ var expr = node.kind === 208 /* SyntaxKind.CallExpression */ ?
node.expression.expression :
node.left.expression;
if (isMatchingReference(reference, getReferenceCandidate(expr))) {
var flowType = getTypeAtFlowNode(flow.antecedent);
var type = getTypeFromFlowType(flowType);
- if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) {
+ if (ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */) {
var evolvedType_1 = type;
- if (node.kind === 207 /* CallExpression */) {
+ if (node.kind === 208 /* SyntaxKind.CallExpression */) {
for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) {
var arg = _a[_i];
evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg);
@@ -69169,7 +70495,7 @@ var ts;
else {
// We must get the context free expression type so as to not recur in an uncached fashion on the LHS (which causes exponential blowup in compile time)
var indexType = getContextFreeTypeOfExpression(node.left.argumentExpression);
- if (isTypeAssignableToKind(indexType, 296 /* NumberLike */)) {
+ if (isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) {
evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right);
}
}
@@ -69183,7 +70509,7 @@ var ts;
function getTypeAtFlowCondition(flow) {
var flowType = getTypeAtFlowNode(flow.antecedent);
var type = getTypeFromFlowType(flowType);
- if (type.flags & 131072 /* Never */) {
+ if (type.flags & 131072 /* TypeFlags.Never */) {
return flowType;
}
// If we have an antecedent type (meaning we're reachable in some way), we first
@@ -69193,7 +70519,7 @@ var ts;
// have the complete type. We proceed by switching to the silent never type which
// doesn't report errors when operators are applied to it. Note that this is the
// *only* place a silent never type is ever generated.
- var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0;
+ var assumeTrue = (flow.flags & 32 /* FlowFlags.TrueCondition */) !== 0;
var nonEvolvingType = finalizeEvolvingArrayType(type);
var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue);
if (narrowedType === nonEvolvingType) {
@@ -69208,16 +70534,16 @@ var ts;
if (isMatchingReference(reference, expr)) {
type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
}
- else if (expr.kind === 215 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
+ else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
}
else {
if (strictNullChecks) {
if (optionalChainContainsReference(expr, reference)) {
- type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); });
+ type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* TypeFlags.Undefined */ | 131072 /* TypeFlags.Never */)); });
}
- else if (expr.kind === 215 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) {
- type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"); });
+ else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) {
+ type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* TypeFlags.Never */ || t.flags & 128 /* TypeFlags.StringLiteral */ && t.value === "undefined"); });
}
}
var access = getDiscriminantPropertyAccess(expr, type);
@@ -69234,7 +70560,7 @@ var ts;
var bypassFlow;
for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) {
var antecedent = _a[_i];
- if (!bypassFlow && antecedent.flags & 128 /* SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) {
+ if (!bypassFlow && antecedent.flags & 128 /* FlowFlags.SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) {
// The antecedent is the bypass branch of a potentially exhaustive switch statement.
bypassFlow = antecedent;
continue;
@@ -69278,7 +70604,7 @@ var ts;
}
}
}
- return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */), seenIncomplete);
+ return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */), seenIncomplete);
}
function getTypeAtFlowLoopLabel(flow) {
// If we have previously computed the control flow type for the reference at
@@ -69304,7 +70630,7 @@ var ts;
// path that leads to the top.
for (var i = flowLoopStart; i < flowLoopCount; i++) {
if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) {
- return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* Literal */), /*incomplete*/ true);
+ return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* UnionReduction.Literal */), /*incomplete*/ true);
}
}
// Add the flow loop junction and reference to the in-process stack and analyze
@@ -69357,7 +70683,7 @@ var ts;
}
// The result is incomplete if the first antecedent (the non-looping control flow path)
// is incomplete.
- var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */);
+ var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */);
if (isIncomplete(firstAntecedentType)) {
return createFlowType(result, /*incomplete*/ true);
}
@@ -69372,13 +70698,13 @@ var ts;
return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType)));
}
var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction);
- if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) {
+ if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* TypeFlags.Union */ && ts.arraysEqual(result.types, declaredType.types)) {
return declaredType;
}
return result;
}
function getCandidateDiscriminantPropertyAccess(expr) {
- if (ts.isBindingPattern(reference) || ts.isFunctionExpressionOrArrowFunction(reference)) {
+ if (ts.isBindingPattern(reference) || ts.isFunctionExpressionOrArrowFunction(reference) || ts.isObjectLiteralMethod(reference)) {
// When the reference is a binding pattern or function or arrow expression, we are narrowing a pesudo-reference in
// getNarrowedTypeOfSymbol. An identifier for a destructuring variable declared in the same binding pattern or
// parameter declared in the same parameter list is a candidate.
@@ -69418,8 +70744,8 @@ var ts;
return undefined;
}
function getDiscriminantPropertyAccess(expr, computedType) {
- var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType;
- if (type.flags & 1048576 /* Union */) {
+ var type = declaredType.flags & 1048576 /* TypeFlags.Union */ ? declaredType : computedType;
+ if (type.flags & 1048576 /* TypeFlags.Union */) {
var access = getCandidateDiscriminantPropertyAccess(expr);
if (access) {
var name = getAccessedPropertyName(access);
@@ -69435,8 +70761,8 @@ var ts;
if (propName === undefined) {
return type;
}
- var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* Nullable */);
- var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName);
+ var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* TypeFlags.Nullable */);
+ var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type, propName);
if (!propType) {
return type;
}
@@ -69444,16 +70770,16 @@ var ts;
var narrowedPropType = narrowType(propType);
return filterType(type, function (t) {
var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName);
- return !(narrowedPropType.flags & 131072 /* Never */) && isTypeComparableTo(narrowedPropType, discriminantType);
+ return !(narrowedPropType.flags & 131072 /* TypeFlags.Never */) && isTypeComparableTo(narrowedPropType, discriminantType);
});
}
function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) {
- if ((operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* Union */) {
+ if ((operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* TypeFlags.Union */) {
var keyPropertyName = getKeyPropertyName(type);
if (keyPropertyName && keyPropertyName === getAccessedPropertyName(access)) {
var candidate = getConstituentTypeForKeyType(type, getTypeOfExpression(value));
if (candidate) {
- return operator === (assumeTrue ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */) ? candidate :
+ return operator === (assumeTrue ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) ? candidate :
isUnitType(getTypeOfPropertyOfType(candidate, keyPropertyName) || unknownType) ? removeType(type, candidate) :
type;
}
@@ -69462,7 +70788,7 @@ var ts;
return narrowTypeByDiscriminant(type, access, function (t) { return narrowTypeByEquality(t, operator, value, assumeTrue); });
}
function narrowTypeBySwitchOnDiscriminantProperty(type, access, switchStatement, clauseStart, clauseEnd) {
- if (clauseStart < clauseEnd && type.flags & 1048576 /* Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) {
+ if (clauseStart < clauseEnd && type.flags & 1048576 /* TypeFlags.Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) {
var clauseTypes = getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd);
var candidate = getUnionType(ts.map(clauseTypes, function (t) { return getConstituentTypeForKeyType(type, t) || unknownType; }));
if (candidate !== unknownType) {
@@ -69473,52 +70799,52 @@ var ts;
}
function narrowTypeByTruthiness(type, expr, assumeTrue) {
if (isMatchingReference(reference, expr)) {
- return type.flags & 2 /* Unknown */ && assumeTrue ? nonNullUnknownType :
- getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */);
+ return type.flags & 2 /* TypeFlags.Unknown */ && assumeTrue ? nonNullUnknownType :
+ getTypeWithFacts(type, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */);
}
if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
- type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
+ type = getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */);
}
var access = getDiscriminantPropertyAccess(expr, type);
if (access) {
- return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); });
+ return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */); });
}
return type;
}
function isTypePresencePossible(type, propName, assumeTrue) {
var prop = getPropertyOfType(type, propName);
if (prop) {
- return prop.flags & 16777216 /* Optional */ ? true : assumeTrue;
+ return prop.flags & 16777216 /* SymbolFlags.Optional */ ? true : assumeTrue;
}
return getApplicableIndexInfoForName(type, propName) ? true : !assumeTrue;
}
function narrowByInKeyword(type, name, assumeTrue) {
- if (type.flags & 1048576 /* Union */
- || type.flags & 524288 /* Object */ && declaredType !== type
+ if (type.flags & 1048576 /* TypeFlags.Union */
+ || type.flags & 524288 /* TypeFlags.Object */ && declaredType !== type
|| ts.isThisTypeParameter(type)
- || type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) {
+ || type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) {
return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); });
}
return type;
}
function narrowTypeByBinaryExpression(type, expr, assumeTrue) {
switch (expr.operatorToken.kind) {
- case 63 /* EqualsToken */:
- case 75 /* BarBarEqualsToken */:
- case 76 /* AmpersandAmpersandEqualsToken */:
- case 77 /* QuestionQuestionEqualsToken */:
+ case 63 /* SyntaxKind.EqualsToken */:
+ case 75 /* SyntaxKind.BarBarEqualsToken */:
+ case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */:
+ case 77 /* SyntaxKind.QuestionQuestionEqualsToken */:
return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue);
- case 34 /* EqualsEqualsToken */:
- case 35 /* ExclamationEqualsToken */:
- case 36 /* EqualsEqualsEqualsToken */:
- case 37 /* ExclamationEqualsEqualsToken */:
+ case 34 /* SyntaxKind.EqualsEqualsToken */:
+ case 35 /* SyntaxKind.ExclamationEqualsToken */:
+ case 36 /* SyntaxKind.EqualsEqualsEqualsToken */:
+ case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */:
var operator = expr.operatorToken.kind;
var left = getReferenceCandidate(expr.left);
var right = getReferenceCandidate(expr.right);
- if (left.kind === 215 /* TypeOfExpression */ && ts.isStringLiteralLike(right)) {
+ if (left.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(right)) {
return narrowTypeByTypeof(type, left, operator, right, assumeTrue);
}
- if (right.kind === 215 /* TypeOfExpression */ && ts.isStringLiteralLike(left)) {
+ if (right.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(left)) {
return narrowTypeByTypeof(type, right, operator, left, assumeTrue);
}
if (isMatchingReference(reference, left)) {
@@ -69550,35 +70876,35 @@ var ts;
return narrowTypeByConstructor(type, operator, left, assumeTrue);
}
break;
- case 102 /* InstanceOfKeyword */:
+ case 102 /* SyntaxKind.InstanceOfKeyword */:
return narrowTypeByInstanceof(type, expr, assumeTrue);
- case 101 /* InKeyword */:
+ case 101 /* SyntaxKind.InKeyword */:
if (ts.isPrivateIdentifier(expr.left)) {
return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue);
}
var target = getReferenceCandidate(expr.right);
var leftType = getTypeOfNode(expr.left);
- if (leftType.flags & 128 /* StringLiteral */) {
+ if (leftType.flags & 128 /* TypeFlags.StringLiteral */) {
var name = ts.escapeLeadingUnderscores(leftType.value);
if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) &&
getAccessedPropertyName(reference) === name) {
- return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */);
+ return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */);
}
if (isMatchingReference(reference, target)) {
return narrowByInKeyword(type, name, assumeTrue);
}
}
break;
- case 27 /* CommaToken */:
+ case 27 /* SyntaxKind.CommaToken */:
return narrowType(type, expr.right, assumeTrue);
// Ordinarily we won't see && and || expressions in control flow analysis because the Binder breaks those
// expressions down to individual conditional control flows. However, we may encounter them when analyzing
// aliased conditional expressions.
- case 55 /* AmpersandAmpersandToken */:
+ case 55 /* SyntaxKind.AmpersandAmpersandToken */:
return assumeTrue ?
narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true) :
getUnionType([narrowType(type, expr.left, /*assumeTrue*/ false), narrowType(type, expr.right, /*assumeTrue*/ false)]);
- case 56 /* BarBarToken */:
+ case 56 /* SyntaxKind.BarBarToken */:
return assumeTrue ?
getUnionType([narrowType(type, expr.left, /*assumeTrue*/ true), narrowType(type, expr.right, /*assumeTrue*/ true)]) :
narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false);
@@ -69611,48 +70937,48 @@ var ts;
// When operator is !== and type of value is undefined, null and undefined is removed from type of obj in true branch.
// When operator is == and type of value is null or undefined, null and undefined is removed from type of obj in false branch.
// When operator is != and type of value is null or undefined, null and undefined is removed from type of obj in true branch.
- var equalsOperator = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */;
- var nullableFlags = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */ ? 98304 /* Nullable */ : 32768 /* Undefined */;
+ var equalsOperator = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */;
+ var nullableFlags = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */ ? 98304 /* TypeFlags.Nullable */ : 32768 /* TypeFlags.Undefined */;
var valueType = getTypeOfExpression(value);
// Note that we include any and unknown in the exclusion test because their domain includes null and undefined.
var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) ||
- equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* AnyOrUnknown */ | nullableFlags)); });
- return removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type;
+ equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* TypeFlags.AnyOrUnknown */ | nullableFlags)); });
+ return removeNullable ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type;
}
function narrowTypeByEquality(type, operator, value, assumeTrue) {
- if (type.flags & 1 /* Any */) {
+ if (type.flags & 1 /* TypeFlags.Any */) {
return type;
}
- if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) {
+ if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) {
assumeTrue = !assumeTrue;
}
var valueType = getTypeOfExpression(value);
- if (assumeTrue && (type.flags & 2 /* Unknown */) && (operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */) && (valueType.flags & 65536 /* Null */)) {
+ if (assumeTrue && (type.flags & 2 /* TypeFlags.Unknown */) && (operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */) && (valueType.flags & 65536 /* TypeFlags.Null */)) {
return getUnionType([nullType, undefinedType]);
}
- if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) {
- if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) {
+ if ((type.flags & 2 /* TypeFlags.Unknown */) && assumeTrue && (operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) {
+ if (valueType.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) {
return valueType;
}
- if (valueType.flags & 524288 /* Object */) {
+ if (valueType.flags & 524288 /* TypeFlags.Object */) {
return nonPrimitiveType;
}
return type;
}
- if (valueType.flags & 98304 /* Nullable */) {
+ if (valueType.flags & 98304 /* TypeFlags.Nullable */) {
if (!strictNullChecks) {
return type;
}
- var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */;
+ var doubleEquals = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */;
var facts = doubleEquals ?
- assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ :
- valueType.flags & 65536 /* Null */ ?
- assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ :
- assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */;
- return type.flags & 2 /* Unknown */ && facts & (1048576 /* NENull */ | 2097152 /* NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts);
+ assumeTrue ? 262144 /* TypeFacts.EQUndefinedOrNull */ : 2097152 /* TypeFacts.NEUndefinedOrNull */ :
+ valueType.flags & 65536 /* TypeFlags.Null */ ?
+ assumeTrue ? 131072 /* TypeFacts.EQNull */ : 1048576 /* TypeFacts.NENull */ :
+ assumeTrue ? 65536 /* TypeFacts.EQUndefined */ : 524288 /* TypeFacts.NEUndefined */;
+ return type.flags & 2 /* TypeFlags.Unknown */ && facts & (1048576 /* TypeFacts.NENull */ | 2097152 /* TypeFacts.NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts);
}
if (assumeTrue) {
- var filterFn = operator === 34 /* EqualsEqualsToken */ ?
+ var filterFn = operator === 34 /* SyntaxKind.EqualsEqualsToken */ ?
function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); } :
function (t) { return areTypesComparable(t, valueType); };
return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType);
@@ -69664,34 +70990,34 @@ var ts;
}
function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) {
// We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands
- if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) {
+ if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) {
assumeTrue = !assumeTrue;
}
var target = getReferenceCandidate(typeOfExpr.expression);
if (!isMatchingReference(reference, target)) {
if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) {
- return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
+ return getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */);
}
return type;
}
- if (type.flags & 1 /* Any */ && literal.text === "function") {
+ if (type.flags & 1 /* TypeFlags.Any */ && literal.text === "function") {
return type;
}
- if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") {
+ if (assumeTrue && type.flags & 2 /* TypeFlags.Unknown */ && literal.text === "object") {
// The non-null unknown type is used to track whether a previous narrowing operation has removed the null type
// from the unknown type. For example, the expression `x && typeof x === 'object'` first narrows x to the non-null
// unknown type, and then narrows that to the non-primitive type.
return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]);
}
var facts = assumeTrue ?
- typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ :
- typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */;
+ typeofEQFacts.get(literal.text) || 128 /* TypeFacts.TypeofEQHostObject */ :
+ typeofNEFacts.get(literal.text) || 32768 /* TypeFacts.TypeofNEHostObject */;
var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts);
}
function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
- return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type;
+ return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type;
}
function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) {
// We only narrow if all case expressions specify
@@ -69704,16 +71030,16 @@ var ts;
}
var clauseTypes = switchTypes.slice(clauseStart, clauseEnd);
var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType);
- if ((type.flags & 2 /* Unknown */) && !hasDefaultClause) {
+ if ((type.flags & 2 /* TypeFlags.Unknown */) && !hasDefaultClause) {
var groundClauseTypes = void 0;
for (var i = 0; i < clauseTypes.length; i += 1) {
var t = clauseTypes[i];
- if (t.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) {
+ if (t.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) {
if (groundClauseTypes !== undefined) {
groundClauseTypes.push(t);
}
}
- else if (t.flags & 524288 /* Object */) {
+ else if (t.flags & 524288 /* TypeFlags.Object */) {
if (groundClauseTypes === undefined) {
groundClauseTypes = clauseTypes.slice(0, i);
}
@@ -69726,20 +71052,20 @@ var ts;
return getUnionType(groundClauseTypes === undefined ? clauseTypes : groundClauseTypes);
}
var discriminantType = getUnionType(clauseTypes);
- var caseType = discriminantType.flags & 131072 /* Never */ ? neverType :
+ var caseType = discriminantType.flags & 131072 /* TypeFlags.Never */ ? neverType :
replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType);
if (!hasDefaultClause) {
return caseType;
}
var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); });
- return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]);
+ return caseType.flags & 131072 /* TypeFlags.Never */ ? defaultType : getUnionType([caseType, defaultType]);
}
function getImpliedTypeFromTypeofGuard(type, text) {
switch (text) {
case "function":
- return type.flags & 1 /* Any */ ? type : globalFunctionType;
+ return type.flags & 1 /* TypeFlags.Any */ ? type : globalFunctionType;
case "object":
- return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type;
+ return type.flags & 2 /* TypeFlags.Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type;
default:
return typeofTypesByName.get(text);
}
@@ -69758,7 +71084,7 @@ var ts;
if (isTypeSubtypeOf(candidate, type)) {
return candidate;
}
- if (type.flags & 465829888 /* Instantiable */) {
+ if (type.flags & 465829888 /* TypeFlags.Instantiable */) {
var constraint = getBaseConstraintOfType(type) || anyType;
if (isTypeSubtypeOf(candidate, constraint)) {
return getIntersectionType([type, candidate]);
@@ -69833,7 +71159,7 @@ var ts;
}
function narrowTypeByConstructor(type, operator, identifier, assumeTrue) {
// Do not narrow when checking inequality.
- if (assumeTrue ? (operator !== 34 /* EqualsEqualsToken */ && operator !== 36 /* EqualsEqualsEqualsToken */) : (operator !== 35 /* ExclamationEqualsToken */ && operator !== 37 /* ExclamationEqualsEqualsToken */)) {
+ if (assumeTrue ? (operator !== 34 /* SyntaxKind.EqualsEqualsToken */ && operator !== 36 /* SyntaxKind.EqualsEqualsEqualsToken */) : (operator !== 35 /* SyntaxKind.ExclamationEqualsToken */ && operator !== 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) {
return type;
}
// Get the type of the constructor identifier expression, if it is not a function then do not narrow.
@@ -69863,8 +71189,8 @@ var ts;
// This is because you may have a class `A` that defines some set of properties, and another class `B`
// that defines the same set of properties as class `A`, in that case they are structurally the same
// type, but when you do something like `instanceOfA.constructor === B` it will return false.
- if (source.flags & 524288 /* Object */ && ts.getObjectFlags(source) & 1 /* Class */ ||
- target.flags & 524288 /* Object */ && ts.getObjectFlags(target) & 1 /* Class */) {
+ if (source.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(source) & 1 /* ObjectFlags.Class */ ||
+ target.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) {
return source.symbol === target.symbol;
}
// For all other types just check that the `source` type is a subtype of the `target` type.
@@ -69875,7 +71201,7 @@ var ts;
var left = getReferenceCandidate(expr.left);
if (!isMatchingReference(reference, left)) {
if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) {
- return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
+ return getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */);
}
return type;
}
@@ -69898,13 +71224,13 @@ var ts;
return type;
}
if (!targetType) {
- var constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */);
+ var constructSignatures = getSignaturesOfType(rightType, 1 /* SignatureKind.Construct */);
targetType = constructSignatures.length ?
getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })) :
emptyObjectType;
}
// We can't narrow a union based off instanceof without negated types see #31576 for more info
- if (!assumeTrue && rightType.flags & 1048576 /* Union */) {
+ if (!assumeTrue && rightType.flags & 1048576 /* TypeFlags.Union */) {
var nonConstructorTypeInUnion = ts.find(rightType.types, function (t) { return !isConstructorType(t); });
if (!nonConstructorTypeInUnion)
return type;
@@ -69917,9 +71243,9 @@ var ts;
}
// If the current type is a union type, remove all constituents that couldn't be instances of
// the candidate type. If one or more constituents remain, return a union of those.
- if (type.flags & 1048576 /* Union */) {
+ if (type.flags & 1048576 /* TypeFlags.Union */) {
var assignableType = filterType(type, function (t) { return isRelated(t, candidate); });
- if (!(assignableType.flags & 131072 /* Never */)) {
+ if (!(assignableType.flags & 131072 /* TypeFlags.Never */)) {
return assignableType;
}
}
@@ -69937,7 +71263,7 @@ var ts;
if (hasMatchingArgument(callExpression, reference)) {
var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined;
var predicate = signature && getTypePredicateOfSignature(signature);
- if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) {
+ if (predicate && (predicate.kind === 0 /* TypePredicateKind.This */ || predicate.kind === 1 /* TypePredicateKind.Identifier */)) {
return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue);
}
}
@@ -69947,7 +71273,7 @@ var ts;
ts.isIdentifier(callAccess.name) && callAccess.name.escapedText === "hasOwnProperty" && callExpression.arguments.length === 1) {
var argument = callExpression.arguments[0];
if (ts.isStringLiteralLike(argument) && getAccessedPropertyName(reference) === ts.escapeLeadingUnderscores(argument.text)) {
- return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */);
+ return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */);
}
}
}
@@ -69962,8 +71288,8 @@ var ts;
return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf);
}
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) &&
- !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) {
- type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
+ !(getTypeFacts(predicate.type) & 65536 /* TypeFacts.EQUndefined */)) {
+ type = getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */);
}
var access = getDiscriminantPropertyAccess(predicateArgument, type);
if (access) {
@@ -69978,11 +71304,11 @@ var ts;
function narrowType(type, expr, assumeTrue) {
// for `a?.b`, we emulate a synthetic `a !== null && a !== undefined` condition for `a`
if (ts.isExpressionOfOptionalChainRoot(expr) ||
- ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* QuestionQuestionToken */ && expr.parent.left === expr) {
+ ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */ && expr.parent.left === expr) {
return narrowTypeByOptionality(type, expr, assumeTrue);
}
switch (expr.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
// When narrowing a reference to a const variable, non-assigned parameter, or readonly property, we inline
// up to five levels of aliased conditional expressions that are themselves declared as const variables.
if (!isMatchingReference(reference, expr) && inlineLevel < 5) {
@@ -69998,20 +71324,20 @@ var ts;
}
}
// falls through
- case 108 /* ThisKeyword */:
- case 106 /* SuperKeyword */:
- case 205 /* PropertyAccessExpression */:
- case 206 /* ElementAccessExpression */:
+ case 108 /* SyntaxKind.ThisKeyword */:
+ case 106 /* SyntaxKind.SuperKeyword */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
return narrowTypeByTruthiness(type, expr, assumeTrue);
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
return narrowTypeByCallExpression(type, expr, assumeTrue);
- case 211 /* ParenthesizedExpression */:
- case 229 /* NonNullExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
+ case 230 /* SyntaxKind.NonNullExpression */:
return narrowType(type, expr.expression, assumeTrue);
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return narrowTypeByBinaryExpression(type, expr, assumeTrue);
- case 218 /* PrefixUnaryExpression */:
- if (expr.operator === 53 /* ExclamationToken */) {
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
+ if (expr.operator === 53 /* SyntaxKind.ExclamationToken */) {
return narrowType(type, expr.operand, !assumeTrue);
}
break;
@@ -70020,11 +71346,11 @@ var ts;
}
function narrowTypeByOptionality(type, expr, assumePresent) {
if (isMatchingReference(reference, expr)) {
- return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */);
+ return getTypeWithFacts(type, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */);
}
var access = getDiscriminantPropertyAccess(expr, type);
if (access) {
- return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); });
+ return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */); });
}
return type;
}
@@ -70035,7 +71361,7 @@ var ts;
// an dotted name expression, and if the location is not an assignment target, obtain the type
// of the expression (which will reflect control flow analysis). If the expression indeed
// resolved to the given symbol, return the narrowed type.
- if (location.kind === 79 /* Identifier */ || location.kind === 80 /* PrivateIdentifier */) {
+ if (location.kind === 79 /* SyntaxKind.Identifier */ || location.kind === 80 /* SyntaxKind.PrivateIdentifier */) {
if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) {
location = location.parent;
}
@@ -70047,7 +71373,7 @@ var ts;
}
}
if (ts.isDeclarationName(location) && ts.isSetAccessor(location.parent) && getAnnotatedAccessorTypeNode(location.parent)) {
- return resolveTypeOfAccessors(location.parent.symbol, /*writing*/ true);
+ return getWriteTypeOfAccessors(location.parent.symbol);
}
// The location isn't a reference to the given symbol, meaning we're being asked
// a hypothetical question of what type the symbol would have if there was a reference
@@ -70059,9 +71385,9 @@ var ts;
function getControlFlowContainer(node) {
return ts.findAncestor(node.parent, function (node) {
return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) ||
- node.kind === 261 /* ModuleBlock */ ||
- node.kind === 303 /* SourceFile */ ||
- node.kind === 166 /* PropertyDeclaration */;
+ node.kind === 262 /* SyntaxKind.ModuleBlock */ ||
+ node.kind === 305 /* SyntaxKind.SourceFile */ ||
+ node.kind === 167 /* SyntaxKind.PropertyDeclaration */;
});
}
// Check if a parameter or catch variable is assigned anywhere
@@ -70071,8 +71397,8 @@ var ts;
}
var parent = ts.getRootDeclaration(symbol.valueDeclaration).parent;
var links = getNodeLinks(parent);
- if (!(links.flags & 8388608 /* AssignmentsMarked */)) {
- links.flags |= 8388608 /* AssignmentsMarked */;
+ if (!(links.flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */)) {
+ links.flags |= 8388608 /* NodeCheckFlags.AssignmentsMarked */;
if (!hasParentWithAssignmentsMarked(parent)) {
markNodeAssignments(parent);
}
@@ -70081,11 +71407,11 @@ var ts;
}
function hasParentWithAssignmentsMarked(node) {
return !!ts.findAncestor(node.parent, function (node) {
- return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */);
+ return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */);
});
}
function markNodeAssignments(node) {
- if (node.kind === 79 /* Identifier */) {
+ if (node.kind === 79 /* SyntaxKind.Identifier */) {
if (ts.isAssignmentTarget(node)) {
var symbol = getResolvedSymbol(node);
if (ts.isParameterOrCatchClauseVariable(symbol)) {
@@ -70098,18 +71424,18 @@ var ts;
}
}
function isConstVariable(symbol) {
- return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0;
+ return symbol.flags & 3 /* SymbolFlags.Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */) !== 0;
}
/** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */
function removeOptionalityFromDeclaredType(declaredType, declaration) {
- if (pushTypeResolution(declaration.symbol, 2 /* DeclaredType */)) {
+ if (pushTypeResolution(declaration.symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) {
var annotationIncludesUndefined = strictNullChecks &&
- declaration.kind === 163 /* Parameter */ &&
+ declaration.kind === 164 /* SyntaxKind.Parameter */ &&
declaration.initializer &&
- getFalsyFlags(declaredType) & 32768 /* Undefined */ &&
- !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */);
+ getFalsyFlags(declaredType) & 32768 /* TypeFlags.Undefined */ &&
+ !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* TypeFlags.Undefined */);
popTypeResolution();
- return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType;
+ return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* TypeFacts.NEUndefined */) : declaredType;
}
else {
reportCircularityError(declaration.symbol);
@@ -70121,16 +71447,17 @@ var ts;
// In an element access obj[x], we consider obj to be in a constraint position, except when obj is of
// a generic type without a nullable constraint and x is a generic type. This is because when both obj
// and x are of generic types T and K, we want the resulting type to be T[K].
- return parent.kind === 205 /* PropertyAccessExpression */ ||
- parent.kind === 207 /* CallExpression */ && parent.expression === node ||
- parent.kind === 206 /* ElementAccessExpression */ && parent.expression === node &&
+ return parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ||
+ parent.kind === 161 /* SyntaxKind.QualifiedName */ ||
+ parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === node ||
+ parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === node &&
!(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
}
function isGenericTypeWithUnionConstraint(type) {
- return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
+ return !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* TypeFlags.Nullable */ | 1048576 /* TypeFlags.Union */));
}
function isGenericTypeWithoutNullableConstraint(type) {
- return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
+ return !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* TypeFlags.Nullable */));
}
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
// Computing the contextual type for a child of a JSX element involves resolving the type of the
@@ -70139,8 +71466,8 @@ var ts;
// as we want the type of a rest element to be generic when possible.
var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
!((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
- (checkMode && checkMode & 32 /* RestBindingElement */ ?
- getContextualType(node, 8 /* SkipBindingPatterns */)
+ (checkMode && checkMode & 64 /* CheckMode.RestBindingElement */ ?
+ getContextualType(node, 8 /* ContextFlags.SkipBindingPatterns */)
: getContextualType(node));
return contextualType && !isGenericType(contextualType);
}
@@ -70152,10 +71479,10 @@ var ts;
// control flow analysis an opportunity to narrow it further. For example, for a reference of a type
// parameter type 'T extends string | undefined' with a contextual type 'string', we substitute
// 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'.
- var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
+ var substituteConstraints = !(checkMode && checkMode & 2 /* CheckMode.Inferential */) &&
someType(type, isGenericTypeWithUnionConstraint) &&
(isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
+ return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* TypeFlags.Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
}
function isExportOrExportExpression(location) {
return !!ts.findAncestor(location, function (n) {
@@ -70173,9 +71500,9 @@ var ts;
});
}
function markAliasReferenced(symbol, location) {
- if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
+ if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
var target = resolveAlias(symbol);
- if (target.flags & 111551 /* Value */) {
+ if (target.flags & 111551 /* SymbolFlags.Value */) {
// An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled
// (because the const enum value will not be inlined), or if (2) the alias is an export
// of a const enum declaration that will be preserved.
@@ -70218,16 +71545,16 @@ var ts;
// destructuring from the narrowed parent type.
if (ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
var parent = declaration.parent.parent;
- if (parent.kind === 253 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 163 /* Parameter */) {
- var links = getNodeLinks(location);
- if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
- links.flags |= 268435456 /* InCheckIdentifier */;
- var parentType = getTypeForBindingElementParent(parent, 0 /* Normal */);
- links.flags &= ~268435456 /* InCheckIdentifier */;
- if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
+ if (parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || parent.kind === 164 /* SyntaxKind.Parameter */) {
+ var links = getNodeLinks(parent);
+ if (!(links.flags & 268435456 /* NodeCheckFlags.InCheckIdentifier */)) {
+ links.flags |= 268435456 /* NodeCheckFlags.InCheckIdentifier */;
+ var parentType = getTypeForBindingElementParent(parent, 0 /* CheckMode.Normal */);
+ links.flags &= ~268435456 /* NodeCheckFlags.InCheckIdentifier */;
+ if (parentType && parentType.flags & 1048576 /* TypeFlags.Union */ && !(parent.kind === 164 /* SyntaxKind.Parameter */ && isSymbolAssigned(symbol))) {
var pattern = declaration.parent;
var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode);
- if (narrowedType.flags & 131072 /* Never */) {
+ if (narrowedType.flags & 131072 /* TypeFlags.Never */) {
return neverType;
}
return getBindingElementTypeFromParentType(declaration, narrowedType);
@@ -70260,8 +71587,8 @@ var ts;
if (func.parameters.length >= 2 && isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
var contextualSignature = getContextualSignature(func);
if (contextualSignature && contextualSignature.parameters.length === 1 && signatureHasRestParameter(contextualSignature)) {
- var restType = getTypeOfSymbol(contextualSignature.parameters[0]);
- if (restType.flags & 1048576 /* Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) {
+ var restType = getReducedApparentType(getTypeOfSymbol(contextualSignature.parameters[0]));
+ if (restType.flags & 1048576 /* TypeFlags.Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) {
var narrowedType = getFlowTypeOfReference(func, restType, restType, /*flowContainer*/ undefined, location.flowNode);
var index = func.parameters.indexOf(declaration) - (ts.getThisParameter(func) ? 1 : 0);
return getIndexedAccessType(narrowedType, getNumberLiteralType(index));
@@ -70292,15 +71619,15 @@ var ts;
return errorType;
}
var container = ts.getContainingFunction(node);
- if (languageVersion < 2 /* ES2015 */) {
- if (container.kind === 213 /* ArrowFunction */) {
+ if (languageVersion < 2 /* ScriptTarget.ES2015 */) {
+ if (container.kind === 214 /* SyntaxKind.ArrowFunction */) {
error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression);
}
- else if (ts.hasSyntacticModifier(container, 256 /* Async */)) {
+ else if (ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) {
error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method);
}
}
- getNodeLinks(container).flags |= 8192 /* CaptureArguments */;
+ getNodeLinks(container).flags |= 8192 /* NodeCheckFlags.CaptureArguments */;
return getTypeOfSymbol(symbol);
}
// We should only mark aliases as referenced if there isn't a local value declaration
@@ -70314,32 +71641,32 @@ var ts;
addDeprecatedSuggestion(node, targetSymbol.declarations, node.escapedText);
}
var declaration = localOrExportSymbol.valueDeclaration;
- if (declaration && localOrExportSymbol.flags & 32 /* Class */) {
+ if (declaration && localOrExportSymbol.flags & 32 /* SymbolFlags.Class */) {
// Due to the emit for class decorators, any reference to the class from inside of the class body
// must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
// behavior of class names in ES6.
- if (declaration.kind === 256 /* ClassDeclaration */
+ if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */
&& ts.nodeIsDecorated(declaration)) {
var container = ts.getContainingClass(node);
while (container !== undefined) {
if (container === declaration && container.name !== node) {
- getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */;
- getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */;
+ getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */;
+ getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */;
break;
}
container = ts.getContainingClass(container);
}
}
- else if (declaration.kind === 225 /* ClassExpression */) {
+ else if (declaration.kind === 226 /* SyntaxKind.ClassExpression */) {
// When we emit a class expression with static members that contain a reference
// to the constructor in the initializer, we will need to substitute that
// binding with an alias as the class name is not in scope.
var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false);
- while (container.kind !== 303 /* SourceFile */) {
+ while (container.kind !== 305 /* SyntaxKind.SourceFile */) {
if (container.parent === declaration) {
if (ts.isPropertyDeclaration(container) && ts.isStatic(container) || ts.isClassStaticBlockDeclaration(container)) {
- getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */;
- getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */;
+ getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */;
+ getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */;
}
break;
}
@@ -70351,19 +71678,19 @@ var ts;
var type = getNarrowedTypeOfSymbol(localOrExportSymbol, node);
var assignmentKind = ts.getAssignmentTargetKind(node);
if (assignmentKind) {
- if (!(localOrExportSymbol.flags & 3 /* Variable */) &&
- !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) {
- var assignmentError = localOrExportSymbol.flags & 384 /* Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum
- : localOrExportSymbol.flags & 32 /* Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class
- : localOrExportSymbol.flags & 1536 /* Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace
- : localOrExportSymbol.flags & 16 /* Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function
- : localOrExportSymbol.flags & 2097152 /* Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import
+ if (!(localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) &&
+ !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* SymbolFlags.ValueModule */)) {
+ var assignmentError = localOrExportSymbol.flags & 384 /* SymbolFlags.Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum
+ : localOrExportSymbol.flags & 32 /* SymbolFlags.Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class
+ : localOrExportSymbol.flags & 1536 /* SymbolFlags.Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace
+ : localOrExportSymbol.flags & 16 /* SymbolFlags.Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function
+ : localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import
: ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable;
error(node, assignmentError, symbolToString(symbol));
return errorType;
}
if (isReadonlySymbol(localOrExportSymbol)) {
- if (localOrExportSymbol.flags & 3 /* Variable */) {
+ if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) {
error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant, symbolToString(symbol));
}
else {
@@ -70372,11 +71699,11 @@ var ts;
return errorType;
}
}
- var isAlias = localOrExportSymbol.flags & 2097152 /* Alias */;
+ var isAlias = localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */;
// We only narrow variables and parameters occurring in a non-assignment position. For all other
// entities we simply return the declared type.
- if (localOrExportSymbol.flags & 3 /* Variable */) {
- if (assignmentKind === 1 /* Definite */) {
+ if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) {
+ if (assignmentKind === 1 /* AssignmentKind.Definite */) {
return type;
}
}
@@ -70393,17 +71720,17 @@ var ts;
// The declaration container is the innermost function that encloses the declaration of the variable
// or parameter. The flow container is the innermost function starting with which we analyze the control
// flow graph to determine the control flow based type.
- var isParameter = ts.getRootDeclaration(declaration).kind === 163 /* Parameter */;
+ var isParameter = ts.getRootDeclaration(declaration).kind === 164 /* SyntaxKind.Parameter */;
var declarationContainer = getControlFlowContainer(declaration);
var flowContainer = getControlFlowContainer(node);
var isOuterVariable = flowContainer !== declarationContainer;
var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent);
- var isModuleExports = symbol.flags & 134217728 /* ModuleExports */;
+ var isModuleExports = symbol.flags & 134217728 /* SymbolFlags.ModuleExports */;
// When the control flow originates in a function expression or arrow function and we are referencing
// a const variable or parameter from an outer function, we extend the origin of the control flow
// analysis to include the immediately enclosing function.
- while (flowContainer !== declarationContainer && (flowContainer.kind === 212 /* FunctionExpression */ ||
- flowContainer.kind === 213 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) &&
+ while (flowContainer !== declarationContainer && (flowContainer.kind === 213 /* SyntaxKind.FunctionExpression */ ||
+ flowContainer.kind === 214 /* SyntaxKind.ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) &&
(isConstVariable(localOrExportSymbol) && type !== autoArrayType || isParameter && !isSymbolAssigned(localOrExportSymbol))) {
flowContainer = getControlFlowContainer(flowContainer);
}
@@ -70411,11 +71738,11 @@ var ts;
// the entire control flow graph from the variable's declaration (i.e. when the flow container and
// declaration container are the same).
var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) ||
- type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 ||
- isInTypeQuery(node) || node.parent.kind === 274 /* ExportSpecifier */) ||
- node.parent.kind === 229 /* NonNullExpression */ ||
- declaration.kind === 253 /* VariableDeclaration */ && declaration.exclamationToken ||
- declaration.flags & 8388608 /* Ambient */;
+ type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */)) !== 0 ||
+ isInTypeQuery(node) || node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) ||
+ node.parent.kind === 230 /* SyntaxKind.NonNullExpression */ ||
+ declaration.kind === 254 /* SyntaxKind.VariableDeclaration */ && declaration.exclamationToken ||
+ declaration.flags & 16777216 /* NodeFlags.Ambient */;
var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) :
type === autoType || type === autoArrayType ? undefinedType :
getOptionalType(type);
@@ -70432,7 +71759,7 @@ var ts;
return convertAutoToAny(flowType);
}
}
- else if (!assumeInitialized && !(getFalsyFlags(type) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) {
+ else if (!assumeInitialized && !(getFalsyFlags(type) & 32768 /* TypeFlags.Undefined */) && getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */) {
error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
// Return the declared type to reduce follow-on errors
return type;
@@ -70449,11 +71776,11 @@ var ts;
return ts.findAncestor(node, function (n) { return (!n || ts.nodeStartsNewLexicalEnvironment(n)) ? "quit" : ts.isIterationStatement(n, /*lookInLabeledStatements*/ false); });
}
function checkNestedBlockScopedBinding(node, symbol) {
- if (languageVersion >= 2 /* ES2015 */ ||
- (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 ||
+ if (languageVersion >= 2 /* ScriptTarget.ES2015 */ ||
+ (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 32 /* SymbolFlags.Class */)) === 0 ||
!symbol.valueDeclaration ||
ts.isSourceFile(symbol.valueDeclaration) ||
- symbol.valueDeclaration.parent.kind === 291 /* CatchClause */) {
+ symbol.valueDeclaration.parent.kind === 292 /* SyntaxKind.CatchClause */) {
return;
}
// 1. walk from the use site up to the declaration and check
@@ -70468,12 +71795,12 @@ var ts;
// mark iteration statement as containing block-scoped binding captured in some function
var capturesBlockScopeBindingInLoopBody = true;
if (ts.isForStatement(container)) {
- var varDeclList = ts.getAncestor(symbol.valueDeclaration, 254 /* VariableDeclarationList */);
+ var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */);
if (varDeclList && varDeclList.parent === container) {
var part = getPartOfForStatementContainingNode(node.parent, container);
if (part) {
var links = getNodeLinks(part);
- links.flags |= 131072 /* ContainsCapturedBlockScopeBinding */;
+ links.flags |= 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */;
var capturedBindings = links.capturedBlockScopeBindings || (links.capturedBlockScopeBindings = []);
ts.pushIfUnique(capturedBindings, symbol);
if (part === container.initializer) {
@@ -70483,22 +71810,22 @@ var ts;
}
}
if (capturesBlockScopeBindingInLoopBody) {
- getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */;
+ getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */;
}
}
// mark variables that are declared in loop initializer and reassigned inside the body of ForStatement.
// if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back.
if (ts.isForStatement(container)) {
- var varDeclList = ts.getAncestor(symbol.valueDeclaration, 254 /* VariableDeclarationList */);
+ var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */);
if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) {
- getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */;
+ getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */;
}
}
// set 'declared inside loop' bit on the block-scoped binding
- getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* BlockScopedBindingInLoop */;
+ getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */;
}
if (isCaptured) {
- getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* CapturedBlockScopedBinding */;
+ getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */;
}
}
function isBindingCapturedByNode(node, decl) {
@@ -70508,7 +71835,7 @@ var ts;
function isAssignedInBodyOfForStatement(node, container) {
// skip parenthesized nodes
var current = node;
- while (current.parent.kind === 211 /* ParenthesizedExpression */) {
+ while (current.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) {
current = current.parent;
}
// check if node is used as LHS in some assignment expression
@@ -70516,9 +71843,9 @@ var ts;
if (ts.isAssignmentTarget(current)) {
isAssigned = true;
}
- else if ((current.parent.kind === 218 /* PrefixUnaryExpression */ || current.parent.kind === 219 /* PostfixUnaryExpression */)) {
+ else if ((current.parent.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || current.parent.kind === 220 /* SyntaxKind.PostfixUnaryExpression */)) {
var expr = current.parent;
- isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */;
+ isAssigned = expr.operator === 45 /* SyntaxKind.PlusPlusToken */ || expr.operator === 46 /* SyntaxKind.MinusMinusToken */;
}
if (!isAssigned) {
return false;
@@ -70528,13 +71855,13 @@ var ts;
return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; });
}
function captureLexicalThis(node, container) {
- getNodeLinks(node).flags |= 2 /* LexicalThis */;
- if (container.kind === 166 /* PropertyDeclaration */ || container.kind === 170 /* Constructor */) {
+ getNodeLinks(node).flags |= 2 /* NodeCheckFlags.LexicalThis */;
+ if (container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || container.kind === 171 /* SyntaxKind.Constructor */) {
var classNode = container.parent;
- getNodeLinks(classNode).flags |= 4 /* CaptureThis */;
+ getNodeLinks(classNode).flags |= 4 /* NodeCheckFlags.CaptureThis */;
}
else {
- getNodeLinks(container).flags |= 4 /* CaptureThis */;
+ getNodeLinks(container).flags |= 4 /* NodeCheckFlags.CaptureThis */;
}
}
function findFirstSuperCall(node) {
@@ -70576,36 +71903,36 @@ var ts;
// tell whether 'this' needs to be captured.
var container = ts.getThisContainer(node, /* includeArrowFunctions */ true);
var capturedByArrowFunction = false;
- if (container.kind === 170 /* Constructor */) {
+ if (container.kind === 171 /* SyntaxKind.Constructor */) {
checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class);
}
// Now skip arrow functions to get the "real" owner of 'this'.
- if (container.kind === 213 /* ArrowFunction */) {
+ if (container.kind === 214 /* SyntaxKind.ArrowFunction */) {
container = ts.getThisContainer(container, /* includeArrowFunctions */ false);
capturedByArrowFunction = true;
}
checkThisInStaticClassFieldInitializerInDecoratedClass(node, container);
switch (container.kind) {
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body);
// do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks
break;
- case 259 /* EnumDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location);
// do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks
break;
- case 170 /* Constructor */:
+ case 171 /* SyntaxKind.Constructor */:
if (isInConstructorArgumentInitializer(node, container)) {
error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments);
// do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks
}
break;
- case 161 /* ComputedPropertyName */:
+ case 162 /* SyntaxKind.ComputedPropertyName */:
error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name);
break;
}
// When targeting es6, mark that we'll need to capture `this` in its lexically bound scope.
- if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ES2015 */) {
+ if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ScriptTarget.ES2015 */) {
captureLexicalThis(node, container);
}
var type = tryGetThisTypeAt(node, /*includeGlobalThis*/ true, container);
@@ -70640,7 +71967,7 @@ var ts;
var className = getClassNameFromPrototypeMethod(container);
if (isInJS && className) {
var classSymbol = checkExpression(className).symbol;
- if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) {
+ if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* SymbolFlags.Function */)) {
thisType = getDeclaredTypeOfSymbol(classSymbol).thisType;
}
}
@@ -70688,9 +72015,9 @@ var ts;
}
function getClassNameFromPrototypeMethod(container) {
// Check if it's the RHS of a x.prototype.y = function [name]() { .... }
- if (container.kind === 212 /* FunctionExpression */ &&
+ if (container.kind === 213 /* SyntaxKind.FunctionExpression */ &&
ts.isBinaryExpression(container.parent) &&
- ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) {
+ ts.getAssignmentDeclarationKind(container.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) {
// Get the 'x' of 'x.prototype.y = container'
return container.parent // x.prototype.y = container
.left // x.prototype.y
@@ -70698,31 +72025,31 @@ var ts;
.expression; // x
}
// x.prototype = { method() { } }
- else if (container.kind === 168 /* MethodDeclaration */ &&
- container.parent.kind === 204 /* ObjectLiteralExpression */ &&
+ else if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ &&
+ container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ &&
ts.isBinaryExpression(container.parent.parent) &&
- ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) {
+ ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) {
return container.parent.parent.left.expression;
}
// x.prototype = { method: function() { } }
- else if (container.kind === 212 /* FunctionExpression */ &&
- container.parent.kind === 294 /* PropertyAssignment */ &&
- container.parent.parent.kind === 204 /* ObjectLiteralExpression */ &&
+ else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ &&
+ container.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ &&
+ container.parent.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ &&
ts.isBinaryExpression(container.parent.parent.parent) &&
- ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) {
+ ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) {
return container.parent.parent.parent.left.expression;
}
// Object.defineProperty(x, "method", { value: function() { } });
// Object.defineProperty(x, "method", { set: (x: () => void) => void });
// Object.defineProperty(x, "method", { get: () => function() { }) });
- else if (container.kind === 212 /* FunctionExpression */ &&
+ else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ &&
ts.isPropertyAssignment(container.parent) &&
ts.isIdentifier(container.parent.name) &&
(container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") &&
ts.isObjectLiteralExpression(container.parent.parent) &&
ts.isCallExpression(container.parent.parent.parent) &&
container.parent.parent.parent.arguments[2] === container.parent.parent &&
- ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) {
+ ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) {
return container.parent.parent.parent.arguments[0].expression;
}
// Object.defineProperty(x, "method", { value() { } });
@@ -70734,17 +72061,17 @@ var ts;
ts.isObjectLiteralExpression(container.parent) &&
ts.isCallExpression(container.parent.parent) &&
container.parent.parent.arguments[2] === container.parent &&
- ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) {
+ ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) {
return container.parent.parent.arguments[0].expression;
}
}
function getTypeForThisExpressionFromJSDoc(node) {
var jsdocType = ts.getJSDocType(node);
- if (jsdocType && jsdocType.kind === 315 /* JSDocFunctionType */) {
+ if (jsdocType && jsdocType.kind === 317 /* SyntaxKind.JSDocFunctionType */) {
var jsDocFunctionType = jsdocType;
if (jsDocFunctionType.parameters.length > 0 &&
jsDocFunctionType.parameters[0].name &&
- jsDocFunctionType.parameters[0].name.escapedText === "this" /* This */) {
+ jsDocFunctionType.parameters[0].name.escapedText === "this" /* InternalSymbolName.This */) {
return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type);
}
}
@@ -70754,18 +72081,18 @@ var ts;
}
}
function isInConstructorArgumentInitializer(node, constructorDecl) {
- return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 163 /* Parameter */ && n.parent === constructorDecl; });
+ return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 164 /* SyntaxKind.Parameter */ && n.parent === constructorDecl; });
}
function checkSuperExpression(node) {
- var isCallExpression = node.parent.kind === 207 /* CallExpression */ && node.parent.expression === node;
+ var isCallExpression = node.parent.kind === 208 /* SyntaxKind.CallExpression */ && node.parent.expression === node;
var immediateContainer = ts.getSuperContainer(node, /*stopOnFunctions*/ true);
var container = immediateContainer;
var needToCaptureLexicalThis = false;
// adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting
if (!isCallExpression) {
- while (container && container.kind === 213 /* ArrowFunction */) {
+ while (container && container.kind === 214 /* SyntaxKind.ArrowFunction */) {
container = ts.getSuperContainer(container, /*stopOnFunctions*/ true);
- needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */;
+ needToCaptureLexicalThis = languageVersion < 2 /* ScriptTarget.ES2015 */;
}
}
var canUseSuperExpression = isLegalUsageOfSuperExpression(container);
@@ -70776,14 +72103,14 @@ var ts;
// class B {
// [super.foo()]() {}
// }
- var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 161 /* ComputedPropertyName */; });
- if (current && current.kind === 161 /* ComputedPropertyName */) {
+ var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 162 /* SyntaxKind.ComputedPropertyName */; });
+ if (current && current.kind === 162 /* SyntaxKind.ComputedPropertyName */) {
error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name);
}
else if (isCallExpression) {
error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors);
}
- else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 204 /* ObjectLiteralExpression */)) {
+ else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) {
error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions);
}
else {
@@ -70791,26 +72118,26 @@ var ts;
}
return errorType;
}
- if (!isCallExpression && immediateContainer.kind === 170 /* Constructor */) {
+ if (!isCallExpression && immediateContainer.kind === 171 /* SyntaxKind.Constructor */) {
checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class);
}
if (ts.isStatic(container) || isCallExpression) {
- nodeCheckFlag = 512 /* SuperStatic */;
+ nodeCheckFlag = 512 /* NodeCheckFlags.SuperStatic */;
if (!isCallExpression &&
- languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ &&
+ languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */ &&
(ts.isPropertyDeclaration(container) || ts.isClassStaticBlockDeclaration(container))) {
// for `super.x` or `super[x]` in a static initializer, mark all enclosing
// block scope containers so that we can report potential collisions with
// `Reflect`.
ts.forEachEnclosingBlockScopeContainer(node.parent, function (current) {
if (!ts.isSourceFile(current) || ts.isExternalOrCommonJsModule(current)) {
- getNodeLinks(current).flags |= 134217728 /* ContainsSuperPropertyInStaticInitializer */;
+ getNodeLinks(current).flags |= 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */;
}
});
}
}
else {
- nodeCheckFlag = 256 /* SuperInstance */;
+ nodeCheckFlag = 256 /* NodeCheckFlags.SuperInstance */;
}
getNodeLinks(node).flags |= nodeCheckFlag;
// Due to how we emit async functions, we need to specialize the emit for an async method that contains a `super` reference.
@@ -70872,12 +72199,12 @@ var ts;
// as a call expression cannot be used as the target of a destructuring assignment while a property access can.
//
// For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations.
- if (container.kind === 168 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) {
+ if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) {
if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) {
- getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */;
+ getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */;
}
else {
- getNodeLinks(container).flags |= 2048 /* AsyncMethodWithSuper */;
+ getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.AsyncMethodWithSuper */;
}
}
if (needToCaptureLexicalThis) {
@@ -70886,8 +72213,8 @@ var ts;
// in this case they should also use correct lexical this
captureLexicalThis(node.parent, container);
}
- if (container.parent.kind === 204 /* ObjectLiteralExpression */) {
- if (languageVersion < 2 /* ES2015 */) {
+ if (container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) {
+ if (languageVersion < 2 /* ScriptTarget.ES2015 */) {
error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher);
return errorType;
}
@@ -70907,12 +72234,12 @@ var ts;
if (!baseClassType) {
return errorType;
}
- if (container.kind === 170 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) {
+ if (container.kind === 171 /* SyntaxKind.Constructor */ && isInConstructorArgumentInitializer(node, container)) {
// issue custom error message for super property access in constructor arguments (to be aligned with old compiler)
error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments);
return errorType;
}
- return nodeCheckFlag === 512 /* SuperStatic */
+ return nodeCheckFlag === 512 /* NodeCheckFlags.SuperStatic */
? getBaseConstructorTypeOfClass(classType)
: getTypeWithThisArgument(baseClassType, classType.thisType);
function isLegalUsageOfSuperExpression(container) {
@@ -70922,7 +72249,7 @@ var ts;
if (isCallExpression) {
// TS 1.0 SPEC (April 2014): 4.8.1
// Super calls are only permitted in constructors of derived classes
- return container.kind === 170 /* Constructor */;
+ return container.kind === 171 /* SyntaxKind.Constructor */;
}
else {
// TS 1.0 SPEC (April 2014)
@@ -70930,23 +72257,23 @@ var ts;
// - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance
// - In a static member function or static member accessor
// topmost container must be something that is directly nested in the class declaration\object literal expression
- if (ts.isClassLike(container.parent) || container.parent.kind === 204 /* ObjectLiteralExpression */) {
+ if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) {
if (ts.isStatic(container)) {
- return container.kind === 168 /* MethodDeclaration */ ||
- container.kind === 167 /* MethodSignature */ ||
- container.kind === 171 /* GetAccessor */ ||
- container.kind === 172 /* SetAccessor */ ||
- container.kind === 166 /* PropertyDeclaration */ ||
- container.kind === 169 /* ClassStaticBlockDeclaration */;
+ return container.kind === 169 /* SyntaxKind.MethodDeclaration */ ||
+ container.kind === 168 /* SyntaxKind.MethodSignature */ ||
+ container.kind === 172 /* SyntaxKind.GetAccessor */ ||
+ container.kind === 173 /* SyntaxKind.SetAccessor */ ||
+ container.kind === 167 /* SyntaxKind.PropertyDeclaration */ ||
+ container.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */;
}
else {
- return container.kind === 168 /* MethodDeclaration */ ||
- container.kind === 167 /* MethodSignature */ ||
- container.kind === 171 /* GetAccessor */ ||
- container.kind === 172 /* SetAccessor */ ||
- container.kind === 166 /* PropertyDeclaration */ ||
- container.kind === 165 /* PropertySignature */ ||
- container.kind === 170 /* Constructor */;
+ return container.kind === 169 /* SyntaxKind.MethodDeclaration */ ||
+ container.kind === 168 /* SyntaxKind.MethodSignature */ ||
+ container.kind === 172 /* SyntaxKind.GetAccessor */ ||
+ container.kind === 173 /* SyntaxKind.SetAccessor */ ||
+ container.kind === 167 /* SyntaxKind.PropertyDeclaration */ ||
+ container.kind === 166 /* SyntaxKind.PropertySignature */ ||
+ container.kind === 171 /* SyntaxKind.Constructor */;
}
}
}
@@ -70954,22 +72281,22 @@ var ts;
}
}
function getContainingObjectLiteral(func) {
- return (func.kind === 168 /* MethodDeclaration */ ||
- func.kind === 171 /* GetAccessor */ ||
- func.kind === 172 /* SetAccessor */) && func.parent.kind === 204 /* ObjectLiteralExpression */ ? func.parent :
- func.kind === 212 /* FunctionExpression */ && func.parent.kind === 294 /* PropertyAssignment */ ? func.parent.parent :
+ return (func.kind === 169 /* SyntaxKind.MethodDeclaration */ ||
+ func.kind === 172 /* SyntaxKind.GetAccessor */ ||
+ func.kind === 173 /* SyntaxKind.SetAccessor */) && func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ ? func.parent :
+ func.kind === 213 /* SyntaxKind.FunctionExpression */ && func.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ? func.parent.parent :
undefined;
}
function getThisTypeArgument(type) {
- return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined;
+ return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined;
}
function getThisTypeFromContextualType(type) {
return mapType(type, function (t) {
- return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t);
+ return t.flags & 2097152 /* TypeFlags.Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t);
});
}
function getContextualThisParameterType(func) {
- if (func.kind === 213 /* ArrowFunction */) {
+ if (func.kind === 214 /* SyntaxKind.ArrowFunction */) {
return undefined;
}
if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
@@ -70996,7 +72323,7 @@ var ts;
if (thisType) {
return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral)));
}
- if (literal.parent.kind !== 294 /* PropertyAssignment */) {
+ if (literal.parent.kind !== 296 /* SyntaxKind.PropertyAssignment */) {
break;
}
literal = literal.parent.parent;
@@ -71010,7 +72337,7 @@ var ts;
// In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the
// contextual type for 'this' is 'obj'.
var parent = ts.walkUpParenthesizedExpressions(func.parent);
- if (parent.kind === 220 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */) {
+ if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) {
var target = parent.left;
if (ts.isAccessExpression(target)) {
var expression = target.expression;
@@ -71038,7 +72365,7 @@ var ts;
var args = getEffectiveCallArguments(iife);
var indexOfParameter = func.parameters.indexOf(parameter);
if (parameter.dotDotDotToken) {
- return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* Normal */);
+ return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* CheckMode.Normal */);
}
var links = getNodeLinks(iife);
var cached = links.resolvedSignature;
@@ -71063,11 +72390,11 @@ var ts;
return getTypeFromTypeNode(typeNode);
}
switch (declaration.kind) {
- case 163 /* Parameter */:
+ case 164 /* SyntaxKind.Parameter */:
return getContextuallyTypedParameterType(declaration);
- case 202 /* BindingElement */:
+ case 203 /* SyntaxKind.BindingElement */:
return getContextualTypeForBindingElement(declaration);
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
if (ts.isStatic(declaration)) {
return getContextualTypeForStaticPropertyDeclaration(declaration);
}
@@ -71078,10 +72405,10 @@ var ts;
var parent = declaration.parent.parent;
var name = declaration.propertyName || declaration.name;
var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
- parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */);
+ parent.kind !== 203 /* SyntaxKind.BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */);
if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
return undefined;
- if (parent.name.kind === 201 /* ArrayBindingPattern */) {
+ if (parent.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) {
var index = ts.indexOfNode(declaration.parent.elements, declaration);
if (index < 0)
return undefined;
@@ -71114,7 +72441,7 @@ var ts;
if (result) {
return result;
}
- if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) { // This is less a contextual type and more an implied shape - in some cases, this may be undesirable
+ if (!(contextFlags & 8 /* ContextFlags.SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) { // This is less a contextual type and more an implied shape - in some cases, this may be undesirable
return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false);
}
}
@@ -71126,8 +72453,8 @@ var ts;
var contextualReturnType = getContextualReturnType(func);
if (contextualReturnType) {
var functionFlags = ts.getFunctionFlags(func);
- if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function
- var use = functionFlags & 2 /* Async */ ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */;
+ if (functionFlags & 1 /* FunctionFlags.Generator */) { // Generator or AsyncGenerator function
+ var use = functionFlags & 2 /* FunctionFlags.Async */ ? 2 /* IterationUse.AsyncGeneratorReturnType */ : 1 /* IterationUse.GeneratorReturnType */;
var iterationTypes = getIterationTypesOfIterable(contextualReturnType, use, /*errorNode*/ undefined);
if (!iterationTypes) {
return undefined;
@@ -71135,7 +72462,7 @@ var ts;
contextualReturnType = iterationTypes.returnType;
// falls through to unwrap Promise for AsyncGenerators
}
- if (functionFlags & 2 /* Async */) { // Async function or AsyncGenerator function
+ if (functionFlags & 2 /* FunctionFlags.Async */) { // Async function or AsyncGenerator function
// Get the awaited type without the `Awaited<T>` alias
var contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeNoAlias);
return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]);
@@ -71161,7 +72488,7 @@ var ts;
if (contextualReturnType) {
return node.asteriskToken
? contextualReturnType
- : getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, contextualReturnType, (functionFlags & 2 /* Async */) !== 0);
+ : getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, contextualReturnType, (functionFlags & 2 /* FunctionFlags.Async */) !== 0);
}
}
return undefined;
@@ -71180,7 +72507,7 @@ var ts;
return false;
}
function getContextualIterationType(kind, functionDecl) {
- var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */);
+ var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* FunctionFlags.Async */);
var contextualReturnType = getContextualReturnType(functionDecl);
if (contextualReturnType) {
return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync)
@@ -71227,11 +72554,11 @@ var ts;
}
var restIndex = signature.parameters.length - 1;
return signatureHasRestParameter(signature) && argIndex >= restIndex ?
- getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* Contextual */) :
+ getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* AccessFlags.Contextual */) :
getTypeAtPosition(signature, argIndex);
}
function getContextualTypeForSubstitutionExpression(template, substitutionExpression) {
- if (template.parent.kind === 209 /* TaggedTemplateExpression */) {
+ if (template.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) {
return getContextualTypeForArgument(template.parent, substitutionExpression);
}
return undefined;
@@ -71240,13 +72567,13 @@ var ts;
var binaryExpression = node.parent;
var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right;
switch (operatorToken.kind) {
- case 63 /* EqualsToken */:
- case 76 /* AmpersandAmpersandEqualsToken */:
- case 75 /* BarBarEqualsToken */:
- case 77 /* QuestionQuestionEqualsToken */:
+ case 63 /* SyntaxKind.EqualsToken */:
+ case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */:
+ case 75 /* SyntaxKind.BarBarEqualsToken */:
+ case 77 /* SyntaxKind.QuestionQuestionEqualsToken */:
return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined;
- case 56 /* BarBarToken */:
- case 60 /* QuestionQuestionToken */:
+ case 56 /* SyntaxKind.BarBarToken */:
+ case 60 /* SyntaxKind.QuestionQuestionToken */:
// When an || expression has a contextual type, the operands are contextually typed by that type, except
// when that type originates in a binding pattern, the right operand is contextually typed by the type of
// the left operand. When an || expression has no contextual type, the right operand is contextually typed
@@ -71255,8 +72582,8 @@ var ts;
var type = getContextualType(binaryExpression, contextFlags);
return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ?
getTypeOfExpression(left) : type;
- case 55 /* AmpersandAmpersandToken */:
- case 27 /* CommaToken */:
+ case 55 /* SyntaxKind.AmpersandAmpersandToken */:
+ case 27 /* SyntaxKind.CommaToken */:
return node === right ? getContextualType(binaryExpression, contextFlags) : undefined;
default:
return undefined;
@@ -71289,8 +72616,8 @@ var ts;
var _a, _b;
var kind = ts.getAssignmentDeclarationKind(binaryExpression);
switch (kind) {
- case 0 /* None */:
- case 4 /* ThisProperty */:
+ case 0 /* AssignmentDeclarationKind.None */:
+ case 4 /* AssignmentDeclarationKind.ThisProperty */:
var lhsSymbol = getSymbolForExpression(binaryExpression.left);
var decl = lhsSymbol && lhsSymbol.valueDeclaration;
// Unannotated, uninitialized property declarations have a type implied by their usage in the constructor.
@@ -71300,11 +72627,11 @@ var ts;
return (overallAnnotation && instantiateType(getTypeFromTypeNode(overallAnnotation), getSymbolLinks(lhsSymbol).mapper)) ||
(decl.initializer && getTypeOfExpression(binaryExpression.left));
}
- if (kind === 0 /* None */) {
+ if (kind === 0 /* AssignmentDeclarationKind.None */) {
return getTypeOfExpression(binaryExpression.left);
}
return getContextualTypeForThisPropertyAssignment(binaryExpression);
- case 5 /* Property */:
+ case 5 /* AssignmentDeclarationKind.Property */:
if (isPossiblyAliasedThisProperty(binaryExpression, kind)) {
return getContextualTypeForThisPropertyAssignment(binaryExpression);
}
@@ -71325,7 +72652,7 @@ var ts;
}
else if (ts.isIdentifier(lhs.expression)) {
var id = lhs.expression;
- var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true);
+ var parentSymbol = resolveName(id, id.escapedText, 111551 /* SymbolFlags.Value */, undefined, id.escapedText, /*isUse*/ true);
if (parentSymbol) {
var annotated_1 = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration);
if (annotated_1) {
@@ -71339,18 +72666,18 @@ var ts;
}
return ts.isInJSFile(decl_1) ? undefined : getTypeOfExpression(binaryExpression.left);
}
- case 1 /* ExportsProperty */:
- case 6 /* Prototype */:
- case 3 /* PrototypeProperty */:
+ case 1 /* AssignmentDeclarationKind.ExportsProperty */:
+ case 6 /* AssignmentDeclarationKind.Prototype */:
+ case 3 /* AssignmentDeclarationKind.PrototypeProperty */:
var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration;
// falls through
- case 2 /* ModuleExports */:
+ case 2 /* AssignmentDeclarationKind.ModuleExports */:
valueDeclaration || (valueDeclaration = (_b = binaryExpression.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration);
var annotated = valueDeclaration && ts.getEffectiveTypeAnnotationNode(valueDeclaration);
return annotated ? getTypeFromTypeNode(annotated) : undefined;
- case 7 /* ObjectDefinePropertyValue */:
- case 8 /* ObjectDefinePropertyExports */:
- case 9 /* ObjectDefinePrototypeProperty */:
+ case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */:
+ case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */:
+ case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */:
return ts.Debug.fail("Does not apply");
default:
return ts.Debug.assertNever(kind);
@@ -71358,14 +72685,14 @@ var ts;
}
function isPossiblyAliasedThisProperty(declaration, kind) {
if (kind === void 0) { kind = ts.getAssignmentDeclarationKind(declaration); }
- if (kind === 4 /* ThisProperty */) {
+ if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */) {
return true;
}
- if (!ts.isInJSFile(declaration) || kind !== 5 /* Property */ || !ts.isIdentifier(declaration.left.expression)) {
+ if (!ts.isInJSFile(declaration) || kind !== 5 /* AssignmentDeclarationKind.Property */ || !ts.isIdentifier(declaration.left.expression)) {
return false;
}
var name = declaration.left.expression.escapedText;
- var symbol = resolveName(declaration.left, name, 111551 /* Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true);
+ var symbol = resolveName(declaration.left, name, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true);
return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration);
}
function getContextualTypeForThisPropertyAssignment(binaryExpression) {
@@ -71389,12 +72716,12 @@ var ts;
return nameStr !== undefined && getTypeOfPropertyOfContextualType(thisType, nameStr) || undefined;
}
function isCircularMappedProperty(symbol) {
- return !!(ts.getCheckFlags(symbol) & 262144 /* Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* Type */) >= 0);
+ return !!(ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* TypeSystemPropertyName.Type */) >= 0);
}
function getTypeOfPropertyOfContextualType(type, name, nameType) {
return mapType(type, function (t) {
var _a;
- if (isGenericMappedType(t)) {
+ if (isGenericMappedType(t) && !t.declaration.nameType) {
var constraint = getConstraintTypeFromMappedType(t);
var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
var propertyNameType = nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name));
@@ -71402,7 +72729,7 @@ var ts;
return substituteIndexedMappedType(t, propertyNameType);
}
}
- else if (t.flags & 3670016 /* StructuredType */) {
+ else if (t.flags & 3670016 /* TypeFlags.StructuredType */) {
var prop = getPropertyOfType(t, name);
if (prop) {
return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop);
@@ -71423,7 +72750,7 @@ var ts;
// exists. Otherwise, it is the type of the string index signature in T, if one exists.
function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
ts.Debug.assert(ts.isObjectLiteralMethod(node));
- if (node.flags & 16777216 /* InWithStatement */) {
+ if (node.flags & 33554432 /* NodeFlags.InWithStatement */) {
// We cannot answer semantic questions within a with block, do not proceed any further
return undefined;
}
@@ -71458,7 +72785,7 @@ var ts;
// type of T.
function getContextualTypeForElementExpression(arrayContextualType, index) {
return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index)
- || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); },
+ || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* IterationUse.Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); },
/*noReductions*/ true));
}
// In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type.
@@ -71513,29 +72840,29 @@ var ts;
// recursive (and possibly infinite) invocations of getContextualType.
function isPossiblyDiscriminantValue(node) {
switch (node.kind) {
- case 10 /* StringLiteral */:
- case 8 /* NumericLiteral */:
- case 9 /* BigIntLiteral */:
- case 14 /* NoSubstitutionTemplateLiteral */:
- case 110 /* TrueKeyword */:
- case 95 /* FalseKeyword */:
- case 104 /* NullKeyword */:
- case 79 /* Identifier */:
- case 152 /* UndefinedKeyword */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
+ case 9 /* SyntaxKind.BigIntLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
+ case 110 /* SyntaxKind.TrueKeyword */:
+ case 95 /* SyntaxKind.FalseKeyword */:
+ case 104 /* SyntaxKind.NullKeyword */:
+ case 79 /* SyntaxKind.Identifier */:
+ case 153 /* SyntaxKind.UndefinedKeyword */:
return true;
- case 205 /* PropertyAccessExpression */:
- case 211 /* ParenthesizedExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
return isPossiblyDiscriminantValue(node.expression);
- case 287 /* JsxExpression */:
+ case 288 /* SyntaxKind.JsxExpression */:
return !node.expression || isPossiblyDiscriminantValue(node.expression);
}
return false;
}
function discriminateContextualTypeByObjectMembers(node, contextualType) {
- return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 294 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType);
+ return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType);
}
function discriminateContextualTypeByJSXAttributes(node, contextualType) {
- return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 284 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType);
+ return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* SyntaxKind.JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType);
}
// Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily
// be "pushed" onto a node using the contextualType property.
@@ -71544,30 +72871,35 @@ var ts;
getContextualTypeForObjectLiteralMethod(node, contextFlags) :
getContextualType(node, contextFlags);
var instantiatedType = instantiateContextualType(contextualType, node, contextFlags);
- if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) {
+ if (instantiatedType && !(contextFlags && contextFlags & 2 /* ContextFlags.NoConstraints */ && instantiatedType.flags & 8650752 /* TypeFlags.TypeVariable */)) {
var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true);
- return apparentType.flags & 1048576 /* Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) :
- apparentType.flags & 1048576 /* Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) :
+ return apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) :
+ apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) :
apparentType;
}
}
// If the given contextual type contains instantiable types and if a mapper representing
// return type inferences is available, instantiate those types using that mapper.
function instantiateContextualType(contextualType, node, contextFlags) {
- if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* Instantiable */)) {
+ if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* TypeFlags.Instantiable */)) {
var inferenceContext = getInferenceContext(node);
// If no inferences have been made, nothing is gained from instantiating as type parameters
// would just be replaced with their defaults similar to the apparent type.
if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
// For contextual signatures we incorporate all inferences made so far, e.g. from return
// types as well as arguments to the left in a function call.
- if (contextFlags && contextFlags & 1 /* Signature */) {
+ if (contextFlags && contextFlags & 1 /* ContextFlags.Signature */) {
return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
}
// For other purposes (e.g. determining whether to produce literal types) we only
- // incorporate inferences made from the return type in a function call.
+ // incorporate inferences made from the return type in a function call. We remove
+ // the 'boolean' type from the contextual type such that contextually typed boolean
+ // literals actually end up widening to 'boolean' (see #48363).
if (inferenceContext.returnMapper) {
- return instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
+ var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
+ return type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
+ filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
+ type;
}
}
}
@@ -71577,13 +72909,13 @@ var ts;
// are classified as instantiable (i.e. it doesn't instantiate object types), and (b) it performs
// no reductions on instantiated union types.
function instantiateInstantiableTypes(type, mapper) {
- if (type.flags & 465829888 /* Instantiable */) {
+ if (type.flags & 465829888 /* TypeFlags.Instantiable */) {
return instantiateType(type, mapper);
}
- if (type.flags & 1048576 /* Union */) {
- return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* None */);
+ if (type.flags & 1048576 /* TypeFlags.Union */) {
+ return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* UnionReduction.None */);
}
- if (type.flags & 2097152 /* Intersection */) {
+ if (type.flags & 2097152 /* TypeFlags.Intersection */) {
return getIntersectionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }));
}
return type;
@@ -71606,7 +72938,7 @@ var ts;
* @returns the contextual type of an expression.
*/
function getContextualType(node, contextFlags) {
- if (node.flags & 16777216 /* InWithStatement */) {
+ if (node.flags & 33554432 /* NodeFlags.InWithStatement */) {
// We cannot answer semantic questions within a with block, do not proceed any further
return undefined;
}
@@ -71615,58 +72947,60 @@ var ts;
}
var parent = node.parent;
switch (parent.kind) {
- case 253 /* VariableDeclaration */:
- case 163 /* Parameter */:
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
- case 202 /* BindingElement */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
+ case 164 /* SyntaxKind.Parameter */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 203 /* SyntaxKind.BindingElement */:
return getContextualTypeForInitializerExpression(node, contextFlags);
- case 213 /* ArrowFunction */:
- case 246 /* ReturnStatement */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 247 /* SyntaxKind.ReturnStatement */:
return getContextualTypeForReturnExpression(node);
- case 223 /* YieldExpression */:
+ case 224 /* SyntaxKind.YieldExpression */:
return getContextualTypeForYieldOperand(parent);
- case 217 /* AwaitExpression */:
+ case 218 /* SyntaxKind.AwaitExpression */:
return getContextualTypeForAwaitOperand(parent, contextFlags);
- case 207 /* CallExpression */:
- case 208 /* NewExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
return getContextualTypeForArgument(parent, node);
- case 210 /* TypeAssertionExpression */:
- case 228 /* AsExpression */:
+ case 211 /* SyntaxKind.TypeAssertionExpression */:
+ case 229 /* SyntaxKind.AsExpression */:
return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type);
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return getContextualTypeForBinaryOperand(node, contextFlags);
- case 294 /* PropertyAssignment */:
- case 295 /* ShorthandPropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
return getContextualTypeForObjectLiteralElement(parent, contextFlags);
- case 296 /* SpreadAssignment */:
+ case 298 /* SyntaxKind.SpreadAssignment */:
return getContextualType(parent.parent, contextFlags);
- case 203 /* ArrayLiteralExpression */: {
+ case 204 /* SyntaxKind.ArrayLiteralExpression */: {
var arrayLiteral = parent;
var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags);
return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node));
}
- case 221 /* ConditionalExpression */:
+ case 222 /* SyntaxKind.ConditionalExpression */:
return getContextualTypeForConditionalOperand(node, contextFlags);
- case 232 /* TemplateSpan */:
- ts.Debug.assert(parent.parent.kind === 222 /* TemplateExpression */);
+ case 233 /* SyntaxKind.TemplateSpan */:
+ ts.Debug.assert(parent.parent.kind === 223 /* SyntaxKind.TemplateExpression */);
return getContextualTypeForSubstitutionExpression(parent.parent, node);
- case 211 /* ParenthesizedExpression */: {
+ case 212 /* SyntaxKind.ParenthesizedExpression */: {
// Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast.
var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined;
return !tag ? getContextualType(parent, contextFlags) :
ts.isJSDocTypeTag(tag) && ts.isConstTypeReference(tag.typeExpression.type) ? tryFindWhenConstTypeReference(parent) :
getTypeFromTypeNode(tag.typeExpression.type);
}
- case 229 /* NonNullExpression */:
+ case 230 /* SyntaxKind.NonNullExpression */:
return getContextualType(parent, contextFlags);
- case 287 /* JsxExpression */:
+ case 271 /* SyntaxKind.ExportAssignment */:
+ return tryGetTypeFromEffectiveTypeNode(parent);
+ case 288 /* SyntaxKind.JsxExpression */:
return getContextualTypeForJsxExpression(parent);
- case 284 /* JsxAttribute */:
- case 286 /* JsxSpreadAttribute */:
+ case 285 /* SyntaxKind.JsxAttribute */:
+ case 287 /* SyntaxKind.JsxSpreadAttribute */:
return getContextualTypeForJsxAttribute(parent);
- case 279 /* JsxOpeningElement */:
- case 278 /* JsxSelfClosingElement */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
return getContextualJsxElementAttributesType(parent, contextFlags);
}
return undefined;
@@ -71679,7 +73013,7 @@ var ts;
return ancestor && ancestor.inferenceContext;
}
function getContextualJsxElementAttributesType(node, contextFlags) {
- if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* Completions */) {
+ if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* ContextFlags.Completions */) {
// Contextually applied type is moved from attributes up to the outer jsx attributes so when walking up from the children they get hit
// _However_ to hit them from the _attributes_ we must look for them here; otherwise we'll used the declared type
// (as below) instead!
@@ -71688,7 +73022,7 @@ var ts;
return getContextualTypeForArgumentAtIndex(node, 0);
}
function getEffectiveFirstArgumentForJsxSignature(signature, node) {
- return getJsxReferenceKind(node) !== 0 /* Component */
+ return getJsxReferenceKind(node) !== 0 /* JsxReferenceKind.Component */
? getJsxPropsTypeFromCallSignature(signature, node)
: getJsxPropsTypeFromClassType(signature, node);
}
@@ -71733,7 +73067,7 @@ var ts;
return getOrCreateTypeFromSignature(fakeSignature);
}
var tagType = checkExpressionCached(context.tagName);
- if (tagType.flags & 128 /* StringLiteral */) {
+ if (tagType.flags & 128 /* TypeFlags.StringLiteral */) {
var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context);
if (!result) {
return errorType;
@@ -71748,7 +73082,7 @@ var ts;
if (managedSym) {
var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); // fetches interface type, or initializes symbol links type parmaeters
var ctorType = getStaticTypeOfReferencedJsxConstructor(context);
- if (managedSym.flags & 524288 /* TypeAlias */) {
+ if (managedSym.flags & 524288 /* SymbolFlags.TypeAlias */) {
var params = getSymbolLinks(managedSym).typeParameters;
if (ts.length(params) >= 2) {
var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context));
@@ -71849,12 +73183,12 @@ var ts;
!leftName ? rightName :
!rightName ? leftName :
undefined;
- var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg".concat(i));
+ var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i));
paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType;
params[i] = paramSymbol;
}
if (needsExtraRestElement) {
- var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args");
+ var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args");
restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount));
if (shorter === right) {
restParamSymbol.type = instantiateType(restParamSymbol.type, mapper);
@@ -71876,18 +73210,18 @@ var ts;
var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount);
var result = createSignature(declaration, typeParams, thisParam, params,
/*resolvedReturnType*/ undefined,
- /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */);
- result.compositeKind = 2097152 /* Intersection */;
- result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]);
+ /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */);
+ result.compositeKind = 2097152 /* TypeFlags.Intersection */;
+ result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]);
if (paramMapper) {
- result.mapper = left.compositeKind === 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper;
+ result.mapper = left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper;
}
return result;
}
// If the given type is an object or union type with a single signature, and if that signature has at
// least as many parameters as the given function, return the signature. Otherwise return undefined.
function getContextualCallSignature(type, node) {
- var signatures = getSignaturesOfType(type, 0 /* Call */);
+ var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */);
var applicableByArity = ts.filter(signatures, function (s) { return !isAritySmaller(s, node); });
return applicableByArity.length === 1 ? applicableByArity[0] : getIntersectedSignatures(applicableByArity);
}
@@ -71917,16 +73251,16 @@ var ts;
// all identical ignoring their return type, the result is same signature but with return type as
// union type of return types from these signatures
function getContextualSignature(node) {
- ts.Debug.assert(node.kind !== 168 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node));
+ ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node));
var typeTagSignature = getSignatureOfTypeTag(node);
if (typeTagSignature) {
return typeTagSignature;
}
- var type = getApparentTypeOfContextualType(node, 1 /* Signature */);
+ var type = getApparentTypeOfContextualType(node, 1 /* ContextFlags.Signature */);
if (!type) {
return undefined;
}
- if (!(type.flags & 1048576 /* Union */)) {
+ if (!(type.flags & 1048576 /* TypeFlags.Union */)) {
return getContextualCallSignature(type, node);
}
var signatureList;
@@ -71955,18 +73289,18 @@ var ts;
}
}
function checkSpreadExpression(node, checkMode) {
- if (languageVersion < 2 /* ES2015 */) {
- checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */);
+ if (languageVersion < 2 /* ScriptTarget.ES2015 */) {
+ checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */);
}
var arrayOrIterableType = checkExpression(node.expression, checkMode);
- return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression);
+ return checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, arrayOrIterableType, undefinedType, node.expression);
}
function checkSyntheticExpression(node) {
return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type;
}
function hasDefaultValue(node) {
- return (node.kind === 202 /* BindingElement */ && !!node.initializer) ||
- (node.kind === 220 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */);
+ return (node.kind === 203 /* SyntaxKind.BindingElement */ && !!node.initializer) ||
+ (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */);
}
function checkArrayLiteral(node, checkMode, forceTuple) {
var elements = node.elements;
@@ -71979,14 +73313,14 @@ var ts;
var hasOmittedExpression = false;
for (var i = 0; i < elementCount; i++) {
var e = elements[i];
- if (e.kind === 224 /* SpreadElement */) {
- if (languageVersion < 2 /* ES2015 */) {
- checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */);
+ if (e.kind === 225 /* SyntaxKind.SpreadElement */) {
+ if (languageVersion < 2 /* ScriptTarget.ES2015 */) {
+ checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */);
}
var spreadType = checkExpression(e.expression, checkMode, forceTuple);
if (isArrayLikeType(spreadType)) {
elementTypes.push(spreadType);
- elementFlags.push(8 /* Variadic */);
+ elementFlags.push(8 /* ElementFlags.Variadic */);
}
else if (inDestructuringPattern) {
// Given the following situation:
@@ -72002,26 +73336,31 @@ var ts;
// getContextualTypeForElementExpression, which will crucially not error
// if there is no index type / iterated type.
var restElementType = getIndexTypeOfType(spreadType, numberType) ||
- getIteratedTypeOrElementType(65 /* Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) ||
+ getIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) ||
unknownType;
elementTypes.push(restElementType);
- elementFlags.push(4 /* Rest */);
+ elementFlags.push(4 /* ElementFlags.Rest */);
}
else {
- elementTypes.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, e.expression));
- elementFlags.push(4 /* Rest */);
+ elementTypes.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, e.expression));
+ elementFlags.push(4 /* ElementFlags.Rest */);
}
}
- else if (exactOptionalPropertyTypes && e.kind === 226 /* OmittedExpression */) {
+ else if (exactOptionalPropertyTypes && e.kind === 227 /* SyntaxKind.OmittedExpression */) {
hasOmittedExpression = true;
elementTypes.push(missingType);
- elementFlags.push(2 /* Optional */);
+ elementFlags.push(2 /* ElementFlags.Optional */);
}
else {
var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length);
var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple);
elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression));
- elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
+ elementFlags.push(hasOmittedExpression ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */);
+ if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) && isContextSensitive(e)) {
+ var inferenceContext = getInferenceContext(node);
+ ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context
+ addIntraExpressionInferenceSite(inferenceContext, e, type);
+ }
}
}
if (inDestructuringPattern) {
@@ -72031,28 +73370,28 @@ var ts;
return createArrayLiteralType(createTupleType(elementTypes, elementFlags, /*readonly*/ inConstContext));
}
return createArrayLiteralType(createArrayType(elementTypes.length ?
- getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* Subtype */) :
+ getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* UnionReduction.Subtype */) :
strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext));
}
function createArrayLiteralType(type) {
- if (!(ts.getObjectFlags(type) & 4 /* Reference */)) {
+ if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */)) {
return type;
}
var literalType = type.literalType;
if (!literalType) {
literalType = type.literalType = cloneTypeReference(type);
- literalType.objectFlags |= 32768 /* ArrayLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */;
+ literalType.objectFlags |= 16384 /* ObjectFlags.ArrayLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */;
}
return literalType;
}
function isNumericName(name) {
switch (name.kind) {
- case 161 /* ComputedPropertyName */:
+ case 162 /* SyntaxKind.ComputedPropertyName */:
return isNumericComputedName(name);
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return ts.isNumericLiteralName(name.escapedText);
- case 8 /* NumericLiteral */:
- case 10 /* StringLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
return ts.isNumericLiteralName(name.text);
default:
return false;
@@ -72061,14 +73400,14 @@ var ts;
function isNumericComputedName(name) {
// It seems odd to consider an expression of type Any to result in a numeric name,
// but this behavior is consistent with checkIndexedAccess
- return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */);
+ return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* TypeFlags.NumberLike */);
}
function checkComputedPropertyName(node) {
var links = getNodeLinks(node.expression);
if (!links.resolvedType) {
if ((ts.isTypeLiteralNode(node.parent.parent) || ts.isClassLike(node.parent.parent) || ts.isInterfaceDeclaration(node.parent.parent))
- && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */
- && node.parent.kind !== 171 /* GetAccessor */ && node.parent.kind !== 172 /* SetAccessor */) {
+ && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */
+ && node.parent.kind !== 172 /* SyntaxKind.GetAccessor */ && node.parent.kind !== 173 /* SyntaxKind.SetAccessor */) {
return links.resolvedType = errorType;
}
links.resolvedType = checkExpression(node.expression);
@@ -72079,17 +73418,17 @@ var ts;
var enclosingIterationStatement = getEnclosingIterationStatement(container);
if (enclosingIterationStatement) {
// The computed field name will use a block scoped binding which can be unique for each iteration of the loop.
- getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */;
+ getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */;
// The generated variable which stores the computed field name must be block-scoped.
- getNodeLinks(node).flags |= 524288 /* BlockScopedBindingInLoop */;
+ getNodeLinks(node).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */;
// The generated variable which stores the class must be block-scoped.
- getNodeLinks(node.parent.parent).flags |= 524288 /* BlockScopedBindingInLoop */;
+ getNodeLinks(node.parent.parent).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */;
}
}
// This will allow types number, string, symbol or any. It will also allow enums, the unknown
// type, and any union of these types (like string | number).
- if (links.resolvedType.flags & 98304 /* Nullable */ ||
- !isTypeAssignableToKind(links.resolvedType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) &&
+ if (links.resolvedType.flags & 98304 /* TypeFlags.Nullable */ ||
+ !isTypeAssignableToKind(links.resolvedType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) &&
!isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) {
error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any);
}
@@ -72105,7 +73444,7 @@ var ts;
var _a;
var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0];
return ts.isKnownSymbol(symbol) || (firstDecl && ts.isNamedDeclaration(firstDecl) && ts.isComputedPropertyName(firstDecl.name) &&
- isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* ESSymbol */));
+ isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* TypeFlags.ESSymbol */));
}
function getObjectLiteralIndexInfo(node, offset, properties, keyType) {
var propTypes = [];
@@ -72117,11 +73456,11 @@ var ts;
propTypes.push(getTypeOfSymbol(properties[i]));
}
}
- var unionType = propTypes.length ? getUnionType(propTypes, 2 /* Subtype */) : undefinedType;
+ var unionType = propTypes.length ? getUnionType(propTypes, 2 /* UnionReduction.Subtype */) : undefinedType;
return createIndexInfo(keyType, unionType, isConstContext(node));
}
function getImmediateAliasedSymbol(symbol) {
- ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here.");
+ ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here.");
var links = getSymbolLinks(symbol);
if (!links.immediateTarget) {
var node = getDeclarationOfAliasSymbol(symbol);
@@ -72141,9 +73480,9 @@ var ts;
var spread = emptyObjectType;
var contextualType = getApparentTypeOfContextualType(node);
var contextualTypeHasPattern = contextualType && contextualType.pattern &&
- (contextualType.pattern.kind === 200 /* ObjectBindingPattern */ || contextualType.pattern.kind === 204 /* ObjectLiteralExpression */);
+ (contextualType.pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* SyntaxKind.ObjectLiteralExpression */);
var inConstContext = isConstContext(node);
- var checkFlags = inConstContext ? 8 /* Readonly */ : 0;
+ var checkFlags = inConstContext ? 8 /* CheckFlags.Readonly */ : 0;
var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node);
var enumTag = ts.getJSDocEnumTag(node);
var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag;
@@ -72165,16 +73504,16 @@ var ts;
for (var _b = 0, _c = node.properties; _b < _c.length; _b++) {
var memberDecl = _c[_b];
var member = getSymbolOfNode(memberDecl);
- var computedNameType = memberDecl.name && memberDecl.name.kind === 161 /* ComputedPropertyName */ ?
+ var computedNameType = memberDecl.name && memberDecl.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ ?
checkComputedPropertyName(memberDecl.name) : undefined;
- if (memberDecl.kind === 294 /* PropertyAssignment */ ||
- memberDecl.kind === 295 /* ShorthandPropertyAssignment */ ||
+ if (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ||
+ memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ||
ts.isObjectLiteralMethod(memberDecl)) {
- var type = memberDecl.kind === 294 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) :
+ var type = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) :
// avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
// for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
// we don't want to say "could not find 'a'".
- memberDecl.kind === 295 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) :
+ memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) :
checkObjectLiteralMethod(memberDecl, checkMode);
if (isInJavascript) {
var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
@@ -72186,29 +73525,29 @@ var ts;
checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl);
}
}
- objectFlags |= ts.getObjectFlags(type) & 917504 /* PropagatingFlags */;
+ objectFlags |= ts.getObjectFlags(type) & 458752 /* ObjectFlags.PropagatingFlags */;
var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined;
var prop = nameType ?
- createSymbol(4 /* Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* Late */) :
- createSymbol(4 /* Property */ | member.flags, member.escapedName, checkFlags);
+ createSymbol(4 /* SymbolFlags.Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* CheckFlags.Late */) :
+ createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName, checkFlags);
if (nameType) {
prop.nameType = nameType;
}
if (inDestructuringPattern) {
// If object literal is an assignment pattern and if the assignment pattern specifies a default value
// for the property, make the property optional.
- var isOptional = (memberDecl.kind === 294 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) ||
- (memberDecl.kind === 295 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer);
+ var isOptional = (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) ||
+ (memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer);
if (isOptional) {
- prop.flags |= 16777216 /* Optional */;
+ prop.flags |= 16777216 /* SymbolFlags.Optional */;
}
}
- else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectLiteralPatternWithComputedProperties */)) {
+ else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */)) {
// If object literal is contextually typed by the implied type of a binding pattern, and if the
// binding pattern specifies a default value for the property, make the property optional.
var impliedProp = getPropertyOfType(contextualType, member.escapedName);
if (impliedProp) {
- prop.flags |= impliedProp.flags & 16777216 /* Optional */;
+ prop.flags |= impliedProp.flags & 16777216 /* SymbolFlags.Optional */;
}
else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, stringType)) {
error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType));
@@ -72223,10 +73562,17 @@ var ts;
prop.target = member;
member = prop;
allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
+ if (contextualType && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) &&
+ (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ || memberDecl.kind === 169 /* SyntaxKind.MethodDeclaration */) && isContextSensitive(memberDecl)) {
+ var inferenceContext = getInferenceContext(node);
+ ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context
+ var inferenceNode = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? memberDecl.initializer : memberDecl;
+ addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type);
+ }
}
- else if (memberDecl.kind === 296 /* SpreadAssignment */) {
- if (languageVersion < 2 /* ES2015 */) {
- checkExternalEmitHelpers(memberDecl, 2 /* Assign */);
+ else if (memberDecl.kind === 298 /* SyntaxKind.SpreadAssignment */) {
+ if (languageVersion < 2 /* ScriptTarget.ES2015 */) {
+ checkExternalEmitHelpers(memberDecl, 2 /* ExternalEmitHelpers.Assign */);
}
if (propertiesArray.length > 0) {
spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext);
@@ -72260,10 +73606,10 @@ var ts;
// an ordinary function declaration(section 6.1) with no parameters.
// A set accessor declaration is processed in the same manner
// as an ordinary function declaration with a single parameter and a Void return type.
- ts.Debug.assert(memberDecl.kind === 171 /* GetAccessor */ || memberDecl.kind === 172 /* SetAccessor */);
+ ts.Debug.assert(memberDecl.kind === 172 /* SyntaxKind.GetAccessor */ || memberDecl.kind === 173 /* SyntaxKind.SetAccessor */);
checkNodeDeferred(memberDecl);
}
- if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) {
+ if (computedNameType && !(computedNameType.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */)) {
if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) {
if (isTypeAssignableTo(computedNameType, numberType)) {
hasComputedNumberProperty = true;
@@ -72288,11 +73634,11 @@ var ts;
// type with those properties for which the binding pattern specifies a default value.
// If the object literal is spread into another object literal, skip this step and let the top-level object
// literal handle it instead.
- if (contextualTypeHasPattern && node.parent.kind !== 296 /* SpreadAssignment */) {
+ if (contextualTypeHasPattern && node.parent.kind !== 298 /* SyntaxKind.SpreadAssignment */) {
for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) {
var prop = _e[_d];
if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
- if (!(prop.flags & 16777216 /* Optional */)) {
+ if (!(prop.flags & 16777216 /* SymbolFlags.Optional */)) {
error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
}
propertiesTable.set(prop.escapedName, prop);
@@ -72324,12 +73670,12 @@ var ts;
if (hasComputedSymbolProperty)
indexInfos.push(getObjectLiteralIndexInfo(node, offset, propertiesArray, esSymbolType));
var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, indexInfos);
- result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */;
+ result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */;
if (isJSObjectLiteral) {
- result.objectFlags |= 8192 /* JSLiteral */;
+ result.objectFlags |= 4096 /* ObjectFlags.JSLiteral */;
}
if (patternWithComputedProperties) {
- result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */;
+ result.objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */;
}
if (inDestructuringPattern) {
result.pattern = node;
@@ -72339,8 +73685,8 @@ var ts;
}
function isValidSpreadType(type) {
var t = removeDefinitelyFalsyTypes(mapType(type, getBaseConstraintOrType));
- return !!(t.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) ||
- t.flags & 3145728 /* UnionOrIntersection */ && ts.every(t.types, isValidSpreadType));
+ return !!(t.flags & (1 /* TypeFlags.Any */ | 67108864 /* TypeFlags.NonPrimitive */ | 524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ||
+ t.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(t.types, isValidSpreadType));
}
function checkJsxSelfClosingElementDeferred(node) {
checkJsxOpeningLikeElementOrOpeningFragment(node);
@@ -72386,7 +73732,7 @@ var ts;
* Returns true iff React would emit this tag name as a string rather than an identifier or qualified name
*/
function isJsxIntrinsicIdentifier(tagName) {
- return tagName.kind === 79 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText);
+ return tagName.kind === 79 /* SyntaxKind.Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText);
}
function checkJsxAttribute(node, checkMode) {
return node.initializer
@@ -72410,15 +73756,15 @@ var ts;
var hasSpreadAnyType = false;
var typeToIntersect;
var explicitlySpecifyChildrenAttribute = false;
- var objectFlags = 2048 /* JsxAttributes */;
+ var objectFlags = 2048 /* ObjectFlags.JsxAttributes */;
var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(openingLikeElement));
for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) {
var attributeDecl = _a[_i];
var member = attributeDecl.symbol;
if (ts.isJsxAttribute(attributeDecl)) {
var exprType = checkJsxAttribute(attributeDecl, checkMode);
- objectFlags |= ts.getObjectFlags(exprType) & 917504 /* PropagatingFlags */;
- var attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName);
+ objectFlags |= ts.getObjectFlags(exprType) & 458752 /* ObjectFlags.PropagatingFlags */;
+ var attributeSymbol = createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName);
attributeSymbol.declarations = member.declarations;
attributeSymbol.parent = member.parent;
if (member.valueDeclaration) {
@@ -72433,7 +73779,7 @@ var ts;
}
}
else {
- ts.Debug.assert(attributeDecl.kind === 286 /* JsxSpreadAttribute */);
+ ts.Debug.assert(attributeDecl.kind === 287 /* SyntaxKind.JsxSpreadAttribute */);
if (attributesTable.size > 0) {
spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false);
attributesTable = ts.createSymbolTable();
@@ -72449,6 +73795,7 @@ var ts;
}
}
else {
+ error(attributeDecl.expression, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types);
typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType;
}
}
@@ -72459,7 +73806,7 @@ var ts;
}
}
// Handle children attribute
- var parent = openingLikeElement.parent.kind === 277 /* JsxElement */ ? openingLikeElement.parent : undefined;
+ var parent = openingLikeElement.parent.kind === 278 /* SyntaxKind.JsxElement */ ? openingLikeElement.parent : undefined;
// We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement
if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) {
var childrenTypes = checkJsxChildren(parent, checkMode);
@@ -72473,7 +73820,7 @@ var ts;
var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes);
var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName);
// If there are children in the body of JSX element, create dummy attribute "children" with the union of children types so that it will pass the attribute checking process
- var childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName);
+ var childrenPropSymbol = createSymbol(4 /* SymbolFlags.Property */, jsxChildrenPropertyName);
childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] :
childrenContextualType && someType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) :
createArrayType(getUnionType(childrenTypes));
@@ -72501,7 +73848,7 @@ var ts;
function createJsxAttributesType() {
objectFlags |= freshObjectLiteralFlag;
var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, ts.emptyArray);
- result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */;
+ result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */;
return result;
}
}
@@ -72511,12 +73858,12 @@ var ts;
var child = _a[_i];
// In React, JSX text that contains only whitespaces will be ignored so we don't want to type-check that
// because then type of children property will have constituent of string type.
- if (child.kind === 11 /* JsxText */) {
+ if (child.kind === 11 /* SyntaxKind.JsxText */) {
if (!child.containsOnlyTriviaWhiteSpaces) {
childrenTypes.push(stringType);
}
}
- else if (child.kind === 287 /* JsxExpression */ && !child.expression) {
+ else if (child.kind === 288 /* SyntaxKind.JsxExpression */ && !child.expression) {
continue; // empty jsx expressions don't *really* count as present children
}
else {
@@ -72528,7 +73875,7 @@ var ts;
function checkSpreadPropOverrides(type, props, spread) {
for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
var right = _a[_i];
- if (!(right.flags & 16777216 /* Optional */)) {
+ if (!(right.flags & 16777216 /* SymbolFlags.Optional */)) {
var left = props.get(right.escapedName);
if (left) {
var diagnostic = error(left.valueDeclaration, ts.Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, ts.unescapeLeadingUnderscores(left.escapedName));
@@ -72548,7 +73895,7 @@ var ts;
function getJsxType(name, location) {
var namespace = getJsxNamespaceAt(location);
var exports = namespace && getExportsOfSymbol(namespace);
- var typeSymbol = exports && getSymbol(exports, name, 788968 /* Type */);
+ var typeSymbol = exports && getSymbol(exports, name, 788968 /* SymbolFlags.Type */);
return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType;
}
/**
@@ -72567,13 +73914,13 @@ var ts;
return ts.Debug.fail();
var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText);
if (intrinsicProp) {
- links.jsxFlags |= 1 /* IntrinsicNamedElement */;
+ links.jsxFlags |= 1 /* JsxFlags.IntrinsicNamedElement */;
return links.resolvedSymbol = intrinsicProp;
}
// Intrinsic string indexer case
var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, stringType);
if (indexSignatureType) {
- links.jsxFlags |= 2 /* IntrinsicIndexedElement */;
+ links.jsxFlags |= 2 /* JsxFlags.IntrinsicIndexedElement */;
return links.resolvedSymbol = intrinsicElementsType.symbol;
}
// Wasn't found
@@ -72622,10 +73969,10 @@ var ts;
var resolvedNamespace = getJsxNamespaceContainerForImplicitImport(location);
if (!resolvedNamespace || resolvedNamespace === unknownSymbol) {
var namespaceName = getJsxNamespace(location);
- resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false);
+ resolvedNamespace = resolveName(location, namespaceName, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false);
}
if (resolvedNamespace) {
- var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */));
+ var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* SymbolFlags.Namespace */));
if (candidate && candidate !== unknownSymbol) {
if (links) {
links.jsxNamespace = candidate;
@@ -72638,7 +73985,7 @@ var ts;
}
}
// JSX global fallback
- var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined));
+ var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined));
if (s === unknownSymbol) {
return undefined; // TODO: GH#18217
}
@@ -72653,7 +74000,7 @@ var ts;
*/
function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) {
// JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol]
- var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* Type */);
+ var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* SymbolFlags.Type */);
// JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type]
var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym);
// The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute
@@ -72677,7 +74024,7 @@ var ts;
}
function getJsxLibraryManagedAttributes(jsxNamespace) {
// JSX.LibraryManagedAttributes [symbol]
- return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* Type */);
+ return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* SymbolFlags.Type */);
}
/// e.g. "props" for React.d.ts,
/// or 'undefined' if ElementAttributesProperty doesn't exist (which means all
@@ -72691,10 +74038,10 @@ var ts;
return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace);
}
function getUninstantiatedJsxSignaturesOfType(elementType, caller) {
- if (elementType.flags & 4 /* String */) {
+ if (elementType.flags & 4 /* TypeFlags.String */) {
return [anySignature];
}
- else if (elementType.flags & 128 /* StringLiteral */) {
+ else if (elementType.flags & 128 /* TypeFlags.StringLiteral */) {
var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller);
if (!intrinsicType) {
error(caller, ts.Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements);
@@ -72707,12 +74054,12 @@ var ts;
}
var apparentElemType = getApparentType(elementType);
// Resolve the signatures, preferring constructor
- var signatures = getSignaturesOfType(apparentElemType, 1 /* Construct */);
+ var signatures = getSignaturesOfType(apparentElemType, 1 /* SignatureKind.Construct */);
if (signatures.length === 0) {
// No construct signatures, try call signatures
- signatures = getSignaturesOfType(apparentElemType, 0 /* Call */);
+ signatures = getSignaturesOfType(apparentElemType, 0 /* SignatureKind.Call */);
}
- if (signatures.length === 0 && apparentElemType.flags & 1048576 /* Union */) {
+ if (signatures.length === 0 && apparentElemType.flags & 1048576 /* TypeFlags.Union */) {
// If each member has some combination of new/call signatures; make a union signature list for those
signatures = getUnionSignatures(ts.map(apparentElemType.types, function (t) { return getUninstantiatedJsxSignaturesOfType(t, caller); }));
}
@@ -72740,13 +74087,13 @@ var ts;
return anyType;
}
function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) {
- if (refKind === 1 /* Function */) {
+ if (refKind === 1 /* JsxReferenceKind.Function */) {
var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement);
if (sfcReturnConstraint) {
checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_return_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
}
}
- else if (refKind === 0 /* Component */) {
+ else if (refKind === 0 /* JsxReferenceKind.Component */) {
var classConstraint = getJsxElementClassTypeAt(openingLikeElement);
if (classConstraint) {
// Issue an error if this return type isn't assignable to JSX.ElementClass, failing that
@@ -72777,10 +74124,10 @@ var ts;
var links = getNodeLinks(node);
if (!links.resolvedJsxElementAttributesType) {
var symbol = getIntrinsicTagSymbol(node);
- if (links.jsxFlags & 1 /* IntrinsicNamedElement */) {
+ if (links.jsxFlags & 1 /* JsxFlags.IntrinsicNamedElement */) {
return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol) || errorType;
}
- else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) {
+ else if (links.jsxFlags & 2 /* JsxFlags.IntrinsicIndexedElement */) {
return links.resolvedJsxElementAttributesType =
getIndexTypeOfType(getJsxType(JsxNames.IntrinsicElements, node), stringType) || errorType;
}
@@ -72814,7 +74161,7 @@ var ts;
}
function checkJsxPreconditions(errorNode) {
// Preconditions for using JSX
- if ((compilerOptions.jsx || 0 /* None */) === 0 /* None */) {
+ if ((compilerOptions.jsx || 0 /* JsxEmit.None */) === 0 /* JsxEmit.None */) {
error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided);
}
if (getJsxElementTypeAt(errorNode) === undefined) {
@@ -72832,20 +74179,20 @@ var ts;
if (!getJsxNamespaceContainerForImplicitImport(node)) {
// The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import.
// And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error.
- var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined;
+ var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* JsxEmit.React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined;
var jsxFactoryNamespace = getJsxNamespace(node);
var jsxFactoryLocation = isNodeOpeningLikeElement ? node.tagName : node;
// allow null as jsxFragmentFactory
var jsxFactorySym = void 0;
if (!(ts.isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) {
- jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true);
+ jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true);
}
if (jsxFactorySym) {
// Mark local symbol as referenced here because it might not have been marked
// if jsx emit was not jsxFactory as there wont be error being emitted
- jsxFactorySym.isReferenced = 67108863 /* All */;
+ jsxFactorySym.isReferenced = 67108863 /* SymbolFlags.All */;
// If react/jsxFactory symbol is alias, mark it as refereced
- if (jsxFactorySym.flags & 2097152 /* Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) {
+ if (jsxFactorySym.flags & 2097152 /* SymbolFlags.Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) {
markAliasSymbolAsReferenced(jsxFactorySym);
}
}
@@ -72854,7 +74201,7 @@ var ts;
var file = ts.getSourceFileOfNode(node);
var localJsxNamespace = getLocalJsxNamespace(file);
if (localJsxNamespace) {
- resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true);
+ resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true);
}
}
}
@@ -72879,7 +74226,7 @@ var ts;
* @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType
*/
function isKnownProperty(targetType, name, isComparingJsxAttributes) {
- if (targetType.flags & 524288 /* Object */) {
+ if (targetType.flags & 524288 /* TypeFlags.Object */) {
// For backwards compatibility a symbol-named property is satisfied by a string index signature. This
// is incorrect and inconsistent with element access expressions, where it is an error, so eventually
// we should remove this exception.
@@ -72891,7 +74238,7 @@ var ts;
return true;
}
}
- else if (targetType.flags & 3145728 /* UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) {
+ else if (targetType.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) {
for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) {
var t = _a[_i];
if (isKnownProperty(t, name, isComparingJsxAttributes)) {
@@ -72902,10 +74249,10 @@ var ts;
return false;
}
function isExcessPropertyCheckTarget(type) {
- return !!(type.flags & 524288 /* Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectLiteralPatternWithComputedProperties */) ||
- type.flags & 67108864 /* NonPrimitive */ ||
- type.flags & 1048576 /* Union */ && ts.some(type.types, isExcessPropertyCheckTarget) ||
- type.flags & 2097152 /* Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget));
+ return !!(type.flags & 524288 /* TypeFlags.Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */) ||
+ type.flags & 67108864 /* TypeFlags.NonPrimitive */ ||
+ type.flags & 1048576 /* TypeFlags.Union */ && ts.some(type.types, isExcessPropertyCheckTarget) ||
+ type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget));
}
function checkJsxExpression(node, checkMode) {
checkGrammarJsxExpression(node);
@@ -72928,13 +74275,13 @@ var ts;
* Note that this is not tracked well within the compiler, so the answer may be incorrect.
*/
function isPrototypeProperty(symbol) {
- if (symbol.flags & 8192 /* Method */ || ts.getCheckFlags(symbol) & 4 /* SyntheticMethod */) {
+ if (symbol.flags & 8192 /* SymbolFlags.Method */ || ts.getCheckFlags(symbol) & 4 /* CheckFlags.SyntheticMethod */) {
return true;
}
if (ts.isInJSFile(symbol.valueDeclaration)) {
var parent = symbol.valueDeclaration.parent;
return parent && ts.isBinaryExpression(parent) &&
- ts.getAssignmentDeclarationKind(parent) === 3 /* PrototypeProperty */;
+ ts.getAssignmentDeclarationKind(parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */;
}
}
/**
@@ -72948,9 +74295,9 @@ var ts;
function checkPropertyAccessibility(node, isSuper, writing, type, prop, reportError) {
if (reportError === void 0) { reportError = true; }
var errorNode = !reportError ? undefined :
- node.kind === 160 /* QualifiedName */ ? node.right :
- node.kind === 199 /* ImportType */ ? node :
- node.kind === 202 /* BindingElement */ && node.propertyName ? node.propertyName : node.name;
+ node.kind === 161 /* SyntaxKind.QualifiedName */ ? node.right :
+ node.kind === 200 /* SyntaxKind.ImportType */ ? node :
+ node.kind === 203 /* SyntaxKind.BindingElement */ && node.propertyName ? node.propertyName : node.name;
return checkPropertyAccessibilityAtLocation(node, isSuper, writing, type, prop, errorNode);
}
/**
@@ -72973,7 +74320,7 @@ var ts;
// - In a static member function or static member accessor
// where this references the constructor function object of a derived class,
// a super property access is permitted and must specify a public static member function of the base class.
- if (languageVersion < 2 /* ES2015 */) {
+ if (languageVersion < 2 /* ScriptTarget.ES2015 */) {
if (symbolHasNonMethodDeclaration(prop)) {
if (errorNode) {
error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword);
@@ -72981,7 +74328,7 @@ var ts;
return false;
}
}
- if (flags & 128 /* Abstract */) {
+ if (flags & 128 /* ModifierFlags.Abstract */) {
// A method cannot be accessed in a super property access if the method is abstract.
// This error could mask a private property access error. But, a member
// cannot simultaneously be private and abstract, so this will trigger an
@@ -72993,7 +74340,7 @@ var ts;
}
}
// Referencing abstract properties within their own constructors is not allowed
- if ((flags & 128 /* Abstract */) && symbolHasNonMethodDeclaration(prop) &&
+ if ((flags & 128 /* ModifierFlags.Abstract */) && symbolHasNonMethodDeclaration(prop) &&
(ts.isThisProperty(location) || ts.isThisInitializedObjectBindingExpression(location) || ts.isObjectBindingPattern(location.parent) && ts.isThisInitializedDeclaration(location.parent.parent))) {
var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop));
if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(location)) {
@@ -73004,12 +74351,12 @@ var ts;
}
}
// Public properties are otherwise accessible.
- if (!(flags & 24 /* NonPublicAccessibilityModifier */)) {
+ if (!(flags & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) {
return true;
}
// Property is known to be private or protected at this point
// Private property is accessible if the property is within the declaring class
- if (flags & 8 /* Private */) {
+ if (flags & 8 /* ModifierFlags.Private */) {
var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop));
if (!isNodeWithinClass(location, declaringClassDeclaration)) {
if (errorNode) {
@@ -73028,27 +74375,26 @@ var ts;
// of the property as base classes
var enclosingClass = forEachEnclosingClass(location, function (enclosingDeclaration) {
var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration));
- return isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing) ? enclosingClass : undefined;
+ return isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing);
});
// A protected property is accessible if the property is within the declaring class or classes derived from it
if (!enclosingClass) {
// allow PropertyAccessibility if context is in function with this parameter
- // static member access is disallow
- var thisParameter = void 0;
- if (flags & 32 /* Static */ || !(thisParameter = getThisParameterFromNodeContext(location)) || !thisParameter.type) {
+ // static member access is disallowed
+ enclosingClass = getEnclosingClassFromThisParameter(location);
+ enclosingClass = enclosingClass && isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing);
+ if (flags & 32 /* ModifierFlags.Static */ || !enclosingClass) {
if (errorNode) {
error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || containingType));
}
return false;
}
- var thisType = getTypeFromTypeNode(thisParameter.type);
- enclosingClass = ((thisType.flags & 262144 /* TypeParameter */) ? getConstraintOfTypeParameter(thisType) : thisType).target;
}
// No further restrictions for static properties
- if (flags & 32 /* Static */) {
+ if (flags & 32 /* ModifierFlags.Static */) {
return true;
}
- if (containingType.flags & 262144 /* TypeParameter */) {
+ if (containingType.flags & 262144 /* TypeFlags.TypeParameter */) {
// get the original type -- represented as the type constraint of the 'this' type
containingType = containingType.isThisType ? getConstraintOfTypeParameter(containingType) : getBaseConstraintOfType(containingType); // TODO: GH#18217 Use a different variable that's allowed to be undefined
}
@@ -73060,44 +74406,55 @@ var ts;
}
return true;
}
+ function getEnclosingClassFromThisParameter(node) {
+ var thisParameter = getThisParameterFromNodeContext(node);
+ var thisType = (thisParameter === null || thisParameter === void 0 ? void 0 : thisParameter.type) && getTypeFromTypeNode(thisParameter.type);
+ if (thisType && thisType.flags & 262144 /* TypeFlags.TypeParameter */) {
+ thisType = getConstraintOfTypeParameter(thisType);
+ }
+ if (thisType && ts.getObjectFlags(thisType) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) {
+ return getTargetType(thisType);
+ }
+ return undefined;
+ }
function getThisParameterFromNodeContext(node) {
var thisContainer = ts.getThisContainer(node, /* includeArrowFunctions */ false);
return thisContainer && ts.isFunctionLike(thisContainer) ? ts.getThisParameter(thisContainer) : undefined;
}
function symbolHasNonMethodDeclaration(symbol) {
- return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* Method */); });
+ return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* SymbolFlags.Method */); });
}
function checkNonNullExpression(node) {
return checkNonNullType(checkExpression(node), node);
}
function isNullableType(type) {
- return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */);
+ return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* TypeFlags.Nullable */);
}
function getNonNullableTypeIfNeeded(type) {
return isNullableType(type) ? getNonNullableType(type) : type;
}
function reportObjectPossiblyNullOrUndefinedError(node, flags) {
- error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ?
+ error(node, flags & 32768 /* TypeFlags.Undefined */ ? flags & 65536 /* TypeFlags.Null */ ?
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 /* Undefined */ ? flags & 65536 /* Null */ ?
+ error(node, flags & 32768 /* TypeFlags.Undefined */ ? flags & 65536 /* TypeFlags.Null */ ?
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);
}
function checkNonNullTypeWithReporter(type, node, reportError) {
- if (strictNullChecks && type.flags & 2 /* Unknown */) {
+ if (strictNullChecks && type.flags & 2 /* TypeFlags.Unknown */) {
error(node, ts.Diagnostics.Object_is_of_type_unknown);
return errorType;
}
- var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */;
+ var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* TypeFlags.Nullable */;
if (kind) {
reportError(node, kind);
var t = getNonNullableType(type);
- return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t;
+ return t.flags & (98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */) ? errorType : t;
}
return type;
}
@@ -73106,13 +74463,13 @@ var ts;
}
function checkNonNullNonVoidType(type, node) {
var nonNullType = checkNonNullType(type, node);
- if (nonNullType.flags & 16384 /* Void */) {
+ if (nonNullType.flags & 16384 /* TypeFlags.Void */) {
error(node, ts.Diagnostics.Object_is_possibly_undefined);
}
return nonNullType;
}
function checkPropertyAccessExpression(node, checkMode) {
- return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node, checkMode) :
+ return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkPropertyAccessChain(node, checkMode) :
checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name, checkMode);
}
function checkPropertyAccessChain(node, checkMode) {
@@ -73125,7 +74482,7 @@ var ts;
return checkPropertyAccessExpressionOrQualifiedName(node, node.left, leftType, node.right, checkMode);
}
function isMethodAccessForCall(node) {
- while (node.parent.kind === 211 /* ParenthesizedExpression */) {
+ while (node.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) {
node = node.parent;
}
return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node;
@@ -73149,7 +74506,7 @@ var ts;
if (!ts.isExpressionNode(privId)) {
return grammarErrorOnNode(privId, ts.Diagnostics.Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression);
}
- var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* InKeyword */;
+ var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */;
if (!getSymbolForPrivateIdentifierExpression(privId) && !isInOperation) {
return grammarErrorOnNode(privId, ts.Diagnostics.Cannot_find_name_0, ts.idText(privId));
}
@@ -73221,16 +74578,16 @@ var ts;
function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right, checkMode) {
var parentSymbol = getNodeLinks(left).resolvedSymbol;
var assignmentKind = ts.getAssignmentTargetKind(node);
- var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType);
+ var apparentType = getApparentType(assignmentKind !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType);
var isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType;
var prop;
if (ts.isPrivateIdentifier(right)) {
- if (languageVersion < 99 /* ESNext */) {
- if (assignmentKind !== 0 /* None */) {
- checkExternalEmitHelpers(node, 1048576 /* ClassPrivateFieldSet */);
+ if (languageVersion < 99 /* ScriptTarget.ESNext */) {
+ if (assignmentKind !== 0 /* AssignmentKind.None */) {
+ checkExternalEmitHelpers(node, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */);
}
- if (assignmentKind !== 1 /* Definite */) {
- checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */);
+ if (assignmentKind !== 1 /* AssignmentKind.Definite */) {
+ checkExternalEmitHelpers(node, 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */);
}
}
var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right);
@@ -73252,8 +74609,8 @@ var ts;
return errorType;
}
else {
- var isSetonlyAccessor = prop && prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */);
- if (isSetonlyAccessor && assignmentKind !== 1 /* Definite */) {
+ var isSetonlyAccessor = prop && prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */);
+ if (isSetonlyAccessor && assignmentKind !== 1 /* AssignmentKind.Definite */) {
error(node, ts.Diagnostics.Private_accessor_was_defined_without_a_getter);
}
}
@@ -73269,15 +74626,20 @@ var ts;
prop = getPropertyOfType(apparentType, right.escapedText);
}
// In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums.
+ // `Foo` is also not referenced in `enum FooCopy { Bar = Foo.Bar }`, because the enum member value gets inlined
+ // here even if `Foo` is not a const enum.
+ //
// The exceptions are:
// 1. if 'isolatedModules' is enabled, because the const enum value will not be inlined, and
// 2. if 'preserveConstEnums' is enabled and the expression is itself an export, e.g. `export = Foo.Bar.Baz`.
- if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || !(prop && isConstEnumOrConstEnumOnlyModule(prop)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) {
+ if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules ||
+ !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* SymbolFlags.EnumMember */ && node.parent.kind === 299 /* SyntaxKind.EnumMember */)) ||
+ ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) {
markAliasReferenced(parentSymbol, node);
}
var propType;
if (!prop) {
- var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ?
+ var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* AssignmentKind.None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ?
getApplicableIndexInfoForName(apparentType, right.escapedText) : undefined;
if (!(indexInfo && indexInfo.type)) {
var isUncheckedJS = isUncheckedJSSuggestion(node, leftType.symbol, /*excludeClasses*/ true);
@@ -73285,7 +74647,7 @@ var ts;
return anyType;
}
if (leftType.symbol === globalThisSymbol) {
- if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* BlockScoped */)) {
+ if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* SymbolFlags.BlockScoped */)) {
error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(right.escapedText), typeToString(leftType));
}
else if (noImplicitAny) {
@@ -73305,6 +74667,9 @@ var ts;
if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
}
+ if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* NodeFlags.Deprecated */) {
+ addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
+ }
}
else {
if (isDeprecatedSymbol(prop) && isUncalledFunctionReference(node, prop) && prop.declarations) {
@@ -73314,7 +74679,7 @@ var ts;
markPropertyAsReferenced(prop, node, isSelfTypeAccess(left, parentSymbol));
getNodeLinks(node).resolvedSymbol = prop;
var writing = ts.isWriteAccess(node);
- checkPropertyAccessibility(node, left.kind === 106 /* SuperKeyword */, writing, apparentType, prop);
+ checkPropertyAccessibility(node, left.kind === 106 /* SyntaxKind.SuperKeyword */, writing, apparentType, prop);
if (isAssignmentToReadonlyEntity(node, prop, assignmentKind)) {
error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right));
return errorType;
@@ -73333,11 +74698,11 @@ var ts;
function isUncheckedJSSuggestion(node, suggestion, excludeClasses) {
var file = ts.getSourceFileOfNode(node);
if (file) {
- if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */)) {
+ if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */)) {
var declarationFile = ts.forEach(suggestion === null || suggestion === void 0 ? void 0 : suggestion.declarations, ts.getSourceFileOfNode);
return !(file !== declarationFile && !!declarationFile && isGlobalSourceFile(declarationFile))
- && !(excludeClasses && suggestion && suggestion.flags & 32 /* Class */)
- && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */);
+ && !(excludeClasses && suggestion && suggestion.flags & 32 /* SymbolFlags.Class */)
+ && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */);
}
}
return false;
@@ -73347,12 +74712,12 @@ var ts;
// assignment target, and the referenced property was declared as a variable, property,
// accessor, or optional method.
var assignmentKind = ts.getAssignmentTargetKind(node);
- if (assignmentKind === 1 /* Definite */) {
- return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* Optional */));
+ if (assignmentKind === 1 /* AssignmentKind.Definite */) {
+ return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* SymbolFlags.Optional */));
}
if (prop &&
- !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */))
- && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)
+ !(prop.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */ | 98304 /* SymbolFlags.Accessor */))
+ && !(prop.flags & 8192 /* SymbolFlags.Method */ && propType.flags & 1048576 /* TypeFlags.Union */)
&& !isDuplicatedCommonJSExport(prop.declarations)) {
return propType;
}
@@ -73365,12 +74730,12 @@ var ts;
// and if we are in a constructor of the same class as the property declaration, assume that
// the property is uninitialized at the top of the control flow.
var assumeUninitialized = false;
- if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */) {
+ if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) {
var declaration = prop && prop.valueDeclaration;
if (declaration && isPropertyWithoutInitializer(declaration)) {
if (!ts.isStatic(declaration)) {
var flowContainer = getControlFlowContainer(node);
- if (flowContainer.kind === 170 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) {
+ if (flowContainer.kind === 171 /* SyntaxKind.Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) {
assumeUninitialized = true;
}
}
@@ -73383,7 +74748,7 @@ var ts;
assumeUninitialized = true;
}
var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType);
- if (assumeUninitialized && !(getFalsyFlags(propType) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) {
+ if (assumeUninitialized && !(getFalsyFlags(propType) & 32768 /* TypeFlags.Undefined */) && getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */) {
error(errorNode, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); // TODO: GH#18217
// Return the declared type to reduce follow-on errors
return propType;
@@ -73401,12 +74766,13 @@ var ts;
&& !isOptionalPropertyDeclaration(valueDeclaration)
&& !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression))
&& !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)
+ && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* ModifierFlags.Static */)
&& (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) {
diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName);
}
- else if (valueDeclaration.kind === 256 /* ClassDeclaration */ &&
- node.parent.kind !== 177 /* TypeReference */ &&
- !(valueDeclaration.flags & 8388608 /* Ambient */) &&
+ else if (valueDeclaration.kind === 257 /* SyntaxKind.ClassDeclaration */ &&
+ node.parent.kind !== 178 /* SyntaxKind.TypeReference */ &&
+ !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */) &&
!isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
}
@@ -73417,25 +74783,25 @@ var ts;
function isInPropertyInitializerOrClassStaticBlock(node) {
return !!ts.findAncestor(node, function (node) {
switch (node.kind) {
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
return true;
- case 294 /* PropertyAssignment */:
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 296 /* SpreadAssignment */:
- case 161 /* ComputedPropertyName */:
- case 232 /* TemplateSpan */:
- case 287 /* JsxExpression */:
- case 284 /* JsxAttribute */:
- case 285 /* JsxAttributes */:
- case 286 /* JsxSpreadAttribute */:
- case 279 /* JsxOpeningElement */:
- case 227 /* ExpressionWithTypeArguments */:
- case 290 /* HeritageClause */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 298 /* SyntaxKind.SpreadAssignment */:
+ case 162 /* SyntaxKind.ComputedPropertyName */:
+ case 233 /* SyntaxKind.TemplateSpan */:
+ case 288 /* SyntaxKind.JsxExpression */:
+ case 285 /* SyntaxKind.JsxAttribute */:
+ case 286 /* SyntaxKind.JsxAttributes */:
+ case 287 /* SyntaxKind.JsxSpreadAttribute */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
+ case 291 /* SyntaxKind.HeritageClause */:
return false;
- case 213 /* ArrowFunction */:
- case 237 /* ExpressionStatement */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 238 /* SyntaxKind.ExpressionStatement */:
return ts.isBlock(node.parent) && ts.isClassStaticBlockDeclaration(node.parent.parent) ? true : "quit";
default:
return ts.isExpressionNode(node) ? false : "quit";
@@ -73447,7 +74813,7 @@ var ts;
* In that case we won't consider it used before its declaration, because it gets its value from the superclass' declaration.
*/
function isPropertyDeclaredInAncestorClass(prop) {
- if (!(prop.parent.flags & 32 /* Class */)) {
+ if (!(prop.parent.flags & 32 /* SymbolFlags.Class */)) {
return false;
}
var classType = getTypeOfSymbol(prop.parent);
@@ -73472,7 +74838,7 @@ var ts;
function reportNonexistentProperty(propNode, containingType, isUncheckedJS) {
var errorInfo;
var relatedInfo;
- if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) {
+ if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* TypeFlags.Union */ && !(containingType.flags & 131068 /* TypeFlags.Primitive */)) {
for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) {
var subtype = _a[_i];
if (!getPropertyOfType(subtype, propNode.escapedText) && !getApplicableIndexInfoForName(subtype, propNode.escapedText)) {
@@ -73560,7 +74926,7 @@ var ts;
}
}
function getSuggestedSymbolForNonexistentClassMember(name, baseType) {
- return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* ClassMember */);
+ return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* SymbolFlags.ClassMember */);
}
function getSuggestedSymbolForNonexistentProperty(name, containingType) {
var props = getPropertiesOfType(containingType);
@@ -73571,7 +74937,7 @@ var ts;
}
name = ts.idText(name);
}
- return getSpellingSuggestionForName(name, props, 111551 /* Value */);
+ return getSpellingSuggestionForName(name, props, 111551 /* SymbolFlags.Value */);
}
function getSuggestedSymbolForNonexistentJSXAttribute(name, containingType) {
var strName = ts.isString(name) ? name : ts.idText(name);
@@ -73579,7 +74945,7 @@ var ts;
var jsxSpecific = strName === "for" ? ts.find(properties, function (x) { return ts.symbolName(x) === "htmlFor"; })
: strName === "class" ? ts.find(properties, function (x) { return ts.symbolName(x) === "className"; })
: undefined;
- return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* Value */);
+ return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* SymbolFlags.Value */);
}
function getSuggestionForNonexistentProperty(name, containingType) {
var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType);
@@ -73598,7 +74964,7 @@ var ts;
var candidates;
if (symbols === globals) {
var primitives = ts.mapDefined(["string", "number", "boolean", "object", "bigint", "symbol"], function (s) { return symbols.has((s.charAt(0).toUpperCase() + s.slice(1)))
- ? createSymbol(524288 /* TypeAlias */, s)
+ ? createSymbol(524288 /* SymbolFlags.TypeAlias */, s)
: undefined; });
candidates = primitives.concat(ts.arrayFrom(symbols.values()));
}
@@ -73614,7 +74980,7 @@ var ts;
return symbolResult && ts.symbolName(symbolResult);
}
function getSuggestedSymbolForNonexistentModule(name, targetModule) {
- return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* ModuleMember */);
+ return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* SymbolFlags.ModuleMember */);
}
function getSuggestionForNonexistentExport(name, targetModule) {
var suggestion = getSuggestedSymbolForNonexistentModule(name, targetModule);
@@ -73645,7 +75011,7 @@ var ts;
return suggestion;
}
function getSuggestedTypeForNonexistentStringLiteralType(source, target) {
- var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* StringLiteral */); });
+ var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* TypeFlags.StringLiteral */); });
return ts.getSpellingSuggestion(source.value, candidates, function (type) { return type.value; });
}
/**
@@ -73673,7 +75039,7 @@ var ts;
if (candidate.flags & meaning) {
return candidateName;
}
- if (candidate.flags & 2097152 /* Alias */) {
+ if (candidate.flags & 2097152 /* SymbolFlags.Alias */) {
var alias = tryResolveAlias(candidate);
if (alias && alias.flags & meaning) {
return candidateName;
@@ -73683,16 +75049,16 @@ var ts;
}
}
function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isSelfTypeAccess) {
- var valueDeclaration = prop && (prop.flags & 106500 /* ClassMember */) && prop.valueDeclaration;
+ var valueDeclaration = prop && (prop.flags & 106500 /* SymbolFlags.ClassMember */) && prop.valueDeclaration;
if (!valueDeclaration) {
return;
}
- var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* Private */);
+ var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* ModifierFlags.Private */);
var hasPrivateIdentifier = prop.valueDeclaration && ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name);
if (!hasPrivateModifier && !hasPrivateIdentifier) {
return;
}
- if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SetAccessor */)) {
+ if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SymbolFlags.SetAccessor */)) {
return;
}
if (isSelfTypeAccess) {
@@ -73702,19 +75068,19 @@ var ts;
return;
}
}
- (ts.getCheckFlags(prop) & 1 /* Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* All */;
+ (ts.getCheckFlags(prop) & 1 /* CheckFlags.Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* SymbolFlags.All */;
}
function isSelfTypeAccess(name, parent) {
- return name.kind === 108 /* ThisKeyword */
+ return name.kind === 108 /* SyntaxKind.ThisKeyword */
|| !!parent && ts.isEntityNameExpression(name) && parent === getResolvedSymbol(ts.getFirstIdentifier(name));
}
function isValidPropertyAccess(node, propertyName) {
switch (node.kind) {
- case 205 /* PropertyAccessExpression */:
- return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression)));
- case 160 /* QualifiedName */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SyntaxKind.SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression)));
+ case 161 /* SyntaxKind.QualifiedName */:
return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left)));
- case 199 /* ImportType */:
+ case 200 /* SyntaxKind.ImportType */:
return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node));
}
}
@@ -73729,7 +75095,7 @@ var ts;
* @param property the accessed property's symbol.
*/
function isValidPropertyAccessForCompletions(node, type, property) {
- return isPropertyAccessible(node, node.kind === 205 /* PropertyAccessExpression */ && node.expression.kind === 106 /* SuperKeyword */,
+ return isPropertyAccessible(node, node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */,
/* isWrite */ false, type, property);
// Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context.
}
@@ -73769,13 +75135,13 @@ var ts;
*/
function getForInVariableSymbol(node) {
var initializer = node.initializer;
- if (initializer.kind === 254 /* VariableDeclarationList */) {
+ if (initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) {
var variable = initializer.declarations[0];
if (variable && !ts.isBindingPattern(variable.name)) {
return getSymbolOfNode(variable);
}
}
- else if (initializer.kind === 79 /* Identifier */) {
+ else if (initializer.kind === 79 /* SyntaxKind.Identifier */) {
return getResolvedSymbol(initializer);
}
return undefined;
@@ -73792,13 +75158,13 @@ var ts;
*/
function isForInVariableForNumericPropertyNames(expr) {
var e = ts.skipParentheses(expr);
- if (e.kind === 79 /* Identifier */) {
+ if (e.kind === 79 /* SyntaxKind.Identifier */) {
var symbol = getResolvedSymbol(e);
- if (symbol.flags & 3 /* Variable */) {
+ if (symbol.flags & 3 /* SymbolFlags.Variable */) {
var child = expr;
var node = expr.parent;
while (node) {
- if (node.kind === 242 /* ForInStatement */ &&
+ if (node.kind === 243 /* SyntaxKind.ForInStatement */ &&
child === node.statement &&
getForInVariableSymbol(node) === symbol &&
hasNumericPropertyNames(getTypeOfExpression(node.expression))) {
@@ -73812,7 +75178,7 @@ var ts;
return false;
}
function checkIndexedAccess(node, checkMode) {
- return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node, checkMode) :
+ return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkElementAccessChain(node, checkMode) :
checkElementAccessExpression(node, checkNonNullExpression(node.expression), checkMode);
}
function checkElementAccessChain(node, checkMode) {
@@ -73821,7 +75187,7 @@ var ts;
return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression), checkMode), node, nonOptionalType !== exprType);
}
function checkElementAccessExpression(node, exprType, checkMode) {
- var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
+ var objectType = ts.getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
var indexExpression = node.argumentExpression;
var indexType = checkExpression(indexExpression);
if (isErrorType(objectType) || objectType === silentNeverType) {
@@ -73833,8 +75199,8 @@ var ts;
}
var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
var accessFlags = ts.isAssignmentTarget(node) ?
- 4 /* Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) :
- 32 /* ExpressionPosition */;
+ 4 /* AccessFlags.Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* AccessFlags.NoIndexSignatures */ : 0) :
+ 32 /* AccessFlags.ExpressionPosition */;
var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType;
return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node);
}
@@ -73847,13 +75213,13 @@ var ts;
// This gets us diagnostics for the type arguments and marks them as referenced.
ts.forEach(node.typeArguments, checkSourceElement);
}
- if (node.kind === 209 /* TaggedTemplateExpression */) {
+ if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) {
checkExpression(node.template);
}
else if (ts.isJsxOpeningLikeElement(node)) {
checkExpression(node.attributes);
}
- else if (node.kind !== 164 /* Decorator */) {
+ else if (node.kind !== 165 /* SyntaxKind.Decorator */) {
ts.forEach(node.arguments, function (argument) {
checkExpression(argument);
});
@@ -73917,16 +75283,16 @@ var ts;
}
}
function isSpreadArgument(arg) {
- return !!arg && (arg.kind === 224 /* SpreadElement */ || arg.kind === 231 /* SyntheticExpression */ && arg.isSpread);
+ return !!arg && (arg.kind === 225 /* SyntaxKind.SpreadElement */ || arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.isSpread);
}
function getSpreadArgumentIndex(args) {
return ts.findIndex(args, isSpreadArgument);
}
function acceptsVoid(t) {
- return !!(t.flags & 16384 /* Void */);
+ return !!(t.flags & 16384 /* TypeFlags.Void */);
}
function acceptsVoidUndefinedUnknownOrAny(t) {
- return !!(t.flags & (16384 /* Void */ | 32768 /* Undefined */ | 2 /* Unknown */ | 1 /* Any */));
+ return !!(t.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 2 /* TypeFlags.Unknown */ | 1 /* TypeFlags.Any */));
}
function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) {
if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; }
@@ -73934,9 +75300,9 @@ var ts;
var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments
var effectiveParameterCount = getParameterCount(signature);
var effectiveMinimumArguments = getMinArgumentCount(signature);
- if (node.kind === 209 /* TaggedTemplateExpression */) {
+ if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) {
argCount = args.length;
- if (node.template.kind === 222 /* TemplateExpression */) {
+ if (node.template.kind === 223 /* SyntaxKind.TemplateExpression */) {
// If a tagged template expression lacks a tail literal, the call is incomplete.
// Specifically, a template only can end in a TemplateTail or a Missing literal.
var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span.
@@ -73947,11 +75313,11 @@ var ts;
// then this might actually turn out to be a TemplateHead in the future;
// so we consider the call to be incomplete.
var templateLiteral = node.template;
- ts.Debug.assert(templateLiteral.kind === 14 /* NoSubstitutionTemplateLiteral */);
+ ts.Debug.assert(templateLiteral.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */);
callIsIncomplete = !!templateLiteral.isUnterminated;
}
}
- else if (node.kind === 164 /* Decorator */) {
+ else if (node.kind === 165 /* SyntaxKind.Decorator */) {
argCount = getDecoratorArgumentCount(node, signature);
}
else if (ts.isJsxOpeningLikeElement(node)) {
@@ -73965,7 +75331,7 @@ var ts;
}
else if (!node.arguments) {
// This only happens when we have something of the form: 'new C'
- ts.Debug.assert(node.kind === 208 /* NewExpression */);
+ ts.Debug.assert(node.kind === 209 /* SyntaxKind.NewExpression */);
return getMinArgumentCount(signature) === 0;
}
else {
@@ -73989,7 +75355,7 @@ var ts;
}
for (var i = argCount; i < effectiveMinimumArguments; i++) {
var type = getTypeAtPosition(signature, i);
- if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* Never */) {
+ if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* TypeFlags.Never */) {
return false;
}
}
@@ -74005,20 +75371,20 @@ var ts;
}
// If type has a single call signature and no other members, return that signature. Otherwise, return undefined.
function getSingleCallSignature(type) {
- return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false);
+ return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false);
}
function getSingleCallOrConstructSignature(type) {
- return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false) ||
- getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ false);
+ return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false) ||
+ getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ false);
}
function getSingleSignature(type, kind, allowMembers) {
- if (type.flags & 524288 /* Object */) {
+ if (type.flags & 524288 /* TypeFlags.Object */) {
var resolved = resolveStructuredTypeMembers(type);
if (allowMembers || resolved.properties.length === 0 && resolved.indexInfos.length === 0) {
- if (kind === 0 /* Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) {
+ if (kind === 0 /* SignatureKind.Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) {
return resolved.callSignatures[0];
}
- if (kind === 1 /* Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) {
+ if (kind === 1 /* SignatureKind.Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) {
return resolved.constructSignatures[0];
}
}
@@ -74027,12 +75393,12 @@ var ts;
}
// Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec)
function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) {
- var context = createInferenceContext(signature.typeParameters, signature, 0 /* None */, compareTypes);
+ var context = createInferenceContext(signature.typeParameters, signature, 0 /* InferenceFlags.None */, compareTypes);
// We clone the inferenceContext to avoid fixing. For example, when the source signature is <T>(x: T) => T[] and
// the contextual signature is (...args: A) => B, we want to infer the element type of A's constraint (say 'any')
// for T but leave it possible to later infer '[any]' back to A.
var restType = getEffectiveRestType(contextualSignature);
- var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper);
+ var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper);
var sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature;
applyToParameterTypes(sourceSignature, signature, function (source, target) {
// Type parameters from outer context referenced by source type are fixed by instantiation of the source type
@@ -74040,7 +75406,7 @@ var ts;
});
if (!inferenceContext) {
applyToReturnTypes(contextualSignature, signature, function (source, target) {
- inferTypes(context.inferences, source, target, 128 /* ReturnType */);
+ inferTypes(context.inferences, source, target, 128 /* InferencePriority.ReturnType */);
});
}
return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration));
@@ -74068,71 +75434,75 @@ var ts;
// example, given a 'function wrap<T, U>(cb: (x: T) => U): (x: T) => U' and a call expression
// 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the
// return type of 'wrap'.
- if (node.kind !== 164 /* Decorator */) {
- var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */);
+ if (node.kind !== 165 /* SyntaxKind.Decorator */) {
+ var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* ContextFlags.SkipBindingPatterns */ : 0 /* ContextFlags.None */);
if (contextualType) {
- // We clone the inference context to avoid disturbing a resolution in progress for an
- // outer call expression. Effectively we just want a snapshot of whatever has been
- // inferred for any outer call expression so far.
- var outerContext = getInferenceContext(node);
- var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
- var instantiatedType = instantiateType(contextualType, outerMapper);
- // If the contextual type is a generic function type with a single call signature, we
- // instantiate the type with its own type parameters and type arguments. This ensures that
- // the type parameters are not erased to type any during type inference such that they can
- // be inferred as actual types from the contextual type. For example:
- // declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
- // const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
- // Above, the type of the 'value' parameter is inferred to be 'A'.
- var contextualSignature = getSingleCallSignature(instantiatedType);
- var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
- getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
- instantiatedType;
var inferenceTargetType = getReturnTypeOfSignature(signature);
- // Inferences made from return types have lower priority than all other inferences.
- inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
- // Create a type mapper for instantiating generic contextual types using the inferences made
- // from the return type. We need a separate inference pass here because (a) instantiation of
- // the source type uses the outer context's return mapper (which excludes inferences made from
- // outer arguments), and (b) we don't want any further inferences going into this context.
- var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
- var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
- inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
- context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined;
+ if (couldContainTypeVariables(inferenceTargetType)) {
+ // We clone the inference context to avoid disturbing a resolution in progress for an
+ // outer call expression. Effectively we just want a snapshot of whatever has been
+ // inferred for any outer call expression so far.
+ var outerContext = getInferenceContext(node);
+ var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* InferenceFlags.NoDefault */));
+ var instantiatedType = instantiateType(contextualType, outerMapper);
+ // If the contextual type is a generic function type with a single call signature, we
+ // instantiate the type with its own type parameters and type arguments. This ensures that
+ // the type parameters are not erased to type any during type inference such that they can
+ // be inferred as actual types from the contextual type. For example:
+ // declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
+ // const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
+ // Above, the type of the 'value' parameter is inferred to be 'A'.
+ var contextualSignature = getSingleCallSignature(instantiatedType);
+ var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
+ getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
+ instantiatedType;
+ // Inferences made from return types have lower priority than all other inferences.
+ inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* InferencePriority.ReturnType */);
+ // Create a type mapper for instantiating generic contextual types using the inferences made
+ // from the return type. We need a separate inference pass here because (a) instantiation of
+ // the source type uses the outer context's return mapper (which excludes inferences made from
+ // outer arguments), and (b) we don't want any further inferences going into this context.
+ var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
+ var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
+ inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
+ context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined;
+ }
}
}
var restType = getNonArrayRestType(signature);
var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length;
- if (restType && restType.flags & 262144 /* TypeParameter */) {
+ if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) {
var info = ts.find(context.inferences, function (info) { return info.typeParameter === restType; });
if (info) {
info.impliedArity = ts.findIndex(args, isSpreadArgument, argCount) < 0 ? args.length - argCount : undefined;
}
}
var thisType = getThisTypeOfSignature(signature);
- if (thisType) {
+ if (thisType && couldContainTypeVariables(thisType)) {
var thisArgumentNode = getThisArgumentOfCall(node);
inferTypes(context.inferences, getThisArgumentType(thisArgumentNode), thisType);
}
for (var i = 0; i < argCount; i++) {
var arg = args[i];
- if (arg.kind !== 226 /* OmittedExpression */) {
+ if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */ && !(checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
var paramType = getTypeAtPosition(signature, i);
- var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
- inferTypes(context.inferences, argType, paramType);
+ if (couldContainTypeVariables(paramType)) {
+ var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
+ inferTypes(context.inferences, argType, paramType);
+ }
}
}
- if (restType) {
+ if (restType && couldContainTypeVariables(restType)) {
var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, context, checkMode);
inferTypes(context.inferences, spreadType, restType);
}
return getInferredTypes(context);
}
function getMutableArrayOrTupleType(type) {
- return type.flags & 1048576 /* Union */ ? mapType(type, getMutableArrayOrTupleType) :
- type.flags & 1 /* Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type :
+ return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getMutableArrayOrTupleType) :
+ type.flags & 1 /* TypeFlags.Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type :
isTupleType(type) ? createTupleType(getTypeArguments(type), type.target.elementFlags, /*readonly*/ false, type.target.labeledElementDeclarations) :
- createTupleType([type], [8 /* Variadic */]);
+ createTupleType([type], [8 /* ElementFlags.Variadic */]);
}
function getSpreadArgumentType(args, index, argCount, restType, context, checkMode) {
if (index >= argCount - 1) {
@@ -74140,7 +75510,7 @@ var ts;
if (isSpreadArgument(arg)) {
// We are inferring from a spread expression in the last argument position, i.e. both the parameter
// and the argument are ...x forms.
- return getMutableArrayOrTupleType(arg.kind === 231 /* SyntheticExpression */ ? arg.type :
+ return getMutableArrayOrTupleType(arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type :
checkExpressionWithContextualType(arg.expression, restType, context, checkMode));
}
}
@@ -74150,24 +75520,24 @@ var ts;
for (var i = index; i < argCount; i++) {
var arg = args[i];
if (isSpreadArgument(arg)) {
- var spreadType = arg.kind === 231 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression);
+ var spreadType = arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpression(arg.expression);
if (isArrayLikeType(spreadType)) {
types.push(spreadType);
- flags.push(8 /* Variadic */);
+ flags.push(8 /* ElementFlags.Variadic */);
}
else {
- types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 224 /* SpreadElement */ ? arg.expression : arg));
- flags.push(4 /* Rest */);
+ types.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, arg.kind === 225 /* SyntaxKind.SpreadElement */ ? arg.expression : arg));
+ flags.push(4 /* ElementFlags.Rest */);
}
}
else {
- var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* Contextual */);
+ var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* AccessFlags.Contextual */);
var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode);
- var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */);
+ var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */);
types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType));
- flags.push(1 /* Required */);
+ flags.push(1 /* ElementFlags.Required */);
}
- if (arg.kind === 231 /* SyntheticExpression */ && arg.tupleNameSource) {
+ if (arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.tupleNameSource) {
names.push(arg.tupleNameSource);
}
}
@@ -74197,16 +75567,16 @@ var ts;
}
function getJsxReferenceKind(node) {
if (isJsxIntrinsicIdentifier(node.tagName)) {
- return 2 /* Mixed */;
+ return 2 /* JsxReferenceKind.Mixed */;
}
var tagType = getApparentType(checkExpression(node.tagName));
- if (ts.length(getSignaturesOfType(tagType, 1 /* Construct */))) {
- return 0 /* Component */;
+ if (ts.length(getSignaturesOfType(tagType, 1 /* SignatureKind.Construct */))) {
+ return 0 /* JsxReferenceKind.Component */;
}
- if (ts.length(getSignaturesOfType(tagType, 0 /* Call */))) {
- return 1 /* Function */;
+ if (ts.length(getSignaturesOfType(tagType, 0 /* SignatureKind.Call */))) {
+ return 1 /* JsxReferenceKind.Function */;
}
- return 2 /* Mixed */;
+ return 2 /* JsxReferenceKind.Mixed */;
}
/**
* Check if the given signature can possibly be a signature called by the JSX opening-like element.
@@ -74231,7 +75601,7 @@ var ts;
if (!tagType) {
return true;
}
- var tagCallSignatures = getSignaturesOfType(tagType, 0 /* Call */);
+ var tagCallSignatures = getSignaturesOfType(tagType, 0 /* SignatureKind.Call */);
if (!ts.length(tagCallSignatures)) {
return true;
}
@@ -74239,12 +75609,12 @@ var ts;
if (!factory) {
return true;
}
- var factorySymbol = resolveEntityName(factory, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node);
+ var factorySymbol = resolveEntityName(factory, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node);
if (!factorySymbol) {
return true;
}
var factoryType = getTypeOfSymbol(factorySymbol);
- var callSignatures = getSignaturesOfType(factoryType, 0 /* Call */);
+ var callSignatures = getSignaturesOfType(factoryType, 0 /* SignatureKind.Call */);
if (!ts.length(callSignatures)) {
return true;
}
@@ -74254,7 +75624,7 @@ var ts;
for (var _i = 0, callSignatures_1 = callSignatures; _i < callSignatures_1.length; _i++) {
var sig = callSignatures_1[_i];
var firstparam = getTypeAtPosition(sig, 0);
- var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* Call */);
+ var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* SignatureKind.Call */);
if (!ts.length(signaturesOfParam))
continue;
for (var _b = 0, signaturesOfParam_1 = signaturesOfParam; _b < signaturesOfParam_1.length; _b++) {
@@ -74311,7 +75681,7 @@ var ts;
return undefined;
}
var thisType = getThisTypeOfSignature(signature);
- if (thisType && thisType !== voidType && node.kind !== 208 /* NewExpression */) {
+ if (thisType && thisType !== voidType && node.kind !== 209 /* SyntaxKind.NewExpression */) {
// If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType
// If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible.
// If the expression is a new expression, then the check is skipped.
@@ -74329,13 +75699,13 @@ var ts;
var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length;
for (var i = 0; i < argCount; i++) {
var arg = args[i];
- if (arg.kind !== 226 /* OmittedExpression */) {
+ if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */) {
var paramType = getTypeAtPosition(signature, i);
var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode);
// If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive),
// we obtain the regular type of any object literal arguments because we may not have inferred complete
// parameter types yet and therefore excess property checks may yield false positives (see #17041).
- var checkArgType = checkMode & 4 /* SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType;
+ var checkArgType = checkMode & 4 /* CheckMode.SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType;
if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) {
ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors");
maybeAddMissingAwaitInfo(arg, checkArgType, paramType);
@@ -74374,8 +75744,8 @@ var ts;
* Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise.
*/
function getThisArgumentOfCall(node) {
- var expression = node.kind === 207 /* CallExpression */ ? node.expression :
- node.kind === 209 /* TaggedTemplateExpression */ ? node.tag : undefined;
+ var expression = node.kind === 208 /* SyntaxKind.CallExpression */ ? node.expression :
+ node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */ ? node.tag : undefined;
if (expression) {
var callee = ts.skipOuterExpressions(expression);
if (ts.isAccessExpression(callee)) {
@@ -74393,17 +75763,17 @@ var ts;
* Returns the effective arguments for an expression that works like a function invocation.
*/
function getEffectiveCallArguments(node) {
- if (node.kind === 209 /* TaggedTemplateExpression */) {
+ if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) {
var template = node.template;
var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())];
- if (template.kind === 222 /* TemplateExpression */) {
+ if (template.kind === 223 /* SyntaxKind.TemplateExpression */) {
ts.forEach(template.templateSpans, function (span) {
args_3.push(span.expression);
});
}
return args_3;
}
- if (node.kind === 164 /* Decorator */) {
+ if (node.kind === 165 /* SyntaxKind.Decorator */) {
return getEffectiveDecoratorArguments(node);
}
if (ts.isJsxOpeningLikeElement(node)) {
@@ -74414,15 +75784,15 @@ var ts;
if (spreadIndex >= 0) {
// Create synthetic arguments from spreads of tuple types.
var effectiveArgs_1 = args.slice(0, spreadIndex);
- var _loop_23 = function (i) {
+ var _loop_24 = function (i) {
var arg = args[i];
// We can call checkExpressionCached because spread expressions never have a contextual type.
- var spreadType = arg.kind === 224 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
+ var spreadType = arg.kind === 225 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
if (spreadType && isTupleType(spreadType)) {
ts.forEach(getTypeArguments(spreadType), function (t, i) {
var _a;
var flags = spreadType.target.elementFlags[i];
- var syntheticArg = createSyntheticExpression(arg, flags & 4 /* Rest */ ? createArrayType(t) : t, !!(flags & 12 /* Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]);
+ var syntheticArg = createSyntheticExpression(arg, flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t, !!(flags & 12 /* ElementFlags.Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]);
effectiveArgs_1.push(syntheticArg);
});
}
@@ -74431,7 +75801,7 @@ var ts;
}
};
for (var i = spreadIndex; i < args.length; i++) {
- _loop_23(i);
+ _loop_24(i);
}
return effectiveArgs_1;
}
@@ -74444,30 +75814,30 @@ var ts;
var parent = node.parent;
var expr = node.expression;
switch (parent.kind) {
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
// For a class decorator, the `target` is the type of the class (e.g. the
// "static" or "constructor" side of the class).
return [
createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent)))
];
- case 163 /* Parameter */:
+ case 164 /* SyntaxKind.Parameter */:
// A parameter declaration decorator will have three arguments (see
// `ParameterDecorator` in core.d.ts).
var func = parent.parent;
return [
- createSyntheticExpression(expr, parent.parent.kind === 170 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType),
+ createSyntheticExpression(expr, parent.parent.kind === 171 /* SyntaxKind.Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType),
createSyntheticExpression(expr, anyType),
createSyntheticExpression(expr, numberType)
];
- case 166 /* PropertyDeclaration */:
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
// A method or accessor declaration decorator will have two or three arguments (see
// `PropertyDecorator` and `MethodDecorator` in core.d.ts). If we are emitting decorators
// for ES3, we will only pass two arguments.
- var hasPropDesc = parent.kind !== 166 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */;
+ var hasPropDesc = parent.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && languageVersion !== 0 /* ScriptTarget.ES3 */;
return [
createSyntheticExpression(expr, getParentTypeOfClassElement(parent)),
createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)),
@@ -74481,17 +75851,17 @@ var ts;
*/
function getDecoratorArgumentCount(node, signature) {
switch (node.parent.kind) {
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
return 1;
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
return 2;
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
// For ES3 or decorators with only two parameters we supply only two arguments
- return languageVersion === 0 /* ES3 */ || signature.parameters.length <= 2 ? 2 : 3;
- case 163 /* Parameter */:
+ return languageVersion === 0 /* ScriptTarget.ES3 */ || signature.parameters.length <= 2 ? 2 : 3;
+ case 164 /* SyntaxKind.Parameter */:
return 3;
default:
return ts.Debug.fail();
@@ -74525,7 +75895,7 @@ var ts;
function isPromiseResolveArityError(node) {
if (!ts.isCallExpression(node) || !ts.isIdentifier(node.expression))
return false;
- var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, undefined, undefined, false);
+ var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, undefined, undefined, false);
var decl = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration;
if (!decl || !ts.isParameter(decl) || !ts.isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) {
return false;
@@ -74567,8 +75937,14 @@ var ts;
var parameterRange = hasRestParameter ? min
: min < max ? min + "-" + max
: min;
- var error = hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1
- : parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise
+ var isVoidPromiseError = !hasRestParameter && parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node);
+ if (isVoidPromiseError && ts.isInJSFile(node)) {
+ return getDiagnosticForCallNode(node, ts.Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments);
+ }
+ var error = hasRestParameter
+ ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1
+ : isVoidPromiseError
+ ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise
: ts.Diagnostics.Expected_0_arguments_but_got_1;
if (min < args.length && args.length < max) {
// between min and max, but with no matching overload
@@ -74627,15 +76003,15 @@ var ts;
return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
}
function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) {
- var isTaggedTemplate = node.kind === 209 /* TaggedTemplateExpression */;
- var isDecorator = node.kind === 164 /* Decorator */;
+ var isTaggedTemplate = node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */;
+ var isDecorator = node.kind === 165 /* SyntaxKind.Decorator */;
var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
- var reportErrors = !candidatesOutArray && produceDiagnostics;
+ var reportErrors = !candidatesOutArray;
var typeArguments;
if (!isDecorator) {
typeArguments = node.typeArguments;
// We already perform checking on the type arguments on the class declaration itself.
- if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SuperKeyword */) {
+ if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) {
ts.forEach(typeArguments, checkSourceElement);
}
}
@@ -74662,7 +76038,8 @@ var ts;
// For a decorator, no arguments are susceptible to contextual typing due to the fact
// decorators are applied to a declaration by the emitter, and not to an expression.
var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
- var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
+ var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* CheckMode.SkipContextSensitive */ : 0 /* CheckMode.Normal */;
+ argCheckMode |= checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */;
// The following variables are captured and modified by calls to chooseOverload.
// If overload resolution or type argument inference fails, we want to report the
// best error possible. The best error is one which says that an argument was not
@@ -74690,7 +76067,7 @@ var ts;
var result;
// If we are in signature help, a trailing comma indicates that we intend to provide another argument,
// so we will only accept overloads with arity at least 1 higher than the current number of provided arguments.
- var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 207 /* CallExpression */ && node.arguments.hasTrailingComma;
+ var signatureHelpTrailingComma = !!(checkMode & 16 /* CheckMode.IsForSignatureHelp */) && node.kind === 208 /* SyntaxKind.CallExpression */ && node.arguments.hasTrailingComma;
// Section 4.12.1:
// if the candidate list contains one or more signatures for which the type of each argument
// expression is a subtype of each corresponding parameter type, the return type of the first
@@ -74723,7 +76100,7 @@ var ts;
chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.The_last_overload_gave_the_following_error);
chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.No_overload_matches_this_call);
}
- var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, function () { return chain_1; });
+ var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, function () { return chain_1; });
if (diags) {
for (var _i = 0, diags_1 = diags; _i < diags_1.length; _i++) {
var d = diags_1[_i];
@@ -74744,9 +76121,9 @@ var ts;
var min_3 = Number.MAX_VALUE;
var minIndex = 0;
var i_1 = 0;
- var _loop_24 = function (c) {
+ var _loop_25 = function (c) {
var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ 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 /* Normal */, /*reportErrors*/ true, chain_2);
+ var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2);
if (diags_2) {
if (diags_2.length <= min_3) {
min_3 = diags_2.length;
@@ -74762,7 +76139,7 @@ var ts;
};
for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
var c = candidatesForArgumentError_1[_a];
- _loop_24(c);
+ _loop_25(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");
@@ -74801,7 +76178,7 @@ var ts;
}
}
}
- return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
+ return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
function addImplementationSuccessElaboration(failed, diagnostic) {
var _a, _b;
var oldCandidatesForArgumentError = candidatesForArgumentError;
@@ -74831,7 +76208,7 @@ var ts;
if (ts.some(typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) {
return undefined;
}
- if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) {
+ if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* CheckMode.Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) {
candidatesForArgumentError = [candidate];
return undefined;
}
@@ -74854,9 +76231,9 @@ var ts;
}
}
else {
- inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */);
- typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* SkipGenericFunctions */, inferenceContext);
- argCheckMode |= inferenceContext.flags & 4 /* SkippedGenericFunction */ ? 8 /* SkipGenericFunctions */ : 0 /* Normal */;
+ inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */);
+ typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext);
+ argCheckMode |= inferenceContext.flags & 4 /* InferenceFlags.SkippedGenericFunction */ ? 8 /* CheckMode.SkipGenericFunctions */ : 0 /* CheckMode.Normal */;
}
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
// If the original signature has a generic rest type, instantiation may produce a
@@ -74878,7 +76255,7 @@ var ts;
// If one or more context sensitive arguments were excluded, we start including
// them now (and keeping do so for any subsequent candidates) and perform a second
// round of type inference and applicability checking for this particular candidate.
- argCheckMode = 0 /* Normal */;
+ argCheckMode = checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */;
if (inferenceContext) {
var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
@@ -74902,14 +76279,14 @@ var ts;
}
}
// No signature was applicable. We have already reported the errors for the invalid signature.
- function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray) {
+ function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray, checkMode) {
ts.Debug.assert(candidates.length > 0); // Else should not have called this.
checkNodeDeferred(node);
// Normally we will combine overloads. Skip this if they have type parameters since that's hard to combine.
// Don't do this if there is a `candidatesOutArray`,
// because then we want the chosen best candidate to be one of the overloads, not a combination.
return hasCandidatesOutArray || candidates.length === 1 || candidates.some(function (c) { return !!c.typeParameters; })
- ? pickLongestCandidateSignature(node, candidates, args)
+ ? pickLongestCandidateSignature(node, candidates, args, checkMode)
: createUnionOfSignaturesForOverloadFailure(candidates);
}
function createUnionOfSignaturesForOverloadFailure(candidates) {
@@ -74920,7 +76297,7 @@ var ts;
}
var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
var parameters = [];
- var _loop_25 = function (i) {
+ var _loop_26 = 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; });
@@ -74928,17 +76305,17 @@ var ts;
parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
};
for (var i = 0; i < maxNonRestParam; i++) {
- _loop_25(i);
+ _loop_26(i);
}
var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
- var flags = 0 /* None */;
+ var flags = 0 /* SignatureFlags.None */;
if (restParameterSymbols.length !== 0) {
- var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* Subtype */));
+ var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* UnionReduction.Subtype */));
parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type));
- flags |= 1 /* HasRestParameter */;
+ flags |= 1 /* SignatureFlags.HasRestParameter */;
}
if (candidates.some(signatureHasLiteralTypes)) {
- flags |= 2 /* HasLiteralTypes */;
+ flags |= 2 /* SignatureFlags.HasLiteralTypes */;
}
return createSignature(candidates[0].declaration,
/*typeParameters*/ undefined, // Before calling this we tested for `!candidates.some(c => !!c.typeParameters)`.
@@ -74951,13 +76328,13 @@ var ts;
return signatureHasRestParameter(signature) ? numParams - 1 : numParams;
}
function createCombinedSymbolFromTypes(sources, types) {
- return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* Subtype */));
+ return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* UnionReduction.Subtype */));
}
function createCombinedSymbolForOverloadFailure(sources, type) {
// This function is currently only used for erroneous overloads, so it's good enough to just use the first source.
return createSymbolWithType(ts.first(sources), type);
}
- function pickLongestCandidateSignature(node, candidates, args) {
+ function pickLongestCandidateSignature(node, candidates, args, checkMode) {
// Pick the longest signature. This way we can get a contextual type for cases like:
// declare function f(a: { xa: number; xb: number; }, b: number);
// f({ |
@@ -74973,7 +76350,7 @@ var ts;
var typeArgumentNodes = callLikeExpressionMayHaveTypeArguments(node) ? node.typeArguments : undefined;
var instantiated = typeArgumentNodes
? createSignatureInstantiation(candidate, getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, ts.isInJSFile(node)))
- : inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args);
+ : inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode);
candidates[bestIndex] = instantiated;
return instantiated;
}
@@ -74987,9 +76364,9 @@ var ts;
}
return typeArguments;
}
- function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args) {
- var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */);
- var typeArgumentTypes = inferTypeArguments(node, candidate, args, 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext);
+ function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode) {
+ var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */);
+ var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* CheckMode.SkipContextSensitive */ | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext);
return createSignatureInstantiation(candidate, typeArgumentTypes);
}
function getLongestCandidateIndex(candidates, argsCount) {
@@ -75009,7 +76386,7 @@ var ts;
return maxParamsIndex;
}
function resolveCallExpression(node, candidatesOutArray, checkMode) {
- if (node.expression.kind === 106 /* SuperKeyword */) {
+ if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) {
var superType = checkSuperExpression(node.expression);
if (isTypeAny(superType)) {
for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) {
@@ -75024,7 +76401,7 @@ var ts;
var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
if (baseTypeNode) {
var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode);
- return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* None */);
+ return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */);
}
}
return resolveUntypedCall(node);
@@ -75033,13 +76410,13 @@ var ts;
var funcType = checkExpression(node.expression);
if (ts.isCallChain(node)) {
var nonOptionalType = getOptionalExpressionType(funcType, node.expression);
- callChainFlags = nonOptionalType === funcType ? 0 /* None */ :
- ts.isOutermostOptionalChain(node) ? 16 /* IsOuterCallChain */ :
- 8 /* IsInnerCallChain */;
+ callChainFlags = nonOptionalType === funcType ? 0 /* SignatureFlags.None */ :
+ ts.isOutermostOptionalChain(node) ? 16 /* SignatureFlags.IsOuterCallChain */ :
+ 8 /* SignatureFlags.IsInnerCallChain */;
funcType = nonOptionalType;
}
else {
- callChainFlags = 0 /* None */;
+ callChainFlags = 0 /* SignatureFlags.None */;
}
funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError);
if (funcType === silentNeverType) {
@@ -75054,8 +76431,8 @@ var ts;
// but we are not including call signatures that may have been added to the Object or
// Function interface, since they have none by default. This is a bit of a leap of faith
// that the user will not add any.
- var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */);
- var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length;
+ var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */);
+ var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length;
// TS 1.0 Spec: 4.12
// In an untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual
// types are provided for the argument expressions, and the result is always of type Any.
@@ -75082,7 +76459,7 @@ var ts;
relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.Are_you_missing_a_semicolon);
}
}
- invocationError(node.expression, apparentType, 0 /* Call */, relatedInformation);
+ invocationError(node.expression, apparentType, 0 /* SignatureKind.Call */, relatedInformation);
}
return resolveErrorCall(node);
}
@@ -75098,7 +76475,7 @@ var ts;
// use the resolvingSignature singleton to indicate that we deferred processing. This result will be
// propagated out and eventually turned into nonInferrableType (a type that is assignable to anything and
// from which we never make inferences).
- if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
+ if (checkMode & 8 /* CheckMode.SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
skippedGenericFunction(node, checkMode);
return resolvingSignature;
}
@@ -75119,11 +76496,11 @@ var ts;
*/
function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
// We exclude union types because we may have a union of function types that happen to have no common signatures.
- return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) ||
- !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType);
+ return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeFlags.TypeParameter */) ||
+ !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* TypeFlags.Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(funcType, globalFunctionType);
}
function resolveNewExpression(node, candidatesOutArray, checkMode) {
- if (node.arguments && languageVersion < 1 /* ES5 */) {
+ if (node.arguments && languageVersion < 1 /* ScriptTarget.ES5 */) {
var spreadIndex = getSpreadArgumentIndex(node.arguments);
if (spreadIndex >= 0) {
error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher);
@@ -75156,7 +76533,7 @@ var ts;
// but we are not including construct signatures that may have been added to the Object or
// Function interface, since they have none by default. This is a bit of a leap of faith
// that the user will not add any.
- var constructSignatures = getSignaturesOfType(expressionType, 1 /* Construct */);
+ var constructSignatures = getSignaturesOfType(expressionType, 1 /* SignatureKind.Construct */);
if (constructSignatures.length) {
if (!isConstructorAccessible(node, constructSignatures[0])) {
return resolveErrorCall(node);
@@ -75165,24 +76542,24 @@ var ts;
// then it cannot be instantiated.
// In the case of a merged class-module or class-interface declaration,
// only the class declaration node will have the Abstract flag set.
- if (constructSignatures.some(function (signature) { return signature.flags & 4 /* Abstract */; })) {
+ if (someSignature(constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); })) {
error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class);
return resolveErrorCall(node);
}
var valueDecl = expressionType.symbol && ts.getClassLikeDeclarationOfSymbol(expressionType.symbol);
- if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* Abstract */)) {
+ if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* ModifierFlags.Abstract */)) {
error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class);
return resolveErrorCall(node);
}
- return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* None */);
+ return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */);
}
// If expressionType's apparent type is an object type with no construct signatures but
// one or more call signatures, the expression is processed as a function call. A compile-time
// error occurs if the result of the function call is not Void. The type of the result of the
// operation is Any. It is an error to have a Void this type.
- var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */);
+ var callSignatures = getSignaturesOfType(expressionType, 0 /* SignatureKind.Call */);
if (callSignatures.length) {
- var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */);
+ var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */);
if (!noImplicitAny) {
if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
@@ -75193,16 +76570,22 @@ var ts;
}
return signature;
}
- invocationError(node.expression, expressionType, 1 /* Construct */);
+ invocationError(node.expression, expressionType, 1 /* SignatureKind.Construct */);
return resolveErrorCall(node);
}
+ function someSignature(signatures, f) {
+ if (ts.isArray(signatures)) {
+ return ts.some(signatures, function (signature) { return someSignature(signature, f); });
+ }
+ return signatures.compositeKind === 1048576 /* TypeFlags.Union */ ? ts.some(signatures.compositeSignatures, f) : f(signatures);
+ }
function typeHasProtectedAccessibleBase(target, type) {
var baseTypes = getBaseTypes(type);
if (!ts.length(baseTypes)) {
return false;
}
var firstBase = baseTypes[0];
- if (firstBase.flags & 2097152 /* Intersection */) {
+ if (firstBase.flags & 2097152 /* TypeFlags.Intersection */) {
var types = firstBase.types;
var mixinFlags = findMixins(types);
var i = 0;
@@ -75210,7 +76593,7 @@ var ts;
var intersectionMember = _a[_i];
// We want to ignore mixin ctors
if (!mixinFlags[i]) {
- if (ts.getObjectFlags(intersectionMember) & (1 /* Class */ | 2 /* Interface */)) {
+ if (ts.getObjectFlags(intersectionMember) & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) {
if (intersectionMember.symbol === target) {
return true;
}
@@ -75233,9 +76616,9 @@ var ts;
return true;
}
var declaration = signature.declaration;
- var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */);
+ var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */);
// (1) Public constructors and (2) constructor functions are always accessible.
- if (!modifiers || declaration.kind !== 170 /* Constructor */) {
+ if (!modifiers || declaration.kind !== 171 /* SyntaxKind.Constructor */) {
return true;
}
var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol);
@@ -75243,16 +76626,16 @@ var ts;
// A private or protected constructor can only be instantiated within its own class (or a subclass, for protected)
if (!isNodeWithinClass(node, declaringClassDeclaration)) {
var containingClass = ts.getContainingClass(node);
- if (containingClass && modifiers & 16 /* Protected */) {
+ if (containingClass && modifiers & 16 /* ModifierFlags.Protected */) {
var containingType = getTypeOfNode(containingClass);
if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType)) {
return true;
}
}
- if (modifiers & 8 /* Private */) {
+ if (modifiers & 8 /* ModifierFlags.Private */) {
error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass));
}
- if (modifiers & 16 /* Protected */) {
+ if (modifiers & 16 /* ModifierFlags.Protected */) {
error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass));
}
return false;
@@ -75261,10 +76644,10 @@ var ts;
}
function invocationErrorDetails(errorTarget, apparentType, kind) {
var errorInfo;
- var isCall = kind === 0 /* Call */;
+ var isCall = kind === 0 /* SignatureKind.Call */;
var awaitedType = getAwaitedType(apparentType);
var maybeMissingAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0;
- if (apparentType.flags & 1048576 /* Union */) {
+ if (apparentType.flags & 1048576 /* TypeFlags.Union */) {
var types = apparentType.types;
var hasSignatures = false;
for (var _i = 0, types_20 = types; _i < types_20.length; _i++) {
@@ -75314,7 +76697,7 @@ var ts;
// Diagnose get accessors incorrectly called as functions
if (ts.isCallExpression(errorTarget.parent) && errorTarget.parent.arguments.length === 0) {
var resolvedSymbol = getNodeLinks(errorTarget).resolvedSymbol;
- if (resolvedSymbol && resolvedSymbol.flags & 32768 /* GetAccessor */) {
+ if (resolvedSymbol && resolvedSymbol.flags & 32768 /* SymbolFlags.GetAccessor */) {
headMessage = ts.Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without;
}
}
@@ -75358,8 +76741,8 @@ var ts;
// Another error has already been reported
return resolveErrorCall(node);
}
- var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */);
- var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length;
+ var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */);
+ var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length;
if (isUntypedFunctionCall(tagType, apparentType, callSignatures.length, numConstructSignatures)) {
return resolveUntypedCall(node);
}
@@ -75369,26 +76752,26 @@ var ts;
diagnostics.add(diagnostic);
return resolveErrorCall(node);
}
- invocationError(node.tag, apparentType, 0 /* Call */);
+ invocationError(node.tag, apparentType, 0 /* SignatureKind.Call */);
return resolveErrorCall(node);
}
- return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */);
+ return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */);
}
/**
* Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression.
*/
function getDiagnosticHeadMessageForDecoratorResolution(node) {
switch (node.parent.kind) {
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression;
- case 163 /* Parameter */:
+ case 164 /* SyntaxKind.Parameter */:
return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression;
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression;
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression;
default:
return ts.Debug.fail();
@@ -75403,8 +76786,8 @@ var ts;
if (isErrorType(apparentType)) {
return resolveErrorCall(node);
}
- var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */);
- var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length;
+ var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */);
+ var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length;
if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
return resolveUntypedCall(node);
}
@@ -75415,38 +76798,38 @@ var ts;
}
var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
if (!callSignatures.length) {
- var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* Call */);
+ var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* SignatureKind.Call */);
var messageChain = ts.chainDiagnosticMessages(errorDetails.messageChain, headMessage);
var diag = ts.createDiagnosticForNodeFromMessageChain(node.expression, messageChain);
if (errorDetails.relatedMessage) {
ts.addRelatedInfo(diag, ts.createDiagnosticForNode(node.expression, errorDetails.relatedMessage));
}
diagnostics.add(diag);
- invocationErrorRecovery(apparentType, 0 /* Call */, diag);
+ invocationErrorRecovery(apparentType, 0 /* SignatureKind.Call */, diag);
return resolveErrorCall(node);
}
- return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage);
+ return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */, headMessage);
}
function createSignatureForJSXIntrinsic(node, result) {
var namespace = getJsxNamespaceAt(node);
var exports = namespace && getExportsOfSymbol(namespace);
// We fake up a SFC signature for each intrinsic, however a more specific per-element signature drawn from the JSX declaration
// file would probably be preferable.
- var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */);
- var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node);
- var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */));
- var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props");
+ var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* SymbolFlags.Type */);
+ var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* SymbolFlags.Type */, node);
+ var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */));
+ var parameterSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "props");
parameterSymbol.type = result;
return createSignature(declaration,
/*typeParameters*/ undefined,
/*thisParameter*/ undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType,
- /*returnTypePredicate*/ undefined, 1, 0 /* None */);
+ /*returnTypePredicate*/ undefined, 1, 0 /* SignatureFlags.None */);
}
function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) {
if (isJsxIntrinsicIdentifier(node.tagName)) {
var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node);
var fakeSignature = createSignatureForJSXIntrinsic(node, result);
- checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* Normal */), result, node.tagName, node.attributes);
+ checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* CheckMode.Normal */), result, node.tagName, node.attributes);
if (ts.length(node.typeArguments)) {
ts.forEach(node.typeArguments, checkSourceElement);
diagnostics.add(ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), node.typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, 0, ts.length(node.typeArguments)));
@@ -75467,7 +76850,7 @@ var ts;
error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName));
return resolveErrorCall(node);
}
- return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */);
+ return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */);
}
/**
* Sometimes, we have a decorator that could accept zero arguments,
@@ -75483,16 +76866,16 @@ var ts;
}
function resolveSignature(node, candidatesOutArray, checkMode) {
switch (node.kind) {
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
return resolveCallExpression(node, candidatesOutArray, checkMode);
- case 208 /* NewExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
return resolveNewExpression(node, candidatesOutArray, checkMode);
- case 209 /* TaggedTemplateExpression */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode);
- case 164 /* Decorator */:
+ case 165 /* SyntaxKind.Decorator */:
return resolveDecorator(node, candidatesOutArray, checkMode);
- case 279 /* JsxOpeningElement */:
- case 278 /* JsxSelfClosingElement */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode);
}
throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable.");
@@ -75515,7 +76898,7 @@ var ts;
return cached;
}
links.resolvedSignature = resolvingSignature;
- var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* Normal */);
+ var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* CheckMode.Normal */);
// When CheckMode.SkipGenericFunctions is set we use resolvingSignature to indicate that call
// resolution should be deferred.
if (result !== resolvingSignature) {
@@ -75556,7 +76939,7 @@ var ts;
var inferred = ts.isTransientSymbol(target) ? target : cloneSymbol(target);
inferred.exports = inferred.exports || ts.createSymbolTable();
inferred.members = inferred.members || ts.createSymbolTable();
- inferred.flags |= source.flags & 32 /* Class */;
+ inferred.flags |= source.flags & 32 /* SymbolFlags.Class */;
if ((_a = source.exports) === null || _a === void 0 ? void 0 : _a.size) {
mergeSymbolTable(inferred.exports, source.exports);
}
@@ -75592,16 +76975,16 @@ var ts;
else if (ts.isBinaryExpression(node.parent)) {
var parentNode = node.parent;
var parentNodeOperator = node.parent.operatorToken.kind;
- if (parentNodeOperator === 63 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) {
+ if (parentNodeOperator === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.right === node)) {
name = parentNode.left;
decl = name;
}
- else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) {
+ else if (parentNodeOperator === 56 /* SyntaxKind.BarBarToken */ || parentNodeOperator === 60 /* SyntaxKind.QuestionQuestionToken */) {
if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) {
name = parentNode.parent.name;
decl = parentNode.parent;
}
- else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) {
+ else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) {
name = parentNode.parent.left;
decl = name;
}
@@ -75624,10 +77007,10 @@ var ts;
return false;
}
var parent = node.parent;
- while (parent && parent.kind === 205 /* PropertyAccessExpression */) {
+ while (parent && parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) {
parent = parent.parent;
}
- if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* EqualsToken */) {
+ if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) {
var right = ts.getInitializerOfBinaryExpression(parent);
return ts.isObjectLiteralExpression(right) && right;
}
@@ -75647,15 +77030,15 @@ var ts;
return nonInferrableType;
}
checkDeprecatedSignature(signature, node);
- if (node.expression.kind === 106 /* SuperKeyword */) {
+ if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) {
return voidType;
}
- if (node.kind === 208 /* NewExpression */) {
+ if (node.kind === 209 /* SyntaxKind.NewExpression */) {
var declaration = signature.declaration;
if (declaration &&
- declaration.kind !== 170 /* Constructor */ &&
- declaration.kind !== 174 /* ConstructSignature */ &&
- declaration.kind !== 179 /* ConstructorType */ &&
+ declaration.kind !== 171 /* SyntaxKind.Constructor */ &&
+ declaration.kind !== 175 /* SyntaxKind.ConstructSignature */ &&
+ declaration.kind !== 180 /* SyntaxKind.ConstructorType */ &&
!ts.isJSDocConstructSignature(declaration) &&
!isJSConstructor(declaration)) {
// When resolved signature is a call signature (and not a construct signature) the result type is any
@@ -75672,11 +77055,11 @@ var ts;
var returnType = getReturnTypeOfSignature(signature);
// Treat any call to the global 'Symbol' function that is part of a const variable or readonly property
// as a fresh unique symbol literal type.
- if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) {
+ if (returnType.flags & 12288 /* TypeFlags.ESSymbolLike */ && isSymbolOrSymbolForCall(node)) {
return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent));
}
- if (node.kind === 207 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 237 /* ExpressionStatement */ &&
- returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) {
+ if (node.kind === 208 /* SyntaxKind.CallExpression */ && !node.questionDotToken && node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ &&
+ returnType.flags & 16384 /* TypeFlags.Void */ && getTypePredicateOfSignature(signature)) {
if (!ts.isDottedName(node.expression)) {
error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name);
}
@@ -75689,14 +77072,14 @@ var ts;
var jsSymbol = getSymbolOfExpando(node, /*allowDeclaration*/ false);
if ((_a = jsSymbol === null || jsSymbol === void 0 ? void 0 : jsSymbol.exports) === null || _a === void 0 ? void 0 : _a.size) {
var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, ts.emptyArray);
- jsAssignmentType.objectFlags |= 8192 /* JSLiteral */;
+ jsAssignmentType.objectFlags |= 4096 /* ObjectFlags.JSLiteral */;
return getIntersectionType([returnType, jsAssignmentType]);
}
}
return returnType;
}
function checkDeprecatedSignature(signature, node) {
- if (signature.declaration && signature.declaration.flags & 134217728 /* Deprecated */) {
+ if (signature.declaration && signature.declaration.flags & 268435456 /* NodeFlags.Deprecated */) {
var suggestionNode = getDeprecatedSuggestionNode(node);
var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node));
addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature));
@@ -75705,20 +77088,20 @@ var ts;
function getDeprecatedSuggestionNode(node) {
node = ts.skipParentheses(node);
switch (node.kind) {
- case 207 /* CallExpression */:
- case 164 /* Decorator */:
- case 208 /* NewExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
+ case 165 /* SyntaxKind.Decorator */:
+ case 209 /* SyntaxKind.NewExpression */:
return getDeprecatedSuggestionNode(node.expression);
- case 209 /* TaggedTemplateExpression */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
return getDeprecatedSuggestionNode(node.tag);
- case 279 /* JsxOpeningElement */:
- case 278 /* JsxSelfClosingElement */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
return getDeprecatedSuggestionNode(node.tagName);
- case 206 /* ElementAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
return node.argumentExpression;
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
return node.name;
- case 177 /* TypeReference */:
+ case 178 /* SyntaxKind.TypeReference */:
var typeReference = node;
return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference;
default:
@@ -75740,7 +77123,7 @@ var ts;
if (!globalESSymbol) {
return false;
}
- return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
+ return globalESSymbol === resolveName(left, "Symbol", 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
}
function checkImportCallExpression(node) {
// Check grammar of dynamic import
@@ -75755,13 +77138,13 @@ var ts;
for (var i = 2; i < node.arguments.length; ++i) {
checkExpressionCached(node.arguments[i]);
}
- if (specifierType.flags & 32768 /* Undefined */ || specifierType.flags & 65536 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) {
+ if (specifierType.flags & 32768 /* TypeFlags.Undefined */ || specifierType.flags & 65536 /* TypeFlags.Null */ || !isTypeAssignableTo(specifierType, stringType)) {
error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType));
}
if (optionsType) {
var importCallOptionsType = getGlobalImportCallOptionsType(/*reportErrors*/ true);
if (importCallOptionsType !== emptyObjectType) {
- checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* Undefined */), node.arguments[1]);
+ checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* TypeFlags.Undefined */), node.arguments[1]);
}
}
// resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal
@@ -75777,11 +77160,11 @@ var ts;
}
function createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol) {
var memberTable = ts.createSymbolTable();
- var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
+ var newSymbol = createSymbol(2097152 /* SymbolFlags.Alias */, "default" /* InternalSymbolName.Default */);
newSymbol.parent = originalSymbol;
newSymbol.nameType = getStringLiteralType("default");
- newSymbol.target = resolveSymbol(symbol);
- memberTable.set("default" /* Default */, newSymbol);
+ newSymbol.aliasTarget = resolveSymbol(symbol);
+ memberTable.set("default" /* InternalSymbolName.Default */, newSymbol);
return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray);
}
function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) {
@@ -75804,7 +77187,7 @@ var ts;
var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier);
if (hasSyntheticDefault) {
- var anonymousSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
+ var anonymousSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */);
var defaultContainingObject = createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol);
anonymousSymbol.type = defaultContainingObject;
synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject;
@@ -75824,40 +77207,40 @@ var ts;
// Make sure require is not a local function
if (!ts.isIdentifier(node.expression))
return ts.Debug.fail();
- var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217
+ var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217
if (resolvedRequire === requireSymbol) {
return true;
}
// project includes symbol named 'require' - make sure that it is ambient and local non-alias
- if (resolvedRequire.flags & 2097152 /* Alias */) {
+ if (resolvedRequire.flags & 2097152 /* SymbolFlags.Alias */) {
return false;
}
- var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */
- ? 255 /* FunctionDeclaration */
- : resolvedRequire.flags & 3 /* Variable */
- ? 253 /* VariableDeclaration */
- : 0 /* Unknown */;
- if (targetDeclarationKind !== 0 /* Unknown */) {
+ var targetDeclarationKind = resolvedRequire.flags & 16 /* SymbolFlags.Function */
+ ? 256 /* SyntaxKind.FunctionDeclaration */
+ : resolvedRequire.flags & 3 /* SymbolFlags.Variable */
+ ? 254 /* SyntaxKind.VariableDeclaration */
+ : 0 /* SyntaxKind.Unknown */;
+ if (targetDeclarationKind !== 0 /* SyntaxKind.Unknown */) {
var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind);
// function/variable declaration should be ambient
- return !!decl && !!(decl.flags & 8388608 /* Ambient */);
+ return !!decl && !!(decl.flags & 16777216 /* NodeFlags.Ambient */);
}
return false;
}
function checkTaggedTemplateExpression(node) {
if (!checkGrammarTaggedTemplateChain(node))
checkGrammarTypeArguments(node, node.typeArguments);
- if (languageVersion < 2 /* ES2015 */) {
- checkExternalEmitHelpers(node, 262144 /* MakeTemplateObject */);
+ if (languageVersion < 2 /* ScriptTarget.ES2015 */) {
+ checkExternalEmitHelpers(node, 262144 /* ExternalEmitHelpers.MakeTemplateObject */);
}
var signature = getResolvedSignature(node);
checkDeprecatedSignature(signature, node);
return getReturnTypeOfSignature(signature);
}
function checkAssertion(node) {
- if (node.kind === 210 /* TypeAssertionExpression */) {
+ if (node.kind === 211 /* SyntaxKind.TypeAssertionExpression */) {
var file = ts.getSourceFileOfNode(node);
- if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Cts */, ".mts" /* Mts */])) {
+ if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */])) {
grammarErrorOnNode(node, ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead);
}
}
@@ -75865,31 +77248,31 @@ var ts;
}
function isValidConstAssertionArgument(node) {
switch (node.kind) {
- case 10 /* StringLiteral */:
- case 14 /* NoSubstitutionTemplateLiteral */:
- case 8 /* NumericLiteral */:
- case 9 /* BigIntLiteral */:
- case 110 /* TrueKeyword */:
- case 95 /* FalseKeyword */:
- case 203 /* ArrayLiteralExpression */:
- case 204 /* ObjectLiteralExpression */:
- case 222 /* TemplateExpression */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
+ case 9 /* SyntaxKind.BigIntLiteral */:
+ case 110 /* SyntaxKind.TrueKeyword */:
+ case 95 /* SyntaxKind.FalseKeyword */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
+ case 223 /* SyntaxKind.TemplateExpression */:
return true;
- case 211 /* ParenthesizedExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
return isValidConstAssertionArgument(node.expression);
- case 218 /* PrefixUnaryExpression */:
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
var op = node.operator;
var arg = node.operand;
- return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) ||
- op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */;
- case 205 /* PropertyAccessExpression */:
- case 206 /* ElementAccessExpression */:
+ return op === 40 /* SyntaxKind.MinusToken */ && (arg.kind === 8 /* SyntaxKind.NumericLiteral */ || arg.kind === 9 /* SyntaxKind.BigIntLiteral */) ||
+ op === 39 /* SyntaxKind.PlusToken */ && arg.kind === 8 /* SyntaxKind.NumericLiteral */;
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
var expr = node.expression;
var symbol = getTypeOfNode(expr).symbol;
- if (symbol && symbol.flags & 2097152 /* Alias */) {
+ if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) {
symbol = resolveAlias(symbol);
}
- return !!(symbol && (symbol.flags & 384 /* Enum */) && getEnumKind(symbol) === 1 /* Literal */);
+ return !!(symbol && (symbol.flags & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */);
}
return false;
}
@@ -75904,11 +77287,13 @@ var ts;
checkSourceElement(type);
exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType));
var targetType = getTypeFromTypeNode(type);
- if (produceDiagnostics && !isErrorType(targetType)) {
- var widenedType = getWidenedType(exprType);
- if (!isTypeComparableTo(targetType, widenedType)) {
- checkTypeComparableTo(exprType, targetType, errNode, ts.Diagnostics.Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first);
- }
+ if (!isErrorType(targetType)) {
+ addLazyDiagnostic(function () {
+ var widenedType = getWidenedType(exprType);
+ if (!isTypeComparableTo(targetType, widenedType)) {
+ checkTypeComparableTo(exprType, targetType, errNode, ts.Diagnostics.Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first);
+ }
+ });
}
return targetType;
}
@@ -75918,24 +77303,90 @@ var ts;
return propagateOptionalTypeMarker(getNonNullableType(nonOptionalType), node, nonOptionalType !== leftType);
}
function checkNonNullAssertion(node) {
- return node.flags & 32 /* OptionalChain */ ? checkNonNullChain(node) :
+ return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkNonNullChain(node) :
getNonNullableType(checkExpression(node.expression));
}
+ function checkExpressionWithTypeArguments(node) {
+ checkGrammarExpressionWithTypeArguments(node);
+ var exprType = node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ? checkExpression(node.expression) :
+ ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) :
+ checkExpression(node.exprName);
+ var typeArguments = node.typeArguments;
+ if (exprType === silentNeverType || isErrorType(exprType) || !ts.some(typeArguments)) {
+ return exprType;
+ }
+ var hasSomeApplicableSignature = false;
+ var nonApplicableType;
+ var result = getInstantiatedType(exprType);
+ var errorType = hasSomeApplicableSignature ? nonApplicableType : exprType;
+ if (errorType) {
+ diagnostics.add(ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable, typeToString(errorType)));
+ }
+ return result;
+ function getInstantiatedType(type) {
+ var hasSignatures = false;
+ var hasApplicableSignature = false;
+ var result = getInstantiatedTypePart(type);
+ hasSomeApplicableSignature || (hasSomeApplicableSignature = hasApplicableSignature);
+ if (hasSignatures && !hasApplicableSignature) {
+ nonApplicableType !== null && nonApplicableType !== void 0 ? nonApplicableType : (nonApplicableType = type);
+ }
+ return result;
+ function getInstantiatedTypePart(type) {
+ if (type.flags & 524288 /* TypeFlags.Object */) {
+ var resolved = resolveStructuredTypeMembers(type);
+ var callSignatures = getInstantiatedSignatures(resolved.callSignatures);
+ var constructSignatures = getInstantiatedSignatures(resolved.constructSignatures);
+ hasSignatures || (hasSignatures = resolved.callSignatures.length !== 0 || resolved.constructSignatures.length !== 0);
+ hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0);
+ if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) {
+ var result_11 = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos);
+ result_11.objectFlags |= 8388608 /* ObjectFlags.InstantiationExpressionType */;
+ result_11.node = node;
+ return result_11;
+ }
+ }
+ else if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) {
+ var constraint = getBaseConstraintOfType(type);
+ if (constraint) {
+ var instantiated = getInstantiatedTypePart(constraint);
+ if (instantiated !== constraint) {
+ return instantiated;
+ }
+ }
+ }
+ else if (type.flags & 1048576 /* TypeFlags.Union */) {
+ return mapType(type, getInstantiatedType);
+ }
+ else if (type.flags & 2097152 /* TypeFlags.Intersection */) {
+ return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypePart));
+ }
+ return type;
+ }
+ }
+ function getInstantiatedSignatures(signatures) {
+ var applicableSignatures = ts.filter(signatures, function (sig) { return !!sig.typeParameters && hasCorrectTypeArgumentArity(sig, typeArguments); });
+ return ts.sameMap(applicableSignatures, function (sig) {
+ var typeArgumentTypes = checkTypeArguments(sig, typeArguments, /*reportErrors*/ true);
+ return typeArgumentTypes ? getSignatureInstantiation(sig, typeArgumentTypes, ts.isInJSFile(sig.declaration)) : sig;
+ });
+ }
+ }
function checkMetaProperty(node) {
checkGrammarMetaProperty(node);
- if (node.keywordToken === 103 /* NewKeyword */) {
+ if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */) {
return checkNewTargetMetaProperty(node);
}
- if (node.keywordToken === 100 /* ImportKeyword */) {
+ if (node.keywordToken === 100 /* SyntaxKind.ImportKeyword */) {
return checkImportMetaProperty(node);
}
return ts.Debug.assertNever(node.keywordToken);
}
function checkMetaPropertyKeyword(node) {
switch (node.keywordToken) {
- case 100 /* ImportKeyword */:
+ case 100 /* SyntaxKind.ImportKeyword */:
return getGlobalImportMetaExpressionType();
- case 103 /* NewKeyword */:
+ case 103 /* SyntaxKind.NewKeyword */:
var type = checkNewTargetMetaProperty(node);
return isErrorType(type) ? errorType : createNewTargetExpressionType(type);
default:
@@ -75948,7 +77399,7 @@ var ts;
error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target");
return errorType;
}
- else if (container.kind === 170 /* Constructor */) {
+ else if (container.kind === 171 /* SyntaxKind.Constructor */) {
var symbol = getSymbolOfNode(container.parent);
return getTypeOfSymbol(symbol);
}
@@ -75958,16 +77409,16 @@ var ts;
}
}
function checkImportMetaProperty(node) {
- if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) {
+ if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) {
if (ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.ESNext) {
error(node, ts.Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output);
}
}
else if (moduleKind < ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.System) {
- error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext);
+ error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext);
}
var file = ts.getSourceFileOfNode(node);
- ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
+ ts.Debug.assert(!!(file.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
}
function getTypeOfParameter(symbol) {
@@ -76000,7 +77451,7 @@ var ts;
}
function getParameterIdentifierNameAtPosition(signature, pos) {
var _a;
- if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 315 /* JSDocFunctionType */) {
+ if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 317 /* SyntaxKind.JSDocFunctionType */) {
return undefined;
}
var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
@@ -76032,7 +77483,7 @@ var ts;
return symbol.valueDeclaration && ts.isParameter(symbol.valueDeclaration) && ts.isIdentifier(symbol.valueDeclaration.name);
}
function isValidDeclarationForTupleLabel(d) {
- return d.kind === 196 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name));
+ return d.kind === 197 /* SyntaxKind.NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name));
}
function getNameableDeclarationAtPosition(signature, pos) {
var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
@@ -76082,11 +77533,11 @@ var ts;
for (var i = pos; i < parameterCount; i++) {
if (!restType || i < parameterCount - 1) {
types.push(getTypeAtPosition(source, i));
- flags.push(i < minArgumentCount ? 1 /* Required */ : 2 /* Optional */);
+ flags.push(i < minArgumentCount ? 1 /* ElementFlags.Required */ : 2 /* ElementFlags.Optional */);
}
else {
types.push(restType);
- flags.push(8 /* Variadic */);
+ flags.push(8 /* ElementFlags.Variadic */);
}
var name = getNameableDeclarationAtPosition(source, i);
if (name) {
@@ -76110,14 +77561,14 @@ var ts;
return length;
}
function getMinArgumentCount(signature, flags) {
- var strongArityForUntypedJS = flags & 1 /* StrongArityForUntypedJS */;
- var voidIsNonOptional = flags & 2 /* VoidIsNonOptional */;
+ var strongArityForUntypedJS = flags & 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */;
+ var voidIsNonOptional = flags & 2 /* MinArgumentCountFlags.VoidIsNonOptional */;
if (voidIsNonOptional || signature.resolvedMinArgumentCount === undefined) {
var minArgumentCount = void 0;
if (signatureHasRestParameter(signature)) {
var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
if (isTupleType(restType)) {
- var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* Required */); });
+ var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* ElementFlags.Required */); });
var requiredCount = firstOptionalIndex < 0 ? restType.target.fixedLength : firstOptionalIndex;
if (requiredCount > 0) {
minArgumentCount = signature.parameters.length - 1 + requiredCount;
@@ -76125,7 +77576,7 @@ var ts;
}
}
if (minArgumentCount === undefined) {
- if (!strongArityForUntypedJS && signature.flags & 32 /* IsUntypedSignatureInJSFile */) {
+ if (!strongArityForUntypedJS && signature.flags & 32 /* SignatureFlags.IsUntypedSignatureInJSFile */) {
return 0;
}
minArgumentCount = signature.minArgumentCount;
@@ -76135,7 +77586,7 @@ var ts;
}
for (var i = minArgumentCount - 1; i >= 0; i--) {
var type = getTypeAtPosition(signature, i);
- if (filterType(type, acceptsVoid).flags & 131072 /* Never */) {
+ if (filterType(type, acceptsVoid).flags & 131072 /* TypeFlags.Never */) {
break;
}
minArgumentCount = i;
@@ -76165,7 +77616,7 @@ var ts;
}
function getNonArrayRestType(signature) {
var restType = getEffectiveRestType(signature);
- return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* Never */) === 0 ? restType : undefined;
+ return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* TypeFlags.Never */) === 0 ? restType : undefined;
}
function getTypeOfFirstParameterOfSignature(signature) {
return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType);
@@ -76185,7 +77636,7 @@ var ts;
}
}
var restType = getEffectiveRestType(context);
- if (restType && restType.flags & 262144 /* TypeParameter */) {
+ if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) {
// The contextual signature has a generic rest parameter. We first instantiate the contextual
// signature (without fixing type parameters) and assign types to contextually typed parameters.
var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper);
@@ -76225,7 +77676,11 @@ var ts;
if (signatureHasRestParameter(signature)) {
// parameter might be a transient symbol generated by use of `arguments` in the function body.
var parameter = ts.last(signature.parameters);
- if (ts.isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) {
+ if (parameter.valueDeclaration
+ ? !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)
+ // a declarationless parameter may still have a `.type` already set by its construction logic
+ // (which may pull a type from a jsdoc) - only allow fixing on `DeferredType` parameters with a fallback type
+ : !!(ts.getCheckFlags(parameter) & 65536 /* CheckFlags.DeferredType */)) {
var contextualParameterType = getRestTypeAtPosition(context, len);
assignParameterType(parameter, contextualParameterType);
}
@@ -76244,8 +77699,8 @@ var ts;
var links = getSymbolLinks(parameter);
if (!links.type) {
var declaration = parameter.valueDeclaration;
- links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true);
- if (declaration.name.kind !== 79 /* Identifier */) {
+ links.type = type || (declaration ? getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true) : getTypeOfSymbol(parameter));
+ if (declaration && declaration.name.kind !== 79 /* SyntaxKind.Identifier */) {
// if inference didn't come up with anything but unknown, fall back to the binding pattern if present.
if (links.type === unknownType) {
links.type = getTypeFromBindingPattern(declaration.name);
@@ -76253,6 +77708,9 @@ var ts;
assignBindingElementTypes(declaration.name, links.type);
}
}
+ else if (type) {
+ ts.Debug.assertEqual(links.type, type, "Parameter symbol already has a cached type which differs from newly assigned type");
+ }
}
// When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push
// the destructured type into the contained binding elements.
@@ -76261,7 +77719,7 @@ var ts;
var element = _a[_i];
if (!ts.isOmittedExpression(element)) {
var type = getBindingElementTypeFromParentType(element, parentType);
- if (element.name.kind === 79 /* Identifier */) {
+ if (element.name.kind === 79 /* SyntaxKind.Identifier */) {
getSymbolLinks(getSymbolOfNode(element)).type = type;
}
else {
@@ -76309,8 +77767,8 @@ var ts;
}
function createNewTargetExpressionType(targetType) {
// Create a synthetic type `NewTargetExpression { target: TargetType; }`
- var symbol = createSymbol(0 /* None */, "NewTargetExpression");
- var targetPropertySymbol = createSymbol(4 /* Property */, "target", 8 /* Readonly */);
+ var symbol = createSymbol(0 /* SymbolFlags.None */, "NewTargetExpression");
+ var targetPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "target", 8 /* CheckFlags.Readonly */);
targetPropertySymbol.parent = symbol;
targetPropertySymbol.type = targetType;
var members = ts.createSymbolTable([targetPropertySymbol]);
@@ -76322,14 +77780,14 @@ var ts;
return errorType;
}
var functionFlags = ts.getFunctionFlags(func);
- var isAsync = (functionFlags & 2 /* Async */) !== 0;
- var isGenerator = (functionFlags & 1 /* Generator */) !== 0;
+ var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0;
+ var isGenerator = (functionFlags & 1 /* FunctionFlags.Generator */) !== 0;
var returnType;
var yieldType;
var nextType;
var fallbackReturnType = voidType;
- if (func.body.kind !== 234 /* Block */) { // Async or normal arrow function
- returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */);
+ if (func.body.kind !== 235 /* SyntaxKind.Block */) { // Async or normal arrow function
+ returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */);
if (isAsync) {
// From within an async function you can return either a non-promise value or a promise. Any
// Promise/A+ compatible implementation will always assimilate any foreign promise, so the
@@ -76344,36 +77802,36 @@ var ts;
fallbackReturnType = neverType;
}
else if (returnTypes.length > 0) {
- returnType = getUnionType(returnTypes, 2 /* Subtype */);
+ returnType = getUnionType(returnTypes, 2 /* UnionReduction.Subtype */);
}
var _a = checkAndAggregateYieldOperandTypes(func, checkMode), yieldTypes = _a.yieldTypes, nextTypes = _a.nextTypes;
- yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* Subtype */) : undefined;
+ yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* UnionReduction.Subtype */) : undefined;
nextType = ts.some(nextTypes) ? getIntersectionType(nextTypes) : undefined;
}
else { // Async or normal function
var types = checkAndAggregateReturnExpressionTypes(func, checkMode);
if (!types) {
// For an async function, the return type will not be never, but rather a Promise for never.
- return functionFlags & 2 /* Async */
+ return functionFlags & 2 /* FunctionFlags.Async */
? createPromiseReturnType(func, neverType) // Async function
: neverType; // Normal function
}
if (types.length === 0) {
// For an async function, the return type will not be void, but rather a Promise for void.
- return functionFlags & 2 /* Async */
+ return functionFlags & 2 /* FunctionFlags.Async */
? createPromiseReturnType(func, voidType) // Async function
: voidType; // Normal function
}
// Return a union of the return expression types.
- returnType = getUnionType(types, 2 /* Subtype */);
+ returnType = getUnionType(types, 2 /* UnionReduction.Subtype */);
}
if (returnType || yieldType || nextType) {
if (yieldType)
- reportErrorsFromWidening(func, yieldType, 3 /* GeneratorYield */);
+ reportErrorsFromWidening(func, yieldType, 3 /* WideningKind.GeneratorYield */);
if (returnType)
- reportErrorsFromWidening(func, returnType, 1 /* FunctionReturn */);
+ reportErrorsFromWidening(func, returnType, 1 /* WideningKind.FunctionReturn */);
if (nextType)
- reportErrorsFromWidening(func, nextType, 2 /* GeneratorNext */);
+ reportErrorsFromWidening(func, nextType, 2 /* WideningKind.GeneratorNext */);
if (returnType && isUnitType(returnType) ||
yieldType && isUnitType(yieldType) ||
nextType && isUnitType(nextType)) {
@@ -76382,9 +77840,9 @@ var ts;
contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType :
instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func);
if (isGenerator) {
- yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* Yield */, isAsync);
- returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* Return */, isAsync);
- nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* Next */, isAsync);
+ yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* IterationTypeKind.Yield */, isAsync);
+ returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* IterationTypeKind.Return */, isAsync);
+ nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* IterationTypeKind.Next */, isAsync);
}
else {
returnType = getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(returnType, contextualType, isAsync);
@@ -76398,7 +77856,7 @@ var ts;
nextType = getWidenedType(nextType);
}
if (isGenerator) {
- return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* Next */, func) || unknownType, isAsync);
+ return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* IterationTypeKind.Next */, func) || unknownType, isAsync);
}
else {
// From within an async function you can return either a non-promise value or a promise. Any
@@ -76441,13 +77899,13 @@ var ts;
function checkAndAggregateYieldOperandTypes(func, checkMode) {
var yieldTypes = [];
var nextTypes = [];
- var isAsync = (ts.getFunctionFlags(func) & 2 /* Async */) !== 0;
+ var isAsync = (ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) !== 0;
ts.forEachYieldExpression(func.body, function (yieldExpression) {
var yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType;
ts.pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, anyType, isAsync));
var nextType;
if (yieldExpression.asteriskToken) {
- var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, yieldExpression.expression);
+ var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, yieldExpression.expression);
nextType = iterationTypes && iterationTypes.nextType;
}
else {
@@ -76461,7 +77919,7 @@ var ts;
function getYieldedTypeOfYieldExpression(node, expressionType, sentType, isAsync) {
var errorNode = node.expression || node;
// A `yield*` expression effectively yields everything that its operand yields
- var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, expressionType, sentType, errorNode) : expressionType;
+ var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, expressionType, sentType, errorNode) : expressionType;
return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken
? 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);
@@ -76473,14 +77931,14 @@ var ts;
* whether the active clause contains a default clause.
*/
function getFactsFromTypeofSwitch(start, end, witnesses, hasDefault) {
- var facts = 0 /* None */;
+ var facts = 0 /* TypeFacts.None */;
// When in the default we only collect inequality facts
// because default is 'in theory' a set of infinite
// equalities.
if (hasDefault) {
// Value is not equal to any types after the active clause.
for (var i = end; i < witnesses.length; i++) {
- facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */;
+ facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeFacts.TypeofNEHostObject */;
}
// Remove inequalities for types that appear in the
// active clause because they appear before other
@@ -76490,7 +77948,7 @@ var ts;
}
// Add inequalities for types before the active clause unconditionally.
for (var i = 0; i < start; i++) {
- facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */;
+ facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeFacts.TypeofNEHostObject */;
}
}
// When in an active clause without default the set of
@@ -76498,7 +77956,7 @@ var ts;
else {
// Add equalities for all types in the active clause.
for (var i = start; i < end; i++) {
- facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeofEQHostObject */;
+ facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeFacts.TypeofEQHostObject */;
}
// Remove equalities for types that appear before the
// active clause.
@@ -76513,17 +77971,17 @@ var ts;
return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node));
}
function computeExhaustiveSwitchStatement(node) {
- if (node.expression.kind === 215 /* TypeOfExpression */) {
+ if (node.expression.kind === 216 /* SyntaxKind.TypeOfExpression */) {
var operandType = getTypeOfExpression(node.expression.expression);
var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
// notEqualFacts states that the type of the switched value is not equal to every type in the switch.
var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
var type_6 = getBaseConstraintOfType(operandType) || operandType;
// Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
- if (type_6.flags & 3 /* AnyOrUnknown */) {
- return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
+ if (type_6.flags & 3 /* TypeFlags.AnyOrUnknown */) {
+ return (556800 /* TypeFacts.AllTypeofNE */ & notEqualFacts_1) === 556800 /* TypeFacts.AllTypeofNE */;
}
- return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
+ return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* TypeFlags.Never */);
}
var type = getTypeOfExpression(node.expression);
if (!isLiteralType(type)) {
@@ -76547,15 +78005,15 @@ var ts;
ts.forEachReturnStatement(func.body, function (returnStatement) {
var expr = returnStatement.expression;
if (expr) {
- var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* SkipGenericFunctions */);
- if (functionFlags & 2 /* Async */) {
+ var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */);
+ if (functionFlags & 2 /* FunctionFlags.Async */) {
// From within an async function you can return either a non-promise value or a promise. Any
// Promise/A+ compatible implementation will always assimilate any foreign promise, so the
// return type of the body should be unwrapped to its awaited type, which should be wrapped in
// the native Promise<T> type by the caller.
type = unwrapAwaitedType(checkAwaitedType(type, /*withAlias*/ false, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member));
}
- if (type.flags & 131072 /* Never */) {
+ if (type.flags & 131072 /* TypeFlags.Never */) {
hasReturnOfTypeNever = true;
}
ts.pushIfUnique(aggregatedTypes, type);
@@ -76576,11 +78034,11 @@ var ts;
}
function mayReturnNever(func) {
switch (func.kind) {
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
return true;
- case 168 /* MethodDeclaration */:
- return func.parent.kind === 204 /* ObjectLiteralExpression */;
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ return func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */;
default:
return false;
}
@@ -76595,57 +78053,58 @@ var ts;
* @param returnType - return type of the function, can be undefined if return type is not explicitly specified
*/
function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
- if (!produceDiagnostics) {
- return;
- }
- var functionFlags = ts.getFunctionFlags(func);
- var type = returnType && unwrapReturnType(returnType, functionFlags);
- // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions.
- if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) {
- return;
- }
- // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check.
- // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw
- if (func.kind === 167 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 234 /* Block */ || !functionHasImplicitReturn(func)) {
- return;
- }
- var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */;
- var errorNode = ts.getEffectiveReturnTypeNode(func) || func;
- if (type && type.flags & 131072 /* Never */) {
- error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
- }
- else if (type && !hasExplicitReturn) {
- // minimal check: function has syntactic return type annotation and no explicit return statements in the body
- // this function does not conform to the specification.
- error(errorNode, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
- }
- else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
- error(errorNode, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
- }
- else if (compilerOptions.noImplicitReturns) {
- if (!type) {
- // If return type annotation is omitted check if function has any explicit return statements.
- // If it does not have any - its inferred return type is void - don't do any checks.
- // Otherwise get inferred return type from function body and report error only if it is not void / anytype
- if (!hasExplicitReturn) {
- return;
- }
- var inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
- if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
- return;
+ addLazyDiagnostic(checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics);
+ return;
+ function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
+ var functionFlags = ts.getFunctionFlags(func);
+ var type = returnType && unwrapReturnType(returnType, functionFlags);
+ // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions.
+ if (type && maybeTypeOfKind(type, 1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)) {
+ return;
+ }
+ // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check.
+ // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw
+ if (func.kind === 168 /* SyntaxKind.MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* SyntaxKind.Block */ || !functionHasImplicitReturn(func)) {
+ return;
+ }
+ var hasExplicitReturn = func.flags & 512 /* NodeFlags.HasExplicitReturn */;
+ var errorNode = ts.getEffectiveReturnTypeNode(func) || func;
+ if (type && type.flags & 131072 /* TypeFlags.Never */) {
+ error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
+ }
+ else if (type && !hasExplicitReturn) {
+ // minimal check: function has syntactic return type annotation and no explicit return statements in the body
+ // this function does not conform to the specification.
+ error(errorNode, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
+ }
+ else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
+ error(errorNode, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
+ }
+ else if (compilerOptions.noImplicitReturns) {
+ if (!type) {
+ // If return type annotation is omitted check if function has any explicit return statements.
+ // If it does not have any - its inferred return type is void - don't do any checks.
+ // Otherwise get inferred return type from function body and report error only if it is not void / anytype
+ if (!hasExplicitReturn) {
+ return;
+ }
+ var inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
+ if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
+ return;
+ }
}
+ error(errorNode, ts.Diagnostics.Not_all_code_paths_return_a_value);
}
- error(errorNode, ts.Diagnostics.Not_all_code_paths_return_a_value);
}
}
function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
- ts.Debug.assert(node.kind !== 168 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node));
+ ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node));
checkNodeDeferred(node);
if (ts.isFunctionExpression(node)) {
checkCollisionsForDeclarationName(node, node.name);
}
// The identityMapper object is used to indicate that function expressions are wildcards
- if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) {
+ if (checkMode && checkMode & 4 /* CheckMode.SkipContextSensitive */ && isContextSensitive(node)) {
// Skip parameters, return signature with return type that retains noncontextual parts so inferences can still be drawn in an early stage
if (!ts.getEffectiveReturnTypeNode(node) && !ts.hasContextSensitiveParameters(node)) {
// Return plain anyFunctionType if there is no possibility we'll make inferences from the return type
@@ -76656,9 +78115,9 @@ var ts;
return links.contextFreeType;
}
var returnType = getReturnTypeFromBody(node, checkMode);
- var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */);
+ var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */);
var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, ts.emptyArray);
- returnOnlyType.objectFlags |= 524288 /* NonInferrableType */;
+ returnOnlyType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */;
return links.contextFreeType = returnOnlyType;
}
}
@@ -76666,7 +78125,7 @@ var ts;
}
// Grammar checking
var hasGrammarError = checkGrammarFunctionLikeDeclaration(node);
- if (!hasGrammarError && node.kind === 212 /* FunctionExpression */) {
+ if (!hasGrammarError && node.kind === 213 /* SyntaxKind.FunctionExpression */) {
checkGrammarForGenerator(node);
}
contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode);
@@ -76675,21 +78134,21 @@ var ts;
function contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
var links = getNodeLinks(node);
// Check if function expression is contextually typed and assign parameter types if so.
- if (!(links.flags & 1024 /* ContextChecked */)) {
+ if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) {
var contextualSignature = getContextualSignature(node);
// If a type check is started at a function expression that is an argument of a function call, obtaining the
// contextual type may recursively get back to here during overload resolution of the call. If so, we will have
// already assigned contextual types.
- if (!(links.flags & 1024 /* ContextChecked */)) {
- links.flags |= 1024 /* ContextChecked */;
- var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* Call */));
+ if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) {
+ links.flags |= 1024 /* NodeCheckFlags.ContextChecked */;
+ var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* SignatureKind.Call */));
if (!signature) {
return;
}
if (isContextSensitive(node)) {
if (contextualSignature) {
var inferenceContext = getInferenceContext(node);
- if (checkMode && checkMode & 2 /* Inferential */) {
+ if (checkMode && checkMode & 2 /* CheckMode.Inferential */) {
inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
}
var instantiatedContextualSignature = inferenceContext ?
@@ -76712,7 +78171,7 @@ var ts;
}
}
function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) {
- ts.Debug.assert(node.kind !== 168 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node));
+ ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node));
var functionFlags = ts.getFunctionFlags(node);
var returnType = getReturnTypeFromAnnotation(node);
checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
@@ -76725,7 +78184,7 @@ var ts;
// checkFunctionExpressionBodies). So it must be done now.
getReturnTypeOfSignature(getSignatureFromDeclaration(node));
}
- if (node.body.kind === 234 /* Block */) {
+ if (node.body.kind === 235 /* SyntaxKind.Block */) {
checkSourceElement(node.body);
}
else {
@@ -76737,7 +78196,7 @@ var ts;
var exprType = checkExpression(node.body);
var returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags);
if (returnOrPromisedType) {
- if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function
+ if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) { // Async function
var awaitedType = checkAwaitedType(exprType, /*withAlias*/ false, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body);
}
@@ -76795,27 +78254,27 @@ var ts;
// Enum members
// Object.defineProperty assignments with writable false or no setter
// Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation)
- return !!(ts.getCheckFlags(symbol) & 8 /* Readonly */ ||
- symbol.flags & 4 /* Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */ ||
- symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */ ||
- symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) ||
- symbol.flags & 8 /* EnumMember */ ||
+ return !!(ts.getCheckFlags(symbol) & 8 /* CheckFlags.Readonly */ ||
+ symbol.flags & 4 /* SymbolFlags.Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* ModifierFlags.Readonly */ ||
+ symbol.flags & 3 /* SymbolFlags.Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */ ||
+ symbol.flags & 98304 /* SymbolFlags.Accessor */ && !(symbol.flags & 65536 /* SymbolFlags.SetAccessor */) ||
+ symbol.flags & 8 /* SymbolFlags.EnumMember */ ||
ts.some(symbol.declarations, isReadonlyAssignmentDeclaration));
}
function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) {
var _a, _b;
- if (assignmentKind === 0 /* None */) {
+ if (assignmentKind === 0 /* AssignmentKind.None */) {
// no assigment means it doesn't matter whether the entity is readonly
return false;
}
if (isReadonlySymbol(symbol)) {
// Allow assignments to readonly properties within constructors of the same class declaration.
- if (symbol.flags & 4 /* Property */ &&
+ if (symbol.flags & 4 /* SymbolFlags.Property */ &&
ts.isAccessExpression(expr) &&
- expr.expression.kind === 108 /* ThisKeyword */) {
+ expr.expression.kind === 108 /* SyntaxKind.ThisKeyword */) {
// Look for if this is the constructor for the class that `symbol` is a property of.
var ctor = ts.getContainingFunction(expr);
- if (!(ctor && (ctor.kind === 170 /* Constructor */ || isJSConstructor(ctor)))) {
+ if (!(ctor && (ctor.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(ctor)))) {
return true;
}
if (symbol.valueDeclaration) {
@@ -76836,11 +78295,11 @@ var ts;
if (ts.isAccessExpression(expr)) {
// references through namespace import should be readonly
var node = ts.skipParentheses(expr.expression);
- if (node.kind === 79 /* Identifier */) {
+ if (node.kind === 79 /* SyntaxKind.Identifier */) {
var symbol_2 = getNodeLinks(node).resolvedSymbol;
- if (symbol_2.flags & 2097152 /* Alias */) {
+ if (symbol_2.flags & 2097152 /* SymbolFlags.Alias */) {
var declaration = getDeclarationOfAliasSymbol(symbol_2);
- return !!declaration && declaration.kind === 267 /* NamespaceImport */;
+ return !!declaration && declaration.kind === 268 /* SyntaxKind.NamespaceImport */;
}
}
}
@@ -76848,12 +78307,12 @@ var ts;
}
function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) {
// References are combinations of identifiers, parentheses, and property accesses.
- var node = ts.skipOuterExpressions(expr, 6 /* Assertions */ | 1 /* Parentheses */);
- if (node.kind !== 79 /* Identifier */ && !ts.isAccessExpression(node)) {
+ var node = ts.skipOuterExpressions(expr, 6 /* OuterExpressionKinds.Assertions */ | 1 /* OuterExpressionKinds.Parentheses */);
+ if (node.kind !== 79 /* SyntaxKind.Identifier */ && !ts.isAccessExpression(node)) {
error(expr, invalidReferenceMessage);
return false;
}
- if (node.flags & 32 /* OptionalChain */) {
+ if (node.flags & 32 /* NodeFlags.OptionalChain */) {
error(expr, invalidOptionalChainMessage);
return false;
}
@@ -76882,8 +78341,8 @@ var ts;
function checkDeleteExpressionMustBeOptional(expr, symbol) {
var type = getTypeOfSymbol(symbol);
if (strictNullChecks &&
- !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) &&
- !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getFalsyFlags(type) & 32768 /* Undefined */)) {
+ !(type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) &&
+ !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* SymbolFlags.Optional */ : getFalsyFlags(type) & 32768 /* TypeFlags.Undefined */)) {
error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
}
}
@@ -76895,52 +78354,68 @@ var ts;
checkExpression(node.expression);
return undefinedWideningType;
}
- function checkAwaitExpression(node) {
+ function checkAwaitExpressionGrammar(node) {
// Grammar checking
- if (produceDiagnostics) {
- var container = ts.getContainingFunctionOrClassStaticBlock(node);
- if (container && ts.isClassStaticBlockDeclaration(container)) {
- error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block);
- }
- else if (!(node.flags & 32768 /* AwaitContext */)) {
- if (ts.isInTopLevelContext(node)) {
- var sourceFile = ts.getSourceFileOfNode(node);
- if (!hasParseDiagnostics(sourceFile)) {
- var span = void 0;
- if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
- if (!span)
- span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
- var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module);
- diagnostics.add(diagnostic);
- }
- if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
- span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
- var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher);
- diagnostics.add(diagnostic);
- }
- }
- }
- else {
- // use of 'await' in non-async function
- var sourceFile = ts.getSourceFileOfNode(node);
- if (!hasParseDiagnostics(sourceFile)) {
- var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
- var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules);
- if (container && container.kind !== 170 /* Constructor */ && (ts.getFunctionFlags(container) & 2 /* Async */) === 0) {
- var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
- ts.addRelatedInfo(diagnostic, relatedInfo);
- }
+ var container = ts.getContainingFunctionOrClassStaticBlock(node);
+ if (container && ts.isClassStaticBlockDeclaration(container)) {
+ error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block);
+ }
+ else if (!(node.flags & 32768 /* NodeFlags.AwaitContext */)) {
+ if (ts.isInTopLevelContext(node)) {
+ var sourceFile = ts.getSourceFileOfNode(node);
+ if (!hasParseDiagnostics(sourceFile)) {
+ var span = void 0;
+ if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
+ span !== null && span !== void 0 ? span : (span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos));
+ var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module);
diagnostics.add(diagnostic);
}
+ switch (moduleKind) {
+ case ts.ModuleKind.Node16:
+ case ts.ModuleKind.NodeNext:
+ if (sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS) {
+ span !== null && span !== void 0 ? span : (span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos));
+ diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level));
+ break;
+ }
+ // fallthrough
+ case ts.ModuleKind.ES2022:
+ case ts.ModuleKind.ESNext:
+ case ts.ModuleKind.System:
+ if (languageVersion >= 4 /* ScriptTarget.ES2017 */) {
+ break;
+ }
+ // fallthrough
+ default:
+ span !== null && span !== void 0 ? span : (span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos));
+ diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher));
+ break;
+ }
}
}
- if (isInParameterInitializerBeforeContainingFunction(node)) {
- error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer);
+ else {
+ // use of 'await' in non-async function
+ var sourceFile = ts.getSourceFileOfNode(node);
+ if (!hasParseDiagnostics(sourceFile)) {
+ var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
+ var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules);
+ if (container && container.kind !== 171 /* SyntaxKind.Constructor */ && (ts.getFunctionFlags(container) & 2 /* FunctionFlags.Async */) === 0) {
+ var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
+ ts.addRelatedInfo(diagnostic, relatedInfo);
+ }
+ diagnostics.add(diagnostic);
+ }
}
}
+ if (isInParameterInitializerBeforeContainingFunction(node)) {
+ error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer);
+ }
+ }
+ function checkAwaitExpression(node) {
+ addLazyDiagnostic(function () { return checkAwaitExpressionGrammar(node); });
var operandType = checkExpression(node.expression);
var awaitedType = checkAwaitedType(operandType, /*withAlias*/ true, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
- if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) {
+ if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* TypeFlags.AnyOrUnknown */)) {
addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression));
}
return awaitedType;
@@ -76951,16 +78426,16 @@ var ts;
return silentNeverType;
}
switch (node.operand.kind) {
- case 8 /* NumericLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
switch (node.operator) {
- case 40 /* MinusToken */:
+ case 40 /* SyntaxKind.MinusToken */:
return getFreshTypeOfLiteralType(getNumberLiteralType(-node.operand.text));
- case 39 /* PlusToken */:
+ case 39 /* SyntaxKind.PlusToken */:
return getFreshTypeOfLiteralType(getNumberLiteralType(+node.operand.text));
}
break;
- case 9 /* BigIntLiteral */:
- if (node.operator === 40 /* MinusToken */) {
+ case 9 /* SyntaxKind.BigIntLiteral */:
+ if (node.operator === 40 /* SyntaxKind.MinusToken */) {
return getFreshTypeOfLiteralType(getBigIntLiteralType({
negative: true,
base10Value: ts.parsePseudoBigInt(node.operand.text)
@@ -76968,28 +78443,28 @@ var ts;
}
}
switch (node.operator) {
- case 39 /* PlusToken */:
- case 40 /* MinusToken */:
- case 54 /* TildeToken */:
+ case 39 /* SyntaxKind.PlusToken */:
+ case 40 /* SyntaxKind.MinusToken */:
+ case 54 /* SyntaxKind.TildeToken */:
checkNonNullType(operandType, node.operand);
- if (maybeTypeOfKind(operandType, 12288 /* ESSymbolLike */)) {
+ if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* TypeFlags.ESSymbolLike */)) {
error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator));
}
- if (node.operator === 39 /* PlusToken */) {
- if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) {
+ if (node.operator === 39 /* SyntaxKind.PlusToken */) {
+ if (maybeTypeOfKind(operandType, 2112 /* TypeFlags.BigIntLike */)) {
error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType)));
}
return numberType;
}
return getUnaryResultType(operandType);
- case 53 /* ExclamationToken */:
+ case 53 /* SyntaxKind.ExclamationToken */:
checkTruthinessExpression(node.operand);
- var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */);
- return facts === 4194304 /* Truthy */ ? falseType :
- facts === 8388608 /* Falsy */ ? trueType :
+ var facts = getTypeFacts(operandType) & (4194304 /* TypeFacts.Truthy */ | 8388608 /* TypeFacts.Falsy */);
+ return facts === 4194304 /* TypeFacts.Truthy */ ? falseType :
+ facts === 8388608 /* TypeFacts.Falsy */ ? trueType :
booleanType;
- case 45 /* PlusPlusToken */:
- case 46 /* MinusMinusToken */:
+ case 45 /* SyntaxKind.PlusPlusToken */:
+ case 46 /* SyntaxKind.MinusMinusToken */:
var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type);
if (ok) {
// run check only if former checks succeeded to avoid reporting cascading errors
@@ -77012,21 +78487,28 @@ var ts;
return getUnaryResultType(operandType);
}
function getUnaryResultType(operandType) {
- if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) {
- return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* NumberLike */)
+ if (maybeTypeOfKind(operandType, 2112 /* TypeFlags.BigIntLike */)) {
+ return isTypeAssignableToKind(operandType, 3 /* TypeFlags.AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* TypeFlags.NumberLike */)
? numberOrBigIntType
: bigintType;
}
// If it's not a bigint type, implicit coercion will result in a number
return numberType;
}
+ function maybeTypeOfKindConsideringBaseConstraint(type, kind) {
+ if (maybeTypeOfKind(type, kind)) {
+ return true;
+ }
+ var baseConstraint = getBaseConstraintOrType(type);
+ return !!baseConstraint && maybeTypeOfKind(baseConstraint, kind);
+ }
// Return true if type might be of the given kind. A union or intersection type might be of a given
// kind if at least one constituent type is of the given kind.
function maybeTypeOfKind(type, kind) {
if (type.flags & kind) {
return true;
}
- if (type.flags & 3145728 /* UnionOrIntersection */) {
+ if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) {
var types = type.types;
for (var _i = 0, types_21 = types; _i < types_21.length; _i++) {
var t = types_21[_i];
@@ -77041,30 +78523,30 @@ var ts;
if (source.flags & kind) {
return true;
}
- if (strict && source.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */)) {
+ if (strict && source.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */)) {
return false;
}
- return !!(kind & 296 /* NumberLike */) && isTypeAssignableTo(source, numberType) ||
- !!(kind & 2112 /* BigIntLike */) && isTypeAssignableTo(source, bigintType) ||
- !!(kind & 402653316 /* StringLike */) && isTypeAssignableTo(source, stringType) ||
- !!(kind & 528 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) ||
- !!(kind & 16384 /* Void */) && isTypeAssignableTo(source, voidType) ||
- !!(kind & 131072 /* Never */) && isTypeAssignableTo(source, neverType) ||
- !!(kind & 65536 /* Null */) && isTypeAssignableTo(source, nullType) ||
- !!(kind & 32768 /* Undefined */) && isTypeAssignableTo(source, undefinedType) ||
- !!(kind & 4096 /* ESSymbol */) && isTypeAssignableTo(source, esSymbolType) ||
- !!(kind & 67108864 /* NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType);
+ return !!(kind & 296 /* TypeFlags.NumberLike */) && isTypeAssignableTo(source, numberType) ||
+ !!(kind & 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableTo(source, bigintType) ||
+ !!(kind & 402653316 /* TypeFlags.StringLike */) && isTypeAssignableTo(source, stringType) ||
+ !!(kind & 528 /* TypeFlags.BooleanLike */) && isTypeAssignableTo(source, booleanType) ||
+ !!(kind & 16384 /* TypeFlags.Void */) && isTypeAssignableTo(source, voidType) ||
+ !!(kind & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(source, neverType) ||
+ !!(kind & 65536 /* TypeFlags.Null */) && isTypeAssignableTo(source, nullType) ||
+ !!(kind & 32768 /* TypeFlags.Undefined */) && isTypeAssignableTo(source, undefinedType) ||
+ !!(kind & 4096 /* TypeFlags.ESSymbol */) && isTypeAssignableTo(source, esSymbolType) ||
+ !!(kind & 67108864 /* TypeFlags.NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType);
}
function allTypesAssignableToKind(source, kind, strict) {
- return source.flags & 1048576 /* Union */ ?
+ return source.flags & 1048576 /* TypeFlags.Union */ ?
ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) :
isTypeAssignableToKind(source, kind, strict);
}
function isConstEnumObjectType(type) {
- return !!(ts.getObjectFlags(type) & 16 /* Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol);
+ return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol);
}
function isConstEnumSymbol(symbol) {
- return (symbol.flags & 128 /* ConstEnum */) !== 0;
+ return (symbol.flags & 128 /* SymbolFlags.ConstEnum */) !== 0;
}
function checkInstanceOfExpression(left, right, leftType, rightType) {
if (leftType === silentNeverType || rightType === silentNeverType) {
@@ -77076,7 +78558,7 @@ var ts;
// The result is always of the Boolean primitive type.
// NOTE: do not raise error if leftType is unknown as related error was already reported
if (!isTypeAny(leftType) &&
- allTypesAssignableToKind(leftType, 131068 /* Primitive */)) {
+ allTypesAssignableToKind(leftType, 131068 /* TypeFlags.Primitive */)) {
error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
}
// NOTE: do not raise error if right is unknown as related error was already reported
@@ -77090,8 +78572,8 @@ var ts;
return silentNeverType;
}
if (ts.isPrivateIdentifier(left)) {
- if (languageVersion < 99 /* ESNext */) {
- checkExternalEmitHelpers(left, 2097152 /* ClassPrivateFieldIn */);
+ if (languageVersion < 99 /* ScriptTarget.ESNext */) {
+ checkExternalEmitHelpers(left, 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */);
}
// Unlike in 'checkPrivateIdentifierExpression' we now have access to the RHS type
// which provides us with the opportunity to emit more detailed errors
@@ -77104,8 +78586,8 @@ var ts;
leftType = checkNonNullType(leftType, left);
// TypeScript 1.0 spec (April 2014): 4.15.5
// Require the left operand to be of type Any, the String primitive type, or the Number primitive type.
- if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) ||
- isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) {
+ if (!(allTypesAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) ||
+ isTypeAssignableToKind(leftType, 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 262144 /* TypeFlags.TypeParameter */))) {
error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol);
}
}
@@ -77130,9 +78612,9 @@ var ts;
//
// The result is always of the Boolean primitive type.
var rightTypeConstraint = getConstraintOfType(rightType);
- if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) ||
- rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) ||
- !maybeTypeOfKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */))) {
+ if (!allTypesAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ||
+ rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* TypeFlags.UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ||
+ !maybeTypeOfKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */))) {
error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive);
}
return booleanType;
@@ -77152,7 +78634,7 @@ var ts;
if (rightIsThis === void 0) { rightIsThis = false; }
var properties = node.properties;
var property = properties[propertyIndex];
- if (property.kind === 294 /* PropertyAssignment */ || property.kind === 295 /* ShorthandPropertyAssignment */) {
+ if (property.kind === 296 /* SyntaxKind.PropertyAssignment */ || property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) {
var name = property.name;
var exprType = getLiteralTypeFromPropertyName(name);
if (isTypeUsableAsPropertyName(exprType)) {
@@ -77163,17 +78645,17 @@ var ts;
checkPropertyAccessibility(property, /*isSuper*/ false, /*writing*/ true, objectLiteralType, prop);
}
}
- var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name);
+ var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* AccessFlags.ExpressionPosition */, name);
var type = getFlowTypeOfDestructuring(property, elementType);
- return checkDestructuringAssignment(property.kind === 295 /* ShorthandPropertyAssignment */ ? property : property.initializer, type);
+ return checkDestructuringAssignment(property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? property : property.initializer, type);
}
- else if (property.kind === 296 /* SpreadAssignment */) {
+ else if (property.kind === 298 /* SyntaxKind.SpreadAssignment */) {
if (propertyIndex < properties.length - 1) {
error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
}
else {
- if (languageVersion < 99 /* ESNext */) {
- checkExternalEmitHelpers(property, 4 /* Rest */);
+ if (languageVersion < 99 /* ScriptTarget.ESNext */) {
+ checkExternalEmitHelpers(property, 4 /* ExternalEmitHelpers.Rest */);
}
var nonRestNames = [];
if (allProperties) {
@@ -77195,18 +78677,18 @@ var ts;
}
function checkArrayLiteralAssignment(node, sourceType, checkMode) {
var elements = node.elements;
- if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) {
- checkExternalEmitHelpers(node, 512 /* Read */);
+ if (languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) {
+ checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */);
}
// This elementType will be used if the specific property corresponding to this index is not
// present (aka the tuple element property). This call also checks that the parentType is in
// fact an iterable or array (depending on target language).
- var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* Destructuring */ | 128 /* PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType;
+ var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | 128 /* IterationUse.PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType;
var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType;
for (var i = 0; i < elements.length; i++) {
var type = possiblyOutOfBoundsType;
- if (node.elements[i].kind === 224 /* SpreadElement */) {
- type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* Destructuring */, sourceType, undefinedType, node) || errorType);
+ if (node.elements[i].kind === 225 /* SyntaxKind.SpreadElement */) {
+ type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, sourceType, undefinedType, node) || errorType);
}
checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode);
}
@@ -77215,15 +78697,15 @@ var ts;
function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) {
var elements = node.elements;
var element = elements[elementIndex];
- if (element.kind !== 226 /* OmittedExpression */) {
- if (element.kind !== 224 /* SpreadElement */) {
+ if (element.kind !== 227 /* SyntaxKind.OmittedExpression */) {
+ if (element.kind !== 225 /* SyntaxKind.SpreadElement */) {
var indexType = getNumberLiteralType(elementIndex);
if (isArrayLikeType(sourceType)) {
// We create a synthetic expression so that getIndexedAccessType doesn't get confused
// when the element is a SyntaxKind.ElementAccessExpression.
- var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* NoTupleBoundsCheck */ : 0);
+ var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0);
var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, accessFlags, createSyntheticExpression(element, indexType)) || errorType;
- var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* NEUndefined */) : elementType_2;
+ var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* TypeFacts.NEUndefined */) : elementType_2;
var type = getFlowTypeOfDestructuring(element, assignedType);
return checkDestructuringAssignment(element, type, checkMode);
}
@@ -77234,7 +78716,7 @@ var ts;
}
else {
var restExpression = element.expression;
- if (restExpression.kind === 220 /* BinaryExpression */ && restExpression.operatorToken.kind === 63 /* EqualsToken */) {
+ if (restExpression.kind === 221 /* SyntaxKind.BinaryExpression */ && restExpression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) {
error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
}
else {
@@ -77250,14 +78732,14 @@ var ts;
}
function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) {
var target;
- if (exprOrAssignment.kind === 295 /* ShorthandPropertyAssignment */) {
+ if (exprOrAssignment.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) {
var prop = exprOrAssignment;
if (prop.objectAssignmentInitializer) {
// In strict null checking mode, if a default value of a non-undefined type is specified, remove
// undefined from the final type.
if (strictNullChecks &&
- !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768 /* Undefined */)) {
- sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */);
+ !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768 /* TypeFlags.Undefined */)) {
+ sourceType = getTypeWithFacts(sourceType, 524288 /* TypeFacts.NEUndefined */);
}
checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
}
@@ -77266,31 +78748,31 @@ var ts;
else {
target = exprOrAssignment;
}
- if (target.kind === 220 /* BinaryExpression */ && target.operatorToken.kind === 63 /* EqualsToken */) {
+ if (target.kind === 221 /* SyntaxKind.BinaryExpression */ && target.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) {
checkBinaryExpression(target, checkMode);
target = target.left;
}
- if (target.kind === 204 /* ObjectLiteralExpression */) {
+ if (target.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) {
return checkObjectLiteralAssignment(target, sourceType, rightIsThis);
}
- if (target.kind === 203 /* ArrayLiteralExpression */) {
+ if (target.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) {
return checkArrayLiteralAssignment(target, sourceType, checkMode);
}
return checkReferenceAssignment(target, sourceType, checkMode);
}
function checkReferenceAssignment(target, sourceType, checkMode) {
var targetType = checkExpression(target, checkMode);
- var error = target.parent.kind === 296 /* SpreadAssignment */ ?
+ var error = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ?
ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access :
ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access;
- var optionalError = target.parent.kind === 296 /* SpreadAssignment */ ?
+ var optionalError = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ?
ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access :
ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access;
if (checkReferenceExpression(target, error, optionalError)) {
checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target);
}
if (ts.isPrivateIdentifierPropertyAccessExpression(target)) {
- checkExternalEmitHelpers(target.parent, 1048576 /* ClassPrivateFieldSet */);
+ checkExternalEmitHelpers(target.parent, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */);
}
return sourceType;
}
@@ -77305,59 +78787,59 @@ var ts;
function isSideEffectFree(node) {
node = ts.skipParentheses(node);
switch (node.kind) {
- case 79 /* Identifier */:
- case 10 /* StringLiteral */:
- case 13 /* RegularExpressionLiteral */:
- case 209 /* TaggedTemplateExpression */:
- case 222 /* TemplateExpression */:
- case 14 /* NoSubstitutionTemplateLiteral */:
- case 8 /* NumericLiteral */:
- case 9 /* BigIntLiteral */:
- case 110 /* TrueKeyword */:
- case 95 /* FalseKeyword */:
- case 104 /* NullKeyword */:
- case 152 /* UndefinedKeyword */:
- case 212 /* FunctionExpression */:
- case 225 /* ClassExpression */:
- case 213 /* ArrowFunction */:
- case 203 /* ArrayLiteralExpression */:
- case 204 /* ObjectLiteralExpression */:
- case 215 /* TypeOfExpression */:
- case 229 /* NonNullExpression */:
- case 278 /* JsxSelfClosingElement */:
- case 277 /* JsxElement */:
+ case 79 /* SyntaxKind.Identifier */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 13 /* SyntaxKind.RegularExpressionLiteral */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
+ case 223 /* SyntaxKind.TemplateExpression */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
+ case 9 /* SyntaxKind.BigIntLiteral */:
+ case 110 /* SyntaxKind.TrueKeyword */:
+ case 95 /* SyntaxKind.FalseKeyword */:
+ case 104 /* SyntaxKind.NullKeyword */:
+ case 153 /* SyntaxKind.UndefinedKeyword */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
+ case 216 /* SyntaxKind.TypeOfExpression */:
+ case 230 /* SyntaxKind.NonNullExpression */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
+ case 278 /* SyntaxKind.JsxElement */:
return true;
- case 221 /* ConditionalExpression */:
+ case 222 /* SyntaxKind.ConditionalExpression */:
return isSideEffectFree(node.whenTrue) &&
isSideEffectFree(node.whenFalse);
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
if (ts.isAssignmentOperator(node.operatorToken.kind)) {
return false;
}
return isSideEffectFree(node.left) &&
isSideEffectFree(node.right);
- case 218 /* PrefixUnaryExpression */:
- case 219 /* PostfixUnaryExpression */:
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
+ case 220 /* SyntaxKind.PostfixUnaryExpression */:
// Unary operators ~, !, +, and - have no side effects.
// The rest do.
switch (node.operator) {
- case 53 /* ExclamationToken */:
- case 39 /* PlusToken */:
- case 40 /* MinusToken */:
- case 54 /* TildeToken */:
+ case 53 /* SyntaxKind.ExclamationToken */:
+ case 39 /* SyntaxKind.PlusToken */:
+ case 40 /* SyntaxKind.MinusToken */:
+ case 54 /* SyntaxKind.TildeToken */:
return true;
}
return false;
// Some forms listed here for clarity
- case 216 /* VoidExpression */: // Explicit opt-out
- case 210 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings
- case 228 /* AsExpression */: // Not SEF, but can produce useful type warnings
+ case 217 /* SyntaxKind.VoidExpression */: // Explicit opt-out
+ case 211 /* SyntaxKind.TypeAssertionExpression */: // Not SEF, but can produce useful type warnings
+ case 229 /* SyntaxKind.AsExpression */: // Not SEF, but can produce useful type warnings
default:
return false;
}
}
function isTypeEqualityComparableTo(source, target) {
- return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target);
+ return (target.flags & 98304 /* TypeFlags.Nullable */) !== 0 || isTypeComparableTo(source, target);
}
function createCheckBinaryExpression() {
var trampoline = ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState);
@@ -77388,9 +78870,9 @@ var ts;
}
checkGrammarNullishCoalesceWithLogicalExpression(node);
var operator = node.operatorToken.kind;
- if (operator === 63 /* EqualsToken */ && (node.left.kind === 204 /* ObjectLiteralExpression */ || node.left.kind === 203 /* ArrayLiteralExpression */)) {
+ if (operator === 63 /* SyntaxKind.EqualsToken */ && (node.left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || node.left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) {
state.skip = true;
- setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* ThisKeyword */));
+ setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* SyntaxKind.ThisKeyword */));
return state;
}
return state;
@@ -77407,10 +78889,10 @@ var ts;
setLeftType(state, leftType);
setLastResult(state, /*type*/ undefined);
var operator = operatorToken.kind;
- if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) {
- if (operator === 55 /* AmpersandAmpersandToken */) {
+ if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) {
+ if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */) {
var parent = ts.walkUpParenthesizedExpressions(node.parent);
- checkTestingKnownTruthyCallableOrAwaitableType(node.left, leftType, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
+ checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
}
checkTruthinessOfType(leftType, node.left);
}
@@ -77468,11 +78950,11 @@ var ts;
}
function checkGrammarNullishCoalesceWithLogicalExpression(node) {
var left = node.left, operatorToken = node.operatorToken, right = node.right;
- if (operatorToken.kind === 60 /* QuestionQuestionToken */) {
- if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* BarBarToken */ || left.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) {
+ if (operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) {
+ if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || left.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) {
grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind));
}
- if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* BarBarToken */ || right.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) {
+ if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || right.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) {
grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind));
}
}
@@ -77481,11 +78963,11 @@ var ts;
// expression-wide checks and does not use a work stack to fold nested binary expressions into the same callstack frame
function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) {
var operator = operatorToken.kind;
- if (operator === 63 /* EqualsToken */ && (left.kind === 204 /* ObjectLiteralExpression */ || left.kind === 203 /* ArrayLiteralExpression */)) {
- return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* ThisKeyword */);
+ if (operator === 63 /* SyntaxKind.EqualsToken */ && (left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) {
+ return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* SyntaxKind.ThisKeyword */);
}
var leftType;
- if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) {
+ if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) {
leftType = checkTruthinessExpression(left, checkMode);
}
else {
@@ -77497,28 +78979,28 @@ var ts;
function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode) {
var operator = operatorToken.kind;
switch (operator) {
- case 41 /* AsteriskToken */:
- case 42 /* AsteriskAsteriskToken */:
- case 66 /* AsteriskEqualsToken */:
- case 67 /* AsteriskAsteriskEqualsToken */:
- case 43 /* SlashToken */:
- case 68 /* SlashEqualsToken */:
- case 44 /* PercentToken */:
- case 69 /* PercentEqualsToken */:
- case 40 /* MinusToken */:
- case 65 /* MinusEqualsToken */:
- case 47 /* LessThanLessThanToken */:
- case 70 /* LessThanLessThanEqualsToken */:
- case 48 /* GreaterThanGreaterThanToken */:
- case 71 /* GreaterThanGreaterThanEqualsToken */:
- case 49 /* GreaterThanGreaterThanGreaterThanToken */:
- case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
- case 51 /* BarToken */:
- case 74 /* BarEqualsToken */:
- case 52 /* CaretToken */:
- case 78 /* CaretEqualsToken */:
- case 50 /* AmpersandToken */:
- case 73 /* AmpersandEqualsToken */:
+ case 41 /* SyntaxKind.AsteriskToken */:
+ case 42 /* SyntaxKind.AsteriskAsteriskToken */:
+ case 66 /* SyntaxKind.AsteriskEqualsToken */:
+ case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */:
+ case 43 /* SyntaxKind.SlashToken */:
+ case 68 /* SyntaxKind.SlashEqualsToken */:
+ case 44 /* SyntaxKind.PercentToken */:
+ case 69 /* SyntaxKind.PercentEqualsToken */:
+ case 40 /* SyntaxKind.MinusToken */:
+ case 65 /* SyntaxKind.MinusEqualsToken */:
+ case 47 /* SyntaxKind.LessThanLessThanToken */:
+ case 70 /* SyntaxKind.LessThanLessThanEqualsToken */:
+ case 48 /* SyntaxKind.GreaterThanGreaterThanToken */:
+ case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */:
+ case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */:
+ case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */:
+ case 51 /* SyntaxKind.BarToken */:
+ case 74 /* SyntaxKind.BarEqualsToken */:
+ case 52 /* SyntaxKind.CaretToken */:
+ case 78 /* SyntaxKind.CaretEqualsToken */:
+ case 50 /* SyntaxKind.AmpersandToken */:
+ case 73 /* SyntaxKind.AmpersandEqualsToken */:
if (leftType === silentNeverType || rightType === silentNeverType) {
return silentNeverType;
}
@@ -77527,8 +79009,8 @@ var ts;
var suggestedOperator = void 0;
// if a user tries to apply a bitwise operator to 2 boolean operands
// try and return them a helpful suggestion
- if ((leftType.flags & 528 /* BooleanLike */) &&
- (rightType.flags & 528 /* BooleanLike */) &&
+ if ((leftType.flags & 528 /* TypeFlags.BooleanLike */) &&
+ (rightType.flags & 528 /* TypeFlags.BooleanLike */) &&
(suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) {
error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator));
return numberType;
@@ -77539,21 +79021,21 @@ var ts;
var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type, /*isAwaitValid*/ true);
var resultType_1;
// If both are any or unknown, allow operation; assume it will resolve to number
- if ((isTypeAssignableToKind(leftType, 3 /* AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* AnyOrUnknown */)) ||
+ if ((isTypeAssignableToKind(leftType, 3 /* TypeFlags.AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* TypeFlags.AnyOrUnknown */)) ||
// Or, if neither could be bigint, implicit coercion results in a number result
- !(maybeTypeOfKind(leftType, 2112 /* BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* BigIntLike */))) {
+ !(maybeTypeOfKind(leftType, 2112 /* TypeFlags.BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* TypeFlags.BigIntLike */))) {
resultType_1 = numberType;
}
// At least one is assignable to bigint, so check that both are
else if (bothAreBigIntLike(leftType, rightType)) {
switch (operator) {
- case 49 /* GreaterThanGreaterThanGreaterThanToken */:
- case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
+ case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */:
+ case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */:
reportOperatorError();
break;
- case 42 /* AsteriskAsteriskToken */:
- case 67 /* AsteriskAsteriskEqualsToken */:
- if (languageVersion < 3 /* ES2016 */) {
+ case 42 /* SyntaxKind.AsteriskAsteriskToken */:
+ case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */:
+ if (languageVersion < 3 /* ScriptTarget.ES2016 */) {
error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later);
}
}
@@ -77569,26 +79051,26 @@ var ts;
}
return resultType_1;
}
- case 39 /* PlusToken */:
- case 64 /* PlusEqualsToken */:
+ case 39 /* SyntaxKind.PlusToken */:
+ case 64 /* SyntaxKind.PlusEqualsToken */:
if (leftType === silentNeverType || rightType === silentNeverType) {
return silentNeverType;
}
- if (!isTypeAssignableToKind(leftType, 402653316 /* StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* StringLike */)) {
+ if (!isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */)) {
leftType = checkNonNullType(leftType, left);
rightType = checkNonNullType(rightType, right);
}
var resultType = void 0;
- if (isTypeAssignableToKind(leftType, 296 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* NumberLike */, /*strict*/ true)) {
+ if (isTypeAssignableToKind(leftType, 296 /* TypeFlags.NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* TypeFlags.NumberLike */, /*strict*/ true)) {
// Operands of an enum type are treated as having the primitive type Number.
// If both operands are of the Number primitive type, the result is of the Number primitive type.
resultType = numberType;
}
- else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */, /*strict*/ true)) {
+ else if (isTypeAssignableToKind(leftType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true)) {
// If both operands are of the BigInt primitive type, the result is of the BigInt primitive type.
resultType = bigintType;
}
- else if (isTypeAssignableToKind(leftType, 402653316 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* StringLike */, /*strict*/ true)) {
+ else if (isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true)) {
// If one or both operands are of the String primitive type, the result is of the String primitive type.
resultType = stringType;
}
@@ -77606,21 +79088,21 @@ var ts;
// If both types have an awaited type of one of these, we'll assume the user
// might be missing an await without doing an exhaustive check that inserting
// await(s) will actually be a completely valid binary expression.
- var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 3 /* AnyOrUnknown */;
+ var closeEnoughKind_1 = 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 3 /* TypeFlags.AnyOrUnknown */;
reportOperatorError(function (left, right) {
return isTypeAssignableToKind(left, closeEnoughKind_1) &&
isTypeAssignableToKind(right, closeEnoughKind_1);
});
return anyType;
}
- if (operator === 64 /* PlusEqualsToken */) {
+ if (operator === 64 /* SyntaxKind.PlusEqualsToken */) {
checkAssignmentOperator(resultType);
}
return resultType;
- case 29 /* LessThanToken */:
- case 31 /* GreaterThanToken */:
- case 32 /* LessThanEqualsToken */:
- case 33 /* GreaterThanEqualsToken */:
+ case 29 /* SyntaxKind.LessThanToken */:
+ case 31 /* SyntaxKind.GreaterThanToken */:
+ case 32 /* SyntaxKind.LessThanEqualsToken */:
+ case 33 /* SyntaxKind.GreaterThanEqualsToken */:
if (checkForDisallowedESSymbolOperand(operator)) {
leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left));
rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right));
@@ -77629,56 +79111,56 @@ var ts;
});
}
return booleanType;
- case 34 /* EqualsEqualsToken */:
- case 35 /* ExclamationEqualsToken */:
- case 36 /* EqualsEqualsEqualsToken */:
- case 37 /* ExclamationEqualsEqualsToken */:
+ case 34 /* SyntaxKind.EqualsEqualsToken */:
+ case 35 /* SyntaxKind.ExclamationEqualsToken */:
+ case 36 /* SyntaxKind.EqualsEqualsEqualsToken */:
+ case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */:
reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); });
return booleanType;
- case 102 /* InstanceOfKeyword */:
+ case 102 /* SyntaxKind.InstanceOfKeyword */:
return checkInstanceOfExpression(left, right, leftType, rightType);
- case 101 /* InKeyword */:
+ case 101 /* SyntaxKind.InKeyword */:
return checkInExpression(left, right, leftType, rightType);
- case 55 /* AmpersandAmpersandToken */:
- case 76 /* AmpersandAmpersandEqualsToken */: {
- var resultType_2 = getTypeFacts(leftType) & 4194304 /* Truthy */ ?
+ case 55 /* SyntaxKind.AmpersandAmpersandToken */:
+ case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: {
+ var resultType_2 = getTypeFacts(leftType) & 4194304 /* TypeFacts.Truthy */ ?
getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) :
leftType;
- if (operator === 76 /* AmpersandAmpersandEqualsToken */) {
+ if (operator === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) {
checkAssignmentOperator(rightType);
}
return resultType_2;
}
- case 56 /* BarBarToken */:
- case 75 /* BarBarEqualsToken */: {
- var resultType_3 = getTypeFacts(leftType) & 8388608 /* Falsy */ ?
- getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) :
+ case 56 /* SyntaxKind.BarBarToken */:
+ case 75 /* SyntaxKind.BarBarEqualsToken */: {
+ var resultType_3 = getTypeFacts(leftType) & 8388608 /* TypeFacts.Falsy */ ?
+ getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* UnionReduction.Subtype */) :
leftType;
- if (operator === 75 /* BarBarEqualsToken */) {
+ if (operator === 75 /* SyntaxKind.BarBarEqualsToken */) {
checkAssignmentOperator(rightType);
}
return resultType_3;
}
- case 60 /* QuestionQuestionToken */:
- case 77 /* QuestionQuestionEqualsToken */: {
- var resultType_4 = getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ?
- getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) :
+ case 60 /* SyntaxKind.QuestionQuestionToken */:
+ case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: {
+ var resultType_4 = getTypeFacts(leftType) & 262144 /* TypeFacts.EQUndefinedOrNull */ ?
+ getUnionType([getNonNullableType(leftType), rightType], 2 /* UnionReduction.Subtype */) :
leftType;
- if (operator === 77 /* QuestionQuestionEqualsToken */) {
+ if (operator === 77 /* SyntaxKind.QuestionQuestionEqualsToken */) {
checkAssignmentOperator(rightType);
}
return resultType_4;
}
- case 63 /* EqualsToken */:
- var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */;
+ case 63 /* SyntaxKind.EqualsToken */:
+ var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* AssignmentDeclarationKind.None */;
checkAssignmentDeclaration(declKind, rightType);
if (isAssignmentDeclaration(declKind)) {
- if (!(rightType.flags & 524288 /* Object */) ||
- declKind !== 2 /* ModuleExports */ &&
- declKind !== 6 /* Prototype */ &&
+ if (!(rightType.flags & 524288 /* TypeFlags.Object */) ||
+ declKind !== 2 /* AssignmentDeclarationKind.ModuleExports */ &&
+ declKind !== 6 /* AssignmentDeclarationKind.Prototype */ &&
!isEmptyObjectType(rightType) &&
!isFunctionObjectType(rightType) &&
- !(ts.getObjectFlags(rightType) & 1 /* Class */)) {
+ !(ts.getObjectFlags(rightType) & 1 /* ObjectFlags.Class */)) {
// don't check assignability of module.exports=, C.prototype=, or expando types because they will necessarily be incomplete
checkAssignmentOperator(rightType);
}
@@ -77688,7 +79170,7 @@ var ts;
checkAssignmentOperator(rightType);
return getRegularTypeOfObjectLiteral(rightType);
}
- case 27 /* CommaToken */:
+ case 27 /* SyntaxKind.CommaToken */:
if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) {
var sf = ts.getSourceFileOfNode(left);
var sourceText = sf.text;
@@ -77706,16 +79188,16 @@ var ts;
return ts.Debug.fail();
}
function bothAreBigIntLike(left, right) {
- return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */);
+ return isTypeAssignableToKind(left, 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableToKind(right, 2112 /* TypeFlags.BigIntLike */);
}
function checkAssignmentDeclaration(kind, rightType) {
- if (kind === 2 /* ModuleExports */) {
+ if (kind === 2 /* AssignmentDeclarationKind.ModuleExports */) {
for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) {
var prop = _a[_i];
var propType = getTypeOfSymbol(prop);
- if (propType.symbol && propType.symbol.flags & 32 /* Class */) {
+ if (propType.symbol && propType.symbol.flags & 32 /* SymbolFlags.Class */) {
var name = prop.escapedName;
- var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false);
+ var symbol = resolveName(prop.valueDeclaration, name, 788968 /* SymbolFlags.Type */, undefined, name, /*isUse*/ false);
if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.declarations.some(ts.isJSDocTypedefTag)) {
addDuplicateDeclarationErrorsForSymbols(symbol, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), prop);
addDuplicateDeclarationErrorsForSymbols(prop, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), symbol);
@@ -77725,12 +79207,12 @@ var ts;
}
}
function isEvalNode(node) {
- return node.kind === 79 /* Identifier */ && node.escapedText === "eval";
+ return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "eval";
}
// Return true if there was no error, false if there was an error.
function checkForDisallowedESSymbolOperand(operator) {
- var offendingSymbolOperand = maybeTypeOfKind(leftType, 12288 /* ESSymbolLike */) ? left :
- maybeTypeOfKind(rightType, 12288 /* ESSymbolLike */) ? right :
+ var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* TypeFlags.ESSymbolLike */) ? left :
+ maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* TypeFlags.ESSymbolLike */) ? right :
undefined;
if (offendingSymbolOperand) {
error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator));
@@ -77740,21 +79222,24 @@ var ts;
}
function getSuggestedBooleanOperator(operator) {
switch (operator) {
- case 51 /* BarToken */:
- case 74 /* BarEqualsToken */:
- return 56 /* BarBarToken */;
- case 52 /* CaretToken */:
- case 78 /* CaretEqualsToken */:
- return 37 /* ExclamationEqualsEqualsToken */;
- case 50 /* AmpersandToken */:
- case 73 /* AmpersandEqualsToken */:
- return 55 /* AmpersandAmpersandToken */;
+ case 51 /* SyntaxKind.BarToken */:
+ case 74 /* SyntaxKind.BarEqualsToken */:
+ return 56 /* SyntaxKind.BarBarToken */;
+ case 52 /* SyntaxKind.CaretToken */:
+ case 78 /* SyntaxKind.CaretEqualsToken */:
+ return 37 /* SyntaxKind.ExclamationEqualsEqualsToken */;
+ case 50 /* SyntaxKind.AmpersandToken */:
+ case 73 /* SyntaxKind.AmpersandEqualsToken */:
+ return 55 /* SyntaxKind.AmpersandAmpersandToken */;
default:
return undefined;
}
}
function checkAssignmentOperator(valueType) {
- if (produceDiagnostics && ts.isAssignmentOperator(operator)) {
+ if (ts.isAssignmentOperator(operator)) {
+ addLazyDiagnostic(checkAssignmentOperatorWorker);
+ }
+ function checkAssignmentOperatorWorker() {
// TypeScript 1.0 spec (April 2014): 4.17
// An assignment of the form
// VarExpr = ValueExpr
@@ -77764,7 +79249,7 @@ var ts;
if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access)
&& (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) {
var headMessage = void 0;
- if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* Undefined */)) {
+ if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* TypeFlags.Undefined */)) {
var target = getTypeOfPropertyOfType(getTypeOfExpression(left.expression), left.name.escapedText);
if (isExactOptionalPropertyMismatch(valueType, target)) {
headMessage = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target;
@@ -77778,13 +79263,13 @@ var ts;
function isAssignmentDeclaration(kind) {
var _a;
switch (kind) {
- case 2 /* ModuleExports */:
+ case 2 /* AssignmentDeclarationKind.ModuleExports */:
return true;
- case 1 /* ExportsProperty */:
- case 5 /* Property */:
- case 6 /* Prototype */:
- case 3 /* PrototypeProperty */:
- case 4 /* ThisProperty */:
+ case 1 /* AssignmentDeclarationKind.ExportsProperty */:
+ case 5 /* AssignmentDeclarationKind.Property */:
+ case 6 /* AssignmentDeclarationKind.Prototype */:
+ case 3 /* AssignmentDeclarationKind.PrototypeProperty */:
+ case 4 /* AssignmentDeclarationKind.ThisProperty */:
var symbol = getSymbolOfNode(left);
var init = ts.getAssignedExpandoInitializer(right);
return !!init && ts.isObjectLiteralExpression(init) &&
@@ -77827,12 +79312,12 @@ var ts;
function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) {
var typeName;
switch (operatorToken.kind) {
- case 36 /* EqualsEqualsEqualsToken */:
- case 34 /* EqualsEqualsToken */:
+ case 36 /* SyntaxKind.EqualsEqualsEqualsToken */:
+ case 34 /* SyntaxKind.EqualsEqualsToken */:
typeName = "false";
break;
- case 37 /* ExclamationEqualsEqualsToken */:
- case 35 /* ExclamationEqualsToken */:
+ case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */:
+ case 35 /* SyntaxKind.ExclamationEqualsToken */:
typeName = "true";
}
if (typeName) {
@@ -77853,33 +79338,25 @@ var ts;
return [effectiveLeft, effectiveRight];
}
function checkYieldExpression(node) {
- // Grammar checking
- if (produceDiagnostics) {
- if (!(node.flags & 8192 /* YieldContext */)) {
- grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
- }
- if (isInParameterInitializerBeforeContainingFunction(node)) {
- error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer);
- }
- }
+ addLazyDiagnostic(checkYieldExpressionGrammar);
var func = ts.getContainingFunction(node);
if (!func)
return anyType;
var functionFlags = ts.getFunctionFlags(func);
- if (!(functionFlags & 1 /* Generator */)) {
+ if (!(functionFlags & 1 /* FunctionFlags.Generator */)) {
// If the user's code is syntactically correct, the func should always have a star. After all, we are in a yield context.
return anyType;
}
- var isAsync = (functionFlags & 2 /* Async */) !== 0;
+ var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0;
if (node.asteriskToken) {
// Async generator functions prior to ESNext require the __await, __asyncDelegator,
// and __asyncValues helpers
- if (isAsync && languageVersion < 99 /* ESNext */) {
- checkExternalEmitHelpers(node, 26624 /* AsyncDelegatorIncludes */);
+ if (isAsync && languageVersion < 99 /* ScriptTarget.ESNext */) {
+ checkExternalEmitHelpers(node, 26624 /* ExternalEmitHelpers.AsyncDelegatorIncludes */);
}
// Generator functions prior to ES2015 require the __values helper
- if (!isAsync && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) {
- checkExternalEmitHelpers(node, 256 /* Values */);
+ if (!isAsync && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) {
+ checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.Values */);
}
}
// There is no point in doing an assignability check if the function
@@ -77896,32 +79373,42 @@ var ts;
checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureYieldType, node.expression || node, node.expression);
}
if (node.asteriskToken) {
- var use = isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */;
- return getIterationTypeOfIterable(use, 1 /* Return */, yieldExpressionType, node.expression)
+ var use = isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */;
+ return getIterationTypeOfIterable(use, 1 /* IterationTypeKind.Return */, yieldExpressionType, node.expression)
|| anyType;
}
else if (returnType) {
- return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync)
+ return getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, isAsync)
|| anyType;
}
- var type = getContextualIterationType(2 /* Next */, func);
+ var type = getContextualIterationType(2 /* IterationTypeKind.Next */, func);
if (!type) {
type = anyType;
- if (produceDiagnostics && noImplicitAny && !ts.expressionResultIsUnused(node)) {
- var contextualType = getContextualType(node);
- 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);
+ addLazyDiagnostic(function () {
+ if (noImplicitAny && !ts.expressionResultIsUnused(node)) {
+ var contextualType = getContextualType(node);
+ 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);
+ }
}
- }
+ });
}
return type;
+ function checkYieldExpressionGrammar() {
+ if (!(node.flags & 8192 /* NodeFlags.YieldContext */)) {
+ grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
+ }
+ if (isInParameterInitializerBeforeContainingFunction(node)) {
+ error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer);
+ }
+ }
}
function checkConditionalExpression(node, checkMode) {
- var type = checkTruthinessExpression(node.condition);
- checkTestingKnownTruthyCallableOrAwaitableType(node.condition, type, node.whenTrue);
+ checkTruthinessExpression(node.condition);
+ checkTestingKnownTruthyCallableOrAwaitableType(node.condition, node.whenTrue);
var type1 = checkExpression(node.whenTrue, checkMode);
var type2 = checkExpression(node.whenFalse, checkMode);
- return getUnionType([type1, type2], 2 /* Subtype */);
+ return getUnionType([type1, type2], 2 /* UnionReduction.Subtype */);
}
function isTemplateLiteralContext(node) {
var parent = node.parent;
@@ -77934,7 +79421,7 @@ var ts;
for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) {
var span = _a[_i];
var type = checkExpression(span.expression);
- if (maybeTypeOfKind(type, 12288 /* ESSymbolLike */)) {
+ if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* TypeFlags.ESSymbolLike */)) {
error(span.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String);
}
texts.push(span.literal.text);
@@ -77943,11 +79430,11 @@ var ts;
return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType;
}
function isTemplateLiteralContextualType(type) {
- return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) ||
- type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */));
+ return !!(type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */) ||
+ type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* TypeFlags.StringLike */));
}
function getContextNode(node) {
- if (node.kind === 285 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) {
+ if (node.kind === 286 /* SyntaxKind.JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) {
return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes)
}
return node;
@@ -77959,11 +79446,16 @@ var ts;
try {
context.contextualType = contextualType;
context.inferenceContext = inferenceContext;
- var type = checkExpression(node, checkMode | 1 /* Contextual */ | (inferenceContext ? 2 /* Inferential */ : 0));
+ var type = checkExpression(node, checkMode | 1 /* CheckMode.Contextual */ | (inferenceContext ? 2 /* CheckMode.Inferential */ : 0));
+ // In CheckMode.Inferential we collect intra-expression inference sites to process before fixing any type
+ // parameters. This information is no longer needed after the call to checkExpression.
+ if (inferenceContext && inferenceContext.intraExpressionInferenceSites) {
+ inferenceContext.intraExpressionInferenceSites = undefined;
+ }
// We strip literal freshness when an appropriate contextual type is present such that contextually typed
// literals always preserve their literal types (otherwise they might widen during type inference). An alternative
// here would be to not mark contextually typed literals as fresh in the first place.
- var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ?
+ var result = maybeTypeOfKind(type, 2944 /* TypeFlags.Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ?
getRegularTypeOfLiteralType(type) : type;
return result;
}
@@ -77976,7 +79468,7 @@ var ts;
}
}
function checkExpressionCached(node, checkMode) {
- if (checkMode && checkMode !== 0 /* Normal */) {
+ if (checkMode && checkMode !== 0 /* CheckMode.Normal */) {
return checkExpression(node, checkMode);
}
var links = getNodeLinks(node);
@@ -77996,17 +79488,17 @@ var ts;
}
function isTypeAssertion(node) {
node = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true);
- return node.kind === 210 /* TypeAssertionExpression */ ||
- node.kind === 228 /* AsExpression */ ||
+ return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */ ||
+ node.kind === 229 /* SyntaxKind.AsExpression */ ||
ts.isJSDocTypeAssertion(node);
}
function checkDeclarationInitializer(declaration, checkMode, contextualType) {
var initializer = ts.getEffectiveInitializer(declaration);
var type = getQuickTypeOfExpression(initializer) ||
(contextualType ?
- checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* Normal */)
+ checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* CheckMode.Normal */)
: checkExpressionCached(initializer, checkMode));
- return ts.isParameter(declaration) && declaration.name.kind === 201 /* ArrayBindingPattern */ &&
+ return ts.isParameter(declaration) && declaration.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ &&
isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
padTupleType(type, declaration.name) : type;
}
@@ -78016,9 +79508,9 @@ var ts;
var elementFlags = type.target.elementFlags.slice();
for (var i = getTypeReferenceArity(type); i < patternElements.length; i++) {
var e = patternElements[i];
- if (i < patternElements.length - 1 || !(e.kind === 202 /* BindingElement */ && e.dotDotDotToken)) {
+ if (i < patternElements.length - 1 || !(e.kind === 203 /* SyntaxKind.BindingElement */ && e.dotDotDotToken)) {
elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType);
- elementFlags.push(2 /* Optional */);
+ elementFlags.push(2 /* ElementFlags.Optional */);
if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) {
reportImplicitAny(e, anyType);
}
@@ -78027,7 +79519,7 @@ var ts;
return createTupleType(elementTypes, elementFlags, type.target.readonly);
}
function widenTypeInferredFromInitializer(declaration, type) {
- var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type);
+ var widened = ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type);
if (ts.isInJSFile(declaration)) {
if (isEmptyLiteralType(widened)) {
reportImplicitAny(declaration, anyType);
@@ -78042,28 +79534,28 @@ var ts;
}
function isLiteralOfContextualType(candidateType, contextualType) {
if (contextualType) {
- if (contextualType.flags & 3145728 /* UnionOrIntersection */) {
+ if (contextualType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) {
var types = contextualType.types;
return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); });
}
- if (contextualType.flags & 58982400 /* InstantiableNonPrimitive */) {
+ if (contextualType.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) {
// If the contextual type is a type variable constrained to a primitive type, consider
// this a literal context for literals of that primitive type. For example, given a
// type parameter 'T extends string', infer string literal types for T.
var constraint = getBaseConstraintOfType(contextualType) || unknownType;
- return maybeTypeOfKind(constraint, 4 /* String */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) ||
- maybeTypeOfKind(constraint, 8 /* Number */) && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) ||
- maybeTypeOfKind(constraint, 64 /* BigInt */) && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) ||
- maybeTypeOfKind(constraint, 4096 /* ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */) ||
+ return maybeTypeOfKind(constraint, 4 /* TypeFlags.String */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) ||
+ maybeTypeOfKind(constraint, 8 /* TypeFlags.Number */) && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) ||
+ maybeTypeOfKind(constraint, 64 /* TypeFlags.BigInt */) && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) ||
+ maybeTypeOfKind(constraint, 4096 /* TypeFlags.ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */) ||
isLiteralOfContextualType(candidateType, constraint);
}
// If the contextual type is a literal of a particular primitive type, we consider this a
// literal context for all literals of that primitive type.
- return !!(contextualType.flags & (128 /* StringLiteral */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) ||
- contextualType.flags & 256 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) ||
- contextualType.flags & 2048 /* BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) ||
- contextualType.flags & 512 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* BooleanLiteral */) ||
- contextualType.flags & 8192 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */));
+ return !!(contextualType.flags & (128 /* TypeFlags.StringLiteral */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) ||
+ contextualType.flags & 256 /* TypeFlags.NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) ||
+ contextualType.flags & 2048 /* TypeFlags.BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) ||
+ contextualType.flags & 512 /* TypeFlags.BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* TypeFlags.BooleanLiteral */) ||
+ contextualType.flags & 8192 /* TypeFlags.UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */));
}
return false;
}
@@ -78076,7 +79568,7 @@ var ts;
}
function checkExpressionForMutableLocation(node, checkMode, contextualType, forceTuple) {
var type = checkExpression(node, checkMode, forceTuple);
- return isConstContext(node) ? getRegularTypeOfLiteralType(type) :
+ return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) :
isTypeAssertion(node) ? type :
getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
}
@@ -78084,7 +79576,7 @@ var ts;
// Do not use hasDynamicName here, because that returns false for well known symbols.
// We want to perform checkComputedPropertyName for all computed properties, including
// well known symbols.
- if (node.name.kind === 161 /* ComputedPropertyName */) {
+ if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) {
checkComputedPropertyName(node.name);
}
return checkExpressionForMutableLocation(node.initializer, checkMode);
@@ -78095,23 +79587,23 @@ var ts;
// Do not use hasDynamicName here, because that returns false for well known symbols.
// We want to perform checkComputedPropertyName for all computed properties, including
// well known symbols.
- if (node.name.kind === 161 /* ComputedPropertyName */) {
+ if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) {
checkComputedPropertyName(node.name);
}
var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode);
return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode);
}
function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) {
- if (checkMode && checkMode & (2 /* Inferential */ | 8 /* SkipGenericFunctions */)) {
- var callSignature = getSingleSignature(type, 0 /* Call */, /*allowMembers*/ true);
- var constructSignature = getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ true);
+ if (checkMode && checkMode & (2 /* CheckMode.Inferential */ | 8 /* CheckMode.SkipGenericFunctions */)) {
+ var callSignature = getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ true);
+ var constructSignature = getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ true);
var signature = callSignature || constructSignature;
if (signature && signature.typeParameters) {
- var contextualType = getApparentTypeOfContextualType(node, 2 /* NoConstraints */);
+ var contextualType = getApparentTypeOfContextualType(node, 2 /* ContextFlags.NoConstraints */);
if (contextualType) {
- var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* Call */ : 1 /* Construct */, /*allowMembers*/ false);
+ var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* SignatureKind.Call */ : 1 /* SignatureKind.Construct */, /*allowMembers*/ false);
if (contextualSignature && !contextualSignature.typeParameters) {
- if (checkMode & 8 /* SkipGenericFunctions */) {
+ if (checkMode & 8 /* CheckMode.SkipGenericFunctions */) {
skippedGenericFunction(node, checkMode);
return anyFunctionType;
}
@@ -78159,11 +79651,11 @@ var ts;
return type;
}
function skippedGenericFunction(node, checkMode) {
- if (checkMode & 2 /* Inferential */) {
+ if (checkMode & 2 /* CheckMode.Inferential */) {
// We have skipped a generic function during inferential typing. Obtain the inference context and
// indicate this has occurred such that we know a second pass of inference is be needed.
var context = getInferenceContext(node);
- context.flags |= 4 /* SkippedGenericFunction */;
+ context.flags |= 4 /* InferenceFlags.SkippedGenericFunction */;
}
}
function hasInferenceCandidates(info) {
@@ -78193,7 +79685,7 @@ var ts;
var name = tp.symbol.escapedName;
if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) {
var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name);
- var symbol = createSymbol(262144 /* TypeParameter */, newName);
+ var symbol = createSymbol(262144 /* SymbolFlags.TypeParameter */, newName);
var newTypeParameter = createTypeParameter(symbol);
newTypeParameter.target = tp;
oldTypeParameters = ts.append(oldTypeParameters, tp);
@@ -78218,7 +79710,7 @@ var ts;
}
function getUniqueTypeParameterName(typeParameters, baseName) {
var len = baseName.length;
- while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* _0 */ && baseName.charCodeAt(len - 1) <= 57 /* _9 */)
+ while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* CharacterCodes._0 */ && baseName.charCodeAt(len - 1) <= 57 /* CharacterCodes._9 */)
len--;
var s = baseName.slice(0, len);
for (var index = 1; true; index++) {
@@ -78251,7 +79743,7 @@ var ts;
return quickType;
}
// If a type has been cached for the node, return it.
- if (node.flags & 67108864 /* TypeCached */ && flowTypeCache) {
+ if (node.flags & 134217728 /* NodeFlags.TypeCached */ && flowTypeCache) {
var cachedType = flowTypeCache[getNodeId(node)];
if (cachedType) {
return cachedType;
@@ -78263,7 +79755,7 @@ var ts;
if (flowInvocationCount !== startInvocationCount) {
var cache = flowTypeCache || (flowTypeCache = []);
cache[getNodeId(node)] = type;
- ts.setNodeFlags(node, node.flags | 67108864 /* TypeCached */);
+ ts.setNodeFlags(node, node.flags | 134217728 /* NodeFlags.TypeCached */);
}
return type;
}
@@ -78278,7 +79770,7 @@ var ts;
expr = ts.skipParentheses(node);
// Optimize for the common case of a call to a function with a single non-generic call
// signature where we can just fetch the return type without checking the arguments.
- if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) {
+ if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) {
var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
if (type) {
@@ -78288,8 +79780,8 @@ var ts;
else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) {
return getTypeFromTypeNode(expr.type);
}
- else if (node.kind === 8 /* NumericLiteral */ || node.kind === 10 /* StringLiteral */ ||
- node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */) {
+ else if (node.kind === 8 /* SyntaxKind.NumericLiteral */ || node.kind === 10 /* SyntaxKind.StringLiteral */ ||
+ node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */) {
return checkExpression(node);
}
return undefined;
@@ -78309,7 +79801,7 @@ var ts;
var saveContextualType = node.contextualType;
node.contextualType = anyType;
try {
- var type = links.contextFreeType = checkExpression(node, 4 /* SkipContextSensitive */);
+ var type = links.contextFreeType = checkExpression(node, 4 /* CheckMode.SkipContextSensitive */);
return type;
}
finally {
@@ -78320,7 +79812,7 @@ var ts;
}
}
function checkExpression(node, checkMode, forceTuple) {
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath });
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath });
var saveCurrentNode = currentNode;
currentNode = node;
instantiationCount = 0;
@@ -78338,18 +79830,18 @@ var ts;
// - 'left' in property access
// - 'object' in indexed access
// - target in rhs of import statement
- var ok = (node.parent.kind === 205 /* PropertyAccessExpression */ && node.parent.expression === node) ||
- (node.parent.kind === 206 /* ElementAccessExpression */ && node.parent.expression === node) ||
- ((node.kind === 79 /* Identifier */ || node.kind === 160 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) ||
- (node.parent.kind === 180 /* TypeQuery */ && node.parent.exprName === node)) ||
- (node.parent.kind === 274 /* ExportSpecifier */); // We allow reexporting const enums
+ var ok = (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.expression === node) ||
+ (node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && node.parent.expression === node) ||
+ ((node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) ||
+ (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ && node.parent.exprName === node)) ||
+ (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */); // We allow reexporting const enums
if (!ok) {
error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query);
}
if (compilerOptions.isolatedModules) {
- ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */));
+ ts.Debug.assert(!!(type.symbol.flags & 128 /* SymbolFlags.ConstEnum */));
var constEnumDeclaration = type.symbol.valueDeclaration;
- if (constEnumDeclaration.flags & 8388608 /* Ambient */) {
+ if (constEnumDeclaration.flags & 16777216 /* NodeFlags.Ambient */) {
error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided);
}
}
@@ -78367,111 +79859,113 @@ var ts;
// Only bother checking on a few construct kinds. We don't want to be excessively
// hitting the cancellation token on every node we check.
switch (kind) {
- case 225 /* ClassExpression */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
cancellationToken.throwIfCancellationRequested();
}
}
switch (kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return checkIdentifier(node, checkMode);
- case 80 /* PrivateIdentifier */:
+ case 80 /* SyntaxKind.PrivateIdentifier */:
return checkPrivateIdentifierExpression(node);
- case 108 /* ThisKeyword */:
+ case 108 /* SyntaxKind.ThisKeyword */:
return checkThisExpression(node);
- case 106 /* SuperKeyword */:
+ case 106 /* SyntaxKind.SuperKeyword */:
return checkSuperExpression(node);
- case 104 /* NullKeyword */:
+ case 104 /* SyntaxKind.NullKeyword */:
return nullWideningType;
- case 14 /* NoSubstitutionTemplateLiteral */:
- case 10 /* StringLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
return getFreshTypeOfLiteralType(getStringLiteralType(node.text));
- case 8 /* NumericLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
checkGrammarNumericLiteral(node);
return getFreshTypeOfLiteralType(getNumberLiteralType(+node.text));
- case 9 /* BigIntLiteral */:
+ case 9 /* SyntaxKind.BigIntLiteral */:
checkGrammarBigIntLiteral(node);
return getFreshTypeOfLiteralType(getBigIntLiteralType({
negative: false,
base10Value: ts.parsePseudoBigInt(node.text)
}));
- case 110 /* TrueKeyword */:
+ case 110 /* SyntaxKind.TrueKeyword */:
return trueType;
- case 95 /* FalseKeyword */:
+ case 95 /* SyntaxKind.FalseKeyword */:
return falseType;
- case 222 /* TemplateExpression */:
+ case 223 /* SyntaxKind.TemplateExpression */:
return checkTemplateExpression(node);
- case 13 /* RegularExpressionLiteral */:
+ case 13 /* SyntaxKind.RegularExpressionLiteral */:
return globalRegExpType;
- case 203 /* ArrayLiteralExpression */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
return checkArrayLiteral(node, checkMode, forceTuple);
- case 204 /* ObjectLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
return checkObjectLiteral(node, checkMode);
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
return checkPropertyAccessExpression(node, checkMode);
- case 160 /* QualifiedName */:
+ case 161 /* SyntaxKind.QualifiedName */:
return checkQualifiedName(node, checkMode);
- case 206 /* ElementAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
return checkIndexedAccess(node, checkMode);
- case 207 /* CallExpression */:
- if (node.expression.kind === 100 /* ImportKeyword */) {
+ case 208 /* SyntaxKind.CallExpression */:
+ if (node.expression.kind === 100 /* SyntaxKind.ImportKeyword */) {
return checkImportCallExpression(node);
}
// falls through
- case 208 /* NewExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
return checkCallExpression(node, checkMode);
- case 209 /* TaggedTemplateExpression */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
return checkTaggedTemplateExpression(node);
- case 211 /* ParenthesizedExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
return checkParenthesizedExpression(node, checkMode);
- case 225 /* ClassExpression */:
+ case 226 /* SyntaxKind.ClassExpression */:
return checkClassExpression(node);
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode);
- case 215 /* TypeOfExpression */:
+ case 216 /* SyntaxKind.TypeOfExpression */:
return checkTypeOfExpression(node);
- case 210 /* TypeAssertionExpression */:
- case 228 /* AsExpression */:
+ case 211 /* SyntaxKind.TypeAssertionExpression */:
+ case 229 /* SyntaxKind.AsExpression */:
return checkAssertion(node);
- case 229 /* NonNullExpression */:
+ case 230 /* SyntaxKind.NonNullExpression */:
return checkNonNullAssertion(node);
- case 230 /* MetaProperty */:
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
+ return checkExpressionWithTypeArguments(node);
+ case 231 /* SyntaxKind.MetaProperty */:
return checkMetaProperty(node);
- case 214 /* DeleteExpression */:
+ case 215 /* SyntaxKind.DeleteExpression */:
return checkDeleteExpression(node);
- case 216 /* VoidExpression */:
+ case 217 /* SyntaxKind.VoidExpression */:
return checkVoidExpression(node);
- case 217 /* AwaitExpression */:
+ case 218 /* SyntaxKind.AwaitExpression */:
return checkAwaitExpression(node);
- case 218 /* PrefixUnaryExpression */:
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
return checkPrefixUnaryExpression(node);
- case 219 /* PostfixUnaryExpression */:
+ case 220 /* SyntaxKind.PostfixUnaryExpression */:
return checkPostfixUnaryExpression(node);
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return checkBinaryExpression(node, checkMode);
- case 221 /* ConditionalExpression */:
+ case 222 /* SyntaxKind.ConditionalExpression */:
return checkConditionalExpression(node, checkMode);
- case 224 /* SpreadElement */:
+ case 225 /* SyntaxKind.SpreadElement */:
return checkSpreadExpression(node, checkMode);
- case 226 /* OmittedExpression */:
+ case 227 /* SyntaxKind.OmittedExpression */:
return undefinedWideningType;
- case 223 /* YieldExpression */:
+ case 224 /* SyntaxKind.YieldExpression */:
return checkYieldExpression(node);
- case 231 /* SyntheticExpression */:
+ case 232 /* SyntaxKind.SyntheticExpression */:
return checkSyntheticExpression(node);
- case 287 /* JsxExpression */:
+ case 288 /* SyntaxKind.JsxExpression */:
return checkJsxExpression(node, checkMode);
- case 277 /* JsxElement */:
+ case 278 /* SyntaxKind.JsxElement */:
return checkJsxElement(node, checkMode);
- case 278 /* JsxSelfClosingElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
return checkJsxSelfClosingElement(node, checkMode);
- case 281 /* JsxFragment */:
+ case 282 /* SyntaxKind.JsxFragment */:
return checkJsxFragment(node);
- case 285 /* JsxAttributes */:
+ case 286 /* SyntaxKind.JsxAttributes */:
return checkJsxAttributes(node, checkMode);
- case 279 /* JsxOpeningElement */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement");
}
return errorType;
@@ -78479,6 +79973,7 @@ var ts;
// DECLARATION AND STATEMENT TYPE CHECKING
function checkTypeParameter(node) {
// Grammar Checking
+ checkGrammarModifiers(node);
if (node.expression) {
grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected);
}
@@ -78495,8 +79990,27 @@ var ts;
if (constraintType && defaultType) {
checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
}
- if (produceDiagnostics) {
- checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0);
+ checkNodeDeferred(node);
+ addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
+ }
+ function checkTypeParameterDeferred(node) {
+ if (ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent)) {
+ var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
+ var modifiers = getVarianceModifiers(typeParameter);
+ if (modifiers) {
+ var symbol = getSymbolOfNode(node.parent);
+ if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */))) {
+ error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
+ }
+ else if (modifiers === 32768 /* ModifierFlags.In */ || modifiers === 65536 /* ModifierFlags.Out */) {
+ var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSubType : markerSuperType);
+ var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSuperType : markerSubType);
+ 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;
+ }
+ }
}
}
function checkParameter(node) {
@@ -78507,11 +80021,11 @@ var ts;
checkGrammarDecoratorsAndModifiers(node);
checkVariableLikeDeclaration(node);
var func = ts.getContainingFunction(node);
- if (ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) {
- if (!(func.kind === 170 /* Constructor */ && ts.nodeIsPresent(func.body))) {
+ if (ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */)) {
+ if (!(func.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(func.body))) {
error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation);
}
- if (func.kind === 170 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") {
+ if (func.kind === 171 /* SyntaxKind.Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") {
error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name);
}
}
@@ -78522,13 +80036,13 @@ var ts;
if (func.parameters.indexOf(node) !== 0) {
error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText);
}
- if (func.kind === 170 /* Constructor */ || func.kind === 174 /* ConstructSignature */ || func.kind === 179 /* ConstructorType */) {
+ if (func.kind === 171 /* SyntaxKind.Constructor */ || func.kind === 175 /* SyntaxKind.ConstructSignature */ || func.kind === 180 /* SyntaxKind.ConstructorType */) {
error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter);
}
- if (func.kind === 213 /* ArrowFunction */) {
+ if (func.kind === 214 /* SyntaxKind.ArrowFunction */) {
error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter);
}
- if (func.kind === 171 /* GetAccessor */ || func.kind === 172 /* SetAccessor */) {
+ if (func.kind === 172 /* SyntaxKind.GetAccessor */ || func.kind === 173 /* SyntaxKind.SetAccessor */) {
error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters);
}
}
@@ -78552,7 +80066,7 @@ var ts;
}
checkSourceElement(node.type);
var parameterName = node.parameterName;
- if (typePredicate.kind === 0 /* This */ || typePredicate.kind === 2 /* AssertsThis */) {
+ if (typePredicate.kind === 0 /* TypePredicateKind.This */ || typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */) {
getTypeFromThisTypeNode(parameterName);
}
else {
@@ -78586,13 +80100,13 @@ var ts;
}
function getTypePredicateParent(node) {
switch (node.parent.kind) {
- case 213 /* ArrowFunction */:
- case 173 /* CallSignature */:
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 178 /* FunctionType */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 179 /* SyntaxKind.FunctionType */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
var parent = node.parent;
if (node === parent.type) {
return parent;
@@ -78606,11 +80120,11 @@ var ts;
continue;
}
var name = element.name;
- if (name.kind === 79 /* Identifier */ && name.escapedText === predicateVariableName) {
+ if (name.kind === 79 /* SyntaxKind.Identifier */ && name.escapedText === predicateVariableName) {
error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName);
return true;
}
- else if (name.kind === 201 /* ArrayBindingPattern */ || name.kind === 200 /* ObjectBindingPattern */) {
+ else if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ || name.kind === 201 /* SyntaxKind.ObjectBindingPattern */) {
if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) {
return true;
}
@@ -78619,29 +80133,29 @@ var ts;
}
function checkSignatureDeclaration(node) {
// Grammar checking
- if (node.kind === 175 /* IndexSignature */) {
+ if (node.kind === 176 /* SyntaxKind.IndexSignature */) {
checkGrammarIndexSignature(node);
}
// TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled
- else if (node.kind === 178 /* FunctionType */ || node.kind === 255 /* FunctionDeclaration */ || node.kind === 179 /* ConstructorType */ ||
- node.kind === 173 /* CallSignature */ || node.kind === 170 /* Constructor */ ||
- node.kind === 174 /* ConstructSignature */) {
+ else if (node.kind === 179 /* SyntaxKind.FunctionType */ || node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 180 /* SyntaxKind.ConstructorType */ ||
+ node.kind === 174 /* SyntaxKind.CallSignature */ || node.kind === 171 /* SyntaxKind.Constructor */ ||
+ node.kind === 175 /* SyntaxKind.ConstructSignature */) {
checkGrammarFunctionLikeDeclaration(node);
}
var functionFlags = ts.getFunctionFlags(node);
- if (!(functionFlags & 4 /* Invalid */)) {
+ if (!(functionFlags & 4 /* FunctionFlags.Invalid */)) {
// Async generators prior to ESNext require the __await and __asyncGenerator helpers
- if ((functionFlags & 3 /* AsyncGenerator */) === 3 /* AsyncGenerator */ && languageVersion < 99 /* ESNext */) {
- checkExternalEmitHelpers(node, 6144 /* AsyncGeneratorIncludes */);
+ if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 3 /* FunctionFlags.AsyncGenerator */ && languageVersion < 99 /* ScriptTarget.ESNext */) {
+ checkExternalEmitHelpers(node, 6144 /* ExternalEmitHelpers.AsyncGeneratorIncludes */);
}
// Async functions prior to ES2017 require the __awaiter helper
- if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /* ES2017 */) {
- checkExternalEmitHelpers(node, 64 /* Awaiter */);
+ if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */ && languageVersion < 4 /* ScriptTarget.ES2017 */) {
+ checkExternalEmitHelpers(node, 64 /* ExternalEmitHelpers.Awaiter */);
}
// Generator functions, Async functions, and Async Generator functions prior to
// ES2015 require the __generator helper
- if ((functionFlags & 3 /* AsyncGenerator */) !== 0 /* Normal */ && languageVersion < 2 /* ES2015 */) {
- checkExternalEmitHelpers(node, 128 /* Generator */);
+ if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) !== 0 /* FunctionFlags.Normal */ && languageVersion < 2 /* ScriptTarget.ES2015 */) {
+ checkExternalEmitHelpers(node, 128 /* ExternalEmitHelpers.Generator */);
}
}
checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node));
@@ -78651,22 +80165,23 @@ var ts;
if (node.type) {
checkSourceElement(node.type);
}
- if (produceDiagnostics) {
+ addLazyDiagnostic(checkSignatureDeclarationDiagnostics);
+ function checkSignatureDeclarationDiagnostics() {
checkCollisionWithArgumentsInGeneratedCode(node);
var returnTypeNode = ts.getEffectiveReturnTypeNode(node);
if (noImplicitAny && !returnTypeNode) {
switch (node.kind) {
- case 174 /* ConstructSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
break;
- case 173 /* CallSignature */:
+ case 174 /* SyntaxKind.CallSignature */:
error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
break;
}
}
if (returnTypeNode) {
var functionFlags_1 = ts.getFunctionFlags(node);
- if ((functionFlags_1 & (4 /* Invalid */ | 1 /* Generator */)) === 1 /* Generator */) {
+ if ((functionFlags_1 & (4 /* FunctionFlags.Invalid */ | 1 /* FunctionFlags.Generator */)) === 1 /* FunctionFlags.Generator */) {
var returnType = getTypeFromTypeNode(returnTypeNode);
if (returnType === voidType) {
error(returnTypeNode, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation);
@@ -78678,18 +80193,18 @@ var ts;
// interface BadGenerator extends Iterable<number>, Iterator<string> { }
// function* g(): BadGenerator { } // Iterable and Iterator have different types!
//
- var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || anyType;
- var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || generatorYieldType;
- var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || unknownType;
- var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* Async */));
+ var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || anyType;
+ var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || generatorYieldType;
+ var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || unknownType;
+ var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* FunctionFlags.Async */));
checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode);
}
}
- else if ((functionFlags_1 & 3 /* AsyncGenerator */) === 2 /* Async */) {
+ else if ((functionFlags_1 & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) {
checkAsyncFunctionReturnType(node, returnTypeNode);
}
}
- if (node.kind !== 175 /* IndexSignature */ && node.kind !== 315 /* JSDocFunctionType */) {
+ if (node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 317 /* SyntaxKind.JSDocFunctionType */) {
registerForUnusedIdentifiersCheck(node);
}
}
@@ -78701,11 +80216,11 @@ var ts;
var privateIdentifiers = new ts.Map();
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
var member = _a[_i];
- if (member.kind === 170 /* Constructor */) {
+ if (member.kind === 171 /* SyntaxKind.Constructor */) {
for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) {
var param = _c[_b];
if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) {
- addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */);
+ addName(instanceNames, param.name, param.name.escapedText, 3 /* DeclarationMeaning.GetOrSetAccessor */);
}
}
}
@@ -78716,24 +80231,24 @@ var ts;
continue;
}
var isPrivate = ts.isPrivateIdentifier(name);
- var privateStaticFlags = isPrivate && isStaticMember ? 16 /* PrivateStatic */ : 0;
+ var privateStaticFlags = isPrivate && isStaticMember ? 16 /* DeclarationMeaning.PrivateStatic */ : 0;
var names = isPrivate ? privateIdentifiers :
isStaticMember ? staticNames :
instanceNames;
var memberName = name && ts.getPropertyNameForPropertyNameNode(name);
if (memberName) {
switch (member.kind) {
- case 171 /* GetAccessor */:
- addName(names, name, memberName, 1 /* GetAccessor */ | privateStaticFlags);
+ case 172 /* SyntaxKind.GetAccessor */:
+ addName(names, name, memberName, 1 /* DeclarationMeaning.GetAccessor */ | privateStaticFlags);
break;
- case 172 /* SetAccessor */:
- addName(names, name, memberName, 2 /* SetAccessor */ | privateStaticFlags);
+ case 173 /* SyntaxKind.SetAccessor */:
+ addName(names, name, memberName, 2 /* DeclarationMeaning.SetAccessor */ | privateStaticFlags);
break;
- case 166 /* PropertyDeclaration */:
- addName(names, name, memberName, 3 /* GetOrSetAccessor */ | privateStaticFlags);
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ addName(names, name, memberName, 3 /* DeclarationMeaning.GetOrSetAccessor */ | privateStaticFlags);
break;
- case 168 /* MethodDeclaration */:
- addName(names, name, memberName, 8 /* Method */ | privateStaticFlags);
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ addName(names, name, memberName, 8 /* DeclarationMeaning.Method */ | privateStaticFlags);
break;
}
}
@@ -78743,19 +80258,19 @@ var ts;
var prev = names.get(name);
if (prev) {
// For private identifiers, do not allow mixing of static and instance members with the same name
- if ((prev & 16 /* PrivateStatic */) !== (meaning & 16 /* PrivateStatic */)) {
+ if ((prev & 16 /* DeclarationMeaning.PrivateStatic */) !== (meaning & 16 /* DeclarationMeaning.PrivateStatic */)) {
error(location, ts.Diagnostics.Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name, ts.getTextOfNode(location));
}
else {
- var prevIsMethod = !!(prev & 8 /* Method */);
- var isMethod = !!(meaning & 8 /* Method */);
+ var prevIsMethod = !!(prev & 8 /* DeclarationMeaning.Method */);
+ var isMethod = !!(meaning & 8 /* DeclarationMeaning.Method */);
if (prevIsMethod || isMethod) {
if (prevIsMethod !== isMethod) {
error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location));
}
// If this is a method/method duplication is might be an overload, so this will be handled when overloads are considered
}
- else if (prev & meaning & ~16 /* PrivateStatic */) {
+ else if (prev & meaning & ~16 /* DeclarationMeaning.PrivateStatic */) {
error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location));
}
else {
@@ -78804,15 +80319,15 @@ var ts;
var names = new ts.Map();
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
var member = _a[_i];
- if (member.kind === 165 /* PropertySignature */) {
+ if (member.kind === 166 /* SyntaxKind.PropertySignature */) {
var memberName = void 0;
var name = member.name;
switch (name.kind) {
- case 10 /* StringLiteral */:
- case 8 /* NumericLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
memberName = name.text;
break;
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
memberName = ts.idText(name);
break;
default:
@@ -78829,7 +80344,7 @@ var ts;
}
}
function checkTypeForDuplicateIndexSignatures(node) {
- if (node.kind === 257 /* InterfaceDeclaration */) {
+ if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) {
var nodeSymbol = getSymbolOfNode(node);
// in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration
// to prevent this run check only for the first declaration of a given kind
@@ -78843,7 +80358,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_26 = function (declaration) {
+ var _loop_27 = 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));
@@ -78858,7 +80373,7 @@ var ts;
};
for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
var declaration = _a[_i];
- _loop_26(declaration);
+ _loop_27(declaration);
}
indexSignatureMap_1.forEach(function (entry) {
if (entry.declarations.length > 1) {
@@ -78877,7 +80392,7 @@ var ts;
checkVariableLikeDeclaration(node);
setNodeLinksForPrivateIdentifierScope(node);
// property signatures already report "initializer not allowed in ambient context" elsewhere
- if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 166 /* PropertyDeclaration */ && node.initializer) {
+ if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 167 /* SyntaxKind.PropertyDeclaration */ && node.initializer) {
error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name));
}
}
@@ -78894,7 +80409,7 @@ var ts;
// Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration
checkFunctionOrMethodDeclaration(node);
// method signatures already report "implementation not allowed in ambient context" elsewhere
- if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 168 /* MethodDeclaration */ && node.body) {
+ if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.body) {
error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name));
}
// Private named methods are only allowed in class declarations
@@ -78904,9 +80419,9 @@ var ts;
setNodeLinksForPrivateIdentifierScope(node);
}
function setNodeLinksForPrivateIdentifierScope(node) {
- if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) {
+ if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ScriptTarget.ESNext */) {
for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) {
- getNodeLinks(lexicalScope).flags |= 67108864 /* ContainsClassWithPrivateIdentifiers */;
+ getNodeLinks(lexicalScope).flags |= 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */;
}
// If this is a private element in a class expression inside the body of a loop,
// then we must use a block-scoped binding to store the additional variables required
@@ -78914,8 +80429,8 @@ var ts;
if (ts.isClassExpression(node.parent)) {
var enclosingIterationStatement = getEnclosingIterationStatement(node.parent);
if (enclosingIterationStatement) {
- getNodeLinks(node.name).flags |= 524288 /* BlockScopedBindingInLoop */;
- getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */;
+ getNodeLinks(node.name).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */;
+ getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */;
}
}
}
@@ -78941,65 +80456,66 @@ var ts;
if (ts.nodeIsMissing(node.body)) {
return;
}
- if (!produceDiagnostics) {
- return;
- }
+ addLazyDiagnostic(checkConstructorDeclarationDiagnostics);
+ return;
function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) {
if (ts.isPrivateIdentifierClassElementDeclaration(n)) {
return true;
}
- return n.kind === 166 /* PropertyDeclaration */ &&
+ return n.kind === 167 /* SyntaxKind.PropertyDeclaration */ &&
!ts.isStatic(n) &&
!!n.initializer;
}
- // TS 1.0 spec (April 2014): 8.3.2
- // Constructors of classes with no extends clause may not contain super calls, whereas
- // constructors of derived classes must contain at least one super call somewhere in their function body.
- var containingClassDecl = node.parent;
- if (ts.getClassExtendsHeritageElement(containingClassDecl)) {
- captureLexicalThis(node.parent, containingClassDecl);
- var classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
- var superCall = findFirstSuperCall(node.body);
- if (superCall) {
- if (classExtendsNull) {
- error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
- }
- // A super call must be root-level in a constructor if both of the following are true:
- // - The containing class is a derived class.
- // - The constructor declares parameter properties
- // or the containing class declares instance member variables with initializers.
- var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) &&
- (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
- ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); }));
- if (superCallShouldBeRootLevel) {
- // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
- // See GH #8277
- if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
- error(superCall, ts.Diagnostics.A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers);
- }
- // Skip past any prologue directives to check statements for referring to 'super' or 'this' before a super call
- else {
- var superCallStatement = void 0;
- for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
- var statement = _a[_i];
- if (ts.isExpressionStatement(statement) && ts.isSuperCall(ts.skipOuterExpressions(statement.expression))) {
- superCallStatement = statement;
- break;
- }
- if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
- break;
- }
- }
+ function checkConstructorDeclarationDiagnostics() {
+ // TS 1.0 spec (April 2014): 8.3.2
+ // Constructors of classes with no extends clause may not contain super calls, whereas
+ // constructors of derived classes must contain at least one super call somewhere in their function body.
+ var containingClassDecl = node.parent;
+ if (ts.getClassExtendsHeritageElement(containingClassDecl)) {
+ captureLexicalThis(node.parent, containingClassDecl);
+ var classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
+ var superCall = findFirstSuperCall(node.body);
+ if (superCall) {
+ if (classExtendsNull) {
+ error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
+ }
+ // A super call must be root-level in a constructor if both of the following are true:
+ // - The containing class is a derived class.
+ // - The constructor declares parameter properties
+ // or the containing class declares instance member variables with initializers.
+ var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields) &&
+ (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
+ ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ModifierFlags.ParameterPropertyModifier */); }));
+ if (superCallShouldBeRootLevel) {
// Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
// See GH #8277
- if (superCallStatement === undefined) {
- error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_class_contains_initialized_properties_parameter_properties_or_private_identifiers);
+ if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
+ error(superCall, ts.Diagnostics.A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers);
+ }
+ // Skip past any prologue directives to check statements for referring to 'super' or 'this' before a super call
+ else {
+ var superCallStatement = void 0;
+ for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
+ var statement = _a[_i];
+ if (ts.isExpressionStatement(statement) && ts.isSuperCall(ts.skipOuterExpressions(statement.expression))) {
+ superCallStatement = statement;
+ break;
+ }
+ if (nodeImmediatelyReferencesSuperOrThis(statement)) {
+ break;
+ }
+ }
+ // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
+ // See GH #8277
+ if (superCallStatement === undefined) {
+ error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_class_contains_initialized_properties_parameter_properties_or_private_identifiers);
+ }
}
}
}
- }
- else if (!classExtendsNull) {
- error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call);
+ else if (!classExtendsNull) {
+ error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call);
+ }
}
}
}
@@ -79008,7 +80524,7 @@ var ts;
return ts.isExpressionStatement(superCallParent) && superCallParent.parent === body;
}
function nodeImmediatelyReferencesSuperOrThis(node) {
- if (node.kind === 106 /* SuperKeyword */ || node.kind === 108 /* ThisKeyword */) {
+ if (node.kind === 106 /* SyntaxKind.SuperKeyword */ || node.kind === 108 /* SyntaxKind.ThisKeyword */) {
return true;
}
if (ts.isThisContainerOrFunctionBlock(node)) {
@@ -79017,15 +80533,18 @@ var ts;
return !!ts.forEachChild(node, nodeImmediatelyReferencesSuperOrThis);
}
function checkAccessorDeclaration(node) {
- if (produceDiagnostics) {
+ addLazyDiagnostic(checkAccessorDeclarationDiagnostics);
+ checkSourceElement(node.body);
+ setNodeLinksForPrivateIdentifierScope(node);
+ function checkAccessorDeclarationDiagnostics() {
// Grammar checking accessors
if (!checkGrammarFunctionLikeDeclaration(node) && !checkGrammarAccessor(node))
checkGrammarComputedPropertyName(node.name);
checkDecorators(node);
checkSignatureDeclaration(node);
- if (node.kind === 171 /* GetAccessor */) {
- if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) {
- if (!(node.flags & 512 /* HasExplicitReturn */)) {
+ if (node.kind === 172 /* SyntaxKind.GetAccessor */) {
+ if (!(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* NodeFlags.HasImplicitReturn */)) {
+ if (!(node.flags & 512 /* NodeFlags.HasExplicitReturn */)) {
error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value);
}
}
@@ -79033,25 +80552,25 @@ var ts;
// Do not use hasDynamicName here, because that returns false for well known symbols.
// We want to perform checkComputedPropertyName for all computed properties, including
// well known symbols.
- if (node.name.kind === 161 /* ComputedPropertyName */) {
+ if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) {
checkComputedPropertyName(node.name);
}
if (hasBindableName(node)) {
// TypeScript 1.0 spec (April 2014): 8.4.3
// Accessors for the same member name must specify the same accessibility.
var symbol = getSymbolOfNode(node);
- var getter = ts.getDeclarationOfKind(symbol, 171 /* GetAccessor */);
- var setter = ts.getDeclarationOfKind(symbol, 172 /* SetAccessor */);
- if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* TypeChecked */)) {
- getNodeLinks(getter).flags |= 1 /* TypeChecked */;
+ var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */);
+ var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */);
+ if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* NodeCheckFlags.TypeChecked */)) {
+ getNodeLinks(getter).flags |= 1 /* NodeCheckFlags.TypeChecked */;
var getterFlags = ts.getEffectiveModifierFlags(getter);
var setterFlags = ts.getEffectiveModifierFlags(setter);
- if ((getterFlags & 128 /* Abstract */) !== (setterFlags & 128 /* Abstract */)) {
+ if ((getterFlags & 128 /* ModifierFlags.Abstract */) !== (setterFlags & 128 /* ModifierFlags.Abstract */)) {
error(getter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract);
error(setter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract);
}
- if (((getterFlags & 16 /* Protected */) && !(setterFlags & (16 /* Protected */ | 8 /* Private */))) ||
- ((getterFlags & 8 /* Private */) && !(setterFlags & 8 /* Private */))) {
+ if (((getterFlags & 16 /* ModifierFlags.Protected */) && !(setterFlags & (16 /* ModifierFlags.Protected */ | 8 /* ModifierFlags.Private */))) ||
+ ((getterFlags & 8 /* ModifierFlags.Private */) && !(setterFlags & 8 /* ModifierFlags.Private */))) {
error(getter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter);
error(setter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter);
}
@@ -79063,12 +80582,10 @@ var ts;
}
}
var returnType = getTypeOfAccessors(getSymbolOfNode(node));
- if (node.kind === 171 /* GetAccessor */) {
+ if (node.kind === 172 /* SyntaxKind.GetAccessor */) {
checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
}
}
- checkSourceElement(node.body);
- setNodeLinksForPrivateIdentifierScope(node);
}
function checkMissingDeclaration(node) {
checkDecorators(node);
@@ -79097,32 +80614,34 @@ var ts;
if (!isErrorType(type)) {
var symbol = getNodeLinks(node).resolvedSymbol;
if (symbol) {
- return symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters ||
- (ts.getObjectFlags(type) & 4 /* Reference */ ? type.target.localTypeParameters : undefined);
+ return symbol.flags & 524288 /* SymbolFlags.TypeAlias */ && getSymbolLinks(symbol).typeParameters ||
+ (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target.localTypeParameters : undefined);
}
}
return undefined;
}
function checkTypeReferenceNode(node) {
checkGrammarTypeArguments(node, node.typeArguments);
- if (node.kind === 177 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) {
+ if (node.kind === 178 /* SyntaxKind.TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) {
grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments);
}
ts.forEach(node.typeArguments, checkSourceElement);
var type = getTypeFromTypeReference(node);
if (!isErrorType(type)) {
- if (node.typeArguments && produceDiagnostics) {
- var typeParameters = getTypeParametersForTypeReference(node);
- if (typeParameters) {
- checkTypeArgumentConstraints(node, typeParameters);
- }
+ if (node.typeArguments) {
+ addLazyDiagnostic(function () {
+ var typeParameters = getTypeParametersForTypeReference(node);
+ if (typeParameters) {
+ checkTypeArgumentConstraints(node, typeParameters);
+ }
+ });
}
var symbol = getNodeLinks(node).resolvedSymbol;
if (symbol) {
- if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 134217728 /* Deprecated */); })) {
+ if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName);
}
- if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) {
+ if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) {
error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type));
}
}
@@ -79143,7 +80662,8 @@ var ts;
}
function checkTypeLiteral(node) {
ts.forEach(node.members, checkSourceElement);
- if (produceDiagnostics) {
+ addLazyDiagnostic(checkTypeLiteralDiagnostics);
+ function checkTypeLiteralDiagnostics() {
var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
checkIndexConstraints(type, type.symbol);
checkTypeForDuplicateIndexSignatures(node);
@@ -79160,29 +80680,29 @@ var ts;
var hasNamedElement = ts.some(elementTypes, ts.isNamedTupleMember);
for (var _i = 0, elementTypes_1 = elementTypes; _i < elementTypes_1.length; _i++) {
var e = elementTypes_1[_i];
- if (e.kind !== 196 /* NamedTupleMember */ && hasNamedElement) {
+ if (e.kind !== 197 /* SyntaxKind.NamedTupleMember */ && hasNamedElement) {
grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names);
break;
}
var flags = getTupleElementFlags(e);
- if (flags & 8 /* Variadic */) {
+ if (flags & 8 /* ElementFlags.Variadic */) {
var type = getTypeFromTypeNode(e.type);
if (!isArrayLikeType(type)) {
error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type);
break;
}
- if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* Rest */) {
+ if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* ElementFlags.Rest */) {
seenRestElement = true;
}
}
- else if (flags & 4 /* Rest */) {
+ else if (flags & 4 /* ElementFlags.Rest */) {
if (seenRestElement) {
grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_cannot_follow_another_rest_element);
break;
}
seenRestElement = true;
}
- else if (flags & 2 /* Optional */) {
+ else if (flags & 2 /* ElementFlags.Optional */) {
if (seenRestElement) {
grammarErrorOnNode(e, ts.Diagnostics.An_optional_element_cannot_follow_a_rest_element);
break;
@@ -79202,15 +80722,15 @@ var ts;
getTypeFromTypeNode(node);
}
function checkIndexedAccessIndexType(type, accessNode) {
- if (!(type.flags & 8388608 /* IndexedAccess */)) {
+ if (!(type.flags & 8388608 /* TypeFlags.IndexedAccess */)) {
return type;
}
// Check if the index type is assignable to 'keyof T' for the object type.
var objectType = type.objectType;
var indexType = type.indexType;
if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) {
- if (accessNode.kind === 206 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) &&
- ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) {
+ if (accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) &&
+ ts.getObjectFlags(objectType) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(objectType) & 1 /* MappedTypeModifiers.IncludeReadonly */) {
error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
}
return type;
@@ -79218,14 +80738,14 @@ var ts;
// Check if we're indexing with a numeric type and if either object or index types
// is a generic type with a constraint that has a numeric index signature.
var apparentObjectType = getApparentType(objectType);
- if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* NumberLike */)) {
+ if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) {
return type;
}
if (isGenericObjectType(objectType)) {
var propertyName_1 = getPropertyNameFromIndex(indexType, accessNode);
if (propertyName_1) {
var propertySymbol = forEachType(apparentObjectType, function (t) { return getPropertyOfType(t, propertyName_1); });
- if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* NonPublicAccessibilityModifier */) {
+ if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) {
error(accessNode, ts.Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, ts.unescapeLeadingUnderscores(propertyName_1));
return errorType;
}
@@ -79274,10 +80794,27 @@ var ts;
ts.forEachChild(node, checkSourceElement);
}
function checkInferType(node) {
- if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 188 /* ConditionalType */ && n.parent.extendsType === n; })) {
+ if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 189 /* SyntaxKind.ConditionalType */ && n.parent.extendsType === n; })) {
grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type);
}
checkSourceElement(node.typeParameter);
+ var symbol = getSymbolOfNode(node.typeParameter);
+ if (symbol.declarations && symbol.declarations.length > 1) {
+ var links = getSymbolLinks(symbol);
+ if (!links.typeParametersChecked) {
+ links.typeParametersChecked = true;
+ var typeParameter = getDeclaredTypeOfTypeParameter(symbol);
+ var declarations = ts.getDeclarationsOfKind(symbol, 163 /* SyntaxKind.TypeParameter */);
+ if (!areTypeParametersIdentical(declarations, [typeParameter], function (decl) { return [decl]; })) {
+ // Report an error on every conflicting declaration.
+ var name = symbolToString(symbol);
+ for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
+ var declaration = declarations_4[_i];
+ error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_constraints, name);
+ }
+ }
+ }
+ }
registerForUnusedIdentifiersCheck(node);
}
function checkTemplateLiteralType(node) {
@@ -79291,44 +80828,52 @@ var ts;
}
function checkImportType(node) {
checkSourceElement(node.argument);
+ if (node.assertions) {
+ var override = ts.getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode);
+ if (override) {
+ if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
+ grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
+ }
+ }
+ }
getTypeFromTypeNode(node);
}
function checkNamedTupleMember(node) {
if (node.dotDotDotToken && node.questionToken) {
grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest);
}
- if (node.type.kind === 184 /* OptionalType */) {
+ if (node.type.kind === 185 /* SyntaxKind.OptionalType */) {
grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type);
}
- if (node.type.kind === 185 /* RestType */) {
+ if (node.type.kind === 186 /* SyntaxKind.RestType */) {
grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type);
}
checkSourceElement(node.type);
getTypeFromTypeNode(node);
}
function isPrivateWithinAmbient(node) {
- return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 8388608 /* Ambient */);
+ return (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* NodeFlags.Ambient */);
}
function getEffectiveDeclarationFlags(n, flagsToCheck) {
var flags = ts.getCombinedModifierFlags(n);
// children of classes (even ambient classes) should not be marked as ambient or export
// because those flags have no useful semantics there.
- if (n.parent.kind !== 257 /* InterfaceDeclaration */ &&
- n.parent.kind !== 256 /* ClassDeclaration */ &&
- n.parent.kind !== 225 /* ClassExpression */ &&
- n.flags & 8388608 /* Ambient */) {
- if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) {
+ if (n.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */ &&
+ n.parent.kind !== 257 /* SyntaxKind.ClassDeclaration */ &&
+ n.parent.kind !== 226 /* SyntaxKind.ClassExpression */ &&
+ n.flags & 16777216 /* NodeFlags.Ambient */) {
+ if (!(flags & 2 /* ModifierFlags.Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) {
// It is nested in an ambient context, which means it is automatically exported
- flags |= 1 /* Export */;
+ flags |= 1 /* ModifierFlags.Export */;
}
- flags |= 2 /* Ambient */;
+ flags |= 2 /* ModifierFlags.Ambient */;
}
return flags & flagsToCheck;
}
function checkFunctionOrConstructorSymbol(symbol) {
- if (!produceDiagnostics) {
- return;
- }
+ addLazyDiagnostic(function () { return checkFunctionOrConstructorSymbolWorker(symbol); });
+ }
+ function checkFunctionOrConstructorSymbolWorker(symbol) {
function getCanonicalOverload(overloads, implementation) {
// Consider the canonical set of flags to be the flags of the bodyDeclaration or the first declaration
// Error on all deviations from this canonical set of flags
@@ -79346,16 +80891,16 @@ var ts;
var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck);
ts.forEach(overloads, function (o) {
var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1;
- if (deviation & 1 /* Export */) {
+ if (deviation & 1 /* ModifierFlags.Export */) {
error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported);
}
- else if (deviation & 2 /* Ambient */) {
+ else if (deviation & 2 /* ModifierFlags.Ambient */) {
error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient);
}
- else if (deviation & (8 /* Private */ | 16 /* Protected */)) {
+ else if (deviation & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) {
error(ts.getNameOfDeclaration(o) || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected);
}
- else if (deviation & 128 /* Abstract */) {
+ else if (deviation & 128 /* ModifierFlags.Abstract */) {
error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract);
}
});
@@ -79372,8 +80917,8 @@ var ts;
});
}
}
- var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 8 /* Private */ | 16 /* Protected */ | 128 /* Abstract */;
- var someNodeFlags = 0 /* None */;
+ var flagsToCheck = 1 /* ModifierFlags.Export */ | 2 /* ModifierFlags.Ambient */ | 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */ | 128 /* ModifierFlags.Abstract */;
+ var someNodeFlags = 0 /* ModifierFlags.None */;
var allNodeFlags = flagsToCheck;
var someHaveQuestionToken = false;
var allHaveQuestionToken = true;
@@ -79382,7 +80927,7 @@ var ts;
var lastSeenNonAmbientDeclaration;
var previousDeclaration;
var declarations = symbol.declarations;
- var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0;
+ var isConstructor = (symbol.flags & 16384 /* SymbolFlags.Constructor */) !== 0;
function reportImplementationExpectedError(node) {
if (node.name && ts.nodeIsMissing(node.name)) {
return;
@@ -79411,7 +80956,7 @@ var ts;
// Both are literal property names that are the same.
ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) &&
ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) {
- var reportError = (node.kind === 168 /* MethodDeclaration */ || node.kind === 167 /* MethodSignature */) &&
+ var reportError = (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */) &&
ts.isStatic(node) !== ts.isStatic(subsequentNode);
// we can get here in two cases
// 1. mixed static and instance class members
@@ -79436,7 +80981,7 @@ var ts;
else {
// Report different errors regarding non-consecutive blocks of declarations depending on whether
// the node in question is abstract.
- if (ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
+ if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) {
error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive);
}
else {
@@ -79449,11 +80994,11 @@ var ts;
var hasNonAmbientClass = false;
var functionDeclarations = [];
if (declarations) {
- for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
- var current = declarations_4[_i];
+ for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
+ var current = declarations_5[_i];
var node = current;
- var inAmbientContext = node.flags & 8388608 /* Ambient */;
- var inAmbientContextOrInterface = node.parent && (node.parent.kind === 257 /* InterfaceDeclaration */ || node.parent.kind === 181 /* TypeLiteral */) || inAmbientContext;
+ var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */;
+ var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) || inAmbientContext;
if (inAmbientContextOrInterface) {
// check if declarations are consecutive only if they are non-ambient
// 1. ambient declarations can be interleaved
@@ -79464,10 +81009,10 @@ var ts;
// 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one
previousDeclaration = undefined;
}
- if ((node.kind === 256 /* ClassDeclaration */ || node.kind === 225 /* ClassExpression */) && !inAmbientContext) {
+ if ((node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */) && !inAmbientContext) {
hasNonAmbientClass = true;
}
- if (node.kind === 255 /* FunctionDeclaration */ || node.kind === 168 /* MethodDeclaration */ || node.kind === 167 /* MethodSignature */ || node.kind === 170 /* Constructor */) {
+ if (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */ || node.kind === 171 /* SyntaxKind.Constructor */) {
functionDeclarations.push(node);
var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck);
someNodeFlags |= currentNodeFlags;
@@ -79511,13 +81056,13 @@ var ts;
error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_function_implementation);
});
}
- if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */ && declarations) {
- var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 256 /* ClassDeclaration */; })
+ if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* SymbolFlags.Function */ && declarations) {
+ var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 257 /* SyntaxKind.ClassDeclaration */; })
.map(function (d) { return ts.createDiagnosticForNode(d, ts.Diagnostics.Consider_adding_a_declare_modifier_to_this_class); });
ts.forEach(declarations, function (declaration) {
- var diagnostic = declaration.kind === 256 /* ClassDeclaration */
+ var diagnostic = declaration.kind === 257 /* SyntaxKind.ClassDeclaration */
? ts.Diagnostics.Class_declaration_cannot_implement_overload_list_for_0
- : declaration.kind === 255 /* FunctionDeclaration */
+ : declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */
? ts.Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient
: undefined;
if (diagnostic) {
@@ -79527,7 +81072,7 @@ var ts;
}
// Abstract methods can't have an implementation -- in particular, they don't need one.
if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body &&
- !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) {
+ !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* ModifierFlags.Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) {
reportImplementationExpectedError(lastSeenNonAmbientDeclaration);
}
if (hasOverloads) {
@@ -79549,9 +81094,9 @@ var ts;
}
}
function checkExportsOnMergedDeclarations(node) {
- if (!produceDiagnostics) {
- return;
- }
+ addLazyDiagnostic(function () { return checkExportsOnMergedDeclarationsWorker(node); });
+ }
+ function checkExportsOnMergedDeclarationsWorker(node) {
// if localSymbol is defined on node then node itself is exported - check is required
var symbol = node.localSymbol;
if (!symbol) {
@@ -79567,15 +81112,15 @@ var ts;
if (ts.getDeclarationOfKind(symbol, node.kind) !== node) {
return;
}
- var exportedDeclarationSpaces = 0 /* None */;
- var nonExportedDeclarationSpaces = 0 /* None */;
- var defaultExportedDeclarationSpaces = 0 /* None */;
+ var exportedDeclarationSpaces = 0 /* DeclarationSpaces.None */;
+ var nonExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */;
+ var defaultExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */;
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var d = _a[_i];
var declarationSpaces = getDeclarationSpaces(d);
- var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 512 /* Default */);
- if (effectiveDeclarationFlags & 1 /* Export */) {
- if (effectiveDeclarationFlags & 512 /* Default */) {
+ var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */);
+ if (effectiveDeclarationFlags & 1 /* ModifierFlags.Export */) {
+ if (effectiveDeclarationFlags & 512 /* ModifierFlags.Default */) {
defaultExportedDeclarationSpaces |= declarationSpaces;
}
else {
@@ -79608,56 +81153,56 @@ var ts;
function getDeclarationSpaces(decl) {
var d = decl;
switch (d.kind) {
- case 257 /* InterfaceDeclaration */:
- case 258 /* TypeAliasDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
// A jsdoc typedef and callback are, by definition, type aliases.
// falls through
- case 343 /* JSDocTypedefTag */:
- case 336 /* JSDocCallbackTag */:
- case 337 /* JSDocEnumTag */:
- return 2 /* ExportType */;
- case 260 /* ModuleDeclaration */:
- return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */
- ? 4 /* ExportNamespace */ | 1 /* ExportValue */
- : 4 /* ExportNamespace */;
- case 256 /* ClassDeclaration */:
- case 259 /* EnumDeclaration */:
- case 297 /* EnumMember */:
- return 2 /* ExportType */ | 1 /* ExportValue */;
- case 303 /* SourceFile */:
- return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */;
- case 270 /* ExportAssignment */:
- case 220 /* BinaryExpression */:
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
+ case 338 /* SyntaxKind.JSDocCallbackTag */:
+ case 339 /* SyntaxKind.JSDocEnumTag */:
+ return 2 /* DeclarationSpaces.ExportType */;
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* ModuleInstanceState.NonInstantiated */
+ ? 4 /* DeclarationSpaces.ExportNamespace */ | 1 /* DeclarationSpaces.ExportValue */
+ : 4 /* DeclarationSpaces.ExportNamespace */;
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 299 /* SyntaxKind.EnumMember */:
+ return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */;
+ case 305 /* SyntaxKind.SourceFile */:
+ return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */ | 4 /* DeclarationSpaces.ExportNamespace */;
+ case 271 /* SyntaxKind.ExportAssignment */:
+ case 221 /* SyntaxKind.BinaryExpression */:
var node_2 = d;
var expression = ts.isExportAssignment(node_2) ? node_2.expression : node_2.right;
// Export assigned entity name expressions act as aliases and should fall through, otherwise they export values
if (!ts.isEntityNameExpression(expression)) {
- return 1 /* ExportValue */;
+ return 1 /* DeclarationSpaces.ExportValue */;
}
d = expression;
// The below options all declare an Alias, which is allowed to merge with other values within the importing module.
// falls through
- case 264 /* ImportEqualsDeclaration */:
- case 267 /* NamespaceImport */:
- case 266 /* ImportClause */:
- var result_11 = 0 /* None */;
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 268 /* SyntaxKind.NamespaceImport */:
+ case 267 /* SyntaxKind.ImportClause */:
+ var result_12 = 0 /* DeclarationSpaces.None */;
var target = resolveAlias(getSymbolOfNode(d));
ts.forEach(target.declarations, function (d) {
- result_11 |= getDeclarationSpaces(d);
+ result_12 |= getDeclarationSpaces(d);
});
- return result_11;
- case 253 /* VariableDeclaration */:
- case 202 /* BindingElement */:
- case 255 /* FunctionDeclaration */:
- case 269 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591
- case 79 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098
+ return result_12;
+ case 254 /* SyntaxKind.VariableDeclaration */:
+ case 203 /* SyntaxKind.BindingElement */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 270 /* SyntaxKind.ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591
+ case 79 /* SyntaxKind.Identifier */: // https://github.com/microsoft/TypeScript/issues/36098
// Identifiers are used as declarations of assignment declarations whose parents may be
// SyntaxKind.CallExpression - `Object.defineProperty(thing, "aField", {value: 42});`
// SyntaxKind.ElementAccessExpression - `thing["aField"] = 42;` or `thing["aField"];` (with a doc comment on it)
// or SyntaxKind.PropertyAccessExpression - `thing.aField = 42;`
// all of which are pretty much always values, or at least imply a value meaning.
// It may be apprpriate to treat these as aliases in the future.
- return 1 /* ExportValue */;
+ return 1 /* DeclarationSpaces.ExportValue */;
default:
return ts.Debug.failBadSyntaxKind(d);
}
@@ -79693,32 +81238,32 @@ var ts;
return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0];
}
// primitives with a `{ then() }` won't be unwrapped/adopted.
- if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) {
+ if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
return undefined;
}
var thenFunction = getTypeOfPropertyOfType(type, "then"); // TODO: GH#18217
if (isTypeAny(thenFunction)) {
return undefined;
}
- var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* Call */) : ts.emptyArray;
+ var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* SignatureKind.Call */) : ts.emptyArray;
if (thenSignatures.length === 0) {
if (errorNode) {
error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method);
}
return undefined;
}
- var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152 /* NEUndefinedOrNull */);
+ var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152 /* TypeFacts.NEUndefinedOrNull */);
if (isTypeAny(onfulfilledParameterType)) {
return undefined;
}
- var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */);
+ var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* SignatureKind.Call */);
if (onfulfilledParameterSignatures.length === 0) {
if (errorNode) {
error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback);
}
return undefined;
}
- return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* Subtype */);
+ return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* UnionReduction.Subtype */);
}
/**
* Gets the "awaited type" of a type.
@@ -79738,16 +81283,16 @@ var ts;
* Determines whether a type is an object with a callable `then` member.
*/
function isThenableType(type) {
- if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) {
+ if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
// primitive types cannot be considered "thenable" since they are not objects.
return false;
}
var thenFunction = getTypeOfPropertyOfType(type, "then");
- return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* NEUndefinedOrNull */), 0 /* Call */).length > 0;
+ return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* TypeFacts.NEUndefinedOrNull */), 0 /* SignatureKind.Call */).length > 0;
}
function isAwaitedTypeInstantiation(type) {
var _a;
- if (type.flags & 16777216 /* Conditional */) {
+ if (type.flags & 16777216 /* TypeFlags.Conditional */) {
var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ false);
return !!awaitedSymbol && type.aliasSymbol === awaitedSymbol && ((_a = type.aliasTypeArguments) === null || _a === void 0 ? void 0 : _a.length) === 1;
}
@@ -79757,7 +81302,7 @@ var ts;
* For a generic `Awaited<T>`, gets `T`.
*/
function unwrapAwaitedType(type) {
- return type.flags & 1048576 /* Union */ ? mapType(type, unwrapAwaitedType) :
+ return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, unwrapAwaitedType) :
isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] :
type;
}
@@ -79781,7 +81326,7 @@ var ts;
var baseConstraint = getBaseConstraintOfType(type);
// Only instantiate `Awaited<T>` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
// or is promise-like.
- if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) {
+ if (!baseConstraint || (baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) {
// Nothing to do if `Awaited<T>` doesn't exist
var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true);
if (awaitedSymbol) {
@@ -79827,7 +81372,7 @@ var ts;
return typeAsAwaitable.awaitedTypeOfType;
}
// For a union, get a union of the awaited types of each constituent.
- if (type.flags & 1048576 /* Union */) {
+ if (type.flags & 1048576 /* TypeFlags.Union */) {
var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias;
return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper);
}
@@ -79944,7 +81489,7 @@ var ts;
// }
//
var returnType = getTypeFromTypeNode(returnTypeNode);
- if (languageVersion >= 2 /* ES2015 */) {
+ if (languageVersion >= 2 /* ScriptTarget.ES2015 */) {
if (isErrorType(returnType)) {
return;
}
@@ -79967,10 +81512,10 @@ var ts;
error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType));
return;
}
- var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true);
+ var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true);
var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType;
if (isErrorType(promiseConstructorType)) {
- if (promiseConstructorName.kind === 79 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) {
+ if (promiseConstructorName.kind === 79 /* SyntaxKind.Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) {
error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option);
}
else {
@@ -79990,7 +81535,7 @@ var ts;
}
// Verify there is no local declaration that could collide with the promise constructor.
var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName);
- var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */);
+ var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* SymbolFlags.Value */);
if (collidingSymbol) {
error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName));
return;
@@ -80003,26 +81548,26 @@ var ts;
var signature = getResolvedSignature(node);
checkDeprecatedSignature(signature, node);
var returnType = getReturnTypeOfSignature(signature);
- if (returnType.flags & 1 /* Any */) {
+ if (returnType.flags & 1 /* TypeFlags.Any */) {
return;
}
var headMessage;
var expectedReturnType;
switch (node.parent.kind) {
- case 256 /* ClassDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
var classSymbol = getSymbolOfNode(node.parent);
var classConstructorType = getTypeOfSymbol(classSymbol);
expectedReturnType = getUnionType([classConstructorType, voidType]);
break;
- case 166 /* PropertyDeclaration */:
- case 163 /* Parameter */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 164 /* SyntaxKind.Parameter */:
headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any;
expectedReturnType = voidType;
break;
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
var methodType = getTypeOfNode(node.parent);
var descriptorType = createTypedPropertyDescriptorType(methodType);
@@ -80038,20 +81583,31 @@ var ts;
* marked as referenced to prevent import elision.
*/
function markTypeNodeAsReferenced(node) {
- markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node));
+ markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node), /*forDecoratorMetadata*/ false);
}
- function markEntityNameOrEntityExpressionAsReference(typeName) {
+ function markEntityNameOrEntityExpressionAsReference(typeName, forDecoratorMetadata) {
if (!typeName)
return;
var rootName = ts.getFirstIdentifier(typeName);
- var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */;
+ var meaning = (typeName.kind === 79 /* SyntaxKind.Identifier */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */) | 2097152 /* SymbolFlags.Alias */;
var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isReference*/ true);
- if (rootSymbol
- && rootSymbol.flags & 2097152 /* Alias */
- && symbolIsValue(rootSymbol)
- && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))
- && !getTypeOnlyAliasDeclaration(rootSymbol)) {
- markAliasSymbolAsReferenced(rootSymbol);
+ if (rootSymbol && rootSymbol.flags & 2097152 /* SymbolFlags.Alias */) {
+ if (symbolIsValue(rootSymbol)
+ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))
+ && !getTypeOnlyAliasDeclaration(rootSymbol)) {
+ markAliasSymbolAsReferenced(rootSymbol);
+ }
+ else if (forDecoratorMetadata
+ && compilerOptions.isolatedModules
+ && ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015
+ && !symbolIsValue(rootSymbol)
+ && !ts.some(rootSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration)) {
+ var diag = error(typeName, ts.Diagnostics.A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled);
+ var aliasDeclaration = ts.find(rootSymbol.declarations || ts.emptyArray, isAliasSymbolDeclaration);
+ if (aliasDeclaration) {
+ ts.addRelatedInfo(diag, ts.createDiagnosticForNode(aliasDeclaration, ts.Diagnostics._0_was_imported_here, ts.idText(rootName)));
+ }
+ }
}
}
/**
@@ -80064,21 +81620,21 @@ var ts;
function markDecoratorMedataDataTypeNodeAsReferenced(node) {
var entityName = getEntityNameForDecoratorMetadata(node);
if (entityName && ts.isEntityName(entityName)) {
- markEntityNameOrEntityExpressionAsReference(entityName);
+ markEntityNameOrEntityExpressionAsReference(entityName, /*forDecoratorMetadata*/ true);
}
}
function getEntityNameForDecoratorMetadata(node) {
if (node) {
switch (node.kind) {
- case 187 /* IntersectionType */:
- case 186 /* UnionType */:
+ case 188 /* SyntaxKind.IntersectionType */:
+ case 187 /* SyntaxKind.UnionType */:
return getEntityNameForDecoratorMetadataFromTypeList(node.types);
- case 188 /* ConditionalType */:
+ case 189 /* SyntaxKind.ConditionalType */:
return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]);
- case 190 /* ParenthesizedType */:
- case 196 /* NamedTupleMember */:
+ case 191 /* SyntaxKind.ParenthesizedType */:
+ case 197 /* SyntaxKind.NamedTupleMember */:
return getEntityNameForDecoratorMetadata(node.type);
- case 177 /* TypeReference */:
+ case 178 /* SyntaxKind.TypeReference */:
return node.typeName;
}
}
@@ -80087,13 +81643,13 @@ var ts;
var commonEntityName;
for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
var typeNode = types_22[_i];
- while (typeNode.kind === 190 /* ParenthesizedType */ || typeNode.kind === 196 /* NamedTupleMember */) {
+ while (typeNode.kind === 191 /* SyntaxKind.ParenthesizedType */ || typeNode.kind === 197 /* SyntaxKind.NamedTupleMember */) {
typeNode = typeNode.type; // Skip parens if need be
}
- if (typeNode.kind === 143 /* NeverKeyword */) {
+ if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) {
continue; // Always elide `never` from the union/intersection if possible
}
- if (!strictNullChecks && (typeNode.kind === 195 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 152 /* UndefinedKeyword */)) {
+ if (!strictNullChecks && (typeNode.kind === 196 /* SyntaxKind.LiteralType */ && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */ || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) {
continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks
}
var individualEntityName = getEntityNameForDecoratorMetadata(typeNode);
@@ -80138,15 +81694,15 @@ var ts;
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];
- checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */);
- if (node.kind === 163 /* Parameter */) {
- checkExternalEmitHelpers(firstDecorator, 32 /* Param */);
+ checkExternalEmitHelpers(firstDecorator, 8 /* ExternalEmitHelpers.Decorate */);
+ if (node.kind === 164 /* SyntaxKind.Parameter */) {
+ checkExternalEmitHelpers(firstDecorator, 32 /* ExternalEmitHelpers.Param */);
}
if (compilerOptions.emitDecoratorMetadata) {
- checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */);
+ checkExternalEmitHelpers(firstDecorator, 16 /* ExternalEmitHelpers.Metadata */);
// we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator.
switch (node.kind) {
- case 256 /* ClassDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
var constructor = ts.getFirstConstructorWithBody(node);
if (constructor) {
for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) {
@@ -80155,23 +81711,23 @@ var ts;
}
}
break;
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- var otherKind = node.kind === 171 /* GetAccessor */ ? 172 /* SetAccessor */ : 171 /* GetAccessor */;
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ var otherKind = node.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */;
var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind);
markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor));
break;
- case 168 /* MethodDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) {
var parameter = _c[_b];
markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
}
markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node));
break;
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node));
break;
- case 163 /* Parameter */:
+ case 164 /* SyntaxKind.Parameter */:
markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node));
var containingSignature = node.parent;
for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) {
@@ -80184,7 +81740,8 @@ var ts;
ts.forEach(node.decorators, checkDecorator);
}
function checkFunctionDeclaration(node) {
- if (produceDiagnostics) {
+ addLazyDiagnostic(checkFunctionDeclarationDiagnostics);
+ function checkFunctionDeclarationDiagnostics() {
checkFunctionOrMethodDeclaration(node);
checkGrammarForGenerator(node);
checkCollisionsForDeclarationName(node, node.name);
@@ -80218,10 +81775,13 @@ var ts;
checkSourceElement(node.typeExpression);
}
function checkJSDocFunctionType(node) {
- if (produceDiagnostics && !node.type && !ts.isJSDocConstructSignature(node)) {
- reportImplicitAny(node, anyType);
- }
+ addLazyDiagnostic(checkJSDocFunctionTypeImplicitAny);
checkSignatureDeclaration(node);
+ function checkJSDocFunctionTypeImplicitAny() {
+ if (!node.type && !ts.isJSDocConstructSignature(node)) {
+ reportImplicitAny(node, anyType);
+ }
+ }
}
function checkJSDocImplementsTag(node) {
var classLike = ts.getEffectiveJSDocHost(node);
@@ -80257,9 +81817,9 @@ var ts;
}
function getIdentifierFromEntityNameExpression(node) {
switch (node.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return node;
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
return node.name;
default:
return undefined;
@@ -80273,7 +81833,7 @@ var ts;
// Do not use hasDynamicName here, because that returns false for well known symbols.
// We want to perform checkComputedPropertyName for all computed properties, including
// well known symbols.
- if (node.name && node.name.kind === 161 /* ComputedPropertyName */) {
+ if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) {
// This check will account for methods in class/interface declarations,
// as well as accessors in classes/object literals
checkComputedPropertyName(node.name);
@@ -80289,7 +81849,7 @@ var ts;
// checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function.
var firstDeclaration = (_a = localSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(
// Get first non javascript function declaration
- function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072 /* JavaScriptFile */); });
+ function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* NodeFlags.JavaScriptFile */); });
// Only type check the symbol once
if (node === firstDeclaration) {
checkFunctionOrConstructorSymbol(localSymbol);
@@ -80299,22 +81859,10 @@ var ts;
checkFunctionOrConstructorSymbol(symbol);
}
}
- var body = node.kind === 167 /* MethodSignature */ ? undefined : node.body;
+ var body = node.kind === 168 /* SyntaxKind.MethodSignature */ ? undefined : node.body;
checkSourceElement(body);
checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node));
- if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) {
- // Report an implicit any error if there is no body, no explicit return type, and node is not a private method
- // in an ambient context
- if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) {
- reportImplicitAny(node, anyType);
- }
- if (functionFlags & 1 /* Generator */ && ts.nodeIsPresent(body)) {
- // A generator with a body and no type annotation can still cause errors. It can error if the
- // yielded values have no common supertype, or it can give an implicit any error if it has no
- // yielded values. The only way to trigger these errors is to try checking its return type.
- getReturnTypeOfSignature(getSignatureFromDeclaration(node));
- }
- }
+ addLazyDiagnostic(checkFunctionOrMethodDeclarationDiagnostics);
// A js function declaration can have a @type tag instead of a return type node, but that type must have a call signature
if (ts.isInJSFile(node)) {
var typeTag = ts.getJSDocTypeTag(node);
@@ -80322,10 +81870,26 @@ var ts;
error(typeTag.typeExpression.type, ts.Diagnostics.The_type_of_a_function_declaration_must_match_the_function_s_signature);
}
}
+ function checkFunctionOrMethodDeclarationDiagnostics() {
+ if (!ts.getEffectiveReturnTypeNode(node)) {
+ // Report an implicit any error if there is no body, no explicit return type, and node is not a private method
+ // in an ambient context
+ if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) {
+ reportImplicitAny(node, anyType);
+ }
+ if (functionFlags & 1 /* FunctionFlags.Generator */ && ts.nodeIsPresent(body)) {
+ // A generator with a body and no type annotation can still cause errors. It can error if the
+ // yielded values have no common supertype, or it can give an implicit any error if it has no
+ // yielded values. The only way to trigger these errors is to try checking its return type.
+ getReturnTypeOfSignature(getSignatureFromDeclaration(node));
+ }
+ }
+ }
}
function registerForUnusedIdentifiersCheck(node) {
- // May be in a call such as getTypeOfNode that happened to call this. But potentiallyUnusedIdentifiers is only defined in the scope of `checkSourceFile`.
- if (produceDiagnostics) {
+ addLazyDiagnostic(registerForUnusedIdentifiersCheckDiagnostics);
+ function registerForUnusedIdentifiersCheckDiagnostics() {
+ // May be in a call such as getTypeOfNode that happened to call this. But potentiallyUnusedIdentifiers is only defined in the scope of `checkSourceFile`.
var sourceFile = ts.getSourceFileOfNode(node);
var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path);
if (!potentiallyUnusedIdentifiers) {
@@ -80341,42 +81905,42 @@ var ts;
for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) {
var node = potentiallyUnusedIdentifiers_1[_i];
switch (node.kind) {
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
checkUnusedClassMembers(node, addDiagnostic);
checkUnusedTypeParameters(node, addDiagnostic);
break;
- case 303 /* SourceFile */:
- case 260 /* ModuleDeclaration */:
- case 234 /* Block */:
- case 262 /* CaseBlock */:
- case 241 /* ForStatement */:
- case 242 /* ForInStatement */:
- case 243 /* ForOfStatement */:
+ case 305 /* SyntaxKind.SourceFile */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 235 /* SyntaxKind.Block */:
+ case 263 /* SyntaxKind.CaseBlock */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
checkUnusedLocalsAndParameters(node, addDiagnostic);
break;
- case 170 /* Constructor */:
- case 212 /* FunctionExpression */:
- case 255 /* FunctionDeclaration */:
- case 213 /* ArrowFunction */:
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
if (node.body) { // Don't report unused parameters in overloads
checkUnusedLocalsAndParameters(node, addDiagnostic);
}
checkUnusedTypeParameters(node, addDiagnostic);
break;
- case 167 /* MethodSignature */:
- case 173 /* CallSignature */:
- case 174 /* ConstructSignature */:
- case 178 /* FunctionType */:
- case 179 /* ConstructorType */:
- case 258 /* TypeAliasDeclaration */:
- case 257 /* InterfaceDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 179 /* SyntaxKind.FunctionType */:
+ case 180 /* SyntaxKind.ConstructorType */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
checkUnusedTypeParameters(node, addDiagnostic);
break;
- case 189 /* InferType */:
+ case 190 /* SyntaxKind.InferType */:
checkUnusedInferTypeParameter(node, addDiagnostic);
break;
default:
@@ -80387,41 +81951,41 @@ var ts;
function errorUnusedLocal(declaration, name, addDiagnostic) {
var node = ts.getNameOfDeclaration(declaration) || declaration;
var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
- addDiagnostic(declaration, 0 /* Local */, ts.createDiagnosticForNode(node, message, name));
+ addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name));
}
function isIdentifierThatStartsWithUnderscore(node) {
- return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* _ */;
+ return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* CharacterCodes._ */;
}
function checkUnusedClassMembers(node, addDiagnostic) {
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
var member = _a[_i];
switch (member.kind) {
- case 168 /* MethodDeclaration */:
- case 166 /* PropertyDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- if (member.kind === 172 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) {
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ if (member.kind === 173 /* SyntaxKind.SetAccessor */ && member.symbol.flags & 32768 /* SymbolFlags.GetAccessor */) {
// Already would have reported an error on the getter.
break;
}
var symbol = getSymbolOfNode(member);
if (!symbol.isReferenced
- && (ts.hasEffectiveModifier(member, 8 /* Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name))
- && !(member.flags & 8388608 /* Ambient */)) {
- addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol)));
+ && (ts.hasEffectiveModifier(member, 8 /* ModifierFlags.Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name))
+ && !(member.flags & 16777216 /* NodeFlags.Ambient */)) {
+ addDiagnostic(member, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol)));
}
break;
- case 170 /* Constructor */:
+ case 171 /* SyntaxKind.Constructor */:
for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) {
var parameter = _c[_b];
- if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* Private */)) {
- addDiagnostic(parameter, 0 /* Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol)));
+ if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* ModifierFlags.Private */)) {
+ addDiagnostic(parameter, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol)));
}
}
break;
- case 175 /* IndexSignature */:
- case 233 /* SemicolonClassElement */:
- case 169 /* ClassStaticBlockDeclaration */:
+ case 176 /* SyntaxKind.IndexSignature */:
+ case 234 /* SyntaxKind.SemicolonClassElement */:
+ case 170 /* SyntaxKind.ClassStaticBlockDeclaration */:
// Can't be private
break;
default:
@@ -80432,7 +81996,7 @@ var ts;
function checkUnusedInferTypeParameter(node, addDiagnostic) {
var typeParameter = node.typeParameter;
if (isTypeParameterUnused(typeParameter)) {
- addDiagnostic(node, 1 /* Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name)));
+ addDiagnostic(node, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name)));
}
}
function checkUnusedTypeParameters(node, addDiagnostic) {
@@ -80449,7 +82013,7 @@ var ts;
continue;
var name = ts.idText(typeParameter.name);
var parent = typeParameter.parent;
- if (parent.kind !== 189 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) {
+ if (parent.kind !== 190 /* SyntaxKind.InferType */ && parent.typeParameters.every(isTypeParameterUnused)) {
if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) {
var sourceFile = ts.getSourceFileOfNode(parent);
var range = ts.isJSDocTemplateTag(parent)
@@ -80461,17 +82025,17 @@ var ts;
//TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag
var message = only ? ts.Diagnostics._0_is_declared_but_its_value_is_never_read : ts.Diagnostics.All_type_parameters_are_unused;
var arg0 = only ? name : undefined;
- addDiagnostic(typeParameter, 1 /* Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0));
+ addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0));
}
}
else {
//TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag
- addDiagnostic(typeParameter, 1 /* Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name));
+ addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name));
}
}
}
function isTypeParameterUnused(typeParameter) {
- return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name);
+ return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* SymbolFlags.TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name);
}
function addToGroup(map, key, value, getKey) {
var keyString = String(getKey(key));
@@ -80508,7 +82072,7 @@ var ts;
nodeWithLocals.locals.forEach(function (local) {
// If it's purely a type parameter, ignore, will be checked in `checkUnusedTypeParameters`.
// If it's a type parameter merged with a parameter, check if the parameter-side is used.
- if (local.flags & 262144 /* TypeParameter */ ? !(local.flags & 3 /* Variable */ && !(local.isReferenced & 3 /* Variable */)) : local.isReferenced || local.exportSymbol) {
+ if (local.flags & 262144 /* SymbolFlags.TypeParameter */ ? !(local.flags & 3 /* SymbolFlags.Variable */ && !(local.isReferenced & 3 /* SymbolFlags.Variable */)) : local.isReferenced || local.exportSymbol) {
return;
}
if (local.declarations) {
@@ -80539,7 +82103,7 @@ var ts;
addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId);
}
else {
- addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local)));
+ addDiagnostic(parameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local)));
}
}
}
@@ -80555,10 +82119,10 @@ var ts;
var importDecl = importClause.parent;
var nDeclarations = (importClause.name ? 1 : 0) +
(importClause.namedBindings ?
- (importClause.namedBindings.kind === 267 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length)
+ (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? 1 : importClause.namedBindings.elements.length)
: 0);
if (nDeclarations === unuseds.length) {
- addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1
+ addDiagnostic(importDecl, 0 /* UnusedKind.Local */, unuseds.length === 1
? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name))
: ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused));
}
@@ -80571,9 +82135,9 @@ var ts;
});
unusedDestructures.forEach(function (_a) {
var bindingPattern = _a[0], bindingElements = _a[1];
- var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */;
+ var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* UnusedKind.Parameter */ : 0 /* UnusedKind.Local */;
if (bindingPattern.elements.length === bindingElements.length) {
- if (bindingElements.length === 1 && bindingPattern.parent.kind === 253 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 254 /* VariableDeclarationList */) {
+ if (bindingElements.length === 1 && bindingPattern.parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && bindingPattern.parent.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */) {
addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId);
}
else {
@@ -80592,38 +82156,38 @@ var ts;
unusedVariables.forEach(function (_a) {
var declarationList = _a[0], declarations = _a[1];
if (declarationList.declarations.length === declarations.length) {
- addDiagnostic(declarationList, 0 /* Local */, declarations.length === 1
+ addDiagnostic(declarationList, 0 /* UnusedKind.Local */, declarations.length === 1
? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name))
- : ts.createDiagnosticForNode(declarationList.parent.kind === 236 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused));
+ : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* SyntaxKind.VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused));
}
else {
- for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
- var decl = declarations_5[_i];
- addDiagnostic(decl, 0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name)));
+ for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
+ var decl = declarations_6[_i];
+ addDiagnostic(decl, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name)));
}
}
});
}
function bindingNameText(name) {
switch (name.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return ts.idText(name);
- case 201 /* ArrayBindingPattern */:
- case 200 /* ObjectBindingPattern */:
+ case 202 /* SyntaxKind.ArrayBindingPattern */:
+ case 201 /* SyntaxKind.ObjectBindingPattern */:
return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name);
default:
return ts.Debug.assertNever(name);
}
}
function isImportedDeclaration(node) {
- return node.kind === 266 /* ImportClause */ || node.kind === 269 /* ImportSpecifier */ || node.kind === 267 /* NamespaceImport */;
+ return node.kind === 267 /* SyntaxKind.ImportClause */ || node.kind === 270 /* SyntaxKind.ImportSpecifier */ || node.kind === 268 /* SyntaxKind.NamespaceImport */;
}
function importClauseFromImported(decl) {
- return decl.kind === 266 /* ImportClause */ ? decl : decl.kind === 267 /* NamespaceImport */ ? decl.parent : decl.parent.parent;
+ return decl.kind === 267 /* SyntaxKind.ImportClause */ ? decl : decl.kind === 268 /* SyntaxKind.NamespaceImport */ ? decl.parent : decl.parent.parent;
}
function checkBlock(node) {
// Grammar checking for SyntaxKind.Block
- if (node.kind === 234 /* Block */) {
+ if (node.kind === 235 /* SyntaxKind.Block */) {
checkGrammarStatementInAmbientContext(node);
}
if (ts.isFunctionOrModuleBlock(node)) {
@@ -80640,7 +82204,7 @@ var ts;
}
function checkCollisionWithArgumentsInGeneratedCode(node) {
// no rest parameters \ declaration context \ overload - no codegen impact
- if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 8388608 /* Ambient */ || ts.nodeIsMissing(node.body)) {
+ if (languageVersion >= 2 /* ScriptTarget.ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* NodeFlags.Ambient */ || ts.nodeIsMissing(node.body)) {
return;
}
ts.forEach(node.parameters, function (p) {
@@ -80658,17 +82222,17 @@ var ts;
if ((identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) !== name) {
return false;
}
- if (node.kind === 166 /* PropertyDeclaration */ ||
- node.kind === 165 /* PropertySignature */ ||
- node.kind === 168 /* MethodDeclaration */ ||
- node.kind === 167 /* MethodSignature */ ||
- node.kind === 171 /* GetAccessor */ ||
- node.kind === 172 /* SetAccessor */ ||
- node.kind === 294 /* PropertyAssignment */) {
+ if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ ||
+ node.kind === 166 /* SyntaxKind.PropertySignature */ ||
+ node.kind === 169 /* SyntaxKind.MethodDeclaration */ ||
+ node.kind === 168 /* SyntaxKind.MethodSignature */ ||
+ node.kind === 172 /* SyntaxKind.GetAccessor */ ||
+ node.kind === 173 /* SyntaxKind.SetAccessor */ ||
+ node.kind === 296 /* SyntaxKind.PropertyAssignment */) {
// it is ok to have member named '_super', '_this', `Promise`, etc. - member access is always qualified
return false;
}
- if (node.flags & 8388608 /* Ambient */) {
+ if (node.flags & 16777216 /* NodeFlags.Ambient */) {
// ambient context - no codegen impact
return false;
}
@@ -80688,8 +82252,8 @@ var ts;
// this function will run after checking the source file so 'CaptureThis' is correct for all nodes
function checkIfThisIsCapturedInEnclosingScope(node) {
ts.findAncestor(node, function (current) {
- if (getNodeCheckFlags(current) & 4 /* CaptureThis */) {
- var isDeclaration_1 = node.kind !== 79 /* Identifier */;
+ if (getNodeCheckFlags(current) & 4 /* NodeCheckFlags.CaptureThis */) {
+ var isDeclaration_1 = node.kind !== 79 /* SyntaxKind.Identifier */;
if (isDeclaration_1) {
error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference);
}
@@ -80703,8 +82267,8 @@ var ts;
}
function checkIfNewTargetIsCapturedInEnclosingScope(node) {
ts.findAncestor(node, function (current) {
- if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) {
- var isDeclaration_2 = node.kind !== 79 /* Identifier */;
+ if (getNodeCheckFlags(current) & 8 /* NodeCheckFlags.CaptureNewTarget */) {
+ var isDeclaration_2 = node.kind !== 79 /* SyntaxKind.Identifier */;
if (isDeclaration_2) {
error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference);
}
@@ -80718,53 +82282,53 @@ var ts;
}
function checkCollisionWithRequireExportsInGeneratedCode(node, name) {
// No need to check for require or exports for ES6 modules and later
- if (moduleKind >= ts.ModuleKind.ES2015 && !(moduleKind >= ts.ModuleKind.Node12 && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) {
+ if (moduleKind >= ts.ModuleKind.ES2015 && !(moduleKind >= ts.ModuleKind.Node16 && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) {
return;
}
if (!name || !needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
return;
}
// Uninstantiated modules shouldnt do this check
- if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) {
+ if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) {
return;
}
// In case of variable declaration, node.parent is variable statement so look at the variable statement's parent
var parent = getDeclarationContainer(node);
- if (parent.kind === 303 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) {
+ if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent)) {
// If the declaration happens to be in external module, report error that require and exports are reserved keywords
errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name));
}
}
function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) {
- if (!name || languageVersion >= 4 /* ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) {
+ if (!name || languageVersion >= 4 /* ScriptTarget.ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) {
return;
}
// Uninstantiated modules shouldnt do this check
- if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) {
+ if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) {
return;
}
// In case of variable declaration, node.parent is variable statement so look at the variable statement's parent
var parent = getDeclarationContainer(node);
- if (parent.kind === 303 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) {
+ if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* NodeFlags.HasAsyncFunctions */) {
// If the declaration happens to be in external module, report error that Promise is a reserved identifier.
errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name));
}
}
function recordPotentialCollisionWithWeakMapSetInGeneratedCode(node, name) {
- if (languageVersion <= 8 /* ES2021 */
+ if (languageVersion <= 8 /* ScriptTarget.ES2021 */
&& (needCollisionCheckForIdentifier(node, name, "WeakMap") || needCollisionCheckForIdentifier(node, name, "WeakSet"))) {
potentialWeakMapSetCollisions.push(node);
}
}
function checkWeakMapSetCollision(node) {
var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node);
- if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* ContainsClassWithPrivateIdentifiers */) {
+ if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */) {
ts.Debug.assert(ts.isNamedDeclaration(node) && ts.isIdentifier(node.name) && typeof node.name.escapedText === "string", "The target of a WeakMap/WeakSet collision check should be an identifier");
errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, node.name.escapedText);
}
}
function recordPotentialCollisionWithReflectInGeneratedCode(node, name) {
- if (name && languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */
+ if (name && languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */
&& needCollisionCheckForIdentifier(node, name, "Reflect")) {
potentialReflectCollisions.push(node);
}
@@ -80775,7 +82339,7 @@ var ts;
// ClassExpression names don't contribute to their containers, but do matter for any of their block-scoped members.
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
var member = _a[_i];
- if (getNodeCheckFlags(member) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) {
+ if (getNodeCheckFlags(member) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) {
hasCollision = true;
break;
}
@@ -80783,13 +82347,13 @@ var ts;
}
else if (ts.isFunctionExpression(node)) {
// FunctionExpression names don't contribute to their containers, but do matter for their contents
- if (getNodeCheckFlags(node) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) {
+ if (getNodeCheckFlags(node) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) {
hasCollision = true;
}
}
else {
var container = ts.getEnclosingBlockScopeContainer(node);
- if (container && getNodeCheckFlags(container) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) {
+ if (container && getNodeCheckFlags(container) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) {
hasCollision = true;
}
}
@@ -80807,7 +82371,7 @@ var ts;
recordPotentialCollisionWithReflectInGeneratedCode(node, name);
if (ts.isClassLike(node)) {
checkTypeNameIsReserved(name, ts.Diagnostics.Class_name_cannot_be_0);
- if (!(node.flags & 8388608 /* Ambient */)) {
+ if (!(node.flags & 16777216 /* NodeFlags.Ambient */)) {
checkClassNameCollisionWithObject(name);
}
}
@@ -80839,35 +82403,35 @@ var ts;
// const x = 0; // symbol for this declaration will be 'symbol'
// }
// skip block-scoped variables and parameters
- if ((ts.getCombinedNodeFlags(node) & 3 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) {
+ if ((ts.getCombinedNodeFlags(node) & 3 /* NodeFlags.BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) {
return;
}
// skip variable declarations that don't have initializers
// NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern
// so we'll always treat binding elements as initialized
- if (node.kind === 253 /* VariableDeclaration */ && !node.initializer) {
+ if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ && !node.initializer) {
return;
}
var symbol = getSymbolOfNode(node);
- if (symbol.flags & 1 /* FunctionScopedVariable */) {
+ if (symbol.flags & 1 /* SymbolFlags.FunctionScopedVariable */) {
if (!ts.isIdentifier(node.name))
return ts.Debug.fail();
- var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
+ var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* SymbolFlags.Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
if (localDeclarationSymbol &&
localDeclarationSymbol !== symbol &&
- localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) {
- if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) {
- var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 254 /* VariableDeclarationList */);
- var container = varDeclList.parent.kind === 236 /* VariableStatement */ && varDeclList.parent.parent
+ localDeclarationSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) {
+ if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* NodeFlags.BlockScoped */) {
+ var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */);
+ var container = varDeclList.parent.kind === 237 /* SyntaxKind.VariableStatement */ && varDeclList.parent.parent
? varDeclList.parent.parent
: undefined;
// names of block-scoped and function scoped variables can collide only
// if block scoped variable is defined in the function\module\source file scope (because of variable hoisting)
var namesShareScope = container &&
- (container.kind === 234 /* Block */ && ts.isFunctionLike(container.parent) ||
- container.kind === 261 /* ModuleBlock */ ||
- container.kind === 260 /* ModuleDeclaration */ ||
- container.kind === 303 /* SourceFile */);
+ (container.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(container.parent) ||
+ container.kind === 262 /* SyntaxKind.ModuleBlock */ ||
+ container.kind === 261 /* SyntaxKind.ModuleDeclaration */ ||
+ container.kind === 305 /* SyntaxKind.SourceFile */);
// here we know that function scoped variable is shadowed by block scoped one
// if they are defined in the same scope - binder has already reported redeclaration error
// otherwise if variable has an initializer - show error that initialization will fail
@@ -80898,23 +82462,23 @@ var ts;
// Do not use hasDynamicName here, because that returns false for well known symbols.
// We want to perform checkComputedPropertyName for all computed properties, including
// well known symbols.
- if (node.name.kind === 161 /* ComputedPropertyName */) {
+ if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) {
checkComputedPropertyName(node.name);
if (node.initializer) {
checkExpressionCached(node.initializer);
}
}
if (ts.isBindingElement(node)) {
- if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) {
- checkExternalEmitHelpers(node, 4 /* Rest */);
+ if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ScriptTarget.ES2018 */) {
+ checkExternalEmitHelpers(node, 4 /* ExternalEmitHelpers.Rest */);
}
// check computed properties inside property names of binding elements
- if (node.propertyName && node.propertyName.kind === 161 /* ComputedPropertyName */) {
+ if (node.propertyName && node.propertyName.kind === 162 /* SyntaxKind.ComputedPropertyName */) {
checkComputedPropertyName(node.propertyName);
}
// check private/protected variable access
var parent = node.parent.parent;
- var parentCheckMode = node.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
+ var parentCheckMode = node.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */;
var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
var name = node.propertyName || node.name;
if (parentType && !ts.isBindingPattern(name)) {
@@ -80924,15 +82488,15 @@ var ts;
var property = getPropertyOfType(parentType, nameText);
if (property) {
markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isSelfTypeAccess*/ false); // A destructuring is never a write-only reference.
- checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SuperKeyword */, /*writing*/ false, parentType, property);
+ checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SyntaxKind.SuperKeyword */, /*writing*/ false, parentType, property);
}
}
}
}
// For a binding pattern, check contained binding elements
if (ts.isBindingPattern(node.name)) {
- if (node.name.kind === 201 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) {
- checkExternalEmitHelpers(node, 512 /* Read */);
+ if (node.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) {
+ checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */);
}
ts.forEach(node.name.elements, checkSourceElement);
}
@@ -80943,7 +82507,7 @@ var ts;
}
// For a binding pattern, validate the initializer and exit
if (ts.isBindingPattern(node.name)) {
- var needCheckInitializer = node.initializer && node.parent.parent.kind !== 242 /* ForInStatement */;
+ var needCheckInitializer = node.initializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */;
var needCheckWidenedType = node.name.elements.length === 0;
if (needCheckInitializer || needCheckWidenedType) {
// Don't validate for-in initializer as it is already an error
@@ -80960,7 +82524,7 @@ var ts;
// check the binding pattern with empty elements
if (needCheckWidenedType) {
if (ts.isArrayBindingPattern(node.name)) {
- checkIteratedTypeOrElementType(65 /* Destructuring */, widenedType, undefinedType, node);
+ checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, widenedType, undefinedType, node);
}
else if (strictNullChecks) {
checkNonNullNonVoidType(widenedType, node);
@@ -80971,7 +82535,7 @@ var ts;
}
// For a commonjs `const x = require`, validate the alias and exit
var symbol = getSymbolOfNode(node);
- if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
+ if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
checkAliasSymbol(node);
return;
}
@@ -80985,7 +82549,7 @@ var ts;
ts.isObjectLiteralExpression(initializer) &&
(initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) &&
!!((_a = symbol.exports) === null || _a === void 0 ? void 0 : _a.size);
- if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 242 /* ForInStatement */) {
+ if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */) {
checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined);
}
}
@@ -81001,7 +82565,7 @@ var ts;
var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node));
if (!isErrorType(type) && !isErrorType(declarationType) &&
!isTypeIdenticalTo(type, declarationType) &&
- !(symbol.flags & 67108864 /* Assignment */)) {
+ !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) {
errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType);
}
if (node.initializer) {
@@ -81011,10 +82575,10 @@ var ts;
error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name));
}
}
- if (node.kind !== 166 /* PropertyDeclaration */ && node.kind !== 165 /* PropertySignature */) {
+ if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */) {
// We know we don't have a binding pattern or computed name here
checkExportsOnMergedDeclarations(node);
- if (node.kind === 253 /* VariableDeclaration */ || node.kind === 202 /* BindingElement */) {
+ if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) {
checkVarDeclaredNamesNotShadowed(node);
}
checkCollisionsForDeclarationName(node, node.name);
@@ -81022,7 +82586,7 @@ var ts;
}
function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) {
var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration);
- var message = nextDeclaration.kind === 166 /* PropertyDeclaration */ || nextDeclaration.kind === 165 /* PropertySignature */
+ var message = nextDeclaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ || nextDeclaration.kind === 166 /* SyntaxKind.PropertySignature */
? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2
: ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2;
var declName = ts.declarationNameToString(nextDeclarationName);
@@ -81032,24 +82596,24 @@ var ts;
}
}
function areDeclarationFlagsIdentical(left, right) {
- if ((left.kind === 163 /* Parameter */ && right.kind === 253 /* VariableDeclaration */) ||
- (left.kind === 253 /* VariableDeclaration */ && right.kind === 163 /* Parameter */)) {
+ if ((left.kind === 164 /* SyntaxKind.Parameter */ && right.kind === 254 /* SyntaxKind.VariableDeclaration */) ||
+ (left.kind === 254 /* SyntaxKind.VariableDeclaration */ && right.kind === 164 /* SyntaxKind.Parameter */)) {
// Differences in optionality between parameters and variables are allowed.
return true;
}
if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) {
return false;
}
- var interestingFlags = 8 /* Private */ |
- 16 /* Protected */ |
- 256 /* Async */ |
- 128 /* Abstract */ |
- 64 /* Readonly */ |
- 32 /* Static */;
+ var interestingFlags = 8 /* ModifierFlags.Private */ |
+ 16 /* ModifierFlags.Protected */ |
+ 256 /* ModifierFlags.Async */ |
+ 128 /* ModifierFlags.Abstract */ |
+ 64 /* ModifierFlags.Readonly */ |
+ 32 /* ModifierFlags.Static */;
return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags);
}
function checkVariableDeclaration(node) {
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath });
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath });
checkGrammarVariableDeclaration(node);
checkVariableLikeDeclaration(node);
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
@@ -81072,50 +82636,61 @@ var ts;
function checkIfStatement(node) {
// Grammar checking
checkGrammarStatementInAmbientContext(node);
- var type = checkTruthinessExpression(node.expression);
- checkTestingKnownTruthyCallableOrAwaitableType(node.expression, type, node.thenStatement);
+ checkTruthinessExpression(node.expression);
+ checkTestingKnownTruthyCallableOrAwaitableType(node.expression, node.thenStatement);
checkSourceElement(node.thenStatement);
- if (node.thenStatement.kind === 235 /* EmptyStatement */) {
+ if (node.thenStatement.kind === 236 /* SyntaxKind.EmptyStatement */) {
error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement);
}
checkSourceElement(node.elseStatement);
}
- function checkTestingKnownTruthyCallableOrAwaitableType(condExpr, type, body) {
+ function checkTestingKnownTruthyCallableOrAwaitableType(condExpr, body) {
if (!strictNullChecks)
return;
- if (getFalsyFlags(type))
- return;
- var location = ts.isBinaryExpression(condExpr) ? condExpr.right : condExpr;
- if (ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression)) {
- return;
- }
- var testedNode = ts.isIdentifier(location) ? location
- : ts.isPropertyAccessExpression(location) ? location.name
- : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right
- : undefined;
- // While it technically should be invalid for any known-truthy value
- // to be tested, we de-scope to functions and Promises unreferenced in
- // the block as a heuristic to identify the most common bugs. There
- // are too many false positives for values sourced from type
- // definitions without strictNullChecks otherwise.
- var callSignatures = getSignaturesOfType(type, 0 /* Call */);
- var isPromise = !!getAwaitedTypeOfPromise(type);
- if (callSignatures.length === 0 && !isPromise) {
- return;
- }
- var testedSymbol = testedNode && getSymbolAtLocation(testedNode);
- if (!testedSymbol && !isPromise) {
- return;
- }
- var isUsed = testedSymbol && ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol)
- || testedSymbol && body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol);
- if (!isUsed) {
- if (isPromise) {
- errorAndMaybeSuggestAwait(location,
- /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type));
+ helper(condExpr, body);
+ while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) {
+ condExpr = condExpr.left;
+ helper(condExpr, body);
+ }
+ function helper(condExpr, body) {
+ var location = ts.isBinaryExpression(condExpr) &&
+ (condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || condExpr.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)
+ ? condExpr.right
+ : condExpr;
+ if (ts.isModuleExportsAccessExpression(location))
+ return;
+ var type = checkTruthinessExpression(location);
+ var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
+ if (getFalsyFlags(type) || isPropertyExpressionCast)
+ return;
+ // While it technically should be invalid for any known-truthy value
+ // to be tested, we de-scope to functions and Promises unreferenced in
+ // the block as a heuristic to identify the most common bugs. There
+ // are too many false positives for values sourced from type
+ // definitions without strictNullChecks otherwise.
+ var callSignatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */);
+ var isPromise = !!getAwaitedTypeOfPromise(type);
+ if (callSignatures.length === 0 && !isPromise) {
+ return;
}
- else {
- error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead);
+ var testedNode = ts.isIdentifier(location) ? location
+ : ts.isPropertyAccessExpression(location) ? location.name
+ : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right
+ : undefined;
+ var testedSymbol = testedNode && getSymbolAtLocation(testedNode);
+ if (!testedSymbol && !isPromise) {
+ return;
+ }
+ var isUsed = testedSymbol && ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol)
+ || testedSymbol && body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol);
+ if (!isUsed) {
+ if (isPromise) {
+ errorAndMaybeSuggestAwait(location,
+ /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type));
+ }
+ else {
+ error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead);
+ }
}
}
}
@@ -81125,7 +82700,7 @@ var ts;
var childSymbol = getSymbolAtLocation(childNode);
if (childSymbol && childSymbol === testedSymbol) {
// If the test was a simple identifier, the above check is sufficient
- if (ts.isIdentifier(expr)) {
+ if (ts.isIdentifier(expr) || ts.isIdentifier(testedNode) && ts.isBinaryExpression(testedNode.parent)) {
return true;
}
// Otherwise we need to ensure the symbol is called on the same target
@@ -81133,7 +82708,7 @@ var ts;
var childExpression = childNode.parent;
while (testedExpression && childExpression) {
if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) ||
- testedExpression.kind === 108 /* ThisKeyword */ && childExpression.kind === 108 /* ThisKeyword */) {
+ testedExpression.kind === 108 /* SyntaxKind.ThisKeyword */ && childExpression.kind === 108 /* SyntaxKind.ThisKeyword */) {
return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression);
}
else if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) {
@@ -81157,7 +82732,7 @@ var ts;
});
}
function isSymbolUsedInBinaryExpressionChain(node, testedSymbol) {
- while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) {
+ while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) {
var isUsed = ts.forEachChild(node.right, function visit(child) {
if (ts.isIdentifier(child)) {
var symbol = getSymbolAtLocation(child);
@@ -81187,7 +82762,7 @@ var ts;
checkSourceElement(node.statement);
}
function checkTruthinessOfType(type, node) {
- if (type.flags & 16384 /* Void */) {
+ if (type.flags & 16384 /* TypeFlags.Void */) {
error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness);
}
return type;
@@ -81198,12 +82773,12 @@ var ts;
function checkForStatement(node) {
// Grammar checking
if (!checkGrammarStatementInAmbientContext(node)) {
- if (node.initializer && node.initializer.kind === 254 /* VariableDeclarationList */) {
+ if (node.initializer && node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) {
checkGrammarVariableDeclarationList(node.initializer);
}
}
if (node.initializer) {
- if (node.initializer.kind === 254 /* VariableDeclarationList */) {
+ if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) {
ts.forEach(node.initializer.declarations, checkVariableDeclaration);
}
else {
@@ -81228,29 +82803,29 @@ var ts;
}
else {
var functionFlags = ts.getFunctionFlags(container);
- if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion < 99 /* ESNext */) {
+ if ((functionFlags & (4 /* FunctionFlags.Invalid */ | 2 /* FunctionFlags.Async */)) === 2 /* FunctionFlags.Async */ && languageVersion < 99 /* ScriptTarget.ESNext */) {
// for..await..of in an async function or async generator function prior to ESNext requires the __asyncValues helper
- checkExternalEmitHelpers(node, 16384 /* ForAwaitOfIncludes */);
+ checkExternalEmitHelpers(node, 16384 /* ExternalEmitHelpers.ForAwaitOfIncludes */);
}
}
}
- else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ES2015 */) {
+ else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ScriptTarget.ES2015 */) {
// for..of prior to ES2015 requires the __values helper when downlevelIteration is enabled
- checkExternalEmitHelpers(node, 256 /* ForOfIncludes */);
+ checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.ForOfIncludes */);
}
// Check the LHS and RHS
// If the LHS is a declaration, just check it as a variable declaration, which will in turn check the RHS
// via checkRightHandSideOfForOf.
// If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference.
// Then check that the RHS is assignable to it.
- if (node.initializer.kind === 254 /* VariableDeclarationList */) {
+ if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) {
checkForInOrForOfVariableDeclaration(node);
}
else {
var varExpr = node.initializer;
var iteratedType = checkRightHandSideOfForOf(node);
// There may be a destructuring assignment on the left side
- if (varExpr.kind === 203 /* ArrayLiteralExpression */ || varExpr.kind === 204 /* ObjectLiteralExpression */) {
+ if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) {
// iteratedType may be undefined. In this case, we still want to check the structure of
// varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like
// to short circuit the type relation checking as much as possible, so we pass the unknownType.
@@ -81282,7 +82857,7 @@ var ts;
// for (let VarDecl in Expr) Statement
// VarDecl must be a variable declaration without a type annotation that declares a variable of type Any,
// and Expr must be an expression of type Any, an object type, or a type parameter type.
- if (node.initializer.kind === 254 /* VariableDeclarationList */) {
+ if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) {
var variable = node.initializer.declarations[0];
if (variable && ts.isBindingPattern(variable.name)) {
error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern);
@@ -81296,7 +82871,7 @@ var ts;
// and Expr must be an expression of type Any, an object type, or a type parameter type.
var varExpr = node.initializer;
var leftType = checkExpression(varExpr);
- if (varExpr.kind === 203 /* ArrayLiteralExpression */ || varExpr.kind === 204 /* ObjectLiteralExpression */) {
+ if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) {
error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern);
}
else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) {
@@ -81309,7 +82884,7 @@ var ts;
}
// unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved
// in this case error about missing name is already reported - do not report extra one
- if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) {
+ if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) {
error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0, typeToString(rightType));
}
checkSourceElement(node.statement);
@@ -81326,7 +82901,7 @@ var ts;
}
}
function checkRightHandSideOfForOf(statement) {
- var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */;
+ var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */;
return checkIteratedTypeOrElementType(use, checkNonNullExpression(statement.expression), undefinedType, statement.expression);
}
function checkIteratedTypeOrElementType(use, inputType, sentType, errorNode) {
@@ -81341,14 +82916,14 @@ var ts;
* of a iterable (if defined globally) or element type of an array like for ES2015 or earlier.
*/
function getIteratedTypeOrElementType(use, inputType, sentType, errorNode, checkAssignability) {
- var allowAsyncIterables = (use & 2 /* AllowsAsyncIterablesFlag */) !== 0;
+ var allowAsyncIterables = (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) !== 0;
if (inputType === neverType) {
reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables); // TODO: GH#18217
return undefined;
}
- var uplevelIteration = languageVersion >= 2 /* ES2015 */;
+ var uplevelIteration = languageVersion >= 2 /* ScriptTarget.ES2015 */;
var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration;
- var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* PossiblyOutOfBounds */);
+ var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* IterationUse.PossiblyOutOfBounds */);
// Get the iterated type of an `Iterable<T>` or `IterableIterator<T>` only in ES2015
// or higher, when inside of an async generator or for-await-if, or when
// downlevelIteration is requested.
@@ -81357,10 +82932,10 @@ var ts;
var iterationTypes = getIterationTypesOfIterable(inputType, use, uplevelIteration ? errorNode : undefined);
if (checkAssignability) {
if (iterationTypes) {
- var diagnostic = use & 8 /* ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 :
- use & 32 /* SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 :
- use & 64 /* DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 :
- use & 16 /* YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 :
+ var diagnostic = use & 8 /* IterationUse.ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 :
+ use & 32 /* IterationUse.SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 :
+ use & 64 /* IterationUse.DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 :
+ use & 16 /* IterationUse.YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 :
undefined;
if (diagnostic) {
checkTypeAssignableTo(sentType, iterationTypes.nextType, errorNode, diagnostic);
@@ -81377,22 +82952,22 @@ var ts;
// If strings are permitted, remove any string-like constituents from the array type.
// This allows us to find other non-string element types from an array unioned with
// a string.
- if (use & 4 /* AllowsStringInputFlag */) {
- if (arrayType.flags & 1048576 /* Union */) {
+ if (use & 4 /* IterationUse.AllowsStringInputFlag */) {
+ if (arrayType.flags & 1048576 /* TypeFlags.Union */) {
// After we remove all types that are StringLike, we will know if there was a string constituent
// based on whether the result of filter is a new array.
var arrayTypes = inputType.types;
- var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* StringLike */); });
+ var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* TypeFlags.StringLike */); });
if (filteredTypes !== arrayTypes) {
- arrayType = getUnionType(filteredTypes, 2 /* Subtype */);
+ arrayType = getUnionType(filteredTypes, 2 /* UnionReduction.Subtype */);
}
}
- else if (arrayType.flags & 402653316 /* StringLike */) {
+ else if (arrayType.flags & 402653316 /* TypeFlags.StringLike */) {
arrayType = neverType;
}
hasStringConstituent = arrayType !== inputType;
if (hasStringConstituent) {
- if (languageVersion < 1 /* ES5 */) {
+ if (languageVersion < 1 /* ScriptTarget.ES5 */) {
if (errorNode) {
error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher);
reportedError = true;
@@ -81400,7 +82975,7 @@ var ts;
}
// Now that we've removed all the StringLike types, if no constituents remain, then the entire
// arrayOrStringType was a string.
- if (arrayType.flags & 131072 /* Never */) {
+ if (arrayType.flags & 131072 /* TypeFlags.Never */) {
return possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType;
}
}
@@ -81412,7 +82987,7 @@ var ts;
// want to say that number is not an array type. But if the input was just
// number and string input is allowed, we want to say that number is not an
// array type or a string type.
- var allowsStrings = !!(use & 4 /* AllowsStringInputFlag */) && !hasStringConstituent;
+ var allowsStrings = !!(use & 4 /* IterationUse.AllowsStringInputFlag */) && !hasStringConstituent;
var _a = getIterationDiagnosticDetails(allowsStrings, downlevelIteration), defaultDiagnostic = _a[0], maybeMissingAwait = _a[1];
errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType));
}
@@ -81421,12 +82996,12 @@ var ts;
var arrayElementType = getIndexTypeOfType(arrayType, numberType);
if (hasStringConstituent && arrayElementType) {
// This is just an optimization for the case where arrayOrStringType is string | string[]
- if (arrayElementType.flags & 402653316 /* StringLike */ && !compilerOptions.noUncheckedIndexedAccess) {
+ if (arrayElementType.flags & 402653316 /* TypeFlags.StringLike */ && !compilerOptions.noUncheckedIndexedAccess) {
return stringType;
}
- return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */);
+ return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* UnionReduction.Subtype */);
}
- return (use & 128 /* PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType;
+ return (use & 128 /* IterationUse.PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType;
function getIterationDiagnosticDetails(allowsStrings, downlevelIteration) {
var _a;
if (downlevelIteration) {
@@ -81434,9 +83009,9 @@ var ts;
? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]
: [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true];
}
- var yieldType = getIterationTypeOfIterable(use, 0 /* Yield */, inputType, /*errorNode*/ undefined);
+ var yieldType = getIterationTypeOfIterable(use, 0 /* IterationTypeKind.Yield */, inputType, /*errorNode*/ undefined);
if (yieldType) {
- return [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false];
+ return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, false];
}
if (isES2015OrLaterIterable((_a = inputType.symbol) === null || _a === void 0 ? void 0 : _a.escapedName)) {
return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, true];
@@ -81483,9 +83058,9 @@ var ts;
// more frequently created (i.e. `Iterator<number, void, unknown>`). Iteration types
// are also cached on the type they are requested for, so we shouldn't need to maintain
// the cache for less-frequently used types.
- if (yieldType.flags & 67359327 /* Intrinsic */ &&
- returnType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */) &&
- nextType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */)) {
+ if (yieldType.flags & 67359327 /* TypeFlags.Intrinsic */ &&
+ returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */) &&
+ nextType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */)) {
var id = getTypeListId([yieldType, returnType, nextType]);
var iterationTypes = iterationTypesCache.get(id);
if (!iterationTypes) {
@@ -81555,17 +83130,17 @@ var ts;
if (isTypeAny(type)) {
return anyIterationTypes;
}
- if (!(type.flags & 1048576 /* Union */)) {
+ if (!(type.flags & 1048576 /* TypeFlags.Union */)) {
var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode);
if (iterationTypes_1 === noIterationTypes) {
if (errorNode) {
- reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
+ reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */));
}
return undefined;
}
return iterationTypes_1;
}
- var cacheKey = use & 2 /* AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable";
+ var cacheKey = use & 2 /* IterationUse.AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable";
var cachedTypes = getCachedIterationTypes(type, cacheKey);
if (cachedTypes)
return cachedTypes === noIterationTypes ? undefined : cachedTypes;
@@ -81575,7 +83150,7 @@ var ts;
var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode);
if (iterationTypes_2 === noIterationTypes) {
if (errorNode) {
- reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
+ reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */));
}
setCachedIterationTypes(type, cacheKey, noIterationTypes);
return undefined;
@@ -81614,20 +83189,20 @@ var ts;
if (isTypeAny(type)) {
return anyIterationTypes;
}
- if (use & 2 /* AllowsAsyncIterablesFlag */) {
+ if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) {
var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) ||
getIterationTypesOfIterableFast(type, asyncIterationTypesResolver);
if (iterationTypes) {
- return use & 8 /* ForOfFlag */ ?
+ return use & 8 /* IterationUse.ForOfFlag */ ?
getAsyncFromSyncIterationTypes(iterationTypes, errorNode) :
iterationTypes;
}
}
- if (use & 1 /* AllowsSyncIterablesFlag */) {
+ if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) {
var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) ||
getIterationTypesOfIterableFast(type, syncIterationTypesResolver);
if (iterationTypes) {
- if (use & 2 /* AllowsAsyncIterablesFlag */) {
+ if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) {
// for a sync iterable in an async context, only use the cached types if they are valid.
if (iterationTypes !== noIterationTypes) {
return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode));
@@ -81638,16 +83213,16 @@ var ts;
}
}
}
- if (use & 2 /* AllowsAsyncIterablesFlag */) {
+ if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) {
var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode);
if (iterationTypes !== noIterationTypes) {
return iterationTypes;
}
}
- if (use & 1 /* AllowsSyncIterablesFlag */) {
+ if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) {
var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode);
if (iterationTypes !== noIterationTypes) {
- if (use & 2 /* AllowsAsyncIterablesFlag */) {
+ if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) {
return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes
? getAsyncFromSyncIterationTypes(iterationTypes, errorNode)
: noIterationTypes);
@@ -81728,11 +83303,11 @@ var ts;
function getIterationTypesOfIterableSlow(type, resolver, errorNode) {
var _a;
var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName));
- var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined;
+ var methodType = method && !(method.flags & 16777216 /* SymbolFlags.Optional */) ? getTypeOfSymbol(method) : undefined;
if (isTypeAny(methodType)) {
return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
}
- var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined;
+ var signatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : undefined;
if (!ts.some(signatures)) {
return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
}
@@ -81812,13 +83387,13 @@ var ts;
// > If the end was not reached `done` is `false` and a value is available.
// > If a `done` property (either own or inherited) does not exist, it is consider to have the value `false`.
var doneType = getTypeOfPropertyOfType(type, "done") || falseType;
- return isTypeAssignableTo(kind === 0 /* Yield */ ? falseType : trueType, doneType);
+ return isTypeAssignableTo(kind === 0 /* IterationTypeKind.Yield */ ? falseType : trueType, doneType);
}
function isYieldIteratorResult(type) {
- return isIteratorResult(type, 0 /* Yield */);
+ return isIteratorResult(type, 0 /* IterationTypeKind.Yield */);
}
function isReturnIteratorResult(type) {
- return isIteratorResult(type, 1 /* Return */);
+ return isIteratorResult(type, 1 /* IterationTypeKind.Return */);
}
/**
* Gets the *yield* and *return* types of an `IteratorResult`-like type.
@@ -81873,15 +83448,15 @@ var ts;
if (!method && methodName !== "next") {
return undefined;
}
- var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* Optional */))
- ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* NEUndefinedOrNull */)
+ var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* SymbolFlags.Optional */))
+ ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* TypeFacts.NEUndefinedOrNull */)
: undefined;
if (isTypeAny(methodType)) {
// `return()` and `throw()` don't provide a *next* type.
return methodName === "next" ? anyIterationTypes : anyIterationTypesExceptNext;
}
// Both async and non-async iterators *must* have a `next` method.
- var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : ts.emptyArray;
+ var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : ts.emptyArray;
if (methodSignatures.length === 0) {
if (errorNode) {
var diagnostic = methodName === "next"
@@ -81987,7 +83562,7 @@ var ts;
if (isTypeAny(type)) {
return anyIterationTypes;
}
- var use = isAsyncGenerator ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */;
+ var use = isAsyncGenerator ? 2 /* IterationUse.AsyncGeneratorReturnType */ : 1 /* IterationUse.GeneratorReturnType */;
var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
return getIterationTypesOfIterable(type, use, /*errorNode*/ undefined) ||
getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined);
@@ -81999,15 +83574,15 @@ var ts;
// TODO: Check that target label is valid
}
function unwrapReturnType(returnType, functionFlags) {
- var isGenerator = !!(functionFlags & 1 /* Generator */);
- var isAsync = !!(functionFlags & 2 /* Async */);
- return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, isAsync) || errorType :
+ var isGenerator = !!(functionFlags & 1 /* FunctionFlags.Generator */);
+ var isAsync = !!(functionFlags & 2 /* FunctionFlags.Async */);
+ return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, isAsync) || errorType :
isAsync ? getAwaitedTypeNoAlias(returnType) || errorType :
returnType;
}
function isUnwrappedReturnTypeVoidOrAny(func, returnType) {
var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func));
- return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */);
+ return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* TypeFlags.Void */ | 3 /* TypeFlags.AnyOrUnknown */);
}
function checkReturnStatement(node) {
var _a;
@@ -82027,21 +83602,21 @@ var ts;
var signature = getSignatureFromDeclaration(container);
var returnType = getReturnTypeOfSignature(signature);
var functionFlags = ts.getFunctionFlags(container);
- if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) {
+ if (strictNullChecks || node.expression || returnType.flags & 131072 /* TypeFlags.Never */) {
var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
- if (container.kind === 172 /* SetAccessor */) {
+ if (container.kind === 173 /* SyntaxKind.SetAccessor */) {
if (node.expression) {
error(node, ts.Diagnostics.Setters_cannot_return_a_value);
}
}
- else if (container.kind === 170 /* Constructor */) {
+ else if (container.kind === 171 /* SyntaxKind.Constructor */) {
if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) {
error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
}
}
else if (getReturnTypeFromAnnotation(container)) {
var unwrappedReturnType = (_a = unwrapReturnType(returnType, functionFlags)) !== null && _a !== void 0 ? _a : returnType;
- var unwrappedExprType = functionFlags & 2 /* Async */
+ var unwrappedExprType = functionFlags & 2 /* FunctionFlags.Async */
? checkAwaitedType(exprType, /*withAlias*/ false, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member)
: exprType;
if (unwrappedReturnType) {
@@ -82052,7 +83627,7 @@ var ts;
}
}
}
- else if (container.kind !== 170 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) {
+ else if (container.kind !== 171 /* SyntaxKind.Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) {
// The function has a return type, but the return statement doesn't have an expression.
error(node, ts.Diagnostics.Not_all_code_paths_return_a_value);
}
@@ -82060,7 +83635,7 @@ var ts;
function checkWithStatement(node) {
// Grammar checking for withStatement
if (!checkGrammarStatementInAmbientContext(node)) {
- if (node.flags & 32768 /* AwaitContext */) {
+ if (node.flags & 32768 /* NodeFlags.AwaitContext */) {
grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block);
}
}
@@ -82081,7 +83656,7 @@ var ts;
var expressionIsLiteral = isLiteralType(expressionType);
ts.forEach(node.caseBlock.clauses, function (clause) {
// Grammar check for duplicate default clauses, skip if we already report duplicate default clause
- if (clause.kind === 289 /* DefaultClause */ && !hasDuplicateDefaultClause) {
+ if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && !hasDuplicateDefaultClause) {
if (firstDefaultClause === undefined) {
firstDefaultClause = clause;
}
@@ -82090,26 +83665,31 @@ var ts;
hasDuplicateDefaultClause = true;
}
}
- if (produceDiagnostics && clause.kind === 288 /* CaseClause */) {
- // TypeScript 1.0 spec (April 2014): 5.9
- // In a 'switch' statement, each 'case' expression must be of a type that is comparable
- // to or from the type of the 'switch' expression.
- var caseType = checkExpression(clause.expression);
- var caseIsLiteral = isLiteralType(caseType);
- var comparedExpressionType = expressionType;
- if (!caseIsLiteral || !expressionIsLiteral) {
- caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
- comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
- }
- if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
- // expressionType is not comparable to caseType, try the reversed check and report errors if it fails
- checkTypeComparableTo(caseType, comparedExpressionType, clause.expression, /*headMessage*/ undefined);
- }
+ if (clause.kind === 289 /* SyntaxKind.CaseClause */) {
+ addLazyDiagnostic(createLazyCaseClauseDiagnostics(clause));
}
ts.forEach(clause.statements, checkSourceElement);
if (compilerOptions.noFallthroughCasesInSwitch && clause.fallthroughFlowNode && isReachableFlowNode(clause.fallthroughFlowNode)) {
error(clause, ts.Diagnostics.Fallthrough_case_in_switch);
}
+ function createLazyCaseClauseDiagnostics(clause) {
+ return function () {
+ // TypeScript 1.0 spec (April 2014): 5.9
+ // In a 'switch' statement, each 'case' expression must be of a type that is comparable
+ // to or from the type of the 'switch' expression.
+ var caseType = checkExpression(clause.expression);
+ var caseIsLiteral = isLiteralType(caseType);
+ var comparedExpressionType = expressionType;
+ if (!caseIsLiteral || !expressionIsLiteral) {
+ caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
+ comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
+ }
+ if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
+ // expressionType is not comparable to caseType, try the reversed check and report errors if it fails
+ checkTypeComparableTo(caseType, comparedExpressionType, clause.expression, /*headMessage*/ undefined);
+ }
+ };
+ }
});
if (node.caseBlock.locals) {
registerForUnusedIdentifiersCheck(node.caseBlock);
@@ -82122,7 +83702,7 @@ var ts;
if (ts.isFunctionLike(current)) {
return "quit";
}
- if (current.kind === 249 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) {
+ if (current.kind === 250 /* SyntaxKind.LabeledStatement */ && current.label.escapedText === node.label.escapedText) {
grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label));
return true;
}
@@ -82154,8 +83734,8 @@ var ts;
var declaration = catchClause.variableDeclaration;
var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration));
if (typeNode) {
- var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* Normal */);
- if (type && !(type.flags & 3 /* AnyOrUnknown */)) {
+ var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* CheckMode.Normal */);
+ if (type && !(type.flags & 3 /* TypeFlags.AnyOrUnknown */)) {
grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified);
}
}
@@ -82167,7 +83747,7 @@ var ts;
if (blockLocals_1) {
ts.forEachKey(catchClause.locals, function (caughtName) {
var blockLocal = blockLocals_1.get(caughtName);
- if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) {
+ if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* SymbolFlags.BlockScopedVariable */) !== 0) {
grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName);
}
});
@@ -82187,8 +83767,8 @@ var ts;
}
for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) {
var prop = _a[_i];
- if (!(isStaticIndex && prop.flags & 4194304 /* Prototype */)) {
- checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop));
+ if (!(isStaticIndex && prop.flags & 4194304 /* SymbolFlags.Prototype */)) {
+ checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop));
}
}
var typeDeclaration = symbol.valueDeclaration;
@@ -82204,8 +83784,8 @@ var ts;
}
}
if (indexInfos.length > 1) {
- for (var _d = 0, indexInfos_6 = indexInfos; _d < indexInfos_6.length; _d++) {
- var info = indexInfos_6[_d];
+ for (var _d = 0, indexInfos_8 = indexInfos; _d < indexInfos_8.length; _d++) {
+ var info = indexInfos_8[_d];
checkIndexConstraintForIndexSignature(type, info);
}
}
@@ -82217,10 +83797,10 @@ var ts;
return;
}
var indexInfos = getApplicableIndexInfos(type, propNameType);
- var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 257 /* InterfaceDeclaration */) : undefined;
- var localPropDeclaration = declaration && declaration.kind === 220 /* BinaryExpression */ ||
- name && name.kind === 161 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
- var _loop_27 = function (info) {
+ var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined;
+ var localPropDeclaration = declaration && declaration.kind === 221 /* SyntaxKind.BinaryExpression */ ||
+ name && name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
+ var _loop_28 = function (info) {
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
// We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
// in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -82231,17 +83811,17 @@ var ts;
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));
}
};
- for (var _i = 0, indexInfos_7 = indexInfos; _i < indexInfos_7.length; _i++) {
- var info = indexInfos_7[_i];
- _loop_27(info);
+ for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
+ var info = indexInfos_9[_i];
+ _loop_28(info);
}
}
function checkIndexConstraintForIndexSignature(type, checkInfo) {
var declaration = checkInfo.declaration;
var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
- var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 257 /* InterfaceDeclaration */) : undefined;
+ var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined;
var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
- var _loop_28 = function (info) {
+ var _loop_29 = function (info) {
if (info === checkInfo)
return "continue";
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -82254,9 +83834,9 @@ var ts;
error(errorNode, ts.Diagnostics._0_index_type_1_is_not_assignable_to_2_index_type_3, typeToString(checkInfo.keyType), typeToString(checkInfo.type), typeToString(info.keyType), typeToString(info.type));
}
};
- for (var _i = 0, indexInfos_8 = indexInfos; _i < indexInfos_8.length; _i++) {
- var info = indexInfos_8[_i];
- _loop_28(info);
+ for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
+ var info = indexInfos_10[_i];
+ _loop_29(info);
}
}
function checkTypeNameIsReserved(name, message) {
@@ -82280,7 +83860,7 @@ var ts;
* The name cannot be used as 'Object' of user defined types with special target.
*/
function checkClassNameCollisionWithObject(name) {
- if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object"
+ if (languageVersion >= 1 /* ScriptTarget.ES5 */ && name.escapedText === "Object"
&& (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(name).impliedNodeFormat === ts.ModuleKind.CommonJS)) {
error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494
}
@@ -82330,35 +83910,38 @@ var ts;
* Check each type parameter and check that type parameters have no duplicate type parameter declarations
*/
function checkTypeParameters(typeParameterDeclarations) {
+ var seenDefault = false;
if (typeParameterDeclarations) {
- var seenDefault = false;
for (var i = 0; i < typeParameterDeclarations.length; i++) {
var node = typeParameterDeclarations[i];
checkTypeParameter(node);
- if (produceDiagnostics) {
- if (node.default) {
- seenDefault = true;
- checkTypeParametersNotReferenced(node.default, typeParameterDeclarations, i);
- }
- else if (seenDefault) {
- error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters);
- }
- for (var j = 0; j < i; j++) {
- if (typeParameterDeclarations[j].symbol === node.symbol) {
- error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name));
- }
+ addLazyDiagnostic(createCheckTypeParameterDiagnostic(node, i));
+ }
+ }
+ function createCheckTypeParameterDiagnostic(node, i) {
+ return function () {
+ if (node.default) {
+ seenDefault = true;
+ checkTypeParametersNotReferenced(node.default, typeParameterDeclarations, i);
+ }
+ else if (seenDefault) {
+ error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters);
+ }
+ for (var j = 0; j < i; j++) {
+ if (typeParameterDeclarations[j].symbol === node.symbol) {
+ error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name));
}
}
- }
+ };
}
}
/** Check that type parameter defaults only reference previously declared type parameters */
function checkTypeParametersNotReferenced(root, typeParameters, index) {
visit(root);
function visit(node) {
- if (node.kind === 177 /* TypeReference */) {
+ if (node.kind === 178 /* SyntaxKind.TypeReference */) {
var type = getTypeFromTypeReference(node);
- if (type.flags & 262144 /* TypeParameter */) {
+ if (type.flags & 262144 /* TypeFlags.TypeParameter */) {
for (var i = index; i < typeParameters.length; i++) {
if (type.symbol === getSymbolOfNode(typeParameters[i])) {
error(node, ts.Diagnostics.Type_parameter_defaults_can_only_reference_previously_declared_type_parameters);
@@ -82382,23 +83965,23 @@ var ts;
return;
}
var type = getDeclaredTypeOfSymbol(symbol);
- if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) {
+ if (!areTypeParametersIdentical(declarations, type.localTypeParameters, ts.getEffectiveTypeParameterDeclarations)) {
// Report an error on every conflicting declaration.
var name = symbolToString(symbol);
- for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
- var declaration = declarations_6[_i];
+ for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
+ var declaration = declarations_7[_i];
error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name);
}
}
}
}
- function areTypeParametersIdentical(declarations, targetParameters) {
+ function areTypeParametersIdentical(declarations, targetParameters, getTypeParameterDeclarations) {
var maxTypeArgumentCount = ts.length(targetParameters);
var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters);
- for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
- var declaration = declarations_7[_i];
+ for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
+ var declaration = declarations_8[_i];
// If this declaration has too few or too many type parameters, we report an error
- var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
+ var sourceParameters = getTypeParameterDeclarations(declaration);
var numTypeParameters = sourceParameters.length;
if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
return false;
@@ -82445,7 +84028,7 @@ var ts;
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);
}
- if (!node.name && !ts.hasSyntacticModifier(node, 512 /* Default */)) {
+ if (!node.name && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) {
grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name);
}
checkClassLikeDeclaration(node);
@@ -82466,100 +84049,105 @@ var ts;
checkFunctionOrConstructorSymbol(symbol);
checkClassForDuplicateDeclarations(node);
// Only check for reserved static identifiers on non-ambient context.
- var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
+ var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */);
if (!nodeInAmbientContext) {
checkClassForStaticPropertyNameConflicts(node);
}
var baseTypeNode = ts.getEffectiveBaseTypeNode(node);
if (baseTypeNode) {
ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
- if (languageVersion < 2 /* ES2015 */) {
- checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */);
+ if (languageVersion < 2 /* ScriptTarget.ES2015 */) {
+ checkExternalEmitHelpers(baseTypeNode.parent, 1 /* ExternalEmitHelpers.Extends */);
}
// check both @extends and extends if both are specified.
var extendsNode = ts.getClassExtendsHeritageElement(node);
if (extendsNode && extendsNode !== baseTypeNode) {
checkExpression(extendsNode.expression);
}
- var baseTypes = getBaseTypes(type);
- if (baseTypes.length && produceDiagnostics) {
- var baseType_1 = baseTypes[0];
- var baseConstructorType = getBaseConstructorTypeOfClass(type);
- var staticBaseType = getApparentType(baseConstructorType);
- checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
- checkSourceElement(baseTypeNode.expression);
- if (ts.some(baseTypeNode.typeArguments)) {
- ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
- for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) {
- var constructor = _a[_i];
- if (!checkTypeArgumentConstraints(baseTypeNode, constructor.typeParameters)) {
- break;
+ var baseTypes_2 = getBaseTypes(type);
+ if (baseTypes_2.length) {
+ addLazyDiagnostic(function () {
+ var baseType = baseTypes_2[0];
+ var baseConstructorType = getBaseConstructorTypeOfClass(type);
+ var staticBaseType = getApparentType(baseConstructorType);
+ checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
+ checkSourceElement(baseTypeNode.expression);
+ if (ts.some(baseTypeNode.typeArguments)) {
+ ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
+ for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) {
+ var constructor = _a[_i];
+ if (!checkTypeArgumentConstraints(baseTypeNode, constructor.typeParameters)) {
+ break;
+ }
}
}
- }
- var baseWithThis = getTypeWithThisArgument(baseType_1, type.thisType);
- if (!checkTypeAssignableTo(typeWithThis, baseWithThis, /*errorNode*/ undefined)) {
- issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
- }
- else {
- // Report static side error only when instance type is assignable
- checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
- }
- if (baseConstructorType.flags & 8650752 /* TypeVariable */) {
- if (!isMixinConstructorType(staticType)) {
- error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
+ var baseWithThis = getTypeWithThisArgument(baseType, type.thisType);
+ if (!checkTypeAssignableTo(typeWithThis, baseWithThis, /*errorNode*/ undefined)) {
+ issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
}
else {
- var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */);
- if (constructSignatures.some(function (signature) { return signature.flags & 4 /* Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
- error(node.name || node, ts.Diagnostics.A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract);
+ // Report static side error only when instance type is assignable
+ checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
+ }
+ if (baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */) {
+ if (!isMixinConstructorType(staticType)) {
+ error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
+ }
+ else {
+ var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */);
+ if (constructSignatures.some(function (signature) { return signature.flags & 4 /* SignatureFlags.Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) {
+ error(node.name || node, ts.Diagnostics.A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract);
+ }
}
}
- }
- if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) {
- // When the static base type is a "class-like" constructor function (but not actually a class), we verify
- // that all instantiated base constructor signatures return the same type.
- var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode);
- if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) {
- error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type);
+ if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* SymbolFlags.Class */) && !(baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */)) {
+ // When the static base type is a "class-like" constructor function (but not actually a class), we verify
+ // that all instantiated base constructor signatures return the same type.
+ var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode);
+ if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType); })) {
+ error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type);
+ }
}
- }
- checkKindsOfPropertyMemberOverrides(type, baseType_1);
+ checkKindsOfPropertyMemberOverrides(type, baseType);
+ });
}
}
checkMembersForOverrideModifier(node, type, typeWithThis, staticType);
var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node);
if (implementedTypeNodes) {
- for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) {
- var typeRefNode = implementedTypeNodes_1[_b];
+ for (var _i = 0, implementedTypeNodes_1 = implementedTypeNodes; _i < implementedTypeNodes_1.length; _i++) {
+ var typeRefNode = implementedTypeNodes_1[_i];
if (!ts.isEntityNameExpression(typeRefNode.expression) || ts.isOptionalChain(typeRefNode.expression)) {
error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments);
}
checkTypeReferenceNode(typeRefNode);
- if (produceDiagnostics) {
- var t = getReducedType(getTypeFromTypeNode(typeRefNode));
- if (!isErrorType(t)) {
- if (isValidBaseType(t)) {
- var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ?
- ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
- ts.Diagnostics.Class_0_incorrectly_implements_interface_1;
- var baseWithThis = getTypeWithThisArgument(t, type.thisType);
- if (!checkTypeAssignableTo(typeWithThis, baseWithThis, /*errorNode*/ undefined)) {
- issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag);
- }
- }
- else {
- error(typeRefNode, ts.Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
- }
- }
- }
+ addLazyDiagnostic(createImplementsDiagnostics(typeRefNode));
}
}
- if (produceDiagnostics) {
+ addLazyDiagnostic(function () {
checkIndexConstraints(type, symbol);
checkIndexConstraints(staticType, symbol, /*isStaticIndex*/ true);
checkTypeForDuplicateIndexSignatures(node);
checkPropertyInitialization(node);
+ });
+ function createImplementsDiagnostics(typeRefNode) {
+ return function () {
+ var t = getReducedType(getTypeFromTypeNode(typeRefNode));
+ if (!isErrorType(t)) {
+ if (isValidBaseType(t)) {
+ var genericDiag = t.symbol && t.symbol.flags & 32 /* SymbolFlags.Class */ ?
+ ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
+ ts.Diagnostics.Class_0_incorrectly_implements_interface_1;
+ var baseWithThis = getTypeWithThisArgument(t, type.thisType);
+ if (!checkTypeAssignableTo(typeWithThis, baseWithThis, /*errorNode*/ undefined)) {
+ issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag);
+ }
+ }
+ else {
+ error(typeRefNode, ts.Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
+ }
+ }
+ };
}
}
function checkMembersForOverrideModifier(node, type, typeWithThis, staticType) {
@@ -82567,7 +84155,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_29 = function (member) {
+ var _loop_30 = function (member) {
if (ts.hasAmbientModifier(member)) {
return "continue";
}
@@ -82584,7 +84172,7 @@ var ts;
};
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
var member = _a[_i];
- _loop_29(member);
+ _loop_30(member);
}
}
/**
@@ -82597,7 +84185,7 @@ var ts;
&& getSymbolAtLocation(member.name)
|| getSymbolAtLocation(member);
if (!declaredProp) {
- return 0 /* Ok */;
+ return 0 /* MemberOverrideStatus.Ok */;
}
return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, ts.hasOverrideModifier(member), ts.hasAbstractModifier(member), ts.isStatic(member), memberIsParameterProperty, ts.symbolName(declaredProp), reportErrors ? member : undefined);
}
@@ -82611,7 +84199,7 @@ var ts;
*/
function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) {
var isJs = ts.isInJSFile(node);
- var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
+ var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */);
if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) {
var memberEscapedName = ts.escapeLeadingUnderscores(memberName);
var thisType = memberIsStatic ? staticType : typeWithThis;
@@ -82630,12 +84218,12 @@ var ts;
ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0 :
ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName);
}
- return 2 /* HasInvalidOverride */;
+ return 2 /* MemberOverrideStatus.HasInvalidOverride */;
}
else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.declarations) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) {
var baseHasAbstract = ts.some(baseProp.declarations, ts.hasAbstractModifier);
if (memberHasOverrideModifier) {
- return 0 /* Ok */;
+ return 0 /* MemberOverrideStatus.Ok */;
}
if (!baseHasAbstract) {
if (errorNode) {
@@ -82648,13 +84236,13 @@ var ts;
ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0;
error(errorNode, diag, baseClassName);
}
- return 1 /* NeedsOverride */;
+ return 1 /* MemberOverrideStatus.NeedsOverride */;
}
else if (memberHasAbstractModifier && baseHasAbstract) {
if (errorNode) {
error(errorNode, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName);
}
- return 1 /* NeedsOverride */;
+ return 1 /* MemberOverrideStatus.NeedsOverride */;
}
}
}
@@ -82665,14 +84253,14 @@ var ts;
ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class :
ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className);
}
- return 2 /* HasInvalidOverride */;
+ return 2 /* MemberOverrideStatus.HasInvalidOverride */;
}
- return 0 /* Ok */;
+ return 0 /* MemberOverrideStatus.Ok */;
}
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
var issuedMemberError = false;
- var _loop_30 = function (member) {
+ var _loop_31 = function (member) {
if (ts.isStatic(member)) {
return "continue";
}
@@ -82691,7 +84279,7 @@ var ts;
};
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
var member = _a[_i];
- _loop_30(member);
+ _loop_31(member);
}
if (!issuedMemberError) {
// check again with diagnostics to generate a less-specific error
@@ -82699,10 +84287,10 @@ var ts;
}
}
function checkBaseTypeAccessibility(type, node) {
- var signatures = getSignaturesOfType(type, 1 /* Construct */);
+ var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */);
if (signatures.length) {
var declaration = signatures[0].declaration;
- if (declaration && ts.hasEffectiveModifier(declaration, 8 /* Private */)) {
+ if (declaration && ts.hasEffectiveModifier(declaration, 8 /* ModifierFlags.Private */)) {
var typeClassDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol);
if (!isNodeWithinClass(node, typeClassDeclaration)) {
error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol));
@@ -82718,7 +84306,7 @@ var ts;
*/
function getMemberOverrideModifierStatus(node, member) {
if (!member.name) {
- return 0 /* Ok */;
+ return 0 /* MemberOverrideStatus.Ok */;
}
var symbol = getSymbolOfNode(node);
var type = getDeclaredTypeOfSymbol(symbol);
@@ -82730,7 +84318,7 @@ var ts;
var baseStaticType = getBaseConstructorTypeOfClass(type);
var memberHasOverrideModifier = member.parent
? ts.hasOverrideModifier(member)
- : ts.hasSyntacticModifier(member, 16384 /* Override */);
+ : ts.hasSyntacticModifier(member, 16384 /* ModifierFlags.Override */);
var memberName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name));
return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, ts.hasAbstractModifier(member), ts.isStatic(member),
/* memberIsParameterProperty */ false, memberName);
@@ -82738,11 +84326,11 @@ var ts;
function getTargetSymbol(s) {
// if symbol is instantiated its flags are not copied from the 'target'
// so we'll need to get back original 'target' symbol to work with correct set of flags
- return ts.getCheckFlags(s) & 1 /* Instantiated */ ? s.target : s;
+ return ts.getCheckFlags(s) & 1 /* CheckFlags.Instantiated */ ? s.target : s;
}
function getClassOrInterfaceDeclarationsOfSymbol(symbol) {
return ts.filter(symbol.declarations, function (d) {
- return d.kind === 256 /* ClassDeclaration */ || d.kind === 257 /* InterfaceDeclaration */;
+ return d.kind === 257 /* SyntaxKind.ClassDeclaration */ || d.kind === 258 /* SyntaxKind.InterfaceDeclaration */;
});
}
function checkKindsOfPropertyMemberOverrides(type, baseType) {
@@ -82765,7 +84353,7 @@ var ts;
basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
var baseProperty = baseProperties_1[_i];
var base = getTargetSymbol(baseProperty);
- if (base.flags & 4194304 /* Prototype */) {
+ if (base.flags & 4194304 /* SymbolFlags.Prototype */) {
continue;
}
var baseSymbol = getPropertyOfObjectType(type, base.escapedName);
@@ -82784,7 +84372,7 @@ var ts;
// It is an error to inherit an abstract member without implementing it or being declared abstract.
// If there is no declaration for the derived class (as in the case of class expressions),
// then the class cannot be declared abstract.
- if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* Abstract */))) {
+ if (baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* ModifierFlags.Abstract */))) {
// Searches other base types for a declaration that would satisfy the inherited abstract member.
// (The class may have more than one base type via declaration merging with an interface with the
// same name.)
@@ -82798,7 +84386,7 @@ var ts;
continue basePropertyCheck;
}
}
- if (derivedClassDecl.kind === 225 /* ClassExpression */) {
+ if (derivedClassDecl.kind === 226 /* SyntaxKind.ClassExpression */) {
error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType));
}
else {
@@ -82809,24 +84397,24 @@ var ts;
else {
// derived overrides base.
var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived);
- if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) {
+ if (baseDeclarationFlags & 8 /* ModifierFlags.Private */ || derivedDeclarationFlags & 8 /* ModifierFlags.Private */) {
// either base or derived property is private - not override, skip it
continue;
}
var errorMessage = void 0;
- var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */;
- var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */;
+ var basePropertyFlags = base.flags & 98308 /* SymbolFlags.PropertyOrAccessor */;
+ var derivedPropertyFlags = derived.flags & 98308 /* SymbolFlags.PropertyOrAccessor */;
if (basePropertyFlags && derivedPropertyFlags) {
// property/accessor is overridden with property/accessor
- if (baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer)
- || base.valueDeclaration && base.valueDeclaration.parent.kind === 257 /* InterfaceDeclaration */
+ if (baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer)
+ || base.valueDeclaration && base.valueDeclaration.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */
|| derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) {
// when the base property is abstract or from an interface, base/derived flags don't need to match
// same when the derived property is from an assignment
continue;
}
- var overriddenInstanceProperty = basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */;
- var overriddenInstanceAccessor = basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */;
+ var overriddenInstanceProperty = basePropertyFlags !== 4 /* SymbolFlags.Property */ && derivedPropertyFlags === 4 /* SymbolFlags.Property */;
+ var overriddenInstanceAccessor = basePropertyFlags === 4 /* SymbolFlags.Property */ && derivedPropertyFlags !== 4 /* SymbolFlags.Property */;
if (overriddenInstanceProperty || overriddenInstanceAccessor) {
var errorMessage_1 = overriddenInstanceProperty ?
ts.Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property :
@@ -82834,12 +84422,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 === 166 /* PropertyDeclaration */ && !d.initializer; });
+ var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !d.initializer; });
if (uninitialized
- && !(derived.flags & 33554432 /* Transient */)
- && !(baseDeclarationFlags & 128 /* Abstract */)
- && !(derivedDeclarationFlags & 128 /* Abstract */)
- && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 8388608 /* Ambient */); }))) {
+ && !(derived.flags & 33554432 /* SymbolFlags.Transient */)
+ && !(baseDeclarationFlags & 128 /* ModifierFlags.Abstract */)
+ && !(derivedDeclarationFlags & 128 /* ModifierFlags.Abstract */)
+ && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* NodeFlags.Ambient */); }))) {
var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol));
var propName = uninitialized.name;
if (uninitialized.exclamationToken
@@ -82856,16 +84444,16 @@ var ts;
continue;
}
else if (isPrototypeProperty(base)) {
- if (isPrototypeProperty(derived) || derived.flags & 4 /* Property */) {
+ if (isPrototypeProperty(derived) || derived.flags & 4 /* SymbolFlags.Property */) {
// method is overridden with method or property -- correct case
continue;
}
else {
- ts.Debug.assert(!!(derived.flags & 98304 /* Accessor */));
+ ts.Debug.assert(!!(derived.flags & 98304 /* SymbolFlags.Accessor */));
errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor;
}
}
- else if (base.flags & 98304 /* Accessor */) {
+ else if (base.flags & 98304 /* SymbolFlags.Accessor */) {
errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function;
}
else {
@@ -82883,8 +84471,8 @@ var ts;
ts.forEach(properties, function (p) {
seen.set(p.escapedName, p);
});
- for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) {
- var base = baseTypes_2[_i];
+ for (var _i = 0, baseTypes_3 = baseTypes; _i < baseTypes_3.length; _i++) {
+ var base = baseTypes_3[_i];
var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
for (var _a = 0, properties_4 = properties_5; _a < properties_4.length; _a++) {
var prop = properties_4[_a];
@@ -82906,8 +84494,8 @@ var ts;
seen.set(p.escapedName, { prop: p, containingType: type });
});
var ok = true;
- for (var _i = 0, baseTypes_3 = baseTypes; _i < baseTypes_3.length; _i++) {
- var base = baseTypes_3[_i];
+ for (var _i = 0, baseTypes_4 = baseTypes; _i < baseTypes_4.length; _i++) {
+ var base = baseTypes_4[_i];
var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) {
var prop = properties_6[_a];
@@ -82931,20 +84519,20 @@ var ts;
return ok;
}
function checkPropertyInitialization(node) {
- if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608 /* Ambient */) {
+ if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* NodeFlags.Ambient */) {
return;
}
var constructor = findConstructorDeclaration(node);
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
var member = _a[_i];
- if (ts.getEffectiveModifierFlags(member) & 2 /* Ambient */) {
+ if (ts.getEffectiveModifierFlags(member) & 2 /* ModifierFlags.Ambient */) {
continue;
}
if (!ts.isStatic(member) && isPropertyWithoutInitializer(member)) {
var propName = member.name;
- if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName)) {
+ if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) {
var type = getTypeOfSymbol(getSymbolOfNode(member));
- if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* Undefined */)) {
+ if (!(type.flags & 3 /* TypeFlags.AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* TypeFlags.Undefined */)) {
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));
}
@@ -82954,7 +84542,7 @@ var ts;
}
}
function isPropertyWithoutInitializer(node) {
- return node.kind === 166 /* PropertyDeclaration */ &&
+ return node.kind === 167 /* SyntaxKind.PropertyDeclaration */ &&
!ts.hasAbstractModifier(node) &&
!node.exclamationToken &&
!node.initializer;
@@ -82969,7 +84557,7 @@ var ts;
ts.setParent(reference, staticBlock);
reference.flowNode = staticBlock.returnFlowNode;
var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
- if (!(getFalsyFlags(flowType) & 32768 /* Undefined */)) {
+ if (!(getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */)) {
return true;
}
}
@@ -82977,25 +84565,27 @@ var ts;
return false;
}
function isPropertyInitializedInConstructor(propName, propType, constructor) {
- var reference = ts.factory.createPropertyAccessExpression(ts.factory.createThis(), propName);
+ var reference = ts.isComputedPropertyName(propName)
+ ? ts.factory.createElementAccessExpression(ts.factory.createThis(), propName.expression)
+ : ts.factory.createPropertyAccessExpression(ts.factory.createThis(), propName);
ts.setParent(reference.expression, reference);
ts.setParent(reference, constructor);
reference.flowNode = constructor.returnFlowNode;
var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
- return !(getFalsyFlags(flowType) & 32768 /* Undefined */);
+ return !(getFalsyFlags(flowType) & 32768 /* TypeFlags.Undefined */);
}
function checkInterfaceDeclaration(node) {
// Grammar checking
if (!checkGrammarDecoratorsAndModifiers(node))
checkGrammarInterfaceDeclaration(node);
checkTypeParameters(node.typeParameters);
- if (produceDiagnostics) {
+ addLazyDiagnostic(function () {
checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0);
checkExportsOnMergedDeclarations(node);
var symbol = getSymbolOfNode(node);
checkTypeParameterListsIdentical(symbol);
// Only check this symbol once
- var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 257 /* InterfaceDeclaration */);
+ var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */);
if (node === firstInterfaceDecl) {
var type = getDeclaredTypeOfSymbol(symbol);
var typeWithThis = getTypeWithThisArgument(type);
@@ -83009,7 +84599,7 @@ var ts;
}
}
checkObjectTypeForDuplicateDeclarations(node);
- }
+ });
ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) {
if (!ts.isEntityNameExpression(heritageElement.expression) || ts.isOptionalChain(heritageElement.expression)) {
error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments);
@@ -83017,10 +84607,10 @@ var ts;
checkTypeReferenceNode(heritageElement);
});
ts.forEach(node.members, checkSourceElement);
- if (produceDiagnostics) {
+ addLazyDiagnostic(function () {
checkTypeForDuplicateIndexSignatures(node);
registerForUnusedIdentifiersCheck(node);
- }
+ });
}
function checkTypeAliasDeclaration(node) {
// Grammar checking
@@ -83028,7 +84618,7 @@ var ts;
checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0);
checkExportsOnMergedDeclarations(node);
checkTypeParameters(node.typeParameters);
- if (node.type.kind === 138 /* IntrinsicKeyword */) {
+ if (node.type.kind === 138 /* SyntaxKind.IntrinsicKeyword */) {
if (!intrinsicTypeKinds.has(node.name.escapedText) || ts.length(node.typeParameters) !== 1) {
error(node.type, ts.Diagnostics.The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types);
}
@@ -83040,8 +84630,8 @@ var ts;
}
function computeEnumMemberValues(node) {
var nodeLinks = getNodeLinks(node);
- if (!(nodeLinks.flags & 16384 /* EnumValuesComputed */)) {
- nodeLinks.flags |= 16384 /* EnumValuesComputed */;
+ if (!(nodeLinks.flags & 16384 /* NodeCheckFlags.EnumValuesComputed */)) {
+ nodeLinks.flags |= 16384 /* NodeCheckFlags.EnumValuesComputed */;
var autoValue = 0;
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
var member = _a[_i];
@@ -83066,7 +84656,7 @@ var ts;
}
// In ambient non-const numeric enum declarations, enum members without initializers are
// considered computed members (as opposed to having auto-incremented values).
- if (member.parent.flags & 8388608 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) {
+ if (member.parent.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* EnumKind.Numeric */) {
return undefined;
}
// If the member declaration specifies no value, the member is considered a constant enum member.
@@ -83083,7 +84673,7 @@ var ts;
var enumKind = getEnumKind(getSymbolOfNode(member.parent));
var isConstEnum = ts.isEnumConst(member.parent);
var initializer = member.initializer;
- var value = enumKind === 1 /* Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer);
+ var value = enumKind === 1 /* EnumKind.Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer);
if (value !== undefined) {
if (isConstEnum && typeof value === "number" && !isFinite(value)) {
error(initializer, isNaN(value) ?
@@ -83091,20 +84681,20 @@ var ts;
ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value);
}
}
- else if (enumKind === 1 /* Literal */) {
+ else if (enumKind === 1 /* EnumKind.Literal */) {
error(initializer, ts.Diagnostics.Computed_values_are_not_permitted_in_an_enum_with_string_valued_members);
return 0;
}
else if (isConstEnum) {
error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values);
}
- else if (member.parent.flags & 8388608 /* Ambient */) {
+ else if (member.parent.flags & 16777216 /* NodeFlags.Ambient */) {
error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression);
}
else {
// Only here do we need to check that the initializer is assignable to the enum type.
var source = checkExpression(initializer);
- if (!isTypeAssignableToKind(source, 296 /* NumberLike */)) {
+ if (!isTypeAssignableToKind(source, 296 /* TypeFlags.NumberLike */)) {
error(initializer, ts.Diagnostics.Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhaustiveness_checks_consider_using_an_object_literal_instead, typeToString(source));
}
else {
@@ -83114,60 +84704,60 @@ var ts;
return value;
function evaluate(expr) {
switch (expr.kind) {
- case 218 /* PrefixUnaryExpression */:
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
var value_2 = evaluate(expr.operand);
if (typeof value_2 === "number") {
switch (expr.operator) {
- case 39 /* PlusToken */: return value_2;
- case 40 /* MinusToken */: return -value_2;
- case 54 /* TildeToken */: return ~value_2;
+ case 39 /* SyntaxKind.PlusToken */: return value_2;
+ case 40 /* SyntaxKind.MinusToken */: return -value_2;
+ case 54 /* SyntaxKind.TildeToken */: return ~value_2;
}
}
break;
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
var left = evaluate(expr.left);
var right = evaluate(expr.right);
if (typeof left === "number" && typeof right === "number") {
switch (expr.operatorToken.kind) {
- case 51 /* BarToken */: return left | right;
- case 50 /* AmpersandToken */: return left & right;
- case 48 /* GreaterThanGreaterThanToken */: return left >> right;
- case 49 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right;
- case 47 /* LessThanLessThanToken */: return left << right;
- case 52 /* CaretToken */: return left ^ right;
- case 41 /* AsteriskToken */: return left * right;
- case 43 /* SlashToken */: return left / right;
- case 39 /* PlusToken */: return left + right;
- case 40 /* MinusToken */: return left - right;
- case 44 /* PercentToken */: return left % right;
- case 42 /* AsteriskAsteriskToken */: return Math.pow(left, right);
- }
- }
- else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* PlusToken */) {
+ case 51 /* SyntaxKind.BarToken */: return left | right;
+ case 50 /* SyntaxKind.AmpersandToken */: return left & right;
+ case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: return left >> right;
+ case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: return left >>> right;
+ case 47 /* SyntaxKind.LessThanLessThanToken */: return left << right;
+ case 52 /* SyntaxKind.CaretToken */: return left ^ right;
+ case 41 /* SyntaxKind.AsteriskToken */: return left * right;
+ case 43 /* SyntaxKind.SlashToken */: return left / right;
+ case 39 /* SyntaxKind.PlusToken */: return left + right;
+ case 40 /* SyntaxKind.MinusToken */: return left - right;
+ case 44 /* SyntaxKind.PercentToken */: return left % right;
+ case 42 /* SyntaxKind.AsteriskAsteriskToken */: return Math.pow(left, right);
+ }
+ }
+ else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) {
return left + right;
}
break;
- case 10 /* StringLiteral */:
- case 14 /* NoSubstitutionTemplateLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
return expr.text;
- case 8 /* NumericLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
checkGrammarNumericLiteral(expr);
return +expr.text;
- case 211 /* ParenthesizedExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
return evaluate(expr.expression);
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
var identifier = expr;
if (ts.isInfinityOrNaNString(identifier.escapedText)) {
return +(identifier.escapedText);
}
return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText);
- case 206 /* ElementAccessExpression */:
- case 205 /* PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
if (isConstantMemberAccess(expr)) {
var type = getTypeOfExpression(expr.expression);
- if (type.symbol && type.symbol.flags & 384 /* Enum */) {
+ if (type.symbol && type.symbol.flags & 384 /* SymbolFlags.Enum */) {
var name = void 0;
- if (expr.kind === 205 /* PropertyAccessExpression */) {
+ if (expr.kind === 206 /* SyntaxKind.PropertyAccessExpression */) {
name = expr.name.escapedText;
}
else {
@@ -83203,15 +84793,15 @@ var ts;
if (type === errorType) {
return false;
}
- return node.kind === 79 /* Identifier */ ||
- node.kind === 205 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) ||
- node.kind === 206 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) &&
+ return node.kind === 79 /* SyntaxKind.Identifier */ ||
+ node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isConstantMemberAccess(node.expression) ||
+ node.kind === 207 /* SyntaxKind.ElementAccessExpression */ && isConstantMemberAccess(node.expression) &&
ts.isStringLiteralLike(node.argumentExpression);
}
function checkEnumDeclaration(node) {
- if (!produceDiagnostics) {
- return;
- }
+ addLazyDiagnostic(function () { return checkEnumDeclarationWorker(node); });
+ }
+ function checkEnumDeclarationWorker(node) {
// Grammar checking
checkGrammarDecoratorsAndModifiers(node);
checkCollisionsForDeclarationName(node, node.name);
@@ -83239,7 +84829,7 @@ var ts;
var seenEnumMissingInitialInitializer_1 = false;
ts.forEach(enumSymbol.declarations, function (declaration) {
// return true if we hit a violation of the rule, false otherwise
- if (declaration.kind !== 259 /* EnumDeclaration */) {
+ if (declaration.kind !== 260 /* SyntaxKind.EnumDeclaration */) {
return false;
}
var enumDeclaration = declaration;
@@ -83266,11 +84856,11 @@ var ts;
function getFirstNonAmbientClassOrFunctionDeclaration(symbol) {
var declarations = symbol.declarations;
if (declarations) {
- for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
- var declaration = declarations_8[_i];
- if ((declaration.kind === 256 /* ClassDeclaration */ ||
- (declaration.kind === 255 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) &&
- !(declaration.flags & 8388608 /* Ambient */)) {
+ for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
+ var declaration = declarations_9[_i];
+ if ((declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ ||
+ (declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) &&
+ !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) {
return declaration;
}
}
@@ -83291,10 +84881,17 @@ var ts;
}
}
function checkModuleDeclaration(node) {
- if (produceDiagnostics) {
+ if (node.body) {
+ checkSourceElement(node.body);
+ if (!ts.isGlobalScopeAugmentation(node)) {
+ registerForUnusedIdentifiersCheck(node);
+ }
+ }
+ addLazyDiagnostic(checkModuleDeclarationDiagnostics);
+ function checkModuleDeclarationDiagnostics() {
// Grammar checking
var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
- var inAmbientContext = node.flags & 8388608 /* Ambient */;
+ var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */;
if (isGlobalAugmentation && !inAmbientContext) {
error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context);
}
@@ -83307,7 +84904,7 @@ var ts;
return;
}
if (!checkGrammarDecoratorsAndModifiers(node)) {
- if (!inAmbientContext && node.name.kind === 10 /* StringLiteral */) {
+ if (!inAmbientContext && node.name.kind === 10 /* SyntaxKind.StringLiteral */) {
grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names);
}
}
@@ -83317,7 +84914,7 @@ var ts;
checkExportsOnMergedDeclarations(node);
var symbol = getSymbolOfNode(node);
// The following checks only apply on a non-ambient instantiated module declaration.
- if (symbol.flags & 512 /* ValueModule */
+ if (symbol.flags & 512 /* SymbolFlags.ValueModule */
&& !inAmbientContext
&& symbol.declarations
&& symbol.declarations.length > 1
@@ -83333,10 +84930,10 @@ var ts;
}
// if the module merges with a class declaration in the same lexical scope,
// we need to track this to ensure the correct emit.
- var mergedClass = ts.getDeclarationOfKind(symbol, 256 /* ClassDeclaration */);
+ var mergedClass = ts.getDeclarationOfKind(symbol, 257 /* SyntaxKind.ClassDeclaration */);
if (mergedClass &&
inSameLexicalScope(node, mergedClass)) {
- getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */;
+ getNodeLinks(node).flags |= 32768 /* NodeCheckFlags.LexicalModuleMergesWithClass */;
}
}
if (isAmbientExternalModule) {
@@ -83346,7 +84943,7 @@ var ts;
// We can detect if augmentation was applied using following rules:
// - augmentation for a global scope is always applied
// - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module).
- var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* Transient */);
+ var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* SymbolFlags.Transient */);
if (checkBody && node.body) {
for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
var statement = _a[_i];
@@ -83374,33 +84971,27 @@ var ts;
}
}
}
- if (node.body) {
- checkSourceElement(node.body);
- if (!ts.isGlobalScopeAugmentation(node)) {
- registerForUnusedIdentifiersCheck(node);
- }
- }
}
function checkModuleAugmentationElement(node, isGlobalAugmentation) {
var _a;
switch (node.kind) {
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
// error each individual name in variable statement instead of marking the entire variable statement
for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) {
var decl = _b[_i];
checkModuleAugmentationElement(decl, isGlobalAugmentation);
}
break;
- case 270 /* ExportAssignment */:
- case 271 /* ExportDeclaration */:
+ case 271 /* SyntaxKind.ExportAssignment */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations);
break;
- case 264 /* ImportEqualsDeclaration */:
- case 265 /* ImportDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module);
break;
- case 202 /* BindingElement */:
- case 253 /* VariableDeclaration */:
+ case 203 /* SyntaxKind.BindingElement */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
var name = node.name;
if (ts.isBindingPattern(name)) {
for (var _c = 0, _d = name.elements; _c < _d.length; _c++) {
@@ -83411,12 +85002,12 @@ var ts;
break;
}
// falls through
- case 256 /* ClassDeclaration */:
- case 259 /* EnumDeclaration */:
- case 255 /* FunctionDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 260 /* ModuleDeclaration */:
- case 258 /* TypeAliasDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
if (isGlobalAugmentation) {
return;
}
@@ -83426,7 +85017,7 @@ var ts;
// this is done it two steps
// 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error
// 2. main check - report error if value declaration of the parent symbol is module augmentation)
- var reportError = !(symbol.flags & 33554432 /* Transient */);
+ var reportError = !(symbol.flags & 33554432 /* SymbolFlags.Transient */);
if (!reportError) {
// symbol should not originate in augmentation
reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]);
@@ -83437,20 +85028,20 @@ var ts;
}
function getFirstNonModuleExportsIdentifier(node) {
switch (node.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return node;
- case 160 /* QualifiedName */:
+ case 161 /* SyntaxKind.QualifiedName */:
do {
node = node.left;
- } while (node.kind !== 79 /* Identifier */);
+ } while (node.kind !== 79 /* SyntaxKind.Identifier */);
return node;
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
do {
if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) {
return node.name;
}
node = node.expression;
- } while (node.kind !== 79 /* Identifier */);
+ } while (node.kind !== 79 /* SyntaxKind.Identifier */);
return node;
}
}
@@ -83464,9 +85055,9 @@ var ts;
error(moduleName, ts.Diagnostics.String_literal_expected);
return false;
}
- var inAmbientExternalModule = node.parent.kind === 261 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent);
- if (node.parent.kind !== 303 /* SourceFile */ && !inAmbientExternalModule) {
- error(moduleName, node.kind === 271 /* ExportDeclaration */ ?
+ var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent);
+ if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule) {
+ error(moduleName, node.kind === 272 /* SyntaxKind.ExportDeclaration */ ?
ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace :
ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module);
return false;
@@ -83507,39 +85098,39 @@ var ts;
// otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export*
// in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names).
symbol = getMergedSymbol(symbol.exportSymbol || symbol);
- var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) |
- (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) |
- (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0);
+ var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) |
+ (symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) |
+ (symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0);
if (target.flags & excludedMeanings) {
- var message = node.kind === 274 /* ExportSpecifier */ ?
+ var message = node.kind === 275 /* SyntaxKind.ExportSpecifier */ ?
ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
error(node, message, symbolToString(symbol));
}
if (compilerOptions.isolatedModules
&& !ts.isTypeOnlyImportOrExportDeclaration(node)
- && !(node.flags & 8388608 /* Ambient */)) {
+ && !(node.flags & 16777216 /* NodeFlags.Ambient */)) {
var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
- var isType = !(target.flags & 111551 /* Value */);
+ var isType = !(target.flags & 111551 /* SymbolFlags.Value */);
if (isType || typeOnlyAlias) {
switch (node.kind) {
- case 266 /* ImportClause */:
- case 269 /* ImportSpecifier */:
- case 264 /* ImportEqualsDeclaration */: {
+ case 267 /* SyntaxKind.ImportClause */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */: {
if (compilerOptions.preserveValueImports) {
ts.Debug.assertIsDefined(node.name, "An ImportClause with a symbol should have a name");
var message = isType
? ts.Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled
: ts.Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled;
- var name = ts.idText(node.kind === 269 /* ImportSpecifier */ ? node.propertyName || node.name : node.name);
+ var name = ts.idText(node.kind === 270 /* SyntaxKind.ImportSpecifier */ ? node.propertyName || node.name : node.name);
addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name);
}
- if (isType && node.kind === 264 /* ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* Export */)) {
+ if (isType && node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* ModifierFlags.Export */)) {
error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided);
}
break;
}
- case 274 /* ExportSpecifier */: {
+ case 275 /* SyntaxKind.ExportSpecifier */: {
// Don't allow re-exporting an export that will be elided when `--isolatedModules` is set.
// The exception is that `import type { A } from './a'; export { A }` is allowed
// because single-file analysis can determine that the export should be dropped.
@@ -83564,15 +85155,15 @@ var ts;
}
}
function isDeprecatedAliasedSymbol(symbol) {
- return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); });
+ return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); });
}
function checkDeprecatedAliasedSymbol(symbol, location) {
- if (!(symbol.flags & 2097152 /* Alias */))
+ if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */))
return symbol;
var targetSymbol = resolveAlias(symbol);
if (targetSymbol === unknownSymbol)
return targetSymbol;
- while (symbol.flags & 2097152 /* Alias */) {
+ while (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
var target = getImmediateAliasedSymbol(symbol);
if (target) {
if (target === targetSymbol)
@@ -83598,16 +85189,27 @@ var ts;
function checkImportBinding(node) {
checkCollisionsForDeclarationName(node, node.name);
checkAliasSymbol(node);
- if (node.kind === 269 /* ImportSpecifier */ &&
+ if (node.kind === 270 /* SyntaxKind.ImportSpecifier */ &&
ts.idText(node.propertyName || node.name) === "default" &&
ts.getESModuleInterop(compilerOptions) &&
moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) {
- checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
+ checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */);
}
}
function checkAssertClause(declaration) {
var _a;
if (declaration.assertClause) {
+ var validForTypeAssertions = ts.isExclusivelyTypeOnlyImportOrExport(declaration);
+ var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined);
+ if (validForTypeAssertions && override) {
+ if (!ts.isNightly()) {
+ grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next);
+ }
+ if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
+ return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
+ }
+ return; // Other grammar checks do not apply to type-only imports with resolution mode assertions
+ }
var mode = (moduleKind === ts.ModuleKind.NodeNext) && declaration.moduleSpecifier && getUsageModeForExpression(declaration.moduleSpecifier);
if (mode !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.ESNext) {
return grammarErrorOnNode(declaration.assertClause, moduleKind === ts.ModuleKind.NodeNext
@@ -83617,6 +85219,9 @@ var ts;
if (ts.isImportDeclaration(declaration) ? (_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.isTypeOnly : declaration.isTypeOnly) {
return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Import_assertions_cannot_be_used_with_type_only_imports_or_exports);
}
+ if (override) {
+ return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.resolution_mode_can_only_be_set_for_type_only_imports);
+ }
}
}
function checkImportDeclaration(node) {
@@ -83634,11 +85239,11 @@ var ts;
checkImportBinding(importClause);
}
if (importClause.namedBindings) {
- if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
+ if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) {
checkImportBinding(importClause.namedBindings);
if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.getESModuleInterop(compilerOptions)) {
// import * as ns from "foo";
- checkExternalEmitHelpers(node, 65536 /* ImportStar */);
+ checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */);
}
}
else {
@@ -83660,20 +85265,20 @@ var ts;
checkGrammarDecoratorsAndModifiers(node);
if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) {
checkImportBinding(node);
- if (ts.hasSyntacticModifier(node, 1 /* Export */)) {
+ if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) {
markExportAsReferenced(node);
}
- if (node.moduleReference.kind !== 276 /* ExternalModuleReference */) {
+ if (node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */) {
var target = resolveAlias(getSymbolOfNode(node));
if (target !== unknownSymbol) {
- if (target.flags & 111551 /* Value */) {
+ if (target.flags & 111551 /* SymbolFlags.Value */) {
// Target is a value symbol, check that it is not hidden by a local declaration with the same name
var moduleName = ts.getFirstIdentifier(node.moduleReference);
- if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) {
+ if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) {
error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
}
}
- if (target.flags & 788968 /* Type */) {
+ if (target.flags & 788968 /* SymbolFlags.Type */) {
checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
}
}
@@ -83682,7 +85287,7 @@ var ts;
}
}
else {
- if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 8388608 /* Ambient */)) {
+ if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* NodeFlags.Ambient */)) {
// Import equals declaration is deprecated in es6 or above
grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead);
}
@@ -83694,11 +85299,11 @@ var ts;
// If we hit an export in an illegal context, just bail out to avoid cascading errors.
return;
}
- if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) {
+ if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasSyntacticModifiers(node)) {
grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers);
}
- if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) {
- checkExternalEmitHelpers(node, 4194304 /* CreateBinding */);
+ if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ScriptTarget.ES3 */) {
+ checkExternalEmitHelpers(node, 4194304 /* ExternalEmitHelpers.CreateBinding */);
}
checkGrammarExportDeclaration(node);
if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) {
@@ -83706,10 +85311,10 @@ var ts;
// export { x, y }
// export { x, y } from "foo"
ts.forEach(node.exportClause.elements, checkExportSpecifier);
- var inAmbientExternalModule = node.parent.kind === 261 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent);
- var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 261 /* ModuleBlock */ &&
- !node.moduleSpecifier && node.flags & 8388608 /* Ambient */;
- if (node.parent.kind !== 303 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) {
+ var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent);
+ var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ &&
+ !node.moduleSpecifier && node.flags & 16777216 /* NodeFlags.Ambient */;
+ if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) {
error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace);
}
}
@@ -83729,12 +85334,12 @@ var ts;
// For ES2015 modules, we emit it as a pair of `import * as a_1 ...; export { a_1 as ns }` and don't need the helper.
// We only use the helper here when in esModuleInterop
if (ts.getESModuleInterop(compilerOptions)) {
- checkExternalEmitHelpers(node, 65536 /* ImportStar */);
+ checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */);
}
}
else {
// export * from "foo"
- checkExternalEmitHelpers(node, 32768 /* ExportStar */);
+ checkExternalEmitHelpers(node, 32768 /* ExternalEmitHelpers.ExportStar */);
}
}
}
@@ -83744,7 +85349,7 @@ var ts;
function checkGrammarExportDeclaration(node) {
var _a;
if (node.isTypeOnly) {
- if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 272 /* NamedExports */) {
+ if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 273 /* SyntaxKind.NamedExports */) {
return checkGrammarNamedImportsOrExports(node.exportClause);
}
else {
@@ -83754,7 +85359,7 @@ var ts;
return false;
}
function checkGrammarModuleElementContext(node, errorMessage) {
- var isInAppropriateContext = node.parent.kind === 303 /* SourceFile */ || node.parent.kind === 261 /* ModuleBlock */ || node.parent.kind === 260 /* ModuleDeclaration */;
+ var isInAppropriateContext = node.parent.kind === 305 /* SyntaxKind.SourceFile */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */;
if (!isInAppropriateContext) {
grammarErrorOnFirstToken(node, errorMessage);
}
@@ -83802,15 +85407,15 @@ var ts;
if (!node.parent.parent.moduleSpecifier) {
var exportedName = node.propertyName || node.name;
// find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases)
- var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */,
+ var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */,
/*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || symbol.declarations && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) {
error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName));
}
else {
markExportAsReferenced(node);
- var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol);
- if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) {
+ var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol);
+ if (!target || target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
checkExpressionCached(node.propertyName || node.name);
}
}
@@ -83820,7 +85425,7 @@ var ts;
moduleKind !== ts.ModuleKind.System &&
(moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) &&
ts.idText(node.propertyName || node.name) === "default") {
- checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
+ checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */);
}
}
}
@@ -83832,8 +85437,8 @@ var ts;
// If we hit an export assignment in an illegal context, just bail out to avoid cascading errors.
return;
}
- var container = node.parent.kind === 303 /* SourceFile */ ? node.parent : node.parent.parent;
- if (container.kind === 260 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) {
+ var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent;
+ if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) {
if (node.isExportEquals) {
error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace);
}
@@ -83850,14 +85455,14 @@ var ts;
if (typeAnnotationNode) {
checkTypeAssignableTo(checkExpressionCached(node.expression), getTypeFromTypeNode(typeAnnotationNode), node.expression);
}
- if (node.expression.kind === 79 /* Identifier */) {
+ if (node.expression.kind === 79 /* SyntaxKind.Identifier */) {
var id = node.expression;
- var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node);
+ var sym = resolveEntityName(id, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node);
if (sym) {
markAliasReferenced(sym, id);
// If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`)
- var target = sym.flags & 2097152 /* Alias */ ? resolveAlias(sym) : sym;
- if (target === unknownSymbol || target.flags & 111551 /* Value */) {
+ var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym;
+ if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
// However if it is a value, we need to check it's being used correctly
checkExpressionCached(node.expression);
}
@@ -83873,10 +85478,10 @@ var ts;
checkExpressionCached(node.expression);
}
checkExternalModuleExports(container);
- if ((node.flags & 8388608 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) {
+ if ((node.flags & 16777216 /* NodeFlags.Ambient */) && !ts.isEntityNameExpression(node.expression)) {
grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
}
- if (node.isExportEquals && !(node.flags & 8388608 /* Ambient */)) {
+ if (node.isExportEquals && !(node.flags & 16777216 /* NodeFlags.Ambient */)) {
if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) {
// export assignment is not supported in es6 modules
grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
@@ -83911,11 +85516,11 @@ var ts;
}
// ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries.
// (TS Exceptions: namespaces, function overloads, enums, and interfaces)
- if (flags & (1920 /* Namespace */ | 64 /* Interface */ | 384 /* Enum */)) {
+ if (flags & (1920 /* SymbolFlags.Namespace */ | 384 /* SymbolFlags.Enum */)) {
return;
}
- var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor);
- if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) {
+ var exportedDeclarationsCount = ts.countWhere(declarations, ts.and(isNotOverloadAndNotAccessor, ts.not(ts.isInterfaceDeclaration)));
+ if (flags & 524288 /* SymbolFlags.TypeAlias */ && exportedDeclarationsCount <= 2) {
// it is legal to merge type alias with other values
// so count should be either 1 (just type alias) or 2 (type alias + merged value)
return;
@@ -83961,177 +85566,177 @@ var ts;
// Only bother checking on a few construct kinds. We don't want to be excessively
// hitting the cancellation token on every node we check.
switch (kind) {
- case 260 /* ModuleDeclaration */:
- case 256 /* ClassDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 255 /* FunctionDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
cancellationToken.throwIfCancellationRequested();
}
}
- if (kind >= 236 /* FirstStatement */ && kind <= 252 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) {
+ if (kind >= 237 /* SyntaxKind.FirstStatement */ && kind <= 253 /* SyntaxKind.LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) {
errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected);
}
switch (kind) {
- case 162 /* TypeParameter */:
+ case 163 /* SyntaxKind.TypeParameter */:
return checkTypeParameter(node);
- case 163 /* Parameter */:
+ case 164 /* SyntaxKind.Parameter */:
return checkParameter(node);
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
return checkPropertyDeclaration(node);
- case 165 /* PropertySignature */:
+ case 166 /* SyntaxKind.PropertySignature */:
return checkPropertySignature(node);
- case 179 /* ConstructorType */:
- case 178 /* FunctionType */:
- case 173 /* CallSignature */:
- case 174 /* ConstructSignature */:
- case 175 /* IndexSignature */:
+ case 180 /* SyntaxKind.ConstructorType */:
+ case 179 /* SyntaxKind.FunctionType */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 176 /* SyntaxKind.IndexSignature */:
return checkSignatureDeclaration(node);
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
return checkMethodDeclaration(node);
- case 169 /* ClassStaticBlockDeclaration */:
+ case 170 /* SyntaxKind.ClassStaticBlockDeclaration */:
return checkClassStaticBlockDeclaration(node);
- case 170 /* Constructor */:
+ case 171 /* SyntaxKind.Constructor */:
return checkConstructorDeclaration(node);
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
return checkAccessorDeclaration(node);
- case 177 /* TypeReference */:
+ case 178 /* SyntaxKind.TypeReference */:
return checkTypeReferenceNode(node);
- case 176 /* TypePredicate */:
+ case 177 /* SyntaxKind.TypePredicate */:
return checkTypePredicate(node);
- case 180 /* TypeQuery */:
+ case 181 /* SyntaxKind.TypeQuery */:
return checkTypeQuery(node);
- case 181 /* TypeLiteral */:
+ case 182 /* SyntaxKind.TypeLiteral */:
return checkTypeLiteral(node);
- case 182 /* ArrayType */:
+ case 183 /* SyntaxKind.ArrayType */:
return checkArrayType(node);
- case 183 /* TupleType */:
+ case 184 /* SyntaxKind.TupleType */:
return checkTupleType(node);
- case 186 /* UnionType */:
- case 187 /* IntersectionType */:
+ case 187 /* SyntaxKind.UnionType */:
+ case 188 /* SyntaxKind.IntersectionType */:
return checkUnionOrIntersectionType(node);
- case 190 /* ParenthesizedType */:
- case 184 /* OptionalType */:
- case 185 /* RestType */:
+ case 191 /* SyntaxKind.ParenthesizedType */:
+ case 185 /* SyntaxKind.OptionalType */:
+ case 186 /* SyntaxKind.RestType */:
return checkSourceElement(node.type);
- case 191 /* ThisType */:
+ case 192 /* SyntaxKind.ThisType */:
return checkThisType(node);
- case 192 /* TypeOperator */:
+ case 193 /* SyntaxKind.TypeOperator */:
return checkTypeOperator(node);
- case 188 /* ConditionalType */:
+ case 189 /* SyntaxKind.ConditionalType */:
return checkConditionalType(node);
- case 189 /* InferType */:
+ case 190 /* SyntaxKind.InferType */:
return checkInferType(node);
- case 197 /* TemplateLiteralType */:
+ case 198 /* SyntaxKind.TemplateLiteralType */:
return checkTemplateLiteralType(node);
- case 199 /* ImportType */:
+ case 200 /* SyntaxKind.ImportType */:
return checkImportType(node);
- case 196 /* NamedTupleMember */:
+ case 197 /* SyntaxKind.NamedTupleMember */:
return checkNamedTupleMember(node);
- case 326 /* JSDocAugmentsTag */:
+ case 328 /* SyntaxKind.JSDocAugmentsTag */:
return checkJSDocAugmentsTag(node);
- case 327 /* JSDocImplementsTag */:
+ case 329 /* SyntaxKind.JSDocImplementsTag */:
return checkJSDocImplementsTag(node);
- case 343 /* JSDocTypedefTag */:
- case 336 /* JSDocCallbackTag */:
- case 337 /* JSDocEnumTag */:
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
+ case 338 /* SyntaxKind.JSDocCallbackTag */:
+ case 339 /* SyntaxKind.JSDocEnumTag */:
return checkJSDocTypeAliasTag(node);
- case 342 /* JSDocTemplateTag */:
+ case 344 /* SyntaxKind.JSDocTemplateTag */:
return checkJSDocTemplateTag(node);
- case 341 /* JSDocTypeTag */:
+ case 343 /* SyntaxKind.JSDocTypeTag */:
return checkJSDocTypeTag(node);
- case 338 /* JSDocParameterTag */:
+ case 340 /* SyntaxKind.JSDocParameterTag */:
return checkJSDocParameterTag(node);
- case 345 /* JSDocPropertyTag */:
+ case 347 /* SyntaxKind.JSDocPropertyTag */:
return checkJSDocPropertyTag(node);
- case 315 /* JSDocFunctionType */:
+ case 317 /* SyntaxKind.JSDocFunctionType */:
checkJSDocFunctionType(node);
// falls through
- case 313 /* JSDocNonNullableType */:
- case 312 /* JSDocNullableType */:
- case 310 /* JSDocAllType */:
- case 311 /* JSDocUnknownType */:
- case 320 /* JSDocTypeLiteral */:
+ case 315 /* SyntaxKind.JSDocNonNullableType */:
+ case 314 /* SyntaxKind.JSDocNullableType */:
+ case 312 /* SyntaxKind.JSDocAllType */:
+ case 313 /* SyntaxKind.JSDocUnknownType */:
+ case 322 /* SyntaxKind.JSDocTypeLiteral */:
checkJSDocTypeIsInJsFile(node);
ts.forEachChild(node, checkSourceElement);
return;
- case 316 /* JSDocVariadicType */:
+ case 318 /* SyntaxKind.JSDocVariadicType */:
checkJSDocVariadicType(node);
return;
- case 307 /* JSDocTypeExpression */:
+ case 309 /* SyntaxKind.JSDocTypeExpression */:
return checkSourceElement(node.type);
- case 331 /* JSDocPublicTag */:
- case 333 /* JSDocProtectedTag */:
- case 332 /* JSDocPrivateTag */:
+ case 333 /* SyntaxKind.JSDocPublicTag */:
+ case 335 /* SyntaxKind.JSDocProtectedTag */:
+ case 334 /* SyntaxKind.JSDocPrivateTag */:
return checkJSDocAccessibilityModifiers(node);
- case 193 /* IndexedAccessType */:
+ case 194 /* SyntaxKind.IndexedAccessType */:
return checkIndexedAccessType(node);
- case 194 /* MappedType */:
+ case 195 /* SyntaxKind.MappedType */:
return checkMappedType(node);
- case 255 /* FunctionDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
return checkFunctionDeclaration(node);
- case 234 /* Block */:
- case 261 /* ModuleBlock */:
+ case 235 /* SyntaxKind.Block */:
+ case 262 /* SyntaxKind.ModuleBlock */:
return checkBlock(node);
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
return checkVariableStatement(node);
- case 237 /* ExpressionStatement */:
+ case 238 /* SyntaxKind.ExpressionStatement */:
return checkExpressionStatement(node);
- case 238 /* IfStatement */:
+ case 239 /* SyntaxKind.IfStatement */:
return checkIfStatement(node);
- case 239 /* DoStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
return checkDoStatement(node);
- case 240 /* WhileStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
return checkWhileStatement(node);
- case 241 /* ForStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
return checkForStatement(node);
- case 242 /* ForInStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
return checkForInStatement(node);
- case 243 /* ForOfStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
return checkForOfStatement(node);
- case 244 /* ContinueStatement */:
- case 245 /* BreakStatement */:
+ case 245 /* SyntaxKind.ContinueStatement */:
+ case 246 /* SyntaxKind.BreakStatement */:
return checkBreakOrContinueStatement(node);
- case 246 /* ReturnStatement */:
+ case 247 /* SyntaxKind.ReturnStatement */:
return checkReturnStatement(node);
- case 247 /* WithStatement */:
+ case 248 /* SyntaxKind.WithStatement */:
return checkWithStatement(node);
- case 248 /* SwitchStatement */:
+ case 249 /* SyntaxKind.SwitchStatement */:
return checkSwitchStatement(node);
- case 249 /* LabeledStatement */:
+ case 250 /* SyntaxKind.LabeledStatement */:
return checkLabeledStatement(node);
- case 250 /* ThrowStatement */:
+ case 251 /* SyntaxKind.ThrowStatement */:
return checkThrowStatement(node);
- case 251 /* TryStatement */:
+ case 252 /* SyntaxKind.TryStatement */:
return checkTryStatement(node);
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return checkVariableDeclaration(node);
- case 202 /* BindingElement */:
+ case 203 /* SyntaxKind.BindingElement */:
return checkBindingElement(node);
- case 256 /* ClassDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
return checkClassDeclaration(node);
- case 257 /* InterfaceDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
return checkInterfaceDeclaration(node);
- case 258 /* TypeAliasDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
return checkTypeAliasDeclaration(node);
- case 259 /* EnumDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
return checkEnumDeclaration(node);
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
return checkModuleDeclaration(node);
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
return checkImportDeclaration(node);
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return checkImportEqualsDeclaration(node);
- case 271 /* ExportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
return checkExportDeclaration(node);
- case 270 /* ExportAssignment */:
+ case 271 /* SyntaxKind.ExportAssignment */:
return checkExportAssignment(node);
- case 235 /* EmptyStatement */:
- case 252 /* DebuggerStatement */:
+ case 236 /* SyntaxKind.EmptyStatement */:
+ case 253 /* SyntaxKind.DebuggerStatement */:
checkGrammarStatementInAmbientContext(node);
return;
- case 275 /* MissingDeclaration */:
+ case 276 /* SyntaxKind.MissingDeclaration */:
return checkMissingDeclaration(node);
}
}
@@ -84212,7 +85817,7 @@ var ts;
function checkNodeDeferred(node) {
var enclosingFile = ts.getSourceFileOfNode(node);
var links = getNodeLinks(enclosingFile);
- if (!(links.flags & 1 /* TypeChecked */)) {
+ if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) {
links.deferredNodes || (links.deferredNodes = new ts.Set());
links.deferredNodes.add(node);
}
@@ -84224,38 +85829,41 @@ var ts;
}
}
function checkDeferredNode(node) {
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath });
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath });
var saveCurrentNode = currentNode;
currentNode = node;
instantiationCount = 0;
switch (node.kind) {
- case 207 /* CallExpression */:
- case 208 /* NewExpression */:
- case 209 /* TaggedTemplateExpression */:
- case 164 /* Decorator */:
- case 279 /* JsxOpeningElement */:
+ case 208 /* SyntaxKind.CallExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
+ case 165 /* SyntaxKind.Decorator */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
// These node kinds are deferred checked when overload resolution fails
// To save on work, we ensure the arguments are checked just once, in
// a deferred way
resolveUntypedCall(node);
break;
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
checkFunctionExpressionOrObjectLiteralMethodDeferred(node);
break;
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
checkAccessorDeclaration(node);
break;
- case 225 /* ClassExpression */:
+ case 226 /* SyntaxKind.ClassExpression */:
checkClassExpressionDeferred(node);
break;
- case 278 /* JsxSelfClosingElement */:
+ case 163 /* SyntaxKind.TypeParameter */:
+ checkTypeParameterDeferred(node);
+ break;
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
checkJsxSelfClosingElementDeferred(node);
break;
- case 277 /* JsxElement */:
+ case 278 /* SyntaxKind.JsxElement */:
checkJsxElementDeferred(node);
break;
}
@@ -84263,7 +85871,7 @@ var ts;
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
}
function checkSourceFile(node) {
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true);
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true);
ts.performance.mark("beforeCheck");
checkSourceFileWorker(node);
ts.performance.mark("afterCheck");
@@ -84275,9 +85883,9 @@ var ts;
return false;
}
switch (kind) {
- case 0 /* Local */:
+ case 0 /* UnusedKind.Local */:
return !!compilerOptions.noUnusedLocals;
- case 1 /* Parameter */:
+ case 1 /* UnusedKind.Parameter */:
return !!compilerOptions.noUnusedParameters;
default:
return ts.Debug.assertNever(kind);
@@ -84289,7 +85897,7 @@ var ts;
// Fully type check a source file and collect the relevant diagnostics.
function checkSourceFileWorker(node) {
var links = getNodeLinks(node);
- if (!(links.flags & 1 /* TypeChecked */)) {
+ if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) {
if (ts.skipTypeChecking(node, compilerOptions, host)) {
return;
}
@@ -84305,14 +85913,17 @@ var ts;
if (ts.isExternalOrCommonJsModule(node)) {
registerForUnusedIdentifiersCheck(node);
}
- if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
- checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
- if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 8388608 /* Ambient */))) {
- diagnostics.add(diag);
- }
- });
- }
- if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ &&
+ addLazyDiagnostic(function () {
+ // This relies on the results of other lazy diagnostics, so must be computed after them
+ if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
+ checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
+ if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) {
+ diagnostics.add(diag);
+ }
+ });
+ }
+ });
+ if (compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ &&
!node.isDeclarationFile &&
ts.isExternalModule(node)) {
checkImportsForTypeOnlyConversion(node);
@@ -84336,7 +85947,7 @@ var ts;
ts.forEach(potentialReflectCollisions, checkReflectCollision);
ts.clear(potentialReflectCollisions);
}
- links.flags |= 1 /* TypeChecked */;
+ links.flags |= 1 /* NodeCheckFlags.TypeChecked */;
}
}
function getDiagnostics(sourceFile, ct) {
@@ -84351,15 +85962,35 @@ var ts;
cancellationToken = undefined;
}
}
+ function ensurePendingDiagnosticWorkComplete() {
+ // Invoke any existing lazy diagnostics to add them, clear the backlog of diagnostics
+ for (var _i = 0, deferredDiagnosticsCallbacks_1 = deferredDiagnosticsCallbacks; _i < deferredDiagnosticsCallbacks_1.length; _i++) {
+ var cb = deferredDiagnosticsCallbacks_1[_i];
+ cb();
+ }
+ deferredDiagnosticsCallbacks = [];
+ }
+ function checkSourceFileWithEagerDiagnostics(sourceFile) {
+ ensurePendingDiagnosticWorkComplete();
+ // then setup diagnostics for immediate invocation (as we are about to collect them, and
+ // this avoids the overhead of longer-lived callbacks we don't need to allocate)
+ // This also serves to make the shift to possibly lazy diagnostics transparent to serial command-line scenarios
+ // (as in those cases, all the diagnostics will still be computed as the appropriate place in the tree,
+ // thus much more likely retaining the same union ordering as before we had lazy diagnostics)
+ var oldAddLazyDiagnostics = addLazyDiagnostic;
+ addLazyDiagnostic = function (cb) { return cb(); };
+ checkSourceFile(sourceFile);
+ addLazyDiagnostic = oldAddLazyDiagnostics;
+ }
function getDiagnosticsWorker(sourceFile) {
- throwIfNonDiagnosticsProducing();
if (sourceFile) {
+ ensurePendingDiagnosticWorkComplete();
// Some global diagnostics are deferred until they are needed and
// may not be reported in the first call to getGlobalDiagnostics.
// We should catch these changes and report them.
var previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
var previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length;
- checkSourceFile(sourceFile);
+ checkSourceFileWithEagerDiagnostics(sourceFile);
var semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
var currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
if (currentGlobalDiagnostics !== previousGlobalDiagnostics) {
@@ -84377,28 +86008,23 @@ var ts;
}
// Global diagnostics are always added when a file is not provided to
// getDiagnostics
- ts.forEach(host.getSourceFiles(), checkSourceFile);
+ ts.forEach(host.getSourceFiles(), checkSourceFileWithEagerDiagnostics);
return diagnostics.getDiagnostics();
}
function getGlobalDiagnostics() {
- throwIfNonDiagnosticsProducing();
+ ensurePendingDiagnosticWorkComplete();
return diagnostics.getGlobalDiagnostics();
}
- function throwIfNonDiagnosticsProducing() {
- if (!produceDiagnostics) {
- throw new Error("Trying to get diagnostics from a type checker that does not produce them.");
- }
- }
// Language service support
function getSymbolsInScope(location, meaning) {
- if (location.flags & 16777216 /* InWithStatement */) {
+ if (location.flags & 33554432 /* NodeFlags.InWithStatement */) {
// We cannot answer semantic questions within a with block, do not proceed any further
return [];
}
var symbols = ts.createSymbolTable();
var isStaticSymbol = false;
populateSymbols();
- symbols.delete("this" /* This */); // Not a symbol, a keyword
+ symbols.delete("this" /* InternalSymbolName.This */); // Not a symbol, a keyword
return symbolsToArray(symbols);
function populateSymbols() {
while (location) {
@@ -84406,17 +86032,17 @@ var ts;
copySymbols(location.locals, meaning);
}
switch (location.kind) {
- case 303 /* SourceFile */:
+ case 305 /* SyntaxKind.SourceFile */:
if (!ts.isExternalModule(location))
break;
// falls through
- case 260 /* ModuleDeclaration */:
- copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */);
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* SymbolFlags.ModuleMember */);
break;
- case 259 /* EnumDeclaration */:
- copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */);
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* SymbolFlags.EnumMember */);
break;
- case 225 /* ClassExpression */:
+ case 226 /* SyntaxKind.ClassExpression */:
var className = location.name;
if (className) {
copySymbol(location.symbol, meaning);
@@ -84424,17 +86050,17 @@ var ts;
// this fall-through is necessary because we would like to handle
// type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration.
// falls through
- case 256 /* ClassDeclaration */:
- case 257 /* InterfaceDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
// If we didn't come from static member of class or interface,
// add the type parameters into the symbol table
// (type parameters of classDeclaration/classExpression and interface are in member property of the symbol.
// Note: that the memberFlags come from previous iteration.
if (!isStaticSymbol) {
- copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */);
+ copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* SymbolFlags.Type */);
}
break;
- case 212 /* FunctionExpression */:
+ case 213 /* SyntaxKind.FunctionExpression */:
var funcName = location.name;
if (funcName) {
copySymbol(location.symbol, meaning);
@@ -84478,7 +86104,7 @@ var ts;
if (meaning) {
source.forEach(function (symbol) {
// Similar condition as in `resolveNameHelper`
- if (!ts.getDeclarationOfKind(symbol, 274 /* ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 273 /* NamespaceExport */)) {
+ if (!ts.getDeclarationOfKind(symbol, 275 /* SyntaxKind.ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 274 /* SyntaxKind.NamespaceExport */)) {
copySymbol(symbol, meaning);
}
});
@@ -84486,25 +86112,25 @@ var ts;
}
}
function isTypeDeclarationName(name) {
- return name.kind === 79 /* Identifier */ &&
+ return name.kind === 79 /* SyntaxKind.Identifier */ &&
isTypeDeclaration(name.parent) &&
ts.getNameOfDeclaration(name.parent) === name;
}
function isTypeDeclaration(node) {
switch (node.kind) {
- case 162 /* TypeParameter */:
- case 256 /* ClassDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 258 /* TypeAliasDeclaration */:
- case 259 /* EnumDeclaration */:
- case 343 /* JSDocTypedefTag */:
- case 336 /* JSDocCallbackTag */:
- case 337 /* JSDocEnumTag */:
+ case 163 /* SyntaxKind.TypeParameter */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
+ case 338 /* SyntaxKind.JSDocCallbackTag */:
+ case 339 /* SyntaxKind.JSDocEnumTag */:
return true;
- case 266 /* ImportClause */:
+ case 267 /* SyntaxKind.ImportClause */:
return node.isTypeOnly;
- case 269 /* ImportSpecifier */:
- case 274 /* ExportSpecifier */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
+ case 275 /* SyntaxKind.ExportSpecifier */:
return node.parent.parent.isTypeOnly;
default:
return false;
@@ -84512,16 +86138,16 @@ var ts;
}
// True if the given identifier is part of a type reference
function isTypeReferenceIdentifier(node) {
- while (node.parent.kind === 160 /* QualifiedName */) {
+ while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) {
node = node.parent;
}
- return node.parent.kind === 177 /* TypeReference */;
+ return node.parent.kind === 178 /* SyntaxKind.TypeReference */;
}
function isHeritageClauseElementIdentifier(node) {
- while (node.parent.kind === 205 /* PropertyAccessExpression */) {
+ while (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) {
node = node.parent;
}
- return node.parent.kind === 227 /* ExpressionWithTypeArguments */;
+ return node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */;
}
function forEachEnclosingClass(node, callback) {
var result;
@@ -84549,13 +86175,13 @@ var ts;
return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; });
}
function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) {
- while (nodeOnRightSide.parent.kind === 160 /* QualifiedName */) {
+ while (nodeOnRightSide.parent.kind === 161 /* SyntaxKind.QualifiedName */) {
nodeOnRightSide = nodeOnRightSide.parent;
}
- if (nodeOnRightSide.parent.kind === 264 /* ImportEqualsDeclaration */) {
+ if (nodeOnRightSide.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined;
}
- if (nodeOnRightSide.parent.kind === 270 /* ExportAssignment */) {
+ if (nodeOnRightSide.parent.kind === 271 /* SyntaxKind.ExportAssignment */) {
return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined;
}
return undefined;
@@ -84566,12 +86192,12 @@ var ts;
function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) {
var specialPropertyAssignmentKind = ts.getAssignmentDeclarationKind(entityName.parent.parent);
switch (specialPropertyAssignmentKind) {
- case 1 /* ExportsProperty */:
- case 3 /* PrototypeProperty */:
+ case 1 /* AssignmentDeclarationKind.ExportsProperty */:
+ case 3 /* AssignmentDeclarationKind.PrototypeProperty */:
return getSymbolOfNode(entityName.parent);
- case 4 /* ThisProperty */:
- case 2 /* ModuleExports */:
- case 5 /* Property */:
+ case 4 /* AssignmentDeclarationKind.ThisProperty */:
+ case 2 /* AssignmentDeclarationKind.ModuleExports */:
+ case 5 /* AssignmentDeclarationKind.Property */:
return getSymbolOfNode(entityName.parent.parent);
}
}
@@ -84581,7 +86207,7 @@ var ts;
node = parent;
parent = parent.parent;
}
- if (parent && parent.kind === 199 /* ImportType */ && parent.qualifier === node) {
+ if (parent && parent.kind === 200 /* SyntaxKind.ImportType */ && parent.qualifier === node) {
return parent;
}
return undefined;
@@ -84591,7 +86217,7 @@ var ts;
return getSymbolOfNode(name.parent);
}
if (ts.isInJSFile(name) &&
- name.parent.kind === 205 /* PropertyAccessExpression */ &&
+ name.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ &&
name.parent === name.parent.parent.left) {
// Check if this is a special property assignment
if (!ts.isPrivateIdentifier(name) && !ts.isJSDocMemberName(name)) {
@@ -84601,17 +86227,17 @@ var ts;
}
}
}
- if (name.parent.kind === 270 /* ExportAssignment */ && ts.isEntityNameExpression(name)) {
+ if (name.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.isEntityNameExpression(name)) {
// Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression
var success = resolveEntityName(name,
- /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true);
+ /*all meanings*/ 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*ignoreErrors*/ true);
if (success && success !== unknownSymbol) {
return success;
}
}
else if (ts.isEntityName(name) && isInRightSideOfImportOrExportAssignment(name)) {
// Since we already checked for ExportAssignment, this really could only be an Import
- var importEqualsDeclaration = ts.getAncestor(name, 264 /* ImportEqualsDeclaration */);
+ var importEqualsDeclaration = ts.getAncestor(name, 265 /* SyntaxKind.ImportEqualsDeclaration */);
ts.Debug.assert(importEqualsDeclaration !== undefined);
return getSymbolOfPartOfRightHandSideOfImportEquals(name, /*dontResolveAlias*/ true);
}
@@ -84627,28 +86253,28 @@ var ts;
name = name.parent;
}
if (isHeritageClauseElementIdentifier(name)) {
- var meaning = 0 /* None */;
+ var meaning = 0 /* SymbolFlags.None */;
// In an interface or class, we're definitely interested in a type.
- if (name.parent.kind === 227 /* ExpressionWithTypeArguments */) {
- meaning = 788968 /* Type */;
+ if (name.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) {
+ meaning = 788968 /* SymbolFlags.Type */;
// In a class 'extends' clause we are also looking for a value.
if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) {
- meaning |= 111551 /* Value */;
+ meaning |= 111551 /* SymbolFlags.Value */;
}
}
else {
- meaning = 1920 /* Namespace */;
+ meaning = 1920 /* SymbolFlags.Namespace */;
}
- meaning |= 2097152 /* Alias */;
+ meaning |= 2097152 /* SymbolFlags.Alias */;
var entityNameSymbol = ts.isEntityNameExpression(name) ? resolveEntityName(name, meaning) : undefined;
if (entityNameSymbol) {
return entityNameSymbol;
}
}
- if (name.parent.kind === 338 /* JSDocParameterTag */) {
+ if (name.parent.kind === 340 /* SyntaxKind.JSDocParameterTag */) {
return ts.getParameterSymbolFromJSDoc(name.parent);
}
- if (name.parent.kind === 162 /* TypeParameter */ && name.parent.parent.kind === 342 /* JSDocTemplateTag */) {
+ if (name.parent.kind === 163 /* SyntaxKind.TypeParameter */ && name.parent.parent.kind === 344 /* SyntaxKind.JSDocTemplateTag */) {
ts.Debug.assert(!ts.isInJSFile(name)); // Otherwise `isDeclarationName` would have been true.
var typeParameter = ts.getTypeParameterFromJsDoc(name.parent);
return typeParameter && typeParameter.symbol;
@@ -84659,13 +86285,13 @@ var ts;
return undefined;
}
var isJSDoc_1 = ts.findAncestor(name, ts.or(ts.isJSDocLinkLike, ts.isJSDocNameReference, ts.isJSDocMemberName));
- var meaning = isJSDoc_1 ? 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */ : 111551 /* Value */;
- if (name.kind === 79 /* Identifier */) {
+ var meaning = isJSDoc_1 ? 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */ : 111551 /* SymbolFlags.Value */;
+ if (name.kind === 79 /* SyntaxKind.Identifier */) {
if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) {
var symbol = getIntrinsicTagSymbol(name.parent);
return symbol === unknownSymbol ? undefined : symbol;
}
- var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ !isJSDoc_1, ts.getHostSignatureFromJSDoc(name));
+ var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /* dontResolveAlias */ true, ts.getHostSignatureFromJSDoc(name));
if (!result && isJSDoc_1) {
var container = ts.findAncestor(name, ts.or(ts.isClassLike, ts.isInterfaceDeclaration));
if (container) {
@@ -84677,16 +86303,16 @@ var ts;
else if (ts.isPrivateIdentifier(name)) {
return getSymbolForPrivateIdentifierExpression(name);
}
- else if (name.kind === 205 /* PropertyAccessExpression */ || name.kind === 160 /* QualifiedName */) {
+ else if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || name.kind === 161 /* SyntaxKind.QualifiedName */) {
var links = getNodeLinks(name);
if (links.resolvedSymbol) {
return links.resolvedSymbol;
}
- if (name.kind === 205 /* PropertyAccessExpression */) {
- checkPropertyAccessExpression(name, 0 /* Normal */);
+ if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) {
+ checkPropertyAccessExpression(name, 0 /* CheckMode.Normal */);
}
else {
- checkQualifiedName(name, 0 /* Normal */);
+ checkQualifiedName(name, 0 /* CheckMode.Normal */);
}
if (!links.resolvedSymbol && isJSDoc_1 && ts.isQualifiedName(name)) {
return resolveJSDocMemberName(name);
@@ -84698,12 +86324,12 @@ var ts;
}
}
else if (isTypeReferenceIdentifier(name)) {
- var meaning = name.parent.kind === 177 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */;
+ var meaning = name.parent.kind === 178 /* SyntaxKind.TypeReference */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */;
var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true);
return symbol && symbol !== unknownSymbol ? symbol : getUnresolvedSymbolForEntityName(name);
}
- if (name.parent.kind === 176 /* TypePredicate */) {
- return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */);
+ if (name.parent.kind === 177 /* SyntaxKind.TypePredicate */) {
+ return resolveEntityName(name, /*meaning*/ 1 /* SymbolFlags.FunctionScopedVariable */);
}
return undefined;
}
@@ -84718,7 +86344,7 @@ var ts;
function resolveJSDocMemberName(name, container) {
if (ts.isEntityName(name)) {
// resolve static values first
- var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */;
+ var meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */;
var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name));
if (!symbol && ts.isIdentifier(name) && container) {
symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning));
@@ -84730,18 +86356,18 @@ var ts;
var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left);
var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText;
if (left) {
- var proto = left.flags & 111551 /* Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype");
+ var proto = left.flags & 111551 /* SymbolFlags.Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype");
var t = proto ? getTypeOfSymbol(proto) : getDeclaredTypeOfSymbol(left);
return getPropertyOfType(t, right);
}
}
function getSymbolAtLocation(node, ignoreErrors) {
- if (node.kind === 303 /* SourceFile */) {
+ if (node.kind === 305 /* SyntaxKind.SourceFile */) {
return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined;
}
var parent = node.parent;
var grandParent = parent.parent;
- if (node.flags & 16777216 /* InWithStatement */) {
+ if (node.flags & 33554432 /* NodeFlags.InWithStatement */) {
// We cannot answer semantic questions within a with block, do not proceed any further
return undefined;
}
@@ -84755,12 +86381,12 @@ var ts;
else if (ts.isLiteralComputedPropertyDeclarationName(node)) {
return getSymbolOfNode(parent.parent);
}
- if (node.kind === 79 /* Identifier */) {
+ if (node.kind === 79 /* SyntaxKind.Identifier */) {
if (isInRightSideOfImportOrExportAssignment(node)) {
return getSymbolOfNameOrPropertyAccessExpression(node);
}
- else if (parent.kind === 202 /* BindingElement */ &&
- grandParent.kind === 200 /* ObjectBindingPattern */ &&
+ else if (parent.kind === 203 /* SyntaxKind.BindingElement */ &&
+ grandParent.kind === 201 /* SyntaxKind.ObjectBindingPattern */ &&
node === parent.propertyName) {
var typeOfPattern = getTypeOfNode(grandParent);
var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText);
@@ -84768,27 +86394,32 @@ var ts;
return propertyDeclaration;
}
}
- else if (ts.isMetaProperty(parent)) {
- var parentType = getTypeOfNode(parent);
- var propertyDeclaration = getPropertyOfType(parentType, node.escapedText);
- if (propertyDeclaration) {
- return propertyDeclaration;
- }
- if (parent.keywordToken === 103 /* NewKeyword */) {
+ else if (ts.isMetaProperty(parent) && parent.name === node) {
+ if (parent.keywordToken === 103 /* SyntaxKind.NewKeyword */ && ts.idText(node) === "target") {
+ // `target` in `new.target`
return checkNewTargetMetaProperty(parent).symbol;
}
+ // The `meta` in `import.meta` could be given `getTypeOfNode(parent).symbol` (the `ImportMeta` interface symbol), but
+ // we have a fake expression type made for other reasons already, whose transient `meta`
+ // member should more exactly be the kind of (declarationless) symbol we want.
+ // (See #44364 and #45031 for relevant implementation PRs)
+ if (parent.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && ts.idText(node) === "meta") {
+ return getGlobalImportMetaExpressionType().members.get("meta");
+ }
+ // no other meta properties are valid syntax, thus no others should have symbols
+ return undefined;
}
}
switch (node.kind) {
- case 79 /* Identifier */:
- case 80 /* PrivateIdentifier */:
- case 205 /* PropertyAccessExpression */:
- case 160 /* QualifiedName */:
+ case 79 /* SyntaxKind.Identifier */:
+ case 80 /* SyntaxKind.PrivateIdentifier */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 161 /* SyntaxKind.QualifiedName */:
if (!ts.isThisInTypeQuery(node)) {
return getSymbolOfNameOrPropertyAccessExpression(node);
}
// falls through
- case 108 /* ThisKeyword */:
+ case 108 /* SyntaxKind.ThisKeyword */:
var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false);
if (ts.isFunctionLike(container)) {
var sig = getSignatureFromDeclaration(container);
@@ -84800,25 +86431,25 @@ var ts;
return checkExpression(node).symbol;
}
// falls through
- case 191 /* ThisType */:
+ case 192 /* SyntaxKind.ThisType */:
return getTypeFromThisTypeNode(node).symbol;
- case 106 /* SuperKeyword */:
+ case 106 /* SyntaxKind.SuperKeyword */:
return checkExpression(node).symbol;
- case 134 /* ConstructorKeyword */:
+ case 134 /* SyntaxKind.ConstructorKeyword */:
// constructor keyword for an overload, should take us to the definition if it exist
var constructorDeclaration = node.parent;
- if (constructorDeclaration && constructorDeclaration.kind === 170 /* Constructor */) {
+ if (constructorDeclaration && constructorDeclaration.kind === 171 /* SyntaxKind.Constructor */) {
return constructorDeclaration.parent.symbol;
}
return undefined;
- case 10 /* StringLiteral */:
- case 14 /* NoSubstitutionTemplateLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
// 1). import x = require("./mo/*gotToDefinitionHere*/d")
// 2). External module name in an import declaration
// 3). Dynamic import call or require in javascript
// 4). type A = import("./f/*gotToDefinitionHere*/oo")
if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) ||
- ((node.parent.kind === 265 /* ImportDeclaration */ || node.parent.kind === 271 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) ||
+ ((node.parent.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.parent.kind === 272 /* SyntaxKind.ExportDeclaration */) && node.parent.moduleSpecifier === node) ||
((ts.isInJSFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) ||
(ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) {
return resolveExternalModuleName(node, node, ignoreErrors);
@@ -84827,7 +86458,7 @@ var ts;
return getSymbolOfNode(parent);
}
// falls through
- case 8 /* NumericLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
// index access
var objectType = ts.isElementAccessExpression(parent)
? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined
@@ -84835,19 +86466,19 @@ var ts;
? getTypeFromTypeNode(grandParent.objectType)
: undefined;
return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text));
- case 88 /* DefaultKeyword */:
- case 98 /* FunctionKeyword */:
- case 38 /* EqualsGreaterThanToken */:
- case 84 /* ClassKeyword */:
+ case 88 /* SyntaxKind.DefaultKeyword */:
+ case 98 /* SyntaxKind.FunctionKeyword */:
+ case 38 /* SyntaxKind.EqualsGreaterThanToken */:
+ case 84 /* SyntaxKind.ClassKeyword */:
return getSymbolOfNode(node.parent);
- case 199 /* ImportType */:
+ case 200 /* SyntaxKind.ImportType */:
return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined;
- case 93 /* ExportKeyword */:
+ case 93 /* SyntaxKind.ExportKeyword */:
return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined;
- case 100 /* ImportKeyword */:
- case 103 /* NewKeyword */:
+ case 100 /* SyntaxKind.ImportKeyword */:
+ case 103 /* SyntaxKind.NewKeyword */:
return ts.isMetaProperty(node.parent) ? checkMetaPropertyKeyword(node.parent).symbol : undefined;
- case 230 /* MetaProperty */:
+ case 231 /* SyntaxKind.MetaProperty */:
return checkExpression(node).symbol;
default:
return undefined;
@@ -84857,14 +86488,14 @@ var ts;
if (ts.isIdentifier(node) && ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) {
var keyType_1 = getLiteralTypeFromPropertyName(node);
var objectType = getTypeOfExpression(node.parent.expression);
- var objectTypes = objectType.flags & 1048576 /* Union */ ? objectType.types : [objectType];
+ var objectTypes = objectType.flags & 1048576 /* TypeFlags.Union */ ? objectType.types : [objectType];
return ts.flatMap(objectTypes, function (t) { return ts.filter(getIndexInfosOfType(t), function (info) { return isApplicableIndexType(keyType_1, info.keyType); }); });
}
return undefined;
}
function getShorthandAssignmentValueSymbol(location) {
- if (location && location.kind === 295 /* ShorthandPropertyAssignment */) {
- return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */);
+ if (location && location.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) {
+ return resolveEntityName(location.name, 111551 /* SymbolFlags.Value */ | 2097152 /* SymbolFlags.Alias */);
}
return undefined;
}
@@ -84873,17 +86504,17 @@ var ts;
if (ts.isExportSpecifier(node)) {
return node.parent.parent.moduleSpecifier ?
getExternalModuleMember(node.parent.parent, node) :
- resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */);
+ resolveEntityName(node.propertyName || node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */);
}
else {
- return resolveEntityName(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */);
+ return resolveEntityName(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */);
}
}
function getTypeOfNode(node) {
if (ts.isSourceFile(node) && !ts.isExternalModule(node)) {
return errorType;
}
- if (node.flags & 16777216 /* InWithStatement */) {
+ if (node.flags & 33554432 /* NodeFlags.InWithStatement */) {
// We cannot answer semantic questions within a with block, do not proceed any further
return errorType;
}
@@ -84914,7 +86545,7 @@ var ts;
if (ts.isDeclaration(node)) {
// In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration
var symbol = getSymbolOfNode(node);
- return getTypeOfSymbol(symbol);
+ return symbol ? getTypeOfSymbol(symbol) : errorType;
}
if (isDeclarationNameOrImportPropertyName(node)) {
var symbol = getSymbolAtLocation(node);
@@ -84924,7 +86555,7 @@ var ts;
return errorType;
}
if (ts.isBindingPattern(node)) {
- return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* Normal */) || errorType;
+ return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* CheckMode.Normal */) || errorType;
}
if (isInRightSideOfImportOrExportAssignment(node)) {
var symbol = getSymbolAtLocation(node);
@@ -84945,23 +86576,23 @@ var ts;
// [ a ] from
// [a] = [ some array ...]
function getTypeOfAssignmentPattern(expr) {
- ts.Debug.assert(expr.kind === 204 /* ObjectLiteralExpression */ || expr.kind === 203 /* ArrayLiteralExpression */);
+ ts.Debug.assert(expr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */);
// If this is from "for of"
// for ( { a } of elems) {
// }
- if (expr.parent.kind === 243 /* ForOfStatement */) {
+ if (expr.parent.kind === 244 /* SyntaxKind.ForOfStatement */) {
var iteratedType = checkRightHandSideOfForOf(expr.parent);
return checkDestructuringAssignment(expr, iteratedType || errorType);
}
// If this is from "for" initializer
// for ({a } = elems[0];.....) { }
- if (expr.parent.kind === 220 /* BinaryExpression */) {
+ if (expr.parent.kind === 221 /* SyntaxKind.BinaryExpression */) {
var iteratedType = getTypeOfExpression(expr.parent.right);
return checkDestructuringAssignment(expr, iteratedType || errorType);
}
// If this is from nested object binding pattern
// for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) {
- if (expr.parent.kind === 294 /* PropertyAssignment */) {
+ if (expr.parent.kind === 296 /* SyntaxKind.PropertyAssignment */) {
var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType;
var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent);
@@ -84971,7 +86602,7 @@ var ts;
var node = ts.cast(expr.parent, ts.isArrayLiteralExpression);
// [{ property1: p1, property2 }] = elems;
var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType;
- var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType;
+ var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType;
return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType);
}
// Gets the property symbol corresponding to the property in destructuring assignment
@@ -85004,14 +86635,14 @@ var ts;
function getClassElementPropertyKeyType(element) {
var name = element.name;
switch (name.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return getStringLiteralType(ts.idText(name));
- case 8 /* NumericLiteral */:
- case 10 /* StringLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
return getStringLiteralType(name.text);
- case 161 /* ComputedPropertyName */:
+ case 162 /* SyntaxKind.ComputedPropertyName */:
var nameType = checkComputedPropertyName(name);
- return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType;
+ return isTypeAssignableToKind(nameType, 12288 /* TypeFlags.ESSymbolLike */) ? nameType : stringType;
default:
return ts.Debug.fail("Unsupported property name.");
}
@@ -85021,8 +86652,8 @@ var ts;
function getAugmentedPropertiesOfType(type) {
type = getApparentType(type);
var propsByName = ts.createSymbolTable(getPropertiesOfType(type));
- var functionType = getSignaturesOfType(type, 0 /* Call */).length ? globalCallableFunctionType :
- getSignaturesOfType(type, 1 /* Construct */).length ? globalNewableFunctionType :
+ var functionType = getSignaturesOfType(type, 0 /* SignatureKind.Call */).length ? globalCallableFunctionType :
+ getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length ? globalNewableFunctionType :
undefined;
if (functionType) {
ts.forEach(getPropertiesOfType(functionType), function (p) {
@@ -85041,18 +86672,18 @@ var ts;
return roots ? ts.flatMap(roots, getRootSymbols) : [symbol];
}
function getImmediateRootSymbols(symbol) {
- if (ts.getCheckFlags(symbol) & 6 /* Synthetic */) {
+ if (ts.getCheckFlags(symbol) & 6 /* CheckFlags.Synthetic */) {
return ts.mapDefined(getSymbolLinks(symbol).containingType.types, function (type) { return getPropertyOfType(type, symbol.escapedName); });
}
- else if (symbol.flags & 33554432 /* Transient */) {
+ else if (symbol.flags & 33554432 /* SymbolFlags.Transient */) {
var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin;
return leftSpread ? [leftSpread, rightSpread]
: syntheticOrigin ? [syntheticOrigin]
- : ts.singleElementArray(tryGetAliasTarget(symbol));
+ : ts.singleElementArray(tryGetTarget(symbol));
}
return undefined;
}
- function tryGetAliasTarget(symbol) {
+ function tryGetTarget(symbol) {
var target;
var next = symbol;
while (next = getSymbolLinks(next).target) {
@@ -85091,13 +86722,13 @@ var ts;
// for export assignments - check if resolved symbol for RHS is itself a value
// otherwise - check if at least one export is value
symbolLinks.exportsSomeValue = hasExportAssignment
- ? !!(moduleSymbol.flags & 111551 /* Value */)
+ ? !!(moduleSymbol.flags & 111551 /* SymbolFlags.Value */)
: ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue);
}
return symbolLinks.exportsSomeValue;
function isValue(s) {
s = resolveSymbol(s);
- return s && !!(s.flags & 111551 /* Value */);
+ return s && !!(s.flags & 111551 /* SymbolFlags.Value */);
}
}
function isNameOfModuleOrEnumDeclaration(node) {
@@ -85115,19 +86746,19 @@ var ts;
// declaration if it contains an exported member with the same name.
var symbol = getReferencedValueSymbol(node, /*startInDeclarationContainer*/ isNameOfModuleOrEnumDeclaration(node));
if (symbol) {
- if (symbol.flags & 1048576 /* ExportValue */) {
+ if (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) {
// If we reference an exported entity within the same module declaration, then whether
// we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the
// kinds that we do NOT prefix.
var exportSymbol = getMergedSymbol(symbol.exportSymbol);
- if (!prefixLocals && exportSymbol.flags & 944 /* ExportHasLocal */ && !(exportSymbol.flags & 3 /* Variable */)) {
+ if (!prefixLocals && exportSymbol.flags & 944 /* SymbolFlags.ExportHasLocal */ && !(exportSymbol.flags & 3 /* SymbolFlags.Variable */)) {
return undefined;
}
symbol = exportSymbol;
}
var parentSymbol_1 = getParentOfSymbol(symbol);
if (parentSymbol_1) {
- if (parentSymbol_1.flags & 512 /* ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 303 /* SourceFile */) {
+ if (parentSymbol_1.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 305 /* SyntaxKind.SourceFile */) {
var symbolFile = parentSymbol_1.valueDeclaration;
var referenceFile = ts.getSourceFileOfNode(node);
// If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined.
@@ -85150,7 +86781,7 @@ var ts;
var symbol = getReferencedValueSymbol(node);
// We should only get the declaration of an alias if there isn't a local value
// declaration for the symbol
- if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !getTypeOnlyAliasDeclaration(symbol)) {
+ if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) {
return getDeclarationOfAliasSymbol(symbol);
}
}
@@ -85159,20 +86790,20 @@ var ts;
function isSymbolOfDestructuredElementOfCatchBinding(symbol) {
return symbol.valueDeclaration
&& ts.isBindingElement(symbol.valueDeclaration)
- && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 291 /* CatchClause */;
+ && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 292 /* SyntaxKind.CatchClause */;
}
function isSymbolOfDeclarationWithCollidingName(symbol) {
- if (symbol.flags & 418 /* BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) {
+ if (symbol.flags & 418 /* SymbolFlags.BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) {
var links = getSymbolLinks(symbol);
if (links.isDeclarationWithCollidingName === undefined) {
var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration);
if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) {
var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration);
- if (resolveName(container.parent, symbol.escapedName, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) {
+ if (resolveName(container.parent, symbol.escapedName, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) {
// redeclaration - always should be renamed
links.isDeclarationWithCollidingName = true;
}
- else if (nodeLinks_1.flags & 262144 /* CapturedBlockScopedBinding */) {
+ else if (nodeLinks_1.flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */) {
// binding is captured in the function
// should be renamed if:
// - binding is not top level - top level bindings never collide with anything
@@ -85188,9 +86819,9 @@ var ts;
// * variables from initializer are passed to rewritten loop body as parameters so they are not captured directly
// * variables that are declared immediately in loop body will become top level variable after loop is rewritten and thus
// they will not collide with anything
- var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */;
+ var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */;
var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false);
- var inLoopBodyBlock = container.kind === 234 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false);
+ var inLoopBodyBlock = container.kind === 235 /* SyntaxKind.Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false);
links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock));
}
else {
@@ -85231,20 +86862,20 @@ var ts;
}
function isValueAliasDeclaration(node) {
switch (node.kind) {
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return isAliasResolvedToValue(getSymbolOfNode(node));
- case 266 /* ImportClause */:
- case 267 /* NamespaceImport */:
- case 269 /* ImportSpecifier */:
- case 274 /* ExportSpecifier */:
+ case 267 /* SyntaxKind.ImportClause */:
+ case 268 /* SyntaxKind.NamespaceImport */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
+ case 275 /* SyntaxKind.ExportSpecifier */:
var symbol = getSymbolOfNode(node);
return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol);
- case 271 /* ExportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
var exportClause = node.exportClause;
return !!exportClause && (ts.isNamespaceExport(exportClause) ||
ts.some(exportClause.elements, isValueAliasDeclaration));
- case 270 /* ExportAssignment */:
- return node.expression && node.expression.kind === 79 /* Identifier */ ?
+ case 271 /* SyntaxKind.ExportAssignment */:
+ return node.expression && node.expression.kind === 79 /* SyntaxKind.Identifier */ ?
isAliasResolvedToValue(getSymbolOfNode(node)) :
true;
}
@@ -85252,7 +86883,7 @@ var ts;
}
function isTopLevelValueImportEqualsWithEntityName(nodeIn) {
var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration);
- if (node === undefined || node.parent.kind !== 303 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) {
+ if (node === undefined || node.parent.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) {
// parent is not source file or it is not reference to internal module
return false;
}
@@ -85269,7 +86900,7 @@ var ts;
}
// const enums and modules that contain only const enums are not considered values from the emit perspective
// unless 'preserveConstEnums' option is set to true
- return !!(target.flags & 111551 /* Value */) &&
+ return !!(target.flags & 111551 /* SymbolFlags.Value */) &&
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target));
}
function isConstEnumOrConstEnumOnlyModule(s) {
@@ -85282,9 +86913,9 @@ var ts;
if (links === null || links === void 0 ? void 0 : links.referenced) {
return true;
}
- var target = getSymbolLinks(symbol).target; // TODO: GH#18217
- if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ &&
- target.flags & 111551 /* Value */ &&
+ var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
+ if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ &&
+ target.flags & 111551 /* SymbolFlags.Value */ &&
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
// An `export import ... =` of a value symbol is always considered referenced
return true;
@@ -85322,18 +86953,13 @@ var ts;
!isOptionalParameter(parameter) &&
!ts.isJSDocParameterTag(parameter) &&
!!parameter.initializer &&
- !ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */);
+ !ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */);
}
function isOptionalUninitializedParameterProperty(parameter) {
return strictNullChecks &&
isOptionalParameter(parameter) &&
!parameter.initializer &&
- ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */);
- }
- function isOptionalUninitializedParameter(parameter) {
- return !!strictNullChecks &&
- isOptionalParameter(parameter) &&
- !parameter.initializer;
+ ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */);
}
function isExpandoFunctionDeclaration(node) {
var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
@@ -85341,10 +86967,10 @@ var ts;
return false;
}
var symbol = getSymbolOfNode(declaration);
- if (!symbol || !(symbol.flags & 16 /* Function */)) {
+ if (!symbol || !(symbol.flags & 16 /* SymbolFlags.Function */)) {
return false;
}
- return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); });
+ return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* SymbolFlags.Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); });
}
function getPropertiesOfContainerFunction(node) {
var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
@@ -85367,19 +86993,19 @@ var ts;
}
function canHaveConstantValue(node) {
switch (node.kind) {
- case 297 /* EnumMember */:
- case 205 /* PropertyAccessExpression */:
- case 206 /* ElementAccessExpression */:
+ case 299 /* SyntaxKind.EnumMember */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
return true;
}
return false;
}
function getConstantValue(node) {
- if (node.kind === 297 /* EnumMember */) {
+ if (node.kind === 299 /* SyntaxKind.EnumMember */) {
return getEnumMemberValue(node);
}
var symbol = getNodeLinks(node).resolvedSymbol;
- if (symbol && (symbol.flags & 8 /* EnumMember */)) {
+ if (symbol && (symbol.flags & 8 /* SymbolFlags.EnumMember */)) {
// inline property\index accesses only for const enums
var member = symbol.valueDeclaration;
if (ts.isEnumConst(member.parent)) {
@@ -85389,7 +87015,7 @@ var ts;
return undefined;
}
function isFunctionType(type) {
- return !!(type.flags & 524288 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0;
+ return !!(type.flags & 524288 /* TypeFlags.Object */) && getSignaturesOfType(type, 0 /* SignatureKind.Call */).length > 0;
}
function getTypeReferenceSerializationKind(typeNameIn, location) {
var _a, _b;
@@ -85405,14 +87031,14 @@ var ts;
// Resolve the symbol as a value to ensure the type can be reached at runtime during emit.
var isTypeOnly = false;
if (ts.isQualifiedName(typeName)) {
- var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location);
+ var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location);
isTypeOnly = !!((_a = rootValueSymbol === null || rootValueSymbol === void 0 ? void 0 : rootValueSymbol.declarations) === null || _a === void 0 ? void 0 : _a.every(ts.isTypeOnlyImportOrExportDeclaration));
}
- var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location);
- var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* Alias */ ? resolveAlias(valueSymbol) : valueSymbol;
+ var valueSymbol = resolveEntityName(typeName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location);
+ var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(valueSymbol) : valueSymbol;
isTypeOnly || (isTypeOnly = !!((_b = valueSymbol === null || valueSymbol === void 0 ? void 0 : valueSymbol.declarations) === null || _b === void 0 ? void 0 : _b.every(ts.isTypeOnlyImportOrExportDeclaration)));
// Resolve the symbol as a type so that we can provide a more useful hint for the type serializer.
- var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location);
+ var typeSymbol = resolveEntityName(typeName, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location);
if (resolvedSymbol && resolvedSymbol === typeSymbol) {
var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false);
if (globalPromiseSymbol && resolvedSymbol === globalPromiseSymbol) {
@@ -85431,28 +87057,28 @@ var ts;
if (isErrorType(type)) {
return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown;
}
- else if (type.flags & 3 /* AnyOrUnknown */) {
+ else if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) {
return ts.TypeReferenceSerializationKind.ObjectType;
}
- else if (isTypeAssignableToKind(type, 16384 /* Void */ | 98304 /* Nullable */ | 131072 /* Never */)) {
+ else if (isTypeAssignableToKind(type, 16384 /* TypeFlags.Void */ | 98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */)) {
return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType;
}
- else if (isTypeAssignableToKind(type, 528 /* BooleanLike */)) {
+ else if (isTypeAssignableToKind(type, 528 /* TypeFlags.BooleanLike */)) {
return ts.TypeReferenceSerializationKind.BooleanType;
}
- else if (isTypeAssignableToKind(type, 296 /* NumberLike */)) {
+ else if (isTypeAssignableToKind(type, 296 /* TypeFlags.NumberLike */)) {
return ts.TypeReferenceSerializationKind.NumberLikeType;
}
- else if (isTypeAssignableToKind(type, 2112 /* BigIntLike */)) {
+ else if (isTypeAssignableToKind(type, 2112 /* TypeFlags.BigIntLike */)) {
return ts.TypeReferenceSerializationKind.BigIntLikeType;
}
- else if (isTypeAssignableToKind(type, 402653316 /* StringLike */)) {
+ else if (isTypeAssignableToKind(type, 402653316 /* TypeFlags.StringLike */)) {
return ts.TypeReferenceSerializationKind.StringLikeType;
}
else if (isTupleType(type)) {
return ts.TypeReferenceSerializationKind.ArrayLikeType;
}
- else if (isTypeAssignableToKind(type, 12288 /* ESSymbolLike */)) {
+ else if (isTypeAssignableToKind(type, 12288 /* TypeFlags.ESSymbolLike */)) {
return ts.TypeReferenceSerializationKind.ESSymbolType;
}
else if (isFunctionType(type)) {
@@ -85468,37 +87094,37 @@ var ts;
function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) {
var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor);
if (!declaration) {
- return ts.factory.createToken(130 /* AnyKeyword */);
+ return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */);
}
// Get type of the symbol if this is the valid symbol otherwise get type at location
var symbol = getSymbolOfNode(declaration);
- var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */))
+ var type = symbol && !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 131072 /* SymbolFlags.Signature */))
? getWidenedLiteralType(getTypeOfSymbol(symbol))
: errorType;
- if (type.flags & 8192 /* UniqueESSymbol */ &&
+ if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ &&
type.symbol === symbol) {
- flags |= 1048576 /* AllowUniqueESSymbolType */;
+ flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */;
}
if (addUndefined) {
type = getOptionalType(type);
}
- return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker);
+ return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker);
}
function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) {
var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike);
if (!signatureDeclaration) {
- return ts.factory.createToken(130 /* AnyKeyword */);
+ return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */);
}
var signature = getSignatureFromDeclaration(signatureDeclaration);
- return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker);
+ return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker);
}
function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) {
var expr = ts.getParseTreeNode(exprIn, ts.isExpression);
if (!expr) {
- return ts.factory.createToken(130 /* AnyKeyword */);
+ return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */);
}
var type = getWidenedType(getRegularTypeOfExpression(expr));
- return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker);
+ return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker);
}
function hasGlobalName(name) {
return globals.has(ts.escapeLeadingUnderscores(name));
@@ -85517,7 +87143,7 @@ var ts;
location = getDeclarationContainer(parent);
}
}
- return resolveName(location, reference.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
+ return resolveName(location, reference.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
}
function getReferencedValueDeclaration(referenceIn) {
if (!ts.isGeneratedIdentifier(referenceIn)) {
@@ -85538,7 +87164,7 @@ var ts;
return false;
}
function literalTypeToNode(type, enclosing, tracker) {
- var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* Value */, enclosing, /*flags*/ undefined, tracker)
+ var enumResult = type.flags & 1024 /* TypeFlags.EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* SymbolFlags.Value */, enclosing, /*flags*/ undefined, tracker)
: type === trueType ? ts.factory.createTrue() : type === falseType && ts.factory.createFalse();
if (enumResult)
return enumResult;
@@ -85581,7 +87207,7 @@ var ts;
if (resolvedTypeReferenceDirectives) {
// populate reverse mapping: file path -> type reference directive that was resolved to this file
fileToDirective = new ts.Map();
- resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) {
+ resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key, mode) {
if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
return;
}
@@ -85589,7 +87215,7 @@ var ts;
if (file) {
// Add the transitive closure of path references loaded by this file (as long as they are not)
// part of an existing type reference.
- addReferencedFilesToTypeDirective(file, key);
+ addReferencedFilesToTypeDirective(file, key, mode);
}
});
}
@@ -85646,18 +87272,18 @@ var ts;
isLateBound: function (nodeIn) {
var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration);
var symbol = node && getSymbolOfNode(node);
- return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* Late */);
+ return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */);
},
getJsxFactoryEntity: getJsxFactoryEntity,
getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity,
getAllAccessorDeclarations: function (accessor) {
accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217
- var otherKind = accessor.kind === 172 /* SetAccessor */ ? 171 /* GetAccessor */ : 172 /* SetAccessor */;
+ var otherKind = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? 172 /* SyntaxKind.GetAccessor */ : 173 /* SyntaxKind.SetAccessor */;
var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind);
var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor;
var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor;
- var setAccessor = accessor.kind === 172 /* SetAccessor */ ? accessor : otherAccessor;
- var getAccessor = accessor.kind === 171 /* GetAccessor */ ? accessor : otherAccessor;
+ var setAccessor = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? accessor : otherAccessor;
+ var getAccessor = accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? accessor : otherAccessor;
return {
firstAccessor: firstAccessor,
secondAccessor: secondAccessor,
@@ -85673,7 +87299,7 @@ var ts;
},
getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) {
var n = ts.getParseTreeNode(node);
- ts.Debug.assert(n && n.kind === 303 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile");
+ ts.Debug.assert(n && n.kind === 305 /* SyntaxKind.SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile");
var sym = getSymbolOfNode(node);
if (!sym) {
return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled);
@@ -85710,7 +87336,7 @@ var ts;
return false;
}
function isInHeritageClause(node) {
- return node.parent && node.parent.kind === 227 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 290 /* HeritageClause */;
+ return node.parent && node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 291 /* SyntaxKind.HeritageClause */;
}
// defined here to avoid outer scope pollution
function getTypeReferenceDirectivesForEntityName(node) {
@@ -85721,9 +87347,9 @@ var ts;
// property access can only be used as values, or types when within an expression with type arguments inside a heritage clause
// qualified names can only be used as types\namespaces
// identifiers are treated as values only if they appear in type queries
- var meaning = 788968 /* Type */ | 1920 /* Namespace */;
- if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 205 /* PropertyAccessExpression */ && !isInHeritageClause(node))) {
- meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
+ var meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */;
+ if ((node.kind === 79 /* SyntaxKind.Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && !isInHeritageClause(node))) {
+ meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */;
}
var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true);
return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined;
@@ -85770,7 +87396,7 @@ var ts;
break;
}
}
- if (current.valueDeclaration && current.valueDeclaration.kind === 303 /* SourceFile */ && current.flags & 512 /* ValueModule */) {
+ if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SyntaxKind.SourceFile */ && current.flags & 512 /* SymbolFlags.ValueModule */) {
return false;
}
// check that at least one declaration of top level symbol originates from type declaration file
@@ -85783,27 +87409,27 @@ var ts;
}
return false;
}
- function addReferencedFilesToTypeDirective(file, key) {
+ function addReferencedFilesToTypeDirective(file, key, mode) {
if (fileToDirective.has(file.path))
return;
- fileToDirective.set(file.path, key);
+ fileToDirective.set(file.path, [key, mode]);
for (var _i = 0, _a = file.referencedFiles; _i < _a.length; _i++) {
- var fileName = _a[_i].fileName;
+ var _b = _a[_i], fileName = _b.fileName, resolutionMode = _b.resolutionMode;
var resolvedFile = ts.resolveTripleslashReference(fileName, file.fileName);
var referencedFile = host.getSourceFile(resolvedFile);
if (referencedFile) {
- addReferencedFilesToTypeDirective(referencedFile, key);
+ addReferencedFilesToTypeDirective(referencedFile, key, resolutionMode || file.impliedNodeFormat);
}
}
}
}
function getExternalModuleFileFromDeclaration(declaration) {
- var specifier = declaration.kind === 260 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration);
+ var specifier = declaration.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration);
var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217
if (!moduleSymbol) {
return undefined;
}
- return ts.getDeclarationOfKind(moduleSymbol, 303 /* SourceFile */);
+ return ts.getDeclarationOfKind(moduleSymbol, 305 /* SyntaxKind.SourceFile */);
}
function initializeTypeChecker() {
// Bind all source files and propagate errors
@@ -85874,7 +87500,7 @@ var ts;
getSymbolLinks(undefinedSymbol).type = undefinedWideningType;
getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", /*arity*/ 0, /*reportErrors*/ true);
getSymbolLinks(unknownSymbol).type = errorType;
- getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* Anonymous */, globalThisSymbol);
+ getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* ObjectFlags.Anonymous */, globalThisSymbol);
// Initialize special types
globalArrayType = getGlobalType("Array", /*arity*/ 1, /*reportErrors*/ true);
globalObjectType = getGlobalType("Object", /*arity*/ 0, /*reportErrors*/ true);
@@ -85936,28 +87562,28 @@ var ts;
function checkExternalEmitHelpers(location, helpers) {
if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) {
var sourceFile = ts.getSourceFileOfNode(location);
- if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608 /* Ambient */)) {
+ if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* NodeFlags.Ambient */)) {
var helpersModule = resolveHelpersModule(sourceFile, location);
if (helpersModule !== unknownSymbol) {
var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
- for (var helper = 1 /* FirstEmitHelper */; helper <= 4194304 /* LastEmitHelper */; helper <<= 1) {
+ for (var helper = 1 /* ExternalEmitHelpers.FirstEmitHelper */; helper <= 4194304 /* ExternalEmitHelpers.LastEmitHelper */; helper <<= 1) {
if (uncheckedHelpers & helper) {
var name = getHelperName(helper);
- var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */);
+ var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* SymbolFlags.Value */);
if (!symbol) {
error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name);
}
- else if (helper & 524288 /* ClassPrivateFieldGet */) {
+ else if (helper & 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */) {
if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 3; })) {
error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 4);
}
}
- else if (helper & 1048576 /* ClassPrivateFieldSet */) {
+ else if (helper & 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */) {
if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 4; })) {
error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 5);
}
}
- else if (helper & 1024 /* SpreadArray */) {
+ else if (helper & 1024 /* ExternalEmitHelpers.SpreadArray */) {
if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 2; })) {
error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 3);
}
@@ -85971,29 +87597,29 @@ var ts;
}
function getHelperName(helper) {
switch (helper) {
- case 1 /* Extends */: return "__extends";
- case 2 /* Assign */: return "__assign";
- case 4 /* Rest */: return "__rest";
- case 8 /* Decorate */: return "__decorate";
- case 16 /* Metadata */: return "__metadata";
- case 32 /* Param */: return "__param";
- case 64 /* Awaiter */: return "__awaiter";
- case 128 /* Generator */: return "__generator";
- case 256 /* Values */: return "__values";
- case 512 /* Read */: return "__read";
- case 1024 /* SpreadArray */: return "__spreadArray";
- case 2048 /* Await */: return "__await";
- case 4096 /* AsyncGenerator */: return "__asyncGenerator";
- case 8192 /* AsyncDelegator */: return "__asyncDelegator";
- case 16384 /* AsyncValues */: return "__asyncValues";
- case 32768 /* ExportStar */: return "__exportStar";
- case 65536 /* ImportStar */: return "__importStar";
- case 131072 /* ImportDefault */: return "__importDefault";
- case 262144 /* MakeTemplateObject */: return "__makeTemplateObject";
- case 524288 /* ClassPrivateFieldGet */: return "__classPrivateFieldGet";
- case 1048576 /* ClassPrivateFieldSet */: return "__classPrivateFieldSet";
- case 2097152 /* ClassPrivateFieldIn */: return "__classPrivateFieldIn";
- case 4194304 /* CreateBinding */: return "__createBinding";
+ case 1 /* ExternalEmitHelpers.Extends */: return "__extends";
+ case 2 /* ExternalEmitHelpers.Assign */: return "__assign";
+ case 4 /* ExternalEmitHelpers.Rest */: return "__rest";
+ case 8 /* ExternalEmitHelpers.Decorate */: return "__decorate";
+ case 16 /* ExternalEmitHelpers.Metadata */: return "__metadata";
+ case 32 /* ExternalEmitHelpers.Param */: return "__param";
+ case 64 /* ExternalEmitHelpers.Awaiter */: return "__awaiter";
+ case 128 /* ExternalEmitHelpers.Generator */: return "__generator";
+ case 256 /* ExternalEmitHelpers.Values */: return "__values";
+ case 512 /* ExternalEmitHelpers.Read */: return "__read";
+ case 1024 /* ExternalEmitHelpers.SpreadArray */: return "__spreadArray";
+ case 2048 /* ExternalEmitHelpers.Await */: return "__await";
+ case 4096 /* ExternalEmitHelpers.AsyncGenerator */: return "__asyncGenerator";
+ case 8192 /* ExternalEmitHelpers.AsyncDelegator */: return "__asyncDelegator";
+ case 16384 /* ExternalEmitHelpers.AsyncValues */: return "__asyncValues";
+ case 32768 /* ExternalEmitHelpers.ExportStar */: return "__exportStar";
+ case 65536 /* ExternalEmitHelpers.ImportStar */: return "__importStar";
+ case 131072 /* ExternalEmitHelpers.ImportDefault */: return "__importDefault";
+ case 262144 /* ExternalEmitHelpers.MakeTemplateObject */: return "__makeTemplateObject";
+ case 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */: return "__classPrivateFieldGet";
+ case 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */: return "__classPrivateFieldSet";
+ case 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */: return "__classPrivateFieldIn";
+ case 4194304 /* ExternalEmitHelpers.CreateBinding */: return "__createBinding";
default: return ts.Debug.fail("Unrecognized helper");
}
}
@@ -86012,14 +87638,14 @@ var ts;
return false;
}
if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) {
- if (node.kind === 168 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) {
+ if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !ts.nodeIsPresent(node.body)) {
return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload);
}
else {
return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here);
}
}
- else if (node.kind === 171 /* GetAccessor */ || node.kind === 172 /* SetAccessor */) {
+ else if (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) {
var accessors = ts.getAllAccessorDeclarations(node.parent.members, node);
if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) {
return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name);
@@ -86033,64 +87659,69 @@ var ts;
return quickResult;
}
var lastStatic, lastDeclare, lastAsync, lastOverride;
- var flags = 0 /* None */;
+ var flags = 0 /* ModifierFlags.None */;
for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
var modifier = _a[_i];
- if (modifier.kind !== 144 /* ReadonlyKeyword */) {
- if (node.kind === 165 /* PropertySignature */ || node.kind === 167 /* MethodSignature */) {
+ if (modifier.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) {
+ if (node.kind === 166 /* SyntaxKind.PropertySignature */ || node.kind === 168 /* SyntaxKind.MethodSignature */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind));
}
- if (node.kind === 175 /* IndexSignature */ && (modifier.kind !== 124 /* StaticKeyword */ || !ts.isClassLike(node.parent))) {
+ if (node.kind === 176 /* SyntaxKind.IndexSignature */ && (modifier.kind !== 124 /* SyntaxKind.StaticKeyword */ || !ts.isClassLike(node.parent))) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind));
}
}
+ if (modifier.kind !== 101 /* SyntaxKind.InKeyword */ && modifier.kind !== 144 /* SyntaxKind.OutKeyword */) {
+ if (node.kind === 163 /* SyntaxKind.TypeParameter */) {
+ return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_parameter, ts.tokenToString(modifier.kind));
+ }
+ }
switch (modifier.kind) {
- case 85 /* ConstKeyword */:
- if (node.kind !== 259 /* EnumDeclaration */) {
- return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* ConstKeyword */));
+ case 85 /* SyntaxKind.ConstKeyword */:
+ if (node.kind !== 260 /* SyntaxKind.EnumDeclaration */) {
+ return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* SyntaxKind.ConstKeyword */));
}
break;
- case 158 /* OverrideKeyword */:
+ case 159 /* SyntaxKind.OverrideKeyword */:
// If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property.
- if (flags & 16384 /* Override */) {
+ if (flags & 16384 /* ModifierFlags.Override */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "override");
}
- else if (flags & 2 /* Ambient */) {
+ else if (flags & 2 /* ModifierFlags.Ambient */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare");
}
- else if (flags & 64 /* Readonly */) {
+ else if (flags & 64 /* ModifierFlags.Readonly */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "readonly");
}
- else if (flags & 256 /* Async */) {
+ else if (flags & 256 /* ModifierFlags.Async */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "async");
}
- flags |= 16384 /* Override */;
+ flags |= 16384 /* ModifierFlags.Override */;
lastOverride = modifier;
break;
- case 123 /* PublicKeyword */:
- case 122 /* ProtectedKeyword */:
- case 121 /* PrivateKeyword */:
+ case 123 /* SyntaxKind.PublicKeyword */:
+ case 122 /* SyntaxKind.ProtectedKeyword */:
+ case 121 /* SyntaxKind.PrivateKeyword */:
var text = visibilityToString(ts.modifierToFlag(modifier.kind));
- if (flags & 28 /* AccessibilityModifier */) {
+ if (flags & 28 /* ModifierFlags.AccessibilityModifier */) {
return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen);
}
- else if (flags & 16384 /* Override */) {
+ else if (flags & 16384 /* ModifierFlags.Override */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "override");
}
- else if (flags & 32 /* Static */) {
+ else if (flags & 32 /* ModifierFlags.Static */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static");
}
- else if (flags & 64 /* Readonly */) {
+ else if (flags & 64 /* ModifierFlags.Readonly */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly");
}
- else if (flags & 256 /* Async */) {
+ else if (flags & 256 /* ModifierFlags.Async */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async");
}
- else if (node.parent.kind === 261 /* ModuleBlock */ || node.parent.kind === 303 /* SourceFile */) {
+ else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text);
}
- else if (flags & 128 /* Abstract */) {
- if (modifier.kind === 121 /* PrivateKeyword */) {
+ else if (flags & 128 /* ModifierFlags.Abstract */) {
+ if (modifier.kind === 121 /* SyntaxKind.PrivateKeyword */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract");
}
else {
@@ -86102,170 +87733,185 @@ var ts;
}
flags |= ts.modifierToFlag(modifier.kind);
break;
- case 124 /* StaticKeyword */:
- if (flags & 32 /* Static */) {
+ case 124 /* SyntaxKind.StaticKeyword */:
+ if (flags & 32 /* ModifierFlags.Static */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static");
}
- else if (flags & 64 /* Readonly */) {
+ else if (flags & 64 /* ModifierFlags.Readonly */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly");
}
- else if (flags & 256 /* Async */) {
+ else if (flags & 256 /* ModifierFlags.Async */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async");
}
- else if (node.parent.kind === 261 /* ModuleBlock */ || node.parent.kind === 303 /* SourceFile */) {
+ else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static");
}
- else if (node.kind === 163 /* Parameter */) {
+ else if (node.kind === 164 /* SyntaxKind.Parameter */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static");
}
- else if (flags & 128 /* Abstract */) {
+ else if (flags & 128 /* ModifierFlags.Abstract */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract");
}
- else if (flags & 16384 /* Override */) {
+ else if (flags & 16384 /* ModifierFlags.Override */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "override");
}
- flags |= 32 /* Static */;
+ flags |= 32 /* ModifierFlags.Static */;
lastStatic = modifier;
break;
- case 144 /* ReadonlyKeyword */:
- if (flags & 64 /* Readonly */) {
+ case 145 /* SyntaxKind.ReadonlyKeyword */:
+ if (flags & 64 /* ModifierFlags.Readonly */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly");
}
- else if (node.kind !== 166 /* PropertyDeclaration */ && node.kind !== 165 /* PropertySignature */ && node.kind !== 175 /* IndexSignature */ && node.kind !== 163 /* Parameter */) {
+ else if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */ && node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 164 /* SyntaxKind.Parameter */) {
// If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property.
return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature);
}
- flags |= 64 /* Readonly */;
+ flags |= 64 /* ModifierFlags.Readonly */;
break;
- case 93 /* ExportKeyword */:
- if (flags & 1 /* Export */) {
+ case 93 /* SyntaxKind.ExportKeyword */:
+ if (flags & 1 /* ModifierFlags.Export */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export");
}
- else if (flags & 2 /* Ambient */) {
+ else if (flags & 2 /* ModifierFlags.Ambient */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare");
}
- else if (flags & 128 /* Abstract */) {
+ else if (flags & 128 /* ModifierFlags.Abstract */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract");
}
- else if (flags & 256 /* Async */) {
+ else if (flags & 256 /* ModifierFlags.Async */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async");
}
else if (ts.isClassLike(node.parent)) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "export");
}
- else if (node.kind === 163 /* Parameter */) {
+ else if (node.kind === 164 /* SyntaxKind.Parameter */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export");
}
- flags |= 1 /* Export */;
+ flags |= 1 /* ModifierFlags.Export */;
break;
- case 88 /* DefaultKeyword */:
- var container = node.parent.kind === 303 /* SourceFile */ ? node.parent : node.parent.parent;
- if (container.kind === 260 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) {
+ case 88 /* SyntaxKind.DefaultKeyword */:
+ var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent;
+ if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) {
return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module);
}
- else if (!(flags & 1 /* Export */)) {
+ else if (!(flags & 1 /* ModifierFlags.Export */)) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "default");
}
- flags |= 512 /* Default */;
+ flags |= 512 /* ModifierFlags.Default */;
break;
- case 135 /* DeclareKeyword */:
- if (flags & 2 /* Ambient */) {
+ case 135 /* SyntaxKind.DeclareKeyword */:
+ if (flags & 2 /* ModifierFlags.Ambient */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare");
}
- else if (flags & 256 /* Async */) {
+ else if (flags & 256 /* ModifierFlags.Async */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
}
- else if (flags & 16384 /* Override */) {
+ else if (flags & 16384 /* ModifierFlags.Override */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "override");
}
else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "declare");
}
- else if (node.kind === 163 /* Parameter */) {
+ else if (node.kind === 164 /* SyntaxKind.Parameter */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");
}
- else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 261 /* ModuleBlock */) {
+ else if ((node.parent.flags & 16777216 /* NodeFlags.Ambient */) && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */) {
return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
}
else if (ts.isPrivateIdentifierClassElementDeclaration(node)) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare");
}
- flags |= 2 /* Ambient */;
+ flags |= 2 /* ModifierFlags.Ambient */;
lastDeclare = modifier;
break;
- case 126 /* AbstractKeyword */:
- if (flags & 128 /* Abstract */) {
+ case 126 /* SyntaxKind.AbstractKeyword */:
+ if (flags & 128 /* ModifierFlags.Abstract */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract");
}
- if (node.kind !== 256 /* ClassDeclaration */ &&
- node.kind !== 179 /* ConstructorType */) {
- if (node.kind !== 168 /* MethodDeclaration */ &&
- node.kind !== 166 /* PropertyDeclaration */ &&
- node.kind !== 171 /* GetAccessor */ &&
- node.kind !== 172 /* SetAccessor */) {
+ if (node.kind !== 257 /* SyntaxKind.ClassDeclaration */ &&
+ node.kind !== 180 /* SyntaxKind.ConstructorType */) {
+ if (node.kind !== 169 /* SyntaxKind.MethodDeclaration */ &&
+ node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ &&
+ node.kind !== 172 /* SyntaxKind.GetAccessor */ &&
+ node.kind !== 173 /* SyntaxKind.SetAccessor */) {
return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration);
}
- if (!(node.parent.kind === 256 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) {
+ if (!(node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */))) {
return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class);
}
- if (flags & 32 /* Static */) {
+ if (flags & 32 /* ModifierFlags.Static */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract");
}
- if (flags & 8 /* Private */) {
+ if (flags & 8 /* ModifierFlags.Private */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract");
}
- if (flags & 256 /* Async */ && lastAsync) {
+ if (flags & 256 /* ModifierFlags.Async */ && lastAsync) {
return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract");
}
- if (flags & 16384 /* Override */) {
+ if (flags & 16384 /* ModifierFlags.Override */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override");
}
}
- if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* PrivateIdentifier */) {
+ if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* SyntaxKind.PrivateIdentifier */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract");
}
- flags |= 128 /* Abstract */;
+ flags |= 128 /* ModifierFlags.Abstract */;
break;
- case 131 /* AsyncKeyword */:
- if (flags & 256 /* Async */) {
+ case 131 /* SyntaxKind.AsyncKeyword */:
+ if (flags & 256 /* ModifierFlags.Async */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async");
}
- else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) {
+ else if (flags & 2 /* ModifierFlags.Ambient */ || node.parent.flags & 16777216 /* NodeFlags.Ambient */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
}
- else if (node.kind === 163 /* Parameter */) {
+ else if (node.kind === 164 /* SyntaxKind.Parameter */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async");
}
- if (flags & 128 /* Abstract */) {
+ if (flags & 128 /* ModifierFlags.Abstract */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract");
}
- flags |= 256 /* Async */;
+ flags |= 256 /* ModifierFlags.Async */;
lastAsync = modifier;
break;
+ case 101 /* SyntaxKind.InKeyword */:
+ case 144 /* SyntaxKind.OutKeyword */:
+ var inOutFlag = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? 32768 /* ModifierFlags.In */ : 65536 /* ModifierFlags.Out */;
+ var inOutText = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? "in" : "out";
+ if (node.kind !== 163 /* SyntaxKind.TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) {
+ return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText);
+ }
+ if (flags & inOutFlag) {
+ return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, inOutText);
+ }
+ if (inOutFlag & 32768 /* ModifierFlags.In */ && flags & 65536 /* ModifierFlags.Out */) {
+ return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "in", "out");
+ }
+ flags |= inOutFlag;
+ break;
}
}
- if (node.kind === 170 /* Constructor */) {
- if (flags & 32 /* Static */) {
+ if (node.kind === 171 /* SyntaxKind.Constructor */) {
+ if (flags & 32 /* ModifierFlags.Static */) {
return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static");
}
- if (flags & 16384 /* Override */) {
+ if (flags & 16384 /* ModifierFlags.Override */) {
return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217
}
- if (flags & 256 /* Async */) {
+ if (flags & 256 /* ModifierFlags.Async */) {
return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async");
}
return false;
}
- else if ((node.kind === 265 /* ImportDeclaration */ || node.kind === 264 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) {
+ else if ((node.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) && flags & 2 /* ModifierFlags.Ambient */) {
return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare");
}
- else if (node.kind === 163 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) {
+ else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) {
return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern);
}
- else if (node.kind === 163 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && node.dotDotDotToken) {
+ else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && node.dotDotDotToken) {
return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter);
}
- if (flags & 256 /* Async */) {
+ if (flags & 256 /* ModifierFlags.Async */) {
return checkGrammarAsyncModifier(node, lastAsync);
}
return false;
@@ -86283,40 +87929,41 @@ var ts;
}
function shouldReportBadModifier(node) {
switch (node.kind) {
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 170 /* Constructor */:
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 175 /* IndexSignature */:
- case 260 /* ModuleDeclaration */:
- case 265 /* ImportDeclaration */:
- case 264 /* ImportEqualsDeclaration */:
- case 271 /* ExportDeclaration */:
- case 270 /* ExportAssignment */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
- case 163 /* Parameter */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 176 /* SyntaxKind.IndexSignature */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
+ case 271 /* SyntaxKind.ExportAssignment */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 164 /* SyntaxKind.Parameter */:
+ case 163 /* SyntaxKind.TypeParameter */:
return false;
default:
- if (node.parent.kind === 261 /* ModuleBlock */ || node.parent.kind === 303 /* SourceFile */) {
+ if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) {
return false;
}
switch (node.kind) {
- case 255 /* FunctionDeclaration */:
- return nodeHasAnyModifiersExcept(node, 131 /* AsyncKeyword */);
- case 256 /* ClassDeclaration */:
- case 179 /* ConstructorType */:
- return nodeHasAnyModifiersExcept(node, 126 /* AbstractKeyword */);
- case 257 /* InterfaceDeclaration */:
- case 236 /* VariableStatement */:
- case 258 /* TypeAliasDeclaration */:
- case 169 /* ClassStaticBlockDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ return nodeHasAnyModifiersExcept(node, 131 /* SyntaxKind.AsyncKeyword */);
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 180 /* SyntaxKind.ConstructorType */:
+ return nodeHasAnyModifiersExcept(node, 126 /* SyntaxKind.AbstractKeyword */);
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 237 /* SyntaxKind.VariableStatement */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 170 /* SyntaxKind.ClassStaticBlockDeclaration */:
return true;
- case 259 /* EnumDeclaration */:
- return nodeHasAnyModifiersExcept(node, 85 /* ConstKeyword */);
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ return nodeHasAnyModifiersExcept(node, 85 /* SyntaxKind.ConstKeyword */);
default:
ts.Debug.fail();
}
@@ -86327,10 +87974,10 @@ var ts;
}
function checkGrammarAsyncModifier(node, asyncModifier) {
switch (node.kind) {
- case 168 /* MethodDeclaration */:
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
return false;
}
return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async");
@@ -86359,7 +88006,7 @@ var ts;
if (i !== (parameterCount - 1)) {
return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
}
- if (!(parameter.flags & 8388608 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070
+ if (!(parameter.flags & 16777216 /* NodeFlags.Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070
checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
}
if (parameter.questionToken) {
@@ -86384,7 +88031,7 @@ var ts;
return ts.filter(parameters, function (parameter) { return !!parameter.initializer || ts.isBindingPattern(parameter.name) || ts.isRestParameter(parameter); });
}
function checkGrammarForUseStrictSimpleParameterList(node) {
- if (languageVersion >= 3 /* ES2016 */) {
+ if (languageVersion >= 3 /* ScriptTarget.ES2016 */) {
var useStrictDirective_1 = node.body && ts.isBlock(node.body) && ts.findUseStrictPrologue(node.body.statements);
if (useStrictDirective_1) {
var nonSimpleParameters = getNonSimpleParameters(node.parameters);
@@ -86419,7 +88066,7 @@ var ts;
return false;
}
if (node.typeParameters && !(ts.length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) {
- if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Mts */, ".cts" /* Cts */])) {
+ if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */])) {
grammarErrorOnNode(node.typeParameters[0], ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint);
}
}
@@ -86455,7 +88102,7 @@ var ts;
return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation);
}
var type = getTypeFromTypeNode(parameter.type);
- if (someType(type, function (t) { return !!(t.flags & 8576 /* StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) {
+ if (someType(type, function (t) { return !!(t.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) {
return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead);
}
if (!everyType(type, isValidIndexKeyType)) {
@@ -86484,7 +88131,7 @@ var ts;
checkGrammarForAtLeastOneTypeArgument(node, typeArguments);
}
function checkGrammarTaggedTemplateChain(node) {
- if (node.questionDotToken || node.flags & 32 /* OptionalChain */) {
+ if (node.questionDotToken || node.flags & 32 /* NodeFlags.OptionalChain */) {
return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain);
}
return false;
@@ -86501,6 +88148,9 @@ var ts;
return ts.some(types, checkGrammarExpressionWithTypeArguments);
}
function checkGrammarExpressionWithTypeArguments(node) {
+ if (ts.isExpressionWithTypeArguments(node) && ts.isImportKeyword(node.expression) && node.typeArguments) {
+ return grammarErrorOnNode(node, ts.Diagnostics.This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments);
+ }
return checkGrammarTypeArguments(node, node.typeArguments);
}
function checkGrammarClassDeclarationHeritageClauses(node) {
@@ -86509,7 +88159,7 @@ var ts;
if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) {
for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) {
var heritageClause = _a[_i];
- if (heritageClause.token === 94 /* ExtendsKeyword */) {
+ if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) {
if (seenExtendsClause) {
return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen);
}
@@ -86522,7 +88172,7 @@ var ts;
seenExtendsClause = true;
}
else {
- ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */);
+ ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */);
if (seenImplementsClause) {
return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen);
}
@@ -86538,14 +88188,14 @@ var ts;
if (node.heritageClauses) {
for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) {
var heritageClause = _a[_i];
- if (heritageClause.token === 94 /* ExtendsKeyword */) {
+ if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) {
if (seenExtendsClause) {
return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen);
}
seenExtendsClause = true;
}
else {
- ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */);
+ ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */);
return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause);
}
// Grammar checking heritageClause inside class declaration
@@ -86556,21 +88206,21 @@ var ts;
}
function checkGrammarComputedPropertyName(node) {
// If node is not a computedPropertyName, just skip the grammar checking
- if (node.kind !== 161 /* ComputedPropertyName */) {
+ if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) {
return false;
}
var computedPropertyName = node;
- if (computedPropertyName.expression.kind === 220 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) {
+ if (computedPropertyName.expression.kind === 221 /* SyntaxKind.BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) {
return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name);
}
return false;
}
function checkGrammarForGenerator(node) {
if (node.asteriskToken) {
- ts.Debug.assert(node.kind === 255 /* FunctionDeclaration */ ||
- node.kind === 212 /* FunctionExpression */ ||
- node.kind === 168 /* MethodDeclaration */);
- if (node.flags & 8388608 /* Ambient */) {
+ ts.Debug.assert(node.kind === 256 /* SyntaxKind.FunctionDeclaration */ ||
+ node.kind === 213 /* SyntaxKind.FunctionExpression */ ||
+ node.kind === 169 /* SyntaxKind.MethodDeclaration */);
+ if (node.flags & 16777216 /* NodeFlags.Ambient */) {
return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context);
}
if (!node.body) {
@@ -86588,7 +88238,7 @@ var ts;
var seen = new ts.Map();
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
var prop = _a[_i];
- if (prop.kind === 296 /* SpreadAssignment */) {
+ if (prop.kind === 298 /* SyntaxKind.SpreadAssignment */) {
if (inDestructuring) {
// a rest property cannot be destructured any further
var expression = ts.skipParentheses(prop.expression);
@@ -86599,23 +88249,23 @@ var ts;
continue;
}
var name = prop.name;
- if (name.kind === 161 /* ComputedPropertyName */) {
+ if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) {
// If the name is not a ComputedPropertyName, the grammar checking will skip it
checkGrammarComputedPropertyName(name);
}
- if (prop.kind === 295 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) {
+ if (prop.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) {
// having objectAssignmentInitializer is only valid in ObjectAssignmentPattern
// outside of destructuring it is a syntax error
grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern);
}
- if (name.kind === 80 /* PrivateIdentifier */) {
+ if (name.kind === 80 /* SyntaxKind.PrivateIdentifier */) {
grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
}
// Modifiers are never allowed on properties except for 'async' on a method declaration
if (prop.modifiers) {
for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) {
var mod = _c[_b];
- if (mod.kind !== 131 /* AsyncKeyword */ || prop.kind !== 168 /* MethodDeclaration */) {
+ if (mod.kind !== 131 /* SyntaxKind.AsyncKeyword */ || prop.kind !== 169 /* SyntaxKind.MethodDeclaration */) {
grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod));
}
}
@@ -86630,25 +88280,25 @@ var ts;
// and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields
var currentKind = void 0;
switch (prop.kind) {
- case 295 /* ShorthandPropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context);
// falls through
- case 294 /* PropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
// Grammar checking for computedPropertyName and shorthandPropertyAssignment
checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional);
- if (name.kind === 8 /* NumericLiteral */) {
+ if (name.kind === 8 /* SyntaxKind.NumericLiteral */) {
checkGrammarNumericLiteral(name);
}
- currentKind = 4 /* PropertyAssignment */;
+ currentKind = 4 /* DeclarationMeaning.PropertyAssignment */;
break;
- case 168 /* MethodDeclaration */:
- currentKind = 8 /* Method */;
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ currentKind = 8 /* DeclarationMeaning.Method */;
break;
- case 171 /* GetAccessor */:
- currentKind = 1 /* GetAccessor */;
+ case 172 /* SyntaxKind.GetAccessor */:
+ currentKind = 1 /* DeclarationMeaning.GetAccessor */;
break;
- case 172 /* SetAccessor */:
- currentKind = 2 /* SetAccessor */;
+ case 173 /* SyntaxKind.SetAccessor */:
+ currentKind = 2 /* DeclarationMeaning.SetAccessor */;
break;
default:
throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind);
@@ -86663,14 +88313,14 @@ var ts;
seen.set(effectiveName, currentKind);
}
else {
- if ((currentKind & 8 /* Method */) && (existingKind & 8 /* Method */)) {
+ if ((currentKind & 8 /* DeclarationMeaning.Method */) && (existingKind & 8 /* DeclarationMeaning.Method */)) {
grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name));
}
- else if ((currentKind & 4 /* PropertyAssignment */) && (existingKind & 4 /* PropertyAssignment */)) {
+ else if ((currentKind & 4 /* DeclarationMeaning.PropertyAssignment */) && (existingKind & 4 /* DeclarationMeaning.PropertyAssignment */)) {
grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name, ts.getTextOfNode(name));
}
- else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) {
- if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) {
+ else if ((currentKind & 3 /* DeclarationMeaning.GetOrSetAccessor */) && (existingKind & 3 /* DeclarationMeaning.GetOrSetAccessor */)) {
+ if (existingKind !== 3 /* DeclarationMeaning.GetOrSetAccessor */ && currentKind !== existingKind) {
seen.set(effectiveName, currentKind | existingKind);
}
else {
@@ -86690,7 +88340,7 @@ var ts;
var seen = new ts.Map();
for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) {
var attr = _a[_i];
- if (attr.kind === 286 /* JsxSpreadAttribute */) {
+ if (attr.kind === 287 /* SyntaxKind.JsxSpreadAttribute */) {
continue;
}
var name = attr.name, initializer = attr.initializer;
@@ -86700,7 +88350,7 @@ var ts;
else {
return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name);
}
- if (initializer && initializer.kind === 287 /* JsxExpression */ && !initializer.expression) {
+ if (initializer && initializer.kind === 288 /* SyntaxKind.JsxExpression */ && !initializer.expression) {
return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression);
}
}
@@ -86735,16 +88385,32 @@ var ts;
if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) {
return true;
}
- if (forInOrOfStatement.kind === 243 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) {
- if (!(forInOrOfStatement.flags & 32768 /* AwaitContext */)) {
+ if (forInOrOfStatement.kind === 244 /* SyntaxKind.ForOfStatement */ && forInOrOfStatement.awaitModifier) {
+ if (!(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */)) {
var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement);
if (ts.isInTopLevelContext(forInOrOfStatement)) {
if (!hasParseDiagnostics(sourceFile)) {
if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module));
}
- if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
- diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher));
+ switch (moduleKind) {
+ case ts.ModuleKind.Node16:
+ case ts.ModuleKind.NodeNext:
+ if (sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS) {
+ diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level));
+ break;
+ }
+ // fallthrough
+ case ts.ModuleKind.ES2022:
+ case ts.ModuleKind.ESNext:
+ case ts.ModuleKind.System:
+ if (languageVersion >= 4 /* ScriptTarget.ES2017 */) {
+ break;
+ }
+ // fallthrough
+ default:
+ diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher));
+ break;
}
}
}
@@ -86753,8 +88419,8 @@ var ts;
if (!hasParseDiagnostics(sourceFile)) {
var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules);
var func = ts.getContainingFunction(forInOrOfStatement);
- if (func && func.kind !== 170 /* Constructor */) {
- ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function.");
+ if (func && func.kind !== 171 /* SyntaxKind.Constructor */) {
+ ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) === 0, "Enclosing function should never be an async function.");
var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
ts.addRelatedInfo(diagnostic, relatedInfo);
}
@@ -86765,12 +88431,12 @@ var ts;
return false;
}
}
- if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* AwaitContext */) &&
+ if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */) &&
ts.isIdentifier(forInOrOfStatement.initializer) && forInOrOfStatement.initializer.escapedText === "async") {
grammarErrorOnNode(forInOrOfStatement.initializer, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_async);
return false;
}
- if (forInOrOfStatement.initializer.kind === 254 /* VariableDeclarationList */) {
+ if (forInOrOfStatement.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) {
var variableList = forInOrOfStatement.initializer;
if (!checkGrammarVariableDeclarationList(variableList)) {
var declarations = variableList.declarations;
@@ -86785,20 +88451,20 @@ var ts;
return false;
}
if (declarations.length > 1) {
- var diagnostic = forInOrOfStatement.kind === 242 /* ForInStatement */
+ var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */
? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement
: ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement;
return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic);
}
var firstDeclaration = declarations[0];
if (firstDeclaration.initializer) {
- var diagnostic = forInOrOfStatement.kind === 242 /* ForInStatement */
+ var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */
? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer
: ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer;
return grammarErrorOnNode(firstDeclaration.name, diagnostic);
}
if (firstDeclaration.type) {
- var diagnostic = forInOrOfStatement.kind === 242 /* ForInStatement */
+ var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */
? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation
: ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation;
return grammarErrorOnNode(firstDeclaration, diagnostic);
@@ -86808,22 +88474,22 @@ var ts;
return false;
}
function checkGrammarAccessor(accessor) {
- if (!(accessor.flags & 8388608 /* Ambient */) && (accessor.parent.kind !== 181 /* TypeLiteral */) && (accessor.parent.kind !== 257 /* InterfaceDeclaration */)) {
- if (languageVersion < 1 /* ES5 */) {
+ if (!(accessor.flags & 16777216 /* NodeFlags.Ambient */) && (accessor.parent.kind !== 182 /* SyntaxKind.TypeLiteral */) && (accessor.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */)) {
+ if (languageVersion < 1 /* ScriptTarget.ES5 */) {
return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
}
- if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(accessor.name)) {
+ if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(accessor.name)) {
return grammarErrorOnNode(accessor.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher);
}
- if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) {
+ if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) {
return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{");
}
}
if (accessor.body) {
- if (ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) {
+ if (ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) {
return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation);
}
- if (accessor.parent.kind === 181 /* TypeLiteral */ || accessor.parent.kind === 257 /* InterfaceDeclaration */) {
+ if (accessor.parent.kind === 182 /* SyntaxKind.TypeLiteral */ || accessor.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) {
return grammarErrorOnNode(accessor.body, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts);
}
}
@@ -86831,11 +88497,11 @@ var ts;
return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters);
}
if (!doesAccessorHaveCorrectParameterCount(accessor)) {
- return grammarErrorOnNode(accessor.name, accessor.kind === 171 /* GetAccessor */ ?
+ return grammarErrorOnNode(accessor.name, accessor.kind === 172 /* SyntaxKind.GetAccessor */ ?
ts.Diagnostics.A_get_accessor_cannot_have_parameters :
ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter);
}
- if (accessor.kind === 172 /* SetAccessor */) {
+ if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) {
if (accessor.type) {
return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation);
}
@@ -86857,47 +88523,46 @@ var ts;
* A set accessor has one parameter or a `this` parameter and one more parameter.
*/
function doesAccessorHaveCorrectParameterCount(accessor) {
- return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 171 /* GetAccessor */ ? 0 : 1);
+ return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 0 : 1);
}
function getAccessorThisParameter(accessor) {
- if (accessor.parameters.length === (accessor.kind === 171 /* GetAccessor */ ? 1 : 2)) {
+ if (accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 1 : 2)) {
return ts.getThisParameter(accessor);
}
}
function checkGrammarTypeOperatorNode(node) {
- if (node.operator === 153 /* UniqueKeyword */) {
- if (node.type.kind !== 150 /* SymbolKeyword */) {
- return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(150 /* SymbolKeyword */));
+ if (node.operator === 154 /* SyntaxKind.UniqueKeyword */) {
+ if (node.type.kind !== 151 /* SyntaxKind.SymbolKeyword */) {
+ return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */));
}
var parent = ts.walkUpParenthesizedTypes(node.parent);
if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) {
- parent = parent.parent;
- if (ts.isJSDocTypeTag(parent)) {
- // walk up past JSDoc comment node
- parent = parent.parent.parent;
+ var host_2 = ts.getJSDocHost(parent);
+ if (host_2) {
+ parent = ts.getSingleVariableOfVariableStatement(host_2) || host_2;
}
}
switch (parent.kind) {
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
var decl = parent;
- if (decl.name.kind !== 79 /* Identifier */) {
+ if (decl.name.kind !== 79 /* SyntaxKind.Identifier */) {
return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name);
}
if (!ts.isVariableDeclarationInVariableStatement(decl)) {
return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement);
}
- if (!(decl.parent.flags & 2 /* Const */)) {
+ if (!(decl.parent.flags & 2 /* NodeFlags.Const */)) {
return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const);
}
break;
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
if (!ts.isStatic(parent) ||
!ts.hasEffectiveReadonlyModifier(parent)) {
return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly);
}
break;
- case 165 /* PropertySignature */:
- if (!ts.hasSyntacticModifier(parent, 64 /* Readonly */)) {
+ case 166 /* SyntaxKind.PropertySignature */:
+ if (!ts.hasSyntacticModifier(parent, 64 /* ModifierFlags.Readonly */)) {
return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly);
}
break;
@@ -86905,9 +88570,9 @@ var ts;
return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here);
}
}
- else if (node.operator === 144 /* ReadonlyKeyword */) {
- if (node.type.kind !== 182 /* ArrayType */ && node.type.kind !== 183 /* TupleType */) {
- return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(150 /* SymbolKeyword */));
+ else if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) {
+ if (node.type.kind !== 183 /* SyntaxKind.ArrayType */ && node.type.kind !== 184 /* SyntaxKind.TupleType */) {
+ return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */));
}
}
}
@@ -86920,10 +88585,10 @@ var ts;
if (checkGrammarFunctionLikeDeclaration(node)) {
return true;
}
- if (node.kind === 168 /* MethodDeclaration */) {
- if (node.parent.kind === 204 /* ObjectLiteralExpression */) {
+ if (node.kind === 169 /* SyntaxKind.MethodDeclaration */) {
+ if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) {
// We only disallow modifier on a method declaration if it is a property of object-literal-expression
- if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* AsyncKeyword */)) {
+ if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* SyntaxKind.AsyncKeyword */)) {
return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here);
}
else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) {
@@ -86941,7 +88606,7 @@ var ts;
}
}
if (ts.isClassLike(node.parent)) {
- if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) {
+ if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) {
return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher);
}
// Technically, computed properties in ambient contexts is disallowed
@@ -86949,17 +88614,17 @@ var ts;
// However, property declarations disallow computed names in general,
// and accessors are not allowed in ambient contexts in general,
// so this error only really matters for methods.
- if (node.flags & 8388608 /* Ambient */) {
+ if (node.flags & 16777216 /* NodeFlags.Ambient */) {
return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type);
}
- else if (node.kind === 168 /* MethodDeclaration */ && !node.body) {
+ else if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !node.body) {
return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type);
}
}
- else if (node.parent.kind === 257 /* InterfaceDeclaration */) {
+ else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) {
return 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);
}
- else if (node.parent.kind === 181 /* TypeLiteral */) {
+ else if (node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) {
return 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);
}
}
@@ -86970,11 +88635,11 @@ var ts;
return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary);
}
switch (current.kind) {
- case 249 /* LabeledStatement */:
+ case 250 /* SyntaxKind.LabeledStatement */:
if (node.label && current.label.escapedText === node.label.escapedText) {
// found matching label - verify that label usage is correct
// continue can only target labels that are on iteration statements
- var isMisplacedContinueLabel = node.kind === 244 /* ContinueStatement */
+ var isMisplacedContinueLabel = node.kind === 245 /* SyntaxKind.ContinueStatement */
&& !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true);
if (isMisplacedContinueLabel) {
return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement);
@@ -86982,8 +88647,8 @@ var ts;
return false;
}
break;
- case 248 /* SwitchStatement */:
- if (node.kind === 245 /* BreakStatement */ && !node.label) {
+ case 249 /* SyntaxKind.SwitchStatement */:
+ if (node.kind === 246 /* SyntaxKind.BreakStatement */ && !node.label) {
// unlabeled break within switch statement - ok
return false;
}
@@ -86998,13 +88663,13 @@ var ts;
current = current.parent;
}
if (node.label) {
- var message = node.kind === 245 /* BreakStatement */
+ var message = node.kind === 246 /* SyntaxKind.BreakStatement */
? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement
: ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement;
return grammarErrorOnNode(node, message);
}
else {
- var message = node.kind === 245 /* BreakStatement */
+ var message = node.kind === 246 /* SyntaxKind.BreakStatement */
? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement
: ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement;
return grammarErrorOnNode(node, message);
@@ -87028,18 +88693,18 @@ var ts;
}
function isStringOrNumberLiteralExpression(expr) {
return ts.isStringOrNumericLiteralLike(expr) ||
- expr.kind === 218 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ &&
- expr.operand.kind === 8 /* NumericLiteral */;
+ expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ &&
+ expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */;
}
function isBigIntLiteralExpression(expr) {
- return expr.kind === 9 /* BigIntLiteral */ ||
- expr.kind === 218 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ &&
- expr.operand.kind === 9 /* BigIntLiteral */;
+ return expr.kind === 9 /* SyntaxKind.BigIntLiteral */ ||
+ expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ &&
+ expr.operand.kind === 9 /* SyntaxKind.BigIntLiteral */;
}
function isSimpleLiteralEnumReference(expr) {
if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) &&
ts.isEntityNameExpression(expr.expression)) {
- return !!(checkExpressionCached(expr).flags & 1024 /* EnumLiteral */);
+ return !!(checkExpressionCached(expr).flags & 1024 /* TypeFlags.EnumLiteral */);
}
}
function checkAmbientInitializer(node) {
@@ -87047,7 +88712,7 @@ var ts;
if (initializer) {
var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) ||
isSimpleLiteralEnumReference(initializer) ||
- initializer.kind === 110 /* TrueKeyword */ || initializer.kind === 95 /* FalseKeyword */ ||
+ initializer.kind === 110 /* SyntaxKind.TrueKeyword */ || initializer.kind === 95 /* SyntaxKind.FalseKeyword */ ||
isBigIntLiteralExpression(initializer));
var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node);
if (isConstOrReadonly && !node.type) {
@@ -87064,8 +88729,8 @@ var ts;
}
}
function checkGrammarVariableDeclaration(node) {
- if (node.parent.parent.kind !== 242 /* ForInStatement */ && node.parent.parent.kind !== 243 /* ForOfStatement */) {
- if (node.flags & 8388608 /* Ambient */) {
+ if (node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */ && node.parent.parent.kind !== 244 /* SyntaxKind.ForOfStatement */) {
+ if (node.flags & 16777216 /* NodeFlags.Ambient */) {
checkAmbientInitializer(node);
}
else if (!node.initializer) {
@@ -87077,7 +88742,7 @@ var ts;
}
}
}
- if (node.exclamationToken && (node.parent.parent.kind !== 236 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) {
+ if (node.exclamationToken && (node.parent.parent.kind !== 237 /* SyntaxKind.VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* NodeFlags.Ambient */)) {
var message = node.initializer
? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
: !node.type
@@ -87086,7 +88751,7 @@ var ts;
return grammarErrorOnNode(node.exclamationToken, message);
}
if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System &&
- !(node.parent.parent.flags & 8388608 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) {
+ !(node.parent.parent.flags & 16777216 /* NodeFlags.Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* ModifierFlags.Export */)) {
checkESModuleMarker(node.name);
}
var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node));
@@ -87099,15 +88764,15 @@ var ts;
return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name);
}
function checkESModuleMarker(name) {
- if (name.kind === 79 /* Identifier */) {
+ if (name.kind === 79 /* SyntaxKind.Identifier */) {
if (ts.idText(name) === "__esModule") {
return grammarErrorOnNodeSkippedOn("noEmit", name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules);
}
}
else {
var elements = name.elements;
- for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) {
- var element = elements_1[_i];
+ for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) {
+ var element = elements_2[_i];
if (!ts.isOmittedExpression(element)) {
return checkESModuleMarker(element.name);
}
@@ -87116,15 +88781,15 @@ var ts;
return false;
}
function checkGrammarNameInLetOrConstDeclarations(name) {
- if (name.kind === 79 /* Identifier */) {
- if (name.originalKeywordKind === 119 /* LetKeyword */) {
+ if (name.kind === 79 /* SyntaxKind.Identifier */) {
+ if (name.originalKeywordKind === 119 /* SyntaxKind.LetKeyword */) {
return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations);
}
}
else {
var elements = name.elements;
- for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) {
- var element = elements_2[_i];
+ for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) {
+ var element = elements_3[_i];
if (!ts.isOmittedExpression(element)) {
checkGrammarNameInLetOrConstDeclarations(element.name);
}
@@ -87144,15 +88809,15 @@ var ts;
}
function allowLetAndConstDeclarations(parent) {
switch (parent.kind) {
- case 238 /* IfStatement */:
- case 239 /* DoStatement */:
- case 240 /* WhileStatement */:
- case 247 /* WithStatement */:
- case 241 /* ForStatement */:
- case 242 /* ForInStatement */:
- case 243 /* ForOfStatement */:
+ case 239 /* SyntaxKind.IfStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
+ case 248 /* SyntaxKind.WithStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
return false;
- case 249 /* LabeledStatement */:
+ case 250 /* SyntaxKind.LabeledStatement */:
return allowLetAndConstDeclarations(parent.parent);
}
return true;
@@ -87170,12 +88835,12 @@ var ts;
function checkGrammarMetaProperty(node) {
var escapedText = node.name.escapedText;
switch (node.keywordToken) {
- case 103 /* NewKeyword */:
+ case 103 /* SyntaxKind.NewKeyword */:
if (escapedText !== "target") {
return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "target");
}
break;
- case 100 /* ImportKeyword */:
+ case 100 /* SyntaxKind.ImportKeyword */:
if (escapedText !== "meta") {
return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "meta");
}
@@ -87233,7 +88898,7 @@ var ts;
}
}
function checkGrammarProperty(node) {
- if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* InKeyword */) {
+ if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */) {
return grammarErrorOnNode(node.parent.members[0], ts.Diagnostics.A_mapped_type_may_not_declare_properties_or_methods);
}
if (ts.isClassLike(node.parent)) {
@@ -87243,11 +88908,11 @@ var ts;
if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type)) {
return true;
}
- if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) {
+ if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) {
return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher);
}
}
- else if (node.parent.kind === 257 /* InterfaceDeclaration */) {
+ else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) {
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;
}
@@ -87263,11 +88928,11 @@ var ts;
return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer);
}
}
- if (node.flags & 8388608 /* Ambient */) {
+ if (node.flags & 16777216 /* NodeFlags.Ambient */) {
checkAmbientInitializer(node);
}
if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer ||
- node.flags & 8388608 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) {
+ node.flags & 16777216 /* NodeFlags.Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) {
var message = node.initializer
? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
: !node.type
@@ -87289,14 +88954,14 @@ var ts;
// export_opt AmbientDeclaration
//
// TODO: The spec needs to be amended to reflect this grammar.
- if (node.kind === 257 /* InterfaceDeclaration */ ||
- node.kind === 258 /* TypeAliasDeclaration */ ||
- node.kind === 265 /* ImportDeclaration */ ||
- node.kind === 264 /* ImportEqualsDeclaration */ ||
- node.kind === 271 /* ExportDeclaration */ ||
- node.kind === 270 /* ExportAssignment */ ||
- node.kind === 263 /* NamespaceExportDeclaration */ ||
- ts.hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) {
+ if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ ||
+ node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */ ||
+ node.kind === 266 /* SyntaxKind.ImportDeclaration */ ||
+ node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ||
+ node.kind === 272 /* SyntaxKind.ExportDeclaration */ ||
+ node.kind === 271 /* SyntaxKind.ExportAssignment */ ||
+ node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ ||
+ ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */ | 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */)) {
return false;
}
return grammarErrorOnFirstToken(node, ts.Diagnostics.Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier);
@@ -87304,7 +88969,7 @@ var ts;
function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) {
for (var _i = 0, _a = file.statements; _i < _a.length; _i++) {
var decl = _a[_i];
- if (ts.isDeclaration(decl) || decl.kind === 236 /* VariableStatement */) {
+ if (ts.isDeclaration(decl) || decl.kind === 237 /* SyntaxKind.VariableStatement */) {
if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) {
return true;
}
@@ -87313,10 +88978,10 @@ var ts;
return false;
}
function checkGrammarSourceFile(node) {
- return !!(node.flags & 8388608 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
+ return !!(node.flags & 16777216 /* NodeFlags.Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
}
function checkGrammarStatementInAmbientContext(node) {
- if (node.flags & 8388608 /* Ambient */) {
+ if (node.flags & 16777216 /* NodeFlags.Ambient */) {
// Find containing block which is either Block, ModuleBlock, SourceFile
var links = getNodeLinks(node);
if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) {
@@ -87327,7 +88992,7 @@ var ts;
// to prevent noisiness. So use a bit on the block to indicate if
// this has already been reported, and don't report if it has.
//
- if (node.parent.kind === 234 /* Block */ || node.parent.kind === 261 /* ModuleBlock */ || node.parent.kind === 303 /* SourceFile */) {
+ if (node.parent.kind === 235 /* SyntaxKind.Block */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) {
var links_2 = getNodeLinks(node.parent);
// Check if the containing block ever report this error
if (!links_2.hasReportedStatementInAmbientContext) {
@@ -87344,19 +89009,19 @@ var ts;
}
function checkGrammarNumericLiteral(node) {
// Grammar checking
- if (node.numericLiteralFlags & 32 /* Octal */) {
+ if (node.numericLiteralFlags & 32 /* TokenFlags.Octal */) {
var diagnosticMessage = void 0;
- if (languageVersion >= 1 /* ES5 */) {
+ if (languageVersion >= 1 /* ScriptTarget.ES5 */) {
diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0;
}
- else if (ts.isChildOfNodeWithKind(node, 195 /* LiteralType */)) {
+ else if (ts.isChildOfNodeWithKind(node, 196 /* SyntaxKind.LiteralType */)) {
diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0;
}
- else if (ts.isChildOfNodeWithKind(node, 297 /* EnumMember */)) {
+ else if (ts.isChildOfNodeWithKind(node, 299 /* SyntaxKind.EnumMember */)) {
diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0;
}
if (diagnosticMessage) {
- var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */;
+ var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* SyntaxKind.MinusToken */;
var literal = (withMinus ? "-" : "") + "0o" + node.text;
return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal);
}
@@ -87369,7 +89034,7 @@ var ts;
// We should test against `getTextOfNode(node)` rather than `node.text`, because `node.text` for large numeric literals can contain "."
// e.g. `node.text` for numeric literal `1100000000000000000000` is `1.1e21`.
var isFractional = ts.getTextOfNode(node).indexOf(".") !== -1;
- var isScientific = node.numericLiteralFlags & 16 /* Scientific */;
+ var isScientific = node.numericLiteralFlags & 16 /* TokenFlags.Scientific */;
// Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint
// Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway
if (isFractional || isScientific) {
@@ -87390,7 +89055,7 @@ var ts;
var literalType = ts.isLiteralTypeNode(node.parent) ||
ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent);
if (!literalType) {
- if (languageVersion < 7 /* ES2020 */) {
+ if (languageVersion < 7 /* ScriptTarget.ES2020 */) {
if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) {
return true;
}
@@ -87424,7 +89089,7 @@ var ts;
if (node.isTypeOnly && node.name && node.namedBindings) {
return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both);
}
- if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* NamedImports */) {
+ if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 269 /* SyntaxKind.NamedImports */) {
return checkGrammarNamedImportsOrExports(node.namedBindings);
}
return false;
@@ -87432,7 +89097,7 @@ var ts;
function checkGrammarNamedImportsOrExports(namedBindings) {
return !!ts.forEach(namedBindings.elements, function (specifier) {
if (specifier.isTypeOnly) {
- return grammarErrorOnFirstToken(specifier, specifier.kind === 269 /* ImportSpecifier */
+ return grammarErrorOnFirstToken(specifier, specifier.kind === 270 /* SyntaxKind.ImportSpecifier */
? ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement
: ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement);
}
@@ -87440,10 +89105,10 @@ var ts;
}
function checkGrammarImportCallExpression(node) {
if (moduleKind === ts.ModuleKind.ES2015) {
- return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext);
+ return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_or_nodenext);
}
if (node.typeArguments) {
- return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
+ return grammarErrorOnNode(node, ts.Diagnostics.This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments);
}
var nodeArguments = node.arguments;
if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.NodeNext) {
@@ -87451,7 +89116,7 @@ var ts;
checkGrammarForDisallowedTrailingComma(nodeArguments);
if (nodeArguments.length > 1) {
var assertionArgument = nodeArguments[1];
- return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext);
+ return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nodenext);
}
}
if (nodeArguments.length === 0 || nodeArguments.length > 2) {
@@ -87467,14 +89132,14 @@ var ts;
}
function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) {
var sourceObjectFlags = ts.getObjectFlags(source);
- if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 1048576 /* Union */) {
+ if (sourceObjectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */) && unionTarget.flags & 1048576 /* TypeFlags.Union */) {
return ts.find(unionTarget.types, function (target) {
- if (target.flags & 524288 /* Object */) {
+ if (target.flags & 524288 /* TypeFlags.Object */) {
var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target);
- if (overlapObjFlags & 4 /* Reference */) {
+ if (overlapObjFlags & 4 /* ObjectFlags.Reference */) {
return source.target === target.target;
}
- if (overlapObjFlags & 16 /* Anonymous */) {
+ if (overlapObjFlags & 16 /* ObjectFlags.Anonymous */) {
return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol;
}
}
@@ -87483,35 +89148,35 @@ var ts;
}
}
function findBestTypeForObjectLiteral(source, unionTarget) {
- if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) {
+ if (ts.getObjectFlags(source) & 128 /* ObjectFlags.ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) {
return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); });
}
}
function findBestTypeForInvokable(source, unionTarget) {
- var signatureKind = 0 /* Call */;
+ var signatureKind = 0 /* SignatureKind.Call */;
var hasSignatures = getSignaturesOfType(source, signatureKind).length > 0 ||
- (signatureKind = 1 /* Construct */, getSignaturesOfType(source, signatureKind).length > 0);
+ (signatureKind = 1 /* SignatureKind.Construct */, getSignaturesOfType(source, signatureKind).length > 0);
if (hasSignatures) {
return ts.find(unionTarget.types, function (t) { return getSignaturesOfType(t, signatureKind).length > 0; });
}
}
function findMostOverlappyType(source, unionTarget) {
var bestMatch;
- if (!(source.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) {
+ if (!(source.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) {
var matchingCount = 0;
for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
var target = _a[_i];
- if (!(target.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) {
+ if (!(target.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) {
var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
- if (overlap.flags & 4194304 /* Index */) {
+ if (overlap.flags & 4194304 /* TypeFlags.Index */) {
// perfect overlap of keys
return target;
}
- else if (isUnitType(overlap) || overlap.flags & 1048576 /* Union */) {
+ else if (isUnitType(overlap) || overlap.flags & 1048576 /* TypeFlags.Union */) {
// We only want to account for literal types otherwise.
// If we have a union of index types, it seems likely that we
// needed to elaborate between two generic mapped types anyway.
- var len = overlap.flags & 1048576 /* Union */ ? ts.countWhere(overlap.types, isUnitType) : 1;
+ var len = overlap.flags & 1048576 /* TypeFlags.Union */ ? ts.countWhere(overlap.types, isUnitType) : 1;
if (len >= matchingCount) {
bestMatch = target;
matchingCount = len;
@@ -87523,9 +89188,9 @@ var ts;
return bestMatch;
}
function filterPrimitivesIfContainsNonPrimitive(type) {
- if (maybeTypeOfKind(type, 67108864 /* NonPrimitive */)) {
- var result = filterType(type, function (t) { return !(t.flags & 131068 /* Primitive */); });
- if (!(result.flags & 131072 /* Never */)) {
+ if (maybeTypeOfKind(type, 67108864 /* TypeFlags.NonPrimitive */)) {
+ var result = filterType(type, function (t) { return !(t.flags & 131068 /* TypeFlags.Primitive */); });
+ if (!(result.flags & 131072 /* TypeFlags.Never */)) {
return result;
}
}
@@ -87533,7 +89198,7 @@ var ts;
}
// Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly
function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) {
- if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) {
+ if (target.flags & 1048576 /* TypeFlags.Union */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 524288 /* TypeFlags.Object */)) {
var match = getMatchingUnionConstituentForType(target, source);
if (match) {
return match;
@@ -87555,14 +89220,14 @@ var ts;
return !ts.isAccessor(declaration);
}
function isNotOverload(declaration) {
- return (declaration.kind !== 255 /* FunctionDeclaration */ && declaration.kind !== 168 /* MethodDeclaration */) ||
+ return (declaration.kind !== 256 /* SyntaxKind.FunctionDeclaration */ && declaration.kind !== 169 /* SyntaxKind.MethodDeclaration */) ||
!!declaration.body;
}
/** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */
function isDeclarationNameOrImportPropertyName(name) {
switch (name.parent.kind) {
- case 269 /* ImportSpecifier */:
- case 274 /* ExportSpecifier */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
+ case 275 /* SyntaxKind.ExportSpecifier */:
return ts.isIdentifier(name);
default:
return ts.isDeclarationName(name);
@@ -87582,17 +89247,17 @@ var ts;
})(JsxNames || (JsxNames = {}));
function getIterationTypesKeyFromIterationTypeKind(typeKind) {
switch (typeKind) {
- case 0 /* Yield */: return "yieldType";
- case 1 /* Return */: return "returnType";
- case 2 /* Next */: return "nextType";
+ case 0 /* IterationTypeKind.Yield */: return "yieldType";
+ case 1 /* IterationTypeKind.Return */: return "returnType";
+ case 2 /* IterationTypeKind.Next */: return "nextType";
}
}
function signatureHasRestParameter(s) {
- return !!(s.flags & 1 /* HasRestParameter */);
+ return !!(s.flags & 1 /* SignatureFlags.HasRestParameter */);
}
ts.signatureHasRestParameter = signatureHasRestParameter;
function signatureHasLiteralTypes(s) {
- return !!(s.flags & 2 /* HasLiteralTypes */);
+ return !!(s.flags & 2 /* SignatureFlags.HasLiteralTypes */);
}
ts.signatureHasLiteralTypes = signatureHasLiteralTypes;
})(ts || (ts = {}));
@@ -87706,7 +89371,7 @@ var ts;
var updated;
context.startLexicalEnvironment();
if (nodes) {
- context.setLexicalEnvironmentFlags(1 /* InParameters */, true);
+ context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, true);
updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration);
// As of ES2015, any runtime execution of that occurs in for a parameter (such as evaluating an
// initializer or a binding pattern), occurs in its own lexical scope. As a result, any expression
@@ -87714,11 +89379,11 @@ var ts;
// exists in a different lexical scope. To address this, we move any binding patterns and initializers
// in a parameter list to the body if we detect a variable being hoisted while visiting a parameter list
// when the emit target is greater than ES2015.
- if (context.getLexicalEnvironmentFlags() & 2 /* VariablesHoistedInParameters */ &&
- ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) {
+ if (context.getLexicalEnvironmentFlags() & 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */ &&
+ ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) {
updated = addDefaultValueAssignmentsIfNeeded(updated, context);
}
- context.setLexicalEnvironmentFlags(1 /* InParameters */, false);
+ context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, false);
}
context.suspendLexicalEnvironment();
return updated;
@@ -87765,8 +89430,8 @@ var ts;
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 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */))
- ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */)));
+ factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */))
+ ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */)));
return factory.updateParameterDeclaration(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, parameter.name, parameter.questionToken, parameter.type,
/*initializer*/ undefined);
}
@@ -87812,443 +89477,446 @@ var ts;
}
var kind = node.kind;
// No need to visit nodes with no children.
- if ((kind > 0 /* FirstToken */ && kind <= 159 /* LastToken */) || kind === 191 /* ThisType */) {
+ if ((kind > 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */) || kind === 192 /* SyntaxKind.ThisType */) {
return node;
}
var factory = context.factory;
switch (kind) {
// Names
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
ts.Debug.type(node);
return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNodeOrTypeParameterDeclaration));
- case 160 /* QualifiedName */:
+ case 161 /* SyntaxKind.QualifiedName */:
ts.Debug.type(node);
return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier));
- case 161 /* ComputedPropertyName */:
+ case 162 /* SyntaxKind.ComputedPropertyName */:
ts.Debug.type(node);
return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression));
// Signature elements
- case 162 /* TypeParameter */:
+ case 163 /* SyntaxKind.TypeParameter */:
ts.Debug.type(node);
- return factory.updateTypeParameterDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode));
- case 163 /* Parameter */:
+ 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 /* SyntaxKind.Parameter */:
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));
- case 164 /* Decorator */:
+ case 165 /* SyntaxKind.Decorator */:
ts.Debug.type(node);
return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression));
// Type elements
- case 165 /* PropertySignature */:
+ case 166 /* SyntaxKind.PropertySignature */:
ts.Debug.type(node);
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 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
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),
// QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too
nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isQuestionOrExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression));
- case 167 /* MethodSignature */:
+ case 168 /* SyntaxKind.MethodSignature */:
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 168 /* MethodDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
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));
- case 170 /* Constructor */:
+ case 171 /* SyntaxKind.Constructor */:
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));
- case 171 /* GetAccessor */:
+ case 172 /* SyntaxKind.GetAccessor */:
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));
- case 172 /* SetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
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));
- case 169 /* ClassStaticBlockDeclaration */:
+ case 170 /* SyntaxKind.ClassStaticBlockDeclaration */:
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));
- case 173 /* CallSignature */:
+ case 174 /* SyntaxKind.CallSignature */:
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));
- case 174 /* ConstructSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
ts.Debug.type(node);
return factory.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode));
- case 175 /* IndexSignature */:
+ case 176 /* SyntaxKind.IndexSignature */:
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));
// Types
- case 176 /* TypePredicate */:
+ case 177 /* SyntaxKind.TypePredicate */:
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));
- case 177 /* TypeReference */:
+ case 178 /* SyntaxKind.TypeReference */:
ts.Debug.type(node);
return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode));
- case 178 /* FunctionType */:
+ case 179 /* SyntaxKind.FunctionType */:
ts.Debug.type(node);
return factory.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode));
- case 179 /* ConstructorType */:
+ case 180 /* SyntaxKind.ConstructorType */:
ts.Debug.type(node);
return factory.updateConstructorTypeNode(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode));
- case 180 /* TypeQuery */:
+ case 181 /* SyntaxKind.TypeQuery */:
ts.Debug.type(node);
- return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName));
- case 181 /* TypeLiteral */:
+ return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode));
+ case 182 /* SyntaxKind.TypeLiteral */:
ts.Debug.type(node);
return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement));
- case 182 /* ArrayType */:
+ case 183 /* SyntaxKind.ArrayType */:
ts.Debug.type(node);
return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode));
- case 183 /* TupleType */:
+ case 184 /* SyntaxKind.TupleType */:
ts.Debug.type(node);
return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode));
- case 184 /* OptionalType */:
+ case 185 /* SyntaxKind.OptionalType */:
ts.Debug.type(node);
return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
- case 185 /* RestType */:
+ case 186 /* SyntaxKind.RestType */:
ts.Debug.type(node);
return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
- case 186 /* UnionType */:
+ case 187 /* SyntaxKind.UnionType */:
ts.Debug.type(node);
return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode));
- case 187 /* IntersectionType */:
+ case 188 /* SyntaxKind.IntersectionType */:
ts.Debug.type(node);
return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode));
- case 188 /* ConditionalType */:
+ case 189 /* SyntaxKind.ConditionalType */:
ts.Debug.type(node);
return factory.updateConditionalTypeNode(node, nodeVisitor(node.checkType, visitor, ts.isTypeNode), nodeVisitor(node.extendsType, visitor, ts.isTypeNode), nodeVisitor(node.trueType, visitor, ts.isTypeNode), nodeVisitor(node.falseType, visitor, ts.isTypeNode));
- case 189 /* InferType */:
+ case 190 /* SyntaxKind.InferType */:
ts.Debug.type(node);
return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration));
- case 199 /* ImportType */:
+ case 200 /* SyntaxKind.ImportType */:
+ 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);
+ case 295 /* SyntaxKind.ImportTypeAssertionContainer */:
ts.Debug.type(node);
- return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf);
- case 196 /* NamedTupleMember */:
+ return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine);
+ case 197 /* SyntaxKind.NamedTupleMember */:
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));
- case 190 /* ParenthesizedType */:
+ case 191 /* SyntaxKind.ParenthesizedType */:
ts.Debug.type(node);
return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
- case 192 /* TypeOperator */:
+ case 193 /* SyntaxKind.TypeOperator */:
ts.Debug.type(node);
return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
- case 193 /* IndexedAccessType */:
+ case 194 /* SyntaxKind.IndexedAccessType */:
ts.Debug.type(node);
return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode));
- case 194 /* MappedType */:
+ case 195 /* SyntaxKind.MappedType */:
ts.Debug.type(node);
return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isReadonlyKeywordOrPlusOrMinusToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionOrPlusOrMinusToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodesVisitor(node.members, visitor, ts.isTypeElement));
- case 195 /* LiteralType */:
+ case 196 /* SyntaxKind.LiteralType */:
ts.Debug.type(node);
return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression));
- case 197 /* TemplateLiteralType */:
+ case 198 /* SyntaxKind.TemplateLiteralType */:
ts.Debug.type(node);
return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan));
- case 198 /* TemplateLiteralTypeSpan */:
+ case 199 /* SyntaxKind.TemplateLiteralTypeSpan */:
ts.Debug.type(node);
return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail));
// Binding patterns
- case 200 /* ObjectBindingPattern */:
+ case 201 /* SyntaxKind.ObjectBindingPattern */:
ts.Debug.type(node);
return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement));
- case 201 /* ArrayBindingPattern */:
+ case 202 /* SyntaxKind.ArrayBindingPattern */:
ts.Debug.type(node);
return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement));
- case 202 /* BindingElement */:
+ case 203 /* SyntaxKind.BindingElement */:
ts.Debug.type(node);
return factory.updateBindingElement(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.propertyName, visitor, ts.isPropertyName), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.initializer, visitor, ts.isExpression));
// Expression
- case 203 /* ArrayLiteralExpression */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
ts.Debug.type(node);
return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression));
- case 204 /* ObjectLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
ts.Debug.type(node);
return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike));
- case 205 /* PropertyAccessExpression */:
- if (node.flags & 32 /* OptionalChain */) {
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ if (node.flags & 32 /* NodeFlags.OptionalChain */) {
ts.Debug.type(node);
return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.name, visitor, ts.isMemberName));
}
ts.Debug.type(node);
return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isMemberName));
- case 206 /* ElementAccessExpression */:
- if (node.flags & 32 /* OptionalChain */) {
+ case 207 /* SyntaxKind.ElementAccessExpression */:
+ if (node.flags & 32 /* NodeFlags.OptionalChain */) {
ts.Debug.type(node);
return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression));
}
ts.Debug.type(node);
return factory.updateElementAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.argumentExpression, visitor, ts.isExpression));
- case 207 /* CallExpression */:
- if (node.flags & 32 /* OptionalChain */) {
+ case 208 /* SyntaxKind.CallExpression */:
+ if (node.flags & 32 /* NodeFlags.OptionalChain */) {
ts.Debug.type(node);
return factory.updateCallChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
}
ts.Debug.type(node);
return factory.updateCallExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
- case 208 /* NewExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
ts.Debug.type(node);
return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
- case 209 /* TaggedTemplateExpression */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
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));
- case 210 /* TypeAssertionExpression */:
+ case 211 /* SyntaxKind.TypeAssertionExpression */:
ts.Debug.type(node);
return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression));
- case 211 /* ParenthesizedExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
ts.Debug.type(node);
return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
- case 212 /* FunctionExpression */:
+ case 213 /* SyntaxKind.FunctionExpression */:
ts.Debug.type(node);
return factory.updateFunctionExpression(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 213 /* ArrowFunction */:
+ case 214 /* SyntaxKind.ArrowFunction */:
ts.Debug.type(node);
return factory.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.equalsGreaterThanToken, tokenVisitor, ts.isEqualsGreaterThanToken), visitFunctionBody(node.body, visitor, context, nodeVisitor));
- case 214 /* DeleteExpression */:
+ case 215 /* SyntaxKind.DeleteExpression */:
ts.Debug.type(node);
return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
- case 215 /* TypeOfExpression */:
+ case 216 /* SyntaxKind.TypeOfExpression */:
ts.Debug.type(node);
return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
- case 216 /* VoidExpression */:
+ case 217 /* SyntaxKind.VoidExpression */:
ts.Debug.type(node);
return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
- case 217 /* AwaitExpression */:
+ case 218 /* SyntaxKind.AwaitExpression */:
ts.Debug.type(node);
return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
- case 218 /* PrefixUnaryExpression */:
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
ts.Debug.type(node);
return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression));
- case 219 /* PostfixUnaryExpression */:
+ case 220 /* SyntaxKind.PostfixUnaryExpression */:
ts.Debug.type(node);
return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression));
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
ts.Debug.type(node);
return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isBinaryOperatorToken), nodeVisitor(node.right, visitor, ts.isExpression));
- case 221 /* ConditionalExpression */:
+ case 222 /* SyntaxKind.ConditionalExpression */:
ts.Debug.type(node);
return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isColonToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression));
- case 222 /* TemplateExpression */:
+ case 223 /* SyntaxKind.TemplateExpression */:
ts.Debug.type(node);
return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan));
- case 223 /* YieldExpression */:
+ case 224 /* SyntaxKind.YieldExpression */:
ts.Debug.type(node);
return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.expression, visitor, ts.isExpression));
- case 224 /* SpreadElement */:
+ case 225 /* SyntaxKind.SpreadElement */:
ts.Debug.type(node);
return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression));
- case 225 /* ClassExpression */:
+ case 226 /* SyntaxKind.ClassExpression */:
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));
- case 227 /* ExpressionWithTypeArguments */:
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
ts.Debug.type(node);
return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode));
- case 228 /* AsExpression */:
+ case 229 /* SyntaxKind.AsExpression */:
ts.Debug.type(node);
return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode));
- case 229 /* NonNullExpression */:
- if (node.flags & 32 /* OptionalChain */) {
+ case 230 /* SyntaxKind.NonNullExpression */:
+ if (node.flags & 32 /* NodeFlags.OptionalChain */) {
ts.Debug.type(node);
return factory.updateNonNullChain(node, nodeVisitor(node.expression, visitor, ts.isExpression));
}
ts.Debug.type(node);
return factory.updateNonNullExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
- case 230 /* MetaProperty */:
+ case 231 /* SyntaxKind.MetaProperty */:
ts.Debug.type(node);
return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier));
// Misc
- case 232 /* TemplateSpan */:
+ case 233 /* SyntaxKind.TemplateSpan */:
ts.Debug.type(node);
return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail));
// Element
- case 234 /* Block */:
+ case 235 /* SyntaxKind.Block */:
ts.Debug.type(node);
return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement));
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
ts.Debug.type(node);
return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList));
- case 237 /* ExpressionStatement */:
+ case 238 /* SyntaxKind.ExpressionStatement */:
ts.Debug.type(node);
return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression));
- case 238 /* IfStatement */:
+ case 239 /* SyntaxKind.IfStatement */:
ts.Debug.type(node);
return factory.updateIfStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.thenStatement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.elseStatement, visitor, ts.isStatement, factory.liftToBlock));
- case 239 /* DoStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
ts.Debug.type(node);
return factory.updateDoStatement(node, visitIterationBody(node.statement, visitor, context), nodeVisitor(node.expression, visitor, ts.isExpression));
- case 240 /* WhileStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
ts.Debug.type(node);
return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context));
- case 241 /* ForStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
ts.Debug.type(node);
return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context));
- case 242 /* ForInStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
ts.Debug.type(node);
return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context));
- case 243 /* ForOfStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
ts.Debug.type(node);
return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isAwaitKeyword), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context));
- case 244 /* ContinueStatement */:
+ case 245 /* SyntaxKind.ContinueStatement */:
ts.Debug.type(node);
return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier));
- case 245 /* BreakStatement */:
+ case 246 /* SyntaxKind.BreakStatement */:
ts.Debug.type(node);
return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier));
- case 246 /* ReturnStatement */:
+ case 247 /* SyntaxKind.ReturnStatement */:
ts.Debug.type(node);
return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression));
- case 247 /* WithStatement */:
+ case 248 /* SyntaxKind.WithStatement */:
ts.Debug.type(node);
return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock));
- case 248 /* SwitchStatement */:
+ case 249 /* SyntaxKind.SwitchStatement */:
ts.Debug.type(node);
return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock));
- case 249 /* LabeledStatement */:
+ case 250 /* SyntaxKind.LabeledStatement */:
ts.Debug.type(node);
return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock));
- case 250 /* ThrowStatement */:
+ case 251 /* SyntaxKind.ThrowStatement */:
ts.Debug.type(node);
return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression));
- case 251 /* TryStatement */:
+ case 252 /* SyntaxKind.TryStatement */:
ts.Debug.type(node);
return factory.updateTryStatement(node, nodeVisitor(node.tryBlock, visitor, ts.isBlock), nodeVisitor(node.catchClause, visitor, ts.isCatchClause), nodeVisitor(node.finallyBlock, visitor, ts.isBlock));
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
ts.Debug.type(node);
return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression));
- case 254 /* VariableDeclarationList */:
+ case 255 /* SyntaxKind.VariableDeclarationList */:
ts.Debug.type(node);
return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration));
- case 255 /* FunctionDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
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));
- case 256 /* ClassDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
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));
- case 257 /* InterfaceDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
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));
- case 258 /* TypeAliasDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
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));
- case 259 /* EnumDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
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));
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
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));
- case 261 /* ModuleBlock */:
+ case 262 /* SyntaxKind.ModuleBlock */:
ts.Debug.type(node);
return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement));
- case 262 /* CaseBlock */:
+ case 263 /* SyntaxKind.CaseBlock */:
ts.Debug.type(node);
return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause));
- case 263 /* NamespaceExportDeclaration */:
+ case 264 /* SyntaxKind.NamespaceExportDeclaration */:
ts.Debug.type(node);
return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier));
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
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));
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
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));
- case 292 /* AssertClause */:
+ case 293 /* SyntaxKind.AssertClause */:
ts.Debug.type(node);
return factory.updateAssertClause(node, nodesVisitor(node.elements, visitor, ts.isAssertEntry), node.multiLine);
- case 293 /* AssertEntry */:
+ case 294 /* SyntaxKind.AssertEntry */:
ts.Debug.type(node);
return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isExpressionNode));
- case 266 /* ImportClause */:
+ case 267 /* SyntaxKind.ImportClause */:
ts.Debug.type(node);
return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings));
- case 267 /* NamespaceImport */:
+ case 268 /* SyntaxKind.NamespaceImport */:
ts.Debug.type(node);
return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier));
- case 273 /* NamespaceExport */:
+ case 274 /* SyntaxKind.NamespaceExport */:
ts.Debug.type(node);
return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier));
- case 268 /* NamedImports */:
+ case 269 /* SyntaxKind.NamedImports */:
ts.Debug.type(node);
return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier));
- case 269 /* ImportSpecifier */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
ts.Debug.type(node);
return factory.updateImportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier));
- case 270 /* ExportAssignment */:
+ case 271 /* SyntaxKind.ExportAssignment */:
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));
- case 271 /* ExportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
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));
- case 272 /* NamedExports */:
+ case 273 /* SyntaxKind.NamedExports */:
ts.Debug.type(node);
return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier));
- case 274 /* ExportSpecifier */:
+ case 275 /* SyntaxKind.ExportSpecifier */:
ts.Debug.type(node);
return factory.updateExportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier));
// Module references
- case 276 /* ExternalModuleReference */:
+ case 277 /* SyntaxKind.ExternalModuleReference */:
ts.Debug.type(node);
return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression));
// JSX
- case 277 /* JsxElement */:
+ case 278 /* SyntaxKind.JsxElement */:
ts.Debug.type(node);
return factory.updateJsxElement(node, nodeVisitor(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingElement, visitor, ts.isJsxClosingElement));
- case 278 /* JsxSelfClosingElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
ts.Debug.type(node);
return factory.updateJsxSelfClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes));
- case 279 /* JsxOpeningElement */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
ts.Debug.type(node);
return factory.updateJsxOpeningElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes));
- case 280 /* JsxClosingElement */:
+ case 281 /* SyntaxKind.JsxClosingElement */:
ts.Debug.type(node);
return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression));
- case 281 /* JsxFragment */:
+ case 282 /* SyntaxKind.JsxFragment */:
ts.Debug.type(node);
return factory.updateJsxFragment(node, nodeVisitor(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingFragment, visitor, ts.isJsxClosingFragment));
- case 284 /* JsxAttribute */:
+ case 285 /* SyntaxKind.JsxAttribute */:
ts.Debug.type(node);
return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression));
- case 285 /* JsxAttributes */:
+ case 286 /* SyntaxKind.JsxAttributes */:
ts.Debug.type(node);
return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike));
- case 286 /* JsxSpreadAttribute */:
+ case 287 /* SyntaxKind.JsxSpreadAttribute */:
ts.Debug.type(node);
return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression));
- case 287 /* JsxExpression */:
+ case 288 /* SyntaxKind.JsxExpression */:
ts.Debug.type(node);
return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
// Clauses
- case 288 /* CaseClause */:
+ case 289 /* SyntaxKind.CaseClause */:
ts.Debug.type(node);
return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement));
- case 289 /* DefaultClause */:
+ case 290 /* SyntaxKind.DefaultClause */:
ts.Debug.type(node);
return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement));
- case 290 /* HeritageClause */:
+ case 291 /* SyntaxKind.HeritageClause */:
ts.Debug.type(node);
return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments));
- case 291 /* CatchClause */:
+ case 292 /* SyntaxKind.CatchClause */:
ts.Debug.type(node);
return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock));
// Property assignments
- case 294 /* PropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
ts.Debug.type(node);
return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression));
- case 295 /* ShorthandPropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
ts.Debug.type(node);
return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression));
- case 296 /* SpreadAssignment */:
+ case 298 /* SyntaxKind.SpreadAssignment */:
ts.Debug.type(node);
return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression));
// Enum
- case 297 /* EnumMember */:
+ case 299 /* SyntaxKind.EnumMember */:
ts.Debug.type(node);
return factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression));
// Top-level nodes
- case 303 /* SourceFile */:
+ case 305 /* SyntaxKind.SourceFile */:
ts.Debug.type(node);
return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context));
// Transformation nodes
- case 348 /* PartiallyEmittedExpression */:
+ case 350 /* SyntaxKind.PartiallyEmittedExpression */:
ts.Debug.type(node);
return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
- case 349 /* CommaListExpression */:
+ case 351 /* SyntaxKind.CommaListExpression */:
ts.Debug.type(node);
return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression));
default:
@@ -88473,7 +90141,7 @@ var ts;
if (lastGeneratedLine < pendingGeneratedLine) {
// Emit line delimiters
do {
- appendMappingCharCode(59 /* semicolon */);
+ appendMappingCharCode(59 /* CharacterCodes.semicolon */);
lastGeneratedLine++;
} while (lastGeneratedLine < pendingGeneratedLine);
// Only need to set this once
@@ -88483,7 +90151,7 @@ var ts;
ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack");
// Emit comma to separate the entry
if (hasLast) {
- appendMappingCharCode(44 /* comma */);
+ appendMappingCharCode(44 /* CharacterCodes.comma */);
}
}
// 1. Relative generated character
@@ -88626,14 +90294,14 @@ var ts;
next: function () {
while (!done && pos < mappings.length) {
var ch = mappings.charCodeAt(pos);
- if (ch === 59 /* semicolon */) {
+ if (ch === 59 /* CharacterCodes.semicolon */) {
// new line
generatedLine++;
generatedCharacter = 0;
pos++;
continue;
}
- if (ch === 44 /* comma */) {
+ if (ch === 44 /* CharacterCodes.comma */) {
// Next entry is on same line - no action needed
pos++;
continue;
@@ -88710,8 +90378,8 @@ var ts;
}
function isSourceMappingSegmentEnd() {
return (pos === mappings.length ||
- mappings.charCodeAt(pos) === 44 /* comma */ ||
- mappings.charCodeAt(pos) === 59 /* semicolon */);
+ mappings.charCodeAt(pos) === 44 /* CharacterCodes.comma */ ||
+ mappings.charCodeAt(pos) === 59 /* CharacterCodes.semicolon */);
}
function base64VLQFormatDecode() {
var moreDigits = true;
@@ -88761,19 +90429,19 @@ var ts;
}
ts.isSourceMapping = isSourceMapping;
function base64FormatEncode(value) {
- return value >= 0 && value < 26 ? 65 /* A */ + value :
- value >= 26 && value < 52 ? 97 /* a */ + value - 26 :
- value >= 52 && value < 62 ? 48 /* _0 */ + value - 52 :
- value === 62 ? 43 /* plus */ :
- value === 63 ? 47 /* slash */ :
+ return value >= 0 && value < 26 ? 65 /* CharacterCodes.A */ + value :
+ value >= 26 && value < 52 ? 97 /* CharacterCodes.a */ + value - 26 :
+ value >= 52 && value < 62 ? 48 /* CharacterCodes._0 */ + value - 52 :
+ value === 62 ? 43 /* CharacterCodes.plus */ :
+ value === 63 ? 47 /* CharacterCodes.slash */ :
ts.Debug.fail("".concat(value, ": not a base64 value"));
}
function base64FormatDecode(ch) {
- return ch >= 65 /* A */ && ch <= 90 /* Z */ ? ch - 65 /* A */ :
- ch >= 97 /* a */ && ch <= 122 /* z */ ? ch - 97 /* a */ + 26 :
- ch >= 48 /* _0 */ && ch <= 57 /* _9 */ ? ch - 48 /* _0 */ + 52 :
- ch === 43 /* plus */ ? 62 :
- ch === 47 /* slash */ ? 63 :
+ return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ ? ch - 65 /* CharacterCodes.A */ :
+ ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ ? ch - 97 /* CharacterCodes.a */ + 26 :
+ ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ ? ch - 48 /* CharacterCodes._0 */ + 52 :
+ ch === 43 /* CharacterCodes.plus */ ? 62 :
+ ch === 47 /* CharacterCodes.slash */ ? 63 :
-1;
}
function isSourceMappedPosition(value) {
@@ -88934,12 +90602,12 @@ var ts;
return ts.some(node.elements, isNamedDefaultReference);
}
function isNamedDefaultReference(e) {
- return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* Default */;
+ return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* InternalSymbolName.Default */;
}
function chainBundle(context, transformSourceFile) {
return transformSourceFileOrBundle;
function transformSourceFileOrBundle(node) {
- return node.kind === 303 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node);
+ return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node);
}
function transformBundle(node) {
return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends);
@@ -88990,7 +90658,7 @@ var ts;
for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
var node = _a[_i];
switch (node.kind) {
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
// import "mod"
// import x from "mod"
// import * as x from "mod"
@@ -89003,13 +90671,13 @@ var ts;
hasImportDefault = true;
}
break;
- case 264 /* ImportEqualsDeclaration */:
- if (node.moduleReference.kind === 276 /* ExternalModuleReference */) {
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ if (node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) {
// import x = require("mod")
externalImports.push(node);
}
break;
- case 271 /* ExportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
if (node.moduleSpecifier) {
if (!node.exportClause) {
// export * from "mod"
@@ -89040,23 +90708,23 @@ var ts;
addExportedNamesForExportDeclaration(node);
}
break;
- case 270 /* ExportAssignment */:
+ case 271 /* SyntaxKind.ExportAssignment */:
if (node.isExportEquals && !exportEquals) {
// export = x
exportEquals = node;
}
break;
- case 236 /* VariableStatement */:
- if (ts.hasSyntacticModifier(node, 1 /* Export */)) {
+ case 237 /* SyntaxKind.VariableStatement */:
+ if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) {
for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) {
var decl = _c[_b];
exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames);
}
}
break;
- case 255 /* FunctionDeclaration */:
- if (ts.hasSyntacticModifier(node, 1 /* Export */)) {
- if (ts.hasSyntacticModifier(node, 512 /* Default */)) {
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) {
+ if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) {
// export default function() { }
if (!hasExportDefault) {
multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node));
@@ -89074,9 +90742,9 @@ var ts;
}
}
break;
- case 256 /* ClassDeclaration */:
- if (ts.hasSyntacticModifier(node, 1 /* Export */)) {
- if (ts.hasSyntacticModifier(node, 512 /* Default */)) {
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) {
+ if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) {
// export default class { }
if (!hasExportDefault) {
multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node));
@@ -89157,7 +90825,7 @@ var ts;
*/
function isSimpleCopiableExpression(expression) {
return ts.isStringLiteralLike(expression) ||
- expression.kind === 8 /* NumericLiteral */ ||
+ expression.kind === 8 /* SyntaxKind.NumericLiteral */ ||
ts.isKeyword(expression.kind) ||
ts.isIdentifier(expression);
}
@@ -89172,27 +90840,27 @@ var ts;
}
ts.isSimpleInlineableExpression = isSimpleInlineableExpression;
function isCompoundAssignment(kind) {
- return kind >= 64 /* FirstCompoundAssignment */
- && kind <= 78 /* LastCompoundAssignment */;
+ return kind >= 64 /* SyntaxKind.FirstCompoundAssignment */
+ && kind <= 78 /* SyntaxKind.LastCompoundAssignment */;
}
ts.isCompoundAssignment = isCompoundAssignment;
function getNonAssignmentOperatorForCompoundAssignment(kind) {
switch (kind) {
- case 64 /* PlusEqualsToken */: return 39 /* PlusToken */;
- case 65 /* MinusEqualsToken */: return 40 /* MinusToken */;
- case 66 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */;
- case 67 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */;
- case 68 /* SlashEqualsToken */: return 43 /* SlashToken */;
- case 69 /* PercentEqualsToken */: return 44 /* PercentToken */;
- case 70 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */;
- case 71 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */;
- case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */;
- case 73 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */;
- case 74 /* BarEqualsToken */: return 51 /* BarToken */;
- case 78 /* CaretEqualsToken */: return 52 /* CaretToken */;
- case 75 /* BarBarEqualsToken */: return 56 /* BarBarToken */;
- case 76 /* AmpersandAmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */;
- case 77 /* QuestionQuestionEqualsToken */: return 60 /* QuestionQuestionToken */;
+ case 64 /* SyntaxKind.PlusEqualsToken */: return 39 /* SyntaxKind.PlusToken */;
+ case 65 /* SyntaxKind.MinusEqualsToken */: return 40 /* SyntaxKind.MinusToken */;
+ case 66 /* SyntaxKind.AsteriskEqualsToken */: return 41 /* SyntaxKind.AsteriskToken */;
+ case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: return 42 /* SyntaxKind.AsteriskAsteriskToken */;
+ case 68 /* SyntaxKind.SlashEqualsToken */: return 43 /* SyntaxKind.SlashToken */;
+ case 69 /* SyntaxKind.PercentEqualsToken */: return 44 /* SyntaxKind.PercentToken */;
+ case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: return 47 /* SyntaxKind.LessThanLessThanToken */;
+ case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: return 48 /* SyntaxKind.GreaterThanGreaterThanToken */;
+ case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */;
+ case 73 /* SyntaxKind.AmpersandEqualsToken */: return 50 /* SyntaxKind.AmpersandToken */;
+ case 74 /* SyntaxKind.BarEqualsToken */: return 51 /* SyntaxKind.BarToken */;
+ case 78 /* SyntaxKind.CaretEqualsToken */: return 52 /* SyntaxKind.CaretToken */;
+ case 75 /* SyntaxKind.BarBarEqualsToken */: return 56 /* SyntaxKind.BarBarToken */;
+ case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: return 55 /* SyntaxKind.AmpersandAmpersandToken */;
+ case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return 60 /* SyntaxKind.QuestionQuestionToken */;
}
}
ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment;
@@ -89254,7 +90922,7 @@ var ts;
* @param isStatic A value indicating whether the member should be a static or instance member.
*/
function isInitializedProperty(member) {
- return member.kind === 166 /* PropertyDeclaration */
+ return member.kind === 167 /* SyntaxKind.PropertyDeclaration */
&& member.initializer !== undefined;
}
ts.isInitializedProperty = isInitializedProperty;
@@ -89375,8 +91043,8 @@ var ts;
}
function bindingOrAssignmentPatternAssignsToName(pattern, escapedName) {
var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
- for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) {
- var element = elements_3[_i];
+ for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) {
+ var element = elements_4[_i];
if (bindingOrAssignmentElementAssignsToName(element, escapedName)) {
return true;
}
@@ -89539,9 +91207,9 @@ var ts;
var element = elements[i];
if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element);
- if (flattenContext.level >= 1 /* ObjectRest */
- && !(element.transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */))
- && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */))
+ if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */
+ && !(element.transformFlags & (16384 /* TransformFlags.ContainsRestOrSpread */ | 32768 /* TransformFlags.ContainsObjectRestOrSpread */))
+ && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* TransformFlags.ContainsRestOrSpread */ | 32768 /* TransformFlags.ContainsObjectRestOrSpread */))
&& !ts.isComputedPropertyName(propertyName)) {
bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor));
}
@@ -89582,14 +91250,14 @@ var ts;
function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) {
var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
var numElements = elements.length;
- if (flattenContext.level < 1 /* ObjectRest */ && flattenContext.downlevelIteration) {
+ if (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ && flattenContext.downlevelIteration) {
// Read the elements of the iterable into an array
value = ensureIdentifier(flattenContext, ts.setTextRange(flattenContext.context.getEmitHelperFactory().createReadHelper(value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1])
? undefined
: numElements), location),
/*reuseIdentifierExpressions*/ false, location);
}
- else if (numElements !== 1 && (flattenContext.level < 1 /* ObjectRest */ || numElements === 0)
+ else if (numElements !== 1 && (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ || numElements === 0)
|| ts.every(elements, ts.isOmittedExpression)) {
// For anything other than a single-element destructuring we need to generate a temporary
// to ensure value is evaluated exactly once. Additionally, if we have zero elements
@@ -89604,10 +91272,10 @@ var ts;
var restContainingElements;
for (var i = 0; i < numElements; i++) {
var element = elements[i];
- if (flattenContext.level >= 1 /* ObjectRest */) {
+ if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */) {
// If an array pattern contains an ObjectRest, we must cache the result so that we
// can perform the ObjectRest destructuring in a different declaration
- if (element.transformFlags & 32768 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) {
+ if (element.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) {
flattenContext.hasTransformedPriorElement = true;
var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined);
if (flattenContext.hoistTempVariables) {
@@ -89810,7 +91478,7 @@ var ts;
// thus we need to remove those characters.
// First template piece starts with "`", others with "}"
// Last template piece ends with "`", others with "${"
- var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */;
+ var isLast = node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || node.kind === 17 /* SyntaxKind.TemplateTail */;
text = text.substring(1, text.length - (isLast ? 1 : 2));
}
// Newline normalization:
@@ -89866,8 +91534,8 @@ var ts;
context.onEmitNode = onEmitNode;
context.onSubstituteNode = onSubstituteNode;
// Enable substitution for property/element access to emit const enum values.
- context.enableSubstitution(205 /* PropertyAccessExpression */);
- context.enableSubstitution(206 /* ElementAccessExpression */);
+ context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */);
+ context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */);
// These variables contain state that changes as we descend into the tree.
var currentSourceFile;
var currentNamespace;
@@ -89893,14 +91561,14 @@ var ts;
var applicableSubstitutions;
return transformSourceFileOrBundle;
function transformSourceFileOrBundle(node) {
- if (node.kind === 304 /* Bundle */) {
+ if (node.kind === 306 /* SyntaxKind.Bundle */) {
return transformBundle(node);
}
return transformSourceFile(node);
}
function transformBundle(node) {
return factory.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) {
- if (prepend.kind === 306 /* InputFiles */) {
+ if (prepend.kind === 308 /* SyntaxKind.InputFiles */) {
return ts.createUnparsedSourceFile(prepend, "js");
}
return prepend;
@@ -89951,17 +91619,17 @@ var ts;
*/
function onBeforeVisitNode(node) {
switch (node.kind) {
- case 303 /* SourceFile */:
- case 262 /* CaseBlock */:
- case 261 /* ModuleBlock */:
- case 234 /* Block */:
+ case 305 /* SyntaxKind.SourceFile */:
+ case 263 /* SyntaxKind.CaseBlock */:
+ case 262 /* SyntaxKind.ModuleBlock */:
+ case 235 /* SyntaxKind.Block */:
currentLexicalScope = node;
currentNameScope = undefined;
currentScopeFirstDeclarationsOfName = undefined;
break;
- case 256 /* ClassDeclaration */:
- case 255 /* FunctionDeclaration */:
- if (ts.hasSyntacticModifier(node, 2 /* Ambient */)) {
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ if (ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) {
break;
}
// Record these declarations provided that they have a name.
@@ -89972,7 +91640,7 @@ var ts;
// These nodes should always have names unless they are default-exports;
// however, class declaration parsing allows for undefined names, so syntactically invalid
// programs may also have an undefined name.
- ts.Debug.assert(node.kind === 256 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */));
+ ts.Debug.assert(node.kind === 257 /* SyntaxKind.ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */));
}
if (ts.isClassDeclaration(node)) {
// XXX: should probably also cover interfaces and type aliases that can have type variables?
@@ -89995,7 +91663,7 @@ var ts;
* @param node The node to visit.
*/
function visitorWorker(node) {
- if (node.transformFlags & 1 /* ContainsTypeScript */) {
+ if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) {
return visitTypeScript(node);
}
return node;
@@ -90015,10 +91683,10 @@ var ts;
*/
function sourceElementVisitorWorker(node) {
switch (node.kind) {
- case 265 /* ImportDeclaration */:
- case 264 /* ImportEqualsDeclaration */:
- case 270 /* ExportAssignment */:
- case 271 /* ExportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 271 /* SyntaxKind.ExportAssignment */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
return visitElidableStatement(node);
default:
return visitorWorker(node);
@@ -90031,7 +91699,7 @@ var ts;
// As the type information we would attempt to lookup to perform ellision is potentially unavailable for the synthesized nodes
// We do not reuse `visitorWorker`, as the ellidable statement syntax kinds are technically unrecognized by the switch-case in `visitTypeScript`,
// and will trigger debug failures when debug verbosity is turned up
- if (node.transformFlags & 1 /* ContainsTypeScript */) {
+ if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) {
// This node contains TypeScript, so we should visit its children.
return ts.visitEachChild(node, visitor, context);
}
@@ -90039,13 +91707,13 @@ var ts;
return node;
}
switch (node.kind) {
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
return visitImportDeclaration(node);
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return visitImportEqualsDeclaration(node);
- case 270 /* ExportAssignment */:
+ case 271 /* SyntaxKind.ExportAssignment */:
return visitExportAssignment(node);
- case 271 /* ExportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
return visitExportDeclaration(node);
default:
ts.Debug.fail("Unhandled ellided statement");
@@ -90065,15 +91733,15 @@ var ts;
* @param node The node to visit.
*/
function namespaceElementVisitorWorker(node) {
- if (node.kind === 271 /* ExportDeclaration */ ||
- node.kind === 265 /* ImportDeclaration */ ||
- node.kind === 266 /* ImportClause */ ||
- (node.kind === 264 /* ImportEqualsDeclaration */ &&
- node.moduleReference.kind === 276 /* ExternalModuleReference */)) {
+ if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ ||
+ node.kind === 266 /* SyntaxKind.ImportDeclaration */ ||
+ node.kind === 267 /* SyntaxKind.ImportClause */ ||
+ (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ &&
+ node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */)) {
// do not emit ES6 imports and exports since they are illegal inside a namespace
return undefined;
}
- else if (node.transformFlags & 1 /* ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* Export */)) {
+ else if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) {
return visitTypeScript(node);
}
return node;
@@ -90093,30 +91761,30 @@ var ts;
*/
function classElementVisitorWorker(node) {
switch (node.kind) {
- case 170 /* Constructor */:
+ case 171 /* SyntaxKind.Constructor */:
return visitConstructor(node);
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
// Property declarations are not TypeScript syntax, but they must be visited
// for the decorator transformation.
return visitPropertyDeclaration(node);
- case 175 /* IndexSignature */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 168 /* MethodDeclaration */:
- case 169 /* ClassStaticBlockDeclaration */:
+ case 176 /* SyntaxKind.IndexSignature */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 170 /* SyntaxKind.ClassStaticBlockDeclaration */:
// Fallback to the default visit behavior.
return visitorWorker(node);
- case 233 /* SemicolonClassElement */:
+ case 234 /* SyntaxKind.SemicolonClassElement */:
return node;
default:
return ts.Debug.failBadSyntaxKind(node);
}
}
function modifierVisitor(node) {
- if (ts.modifierToFlag(node.kind) & 18654 /* TypeScriptModifier */) {
+ if (ts.modifierToFlag(node.kind) & 116958 /* ModifierFlags.TypeScriptModifier */) {
return undefined;
}
- else if (currentNamespace && node.kind === 93 /* ExportKeyword */) {
+ else if (currentNamespace && node.kind === 93 /* SyntaxKind.ExportKeyword */) {
return undefined;
}
return node;
@@ -90127,78 +91795,80 @@ var ts;
* @param node The node to visit.
*/
function visitTypeScript(node) {
- if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* Ambient */)) {
+ if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) {
// TypeScript ambient declarations are elided, but some comments may be preserved.
// See the implementation of `getLeadingComments` in comments.ts for more details.
return factory.createNotEmittedStatement(node);
}
switch (node.kind) {
- case 93 /* ExportKeyword */:
- case 88 /* DefaultKeyword */:
+ case 93 /* SyntaxKind.ExportKeyword */:
+ case 88 /* SyntaxKind.DefaultKeyword */:
// ES6 export and default modifiers are elided when inside a namespace.
return currentNamespace ? undefined : node;
- case 123 /* PublicKeyword */:
- case 121 /* PrivateKeyword */:
- case 122 /* ProtectedKeyword */:
- case 126 /* AbstractKeyword */:
- case 158 /* OverrideKeyword */:
- case 85 /* ConstKeyword */:
- case 135 /* DeclareKeyword */:
- case 144 /* ReadonlyKeyword */:
+ case 123 /* SyntaxKind.PublicKeyword */:
+ case 121 /* SyntaxKind.PrivateKeyword */:
+ case 122 /* SyntaxKind.ProtectedKeyword */:
+ case 126 /* SyntaxKind.AbstractKeyword */:
+ case 159 /* SyntaxKind.OverrideKeyword */:
+ case 85 /* SyntaxKind.ConstKeyword */:
+ case 135 /* SyntaxKind.DeclareKeyword */:
+ case 145 /* SyntaxKind.ReadonlyKeyword */:
+ case 101 /* SyntaxKind.InKeyword */:
+ case 144 /* SyntaxKind.OutKeyword */:
// TypeScript accessibility and readonly modifiers are elided
// falls through
- case 182 /* ArrayType */:
- case 183 /* TupleType */:
- case 184 /* OptionalType */:
- case 185 /* RestType */:
- case 181 /* TypeLiteral */:
- case 176 /* TypePredicate */:
- case 162 /* TypeParameter */:
- case 130 /* AnyKeyword */:
- case 154 /* UnknownKeyword */:
- case 133 /* BooleanKeyword */:
- case 149 /* StringKeyword */:
- case 146 /* NumberKeyword */:
- case 143 /* NeverKeyword */:
- case 114 /* VoidKeyword */:
- case 150 /* SymbolKeyword */:
- case 179 /* ConstructorType */:
- case 178 /* FunctionType */:
- case 180 /* TypeQuery */:
- case 177 /* TypeReference */:
- case 186 /* UnionType */:
- case 187 /* IntersectionType */:
- case 188 /* ConditionalType */:
- case 190 /* ParenthesizedType */:
- case 191 /* ThisType */:
- case 192 /* TypeOperator */:
- case 193 /* IndexedAccessType */:
- case 194 /* MappedType */:
- case 195 /* LiteralType */:
+ case 183 /* SyntaxKind.ArrayType */:
+ case 184 /* SyntaxKind.TupleType */:
+ case 185 /* SyntaxKind.OptionalType */:
+ case 186 /* SyntaxKind.RestType */:
+ case 182 /* SyntaxKind.TypeLiteral */:
+ case 177 /* SyntaxKind.TypePredicate */:
+ case 163 /* SyntaxKind.TypeParameter */:
+ case 130 /* SyntaxKind.AnyKeyword */:
+ case 155 /* SyntaxKind.UnknownKeyword */:
+ case 133 /* SyntaxKind.BooleanKeyword */:
+ case 150 /* SyntaxKind.StringKeyword */:
+ case 147 /* SyntaxKind.NumberKeyword */:
+ case 143 /* SyntaxKind.NeverKeyword */:
+ case 114 /* SyntaxKind.VoidKeyword */:
+ case 151 /* SyntaxKind.SymbolKeyword */:
+ case 180 /* SyntaxKind.ConstructorType */:
+ case 179 /* SyntaxKind.FunctionType */:
+ case 181 /* SyntaxKind.TypeQuery */:
+ case 178 /* SyntaxKind.TypeReference */:
+ case 187 /* SyntaxKind.UnionType */:
+ case 188 /* SyntaxKind.IntersectionType */:
+ case 189 /* SyntaxKind.ConditionalType */:
+ case 191 /* SyntaxKind.ParenthesizedType */:
+ case 192 /* SyntaxKind.ThisType */:
+ case 193 /* SyntaxKind.TypeOperator */:
+ case 194 /* SyntaxKind.IndexedAccessType */:
+ case 195 /* SyntaxKind.MappedType */:
+ case 196 /* SyntaxKind.LiteralType */:
// TypeScript type nodes are elided.
// falls through
- case 175 /* IndexSignature */:
+ case 176 /* SyntaxKind.IndexSignature */:
// TypeScript index signatures are elided.
// falls through
- case 164 /* Decorator */:
+ case 165 /* SyntaxKind.Decorator */:
// TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration.
return undefined;
- case 258 /* TypeAliasDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
// TypeScript type-only declarations are elided.
return factory.createNotEmittedStatement(node);
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
// TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects
return visitPropertyDeclaration(node);
- case 263 /* NamespaceExportDeclaration */:
+ case 264 /* SyntaxKind.NamespaceExportDeclaration */:
// TypeScript namespace export declarations are elided.
return undefined;
- case 170 /* Constructor */:
+ case 171 /* SyntaxKind.Constructor */:
return visitConstructor(node);
- case 257 /* InterfaceDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
// TypeScript interfaces are elided, but some comments may be preserved.
// See the implementation of `getLeadingComments` in comments.ts for more details.
return factory.createNotEmittedStatement(node);
- case 256 /* ClassDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
// This may be a class declaration with TypeScript syntax extensions.
//
// TypeScript class syntax extensions include:
@@ -90208,7 +91878,7 @@ var ts;
// - index signatures
// - method overload signatures
return visitClassDeclaration(node);
- case 225 /* ClassExpression */:
+ case 226 /* SyntaxKind.ClassExpression */:
// This may be a class expression with TypeScript syntax extensions.
//
// TypeScript class syntax extensions include:
@@ -90218,35 +91888,35 @@ var ts;
// - index signatures
// - method overload signatures
return visitClassExpression(node);
- case 290 /* HeritageClause */:
+ case 291 /* SyntaxKind.HeritageClause */:
// This may be a heritage clause with TypeScript syntax extensions.
//
// TypeScript heritage clause extensions include:
// - `implements` clause
return visitHeritageClause(node);
- case 227 /* ExpressionWithTypeArguments */:
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
// TypeScript supports type arguments on an expression in an `extends` heritage clause.
return visitExpressionWithTypeArguments(node);
- case 168 /* MethodDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
// TypeScript method declarations may have decorators, modifiers
// or type annotations.
return visitMethodDeclaration(node);
- case 171 /* GetAccessor */:
+ case 172 /* SyntaxKind.GetAccessor */:
// Get Accessors can have TypeScript modifiers, decorators, and type annotations.
return visitGetAccessor(node);
- case 172 /* SetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
// Set Accessors can have TypeScript modifiers and type annotations.
return visitSetAccessor(node);
- case 255 /* FunctionDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
// Typescript function declarations can have modifiers, decorators, and type annotations.
return visitFunctionDeclaration(node);
- case 212 /* FunctionExpression */:
+ case 213 /* SyntaxKind.FunctionExpression */:
// TypeScript function expressions can have modifiers and type annotations.
return visitFunctionExpression(node);
- case 213 /* ArrowFunction */:
+ case 214 /* SyntaxKind.ArrowFunction */:
// TypeScript arrow functions can have modifiers and type annotations.
return visitArrowFunction(node);
- case 163 /* Parameter */:
+ case 164 /* SyntaxKind.Parameter */:
// This may be a parameter declaration with TypeScript syntax extensions.
//
// TypeScript parameter declaration syntax extensions include:
@@ -90256,40 +91926,40 @@ var ts;
// - type annotations
// - this parameters
return visitParameter(node);
- case 211 /* ParenthesizedExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
// ParenthesizedExpressions are TypeScript if their expression is a
// TypeAssertion or AsExpression
return visitParenthesizedExpression(node);
- case 210 /* TypeAssertionExpression */:
- case 228 /* AsExpression */:
+ case 211 /* SyntaxKind.TypeAssertionExpression */:
+ case 229 /* SyntaxKind.AsExpression */:
// TypeScript type assertions are removed, but their subtrees are preserved.
return visitAssertionExpression(node);
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
return visitCallExpression(node);
- case 208 /* NewExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
return visitNewExpression(node);
- case 209 /* TaggedTemplateExpression */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
return visitTaggedTemplateExpression(node);
- case 229 /* NonNullExpression */:
+ case 230 /* SyntaxKind.NonNullExpression */:
// TypeScript non-null expressions are removed, but their subtrees are preserved.
return visitNonNullExpression(node);
- case 259 /* EnumDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
// TypeScript enum declarations do not exist in ES6 and must be rewritten.
return visitEnumDeclaration(node);
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
// TypeScript namespace exports for variable statements must be transformed.
return visitVariableStatement(node);
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return visitVariableDeclaration(node);
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
// TypeScript namespace declarations must be transformed.
return visitModuleDeclaration(node);
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
// TypeScript namespace or external module import.
return visitImportEqualsDeclaration(node);
- case 278 /* JsxSelfClosingElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
return visitJsxSelfClosingElement(node);
- case 279 /* JsxOpeningElement */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
return visitJsxJsxOpeningElement(node);
default:
// node contains some other TypeScript syntax
@@ -90303,28 +91973,28 @@ var ts;
return factory.updateSourceFile(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict));
}
function getClassFacts(node, staticProperties) {
- var facts = 0 /* None */;
+ var facts = 0 /* ClassFacts.None */;
if (ts.some(staticProperties))
- facts |= 1 /* HasStaticInitializedProperties */;
+ facts |= 1 /* ClassFacts.HasStaticInitializedProperties */;
var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
- if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */)
- facts |= 64 /* IsDerivedClass */;
+ if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */)
+ facts |= 64 /* ClassFacts.IsDerivedClass */;
if (ts.classOrConstructorParameterIsDecorated(node))
- facts |= 2 /* HasConstructorDecorators */;
+ facts |= 2 /* ClassFacts.HasConstructorDecorators */;
if (ts.childIsDecorated(node))
- facts |= 4 /* HasMemberDecorators */;
+ facts |= 4 /* ClassFacts.HasMemberDecorators */;
if (isExportOfNamespace(node))
- facts |= 8 /* IsExportOfNamespace */;
+ facts |= 8 /* ClassFacts.IsExportOfNamespace */;
else if (isDefaultExternalModuleExport(node))
- facts |= 32 /* IsDefaultExternalExport */;
+ facts |= 32 /* ClassFacts.IsDefaultExternalExport */;
else if (isNamedExternalModuleExport(node))
- facts |= 16 /* IsNamedExternalExport */;
- if (languageVersion <= 1 /* ES5 */ && (facts & 7 /* MayNeedImmediatelyInvokedFunctionExpression */))
- facts |= 128 /* UseImmediatelyInvokedFunctionExpression */;
+ facts |= 16 /* ClassFacts.IsNamedExternalExport */;
+ if (languageVersion <= 1 /* ScriptTarget.ES5 */ && (facts & 7 /* ClassFacts.MayNeedImmediatelyInvokedFunctionExpression */))
+ facts |= 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */;
return facts;
}
function hasTypeScriptClassSyntax(node) {
- return !!(node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */);
+ return !!(node.transformFlags & 4096 /* TransformFlags.ContainsTypeScriptClassSyntax */);
}
function isClassLikeDeclarationWithTypeScriptSyntax(node) {
return ts.some(node.decorators)
@@ -90333,16 +92003,16 @@ var ts;
|| ts.some(node.members, hasTypeScriptClassSyntax);
}
function visitClassDeclaration(node) {
- if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* Export */))) {
+ if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) {
return ts.visitEachChild(node, visitor, context);
}
var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true);
var facts = getClassFacts(node, staticProperties);
- if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) {
+ if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) {
context.startLexicalEnvironment();
}
- var name = node.name || (facts & 5 /* NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined);
- var classStatement = facts & 2 /* HasConstructorDecorators */
+ var name = node.name || (facts & 5 /* ClassFacts.NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined);
+ var classStatement = facts & 2 /* ClassFacts.HasConstructorDecorators */
? createClassDeclarationHeadWithDecorators(node, name)
: createClassDeclarationHeadWithoutDecorators(node, name, facts);
var statements = [classStatement];
@@ -90350,7 +92020,7 @@ var ts;
addClassElementDecorationStatements(statements, node, /*isStatic*/ false);
addClassElementDecorationStatements(statements, node, /*isStatic*/ true);
addConstructorDecorationStatement(statements, node);
- if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) {
+ if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) {
// When we emit a TypeScript class down to ES5, we must wrap it in an IIFE so that the
// 'es2015' transformer can properly nest static initializers and decorators. The result
// looks something like:
@@ -90362,20 +92032,20 @@ var ts;
// return C;
// }();
//
- var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* CloseBraceToken */);
+ var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* SyntaxKind.CloseBraceToken */);
var localName = factory.getInternalName(node);
// The following partially-emitted expression exists purely to align our sourcemap
// emit with the original emitter.
var outer = factory.createPartiallyEmittedExpression(localName);
ts.setTextRangeEnd(outer, closingBraceLocation.end);
- ts.setEmitFlags(outer, 1536 /* NoComments */);
+ ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */);
var statement = factory.createReturnStatement(outer);
ts.setTextRangePos(statement, closingBraceLocation.pos);
- ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */);
+ ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */);
statements.push(statement);
ts.insertStatementsAfterStandardPrologue(statements, context.endLexicalEnvironment());
var iife = factory.createImmediatelyInvokedArrowFunction(statements);
- ts.setEmitFlags(iife, 33554432 /* TypeScriptClassWrapper */);
+ ts.setEmitFlags(iife, 33554432 /* EmitFlags.TypeScriptClassWrapper */);
var varStatement = factory.createVariableStatement(
/*modifiers*/ undefined, factory.createVariableDeclarationList([
factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ false),
@@ -90391,21 +92061,21 @@ var ts;
// If the class is exported as part of a TypeScript namespace, emit the namespace export.
// Otherwise, if the class was exported at the top level and was decorated, emit an export
// declaration or export default for the class.
- if (facts & 8 /* IsExportOfNamespace */) {
+ if (facts & 8 /* ClassFacts.IsExportOfNamespace */) {
addExportMemberAssignment(statements, node);
}
- else if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* HasConstructorDecorators */) {
- if (facts & 32 /* IsDefaultExternalExport */) {
+ else if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* ClassFacts.HasConstructorDecorators */) {
+ if (facts & 32 /* ClassFacts.IsDefaultExternalExport */) {
statements.push(factory.createExportDefault(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)));
}
- else if (facts & 16 /* IsNamedExternalExport */) {
+ else if (facts & 16 /* ClassFacts.IsNamedExternalExport */) {
statements.push(factory.createExternalModuleExport(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)));
}
}
if (statements.length > 1) {
// Add a DeclarationMarker as a marker for the end of the declaration
statements.push(factory.createEndOfDeclarationMarker(node));
- ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */);
+ ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */);
}
return ts.singleOrMany(statements);
}
@@ -90421,7 +92091,7 @@ var ts;
// ${members}
// }
// we do not emit modifiers on the declaration if we are emitting an IIFE
- var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */)
+ var modifiers = !(facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */)
? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)
: undefined;
var classDeclaration = factory.createClassDeclaration(
@@ -90430,8 +92100,8 @@ var ts;
// To better align with the old emitter, we should not emit a trailing source map
// entry if the class has static properties.
var emitFlags = ts.getEmitFlags(node);
- if (facts & 1 /* HasStaticInitializedProperties */) {
- emitFlags |= 32 /* NoTrailingSourceMap */;
+ if (facts & 1 /* ClassFacts.HasStaticInitializedProperties */) {
+ emitFlags |= 32 /* EmitFlags.NoTrailingSourceMap */;
}
ts.setTextRange(classDeclaration, node);
ts.setOriginalNode(classDeclaration, node);
@@ -90532,7 +92202,7 @@ var ts;
var classAlias = getClassAliasIfNeeded(node);
// When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
// without any block-scoped variable collision handling
- var declName = languageVersion <= 2 /* ES2015 */ ?
+ var declName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ?
factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
// ... = class ${name} ${heritageClauses} {
@@ -90550,7 +92220,7 @@ var ts;
factory.createVariableDeclaration(declName,
/*exclamationToken*/ undefined,
/*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression)
- ], 1 /* Let */));
+ ], 1 /* NodeFlags.Let */));
ts.setOriginalNode(statement, node);
ts.setTextRange(statement, location);
ts.setCommentRange(statement, node);
@@ -90683,12 +92353,12 @@ var ts;
*/
function getAllDecoratorsOfClassElement(node, member) {
switch (member.kind) {
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
return getAllDecoratorsOfAccessors(node, member);
- case 168 /* MethodDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
return getAllDecoratorsOfMethod(member);
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
return getAllDecoratorsOfProperty(member);
default:
return undefined;
@@ -90782,8 +92452,8 @@ var ts;
function generateClassElementDecorationExpressions(node, isStatic) {
var members = getDecoratedClassElements(node, isStatic);
var expressions;
- for (var _i = 0, members_6 = members; _i < members_6.length; _i++) {
- var member = members_6[_i];
+ 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) {
@@ -90839,9 +92509,9 @@ var ts;
// ], C.prototype, "prop");
//
var prefix = getClassMemberPrefix(node, member);
- var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */));
- var descriptor = languageVersion > 0 /* ES3 */
- ? member.kind === 166 /* PropertyDeclaration */
+ var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* ModifierFlags.Ambient */));
+ var descriptor = languageVersion > 0 /* ScriptTarget.ES3 */
+ ? member.kind === 167 /* SyntaxKind.PropertyDeclaration */
// We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it
// should not invoke `Object.getOwnPropertyDescriptor`.
? factory.createVoidZero()
@@ -90851,7 +92521,7 @@ var ts;
: undefined;
var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor);
ts.setTextRange(helper, ts.moveRangePastDecorators(member));
- ts.setEmitFlags(helper, 1536 /* NoComments */);
+ ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */);
return helper;
}
/**
@@ -90879,12 +92549,12 @@ var ts;
var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)];
// When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
// without any block-scoped variable collision handling
- var localName = languageVersion <= 2 /* ES2015 */ ?
+ var localName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ?
factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName);
var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate);
- ts.setEmitFlags(expression, 1536 /* NoComments */);
+ ts.setEmitFlags(expression, 1536 /* EmitFlags.NoComments */);
ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node));
return expression;
}
@@ -90910,7 +92580,7 @@ var ts;
var decorator = decorators_1[_i];
var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset);
ts.setTextRange(helper, decorator.expression);
- ts.setEmitFlags(helper, 1536 /* NoComments */);
+ ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */);
expressions.push(helper);
}
}
@@ -90947,13 +92617,13 @@ var ts;
if (compilerOptions.emitDecoratorMetadata) {
var properties = void 0;
if (shouldAddTypeMetadata(node)) {
- (properties || (properties = [])).push(factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeTypeOfNode(node))));
+ (properties || (properties = [])).push(factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), serializeTypeOfNode(node))));
}
if (shouldAddParamTypesMetadata(node)) {
- (properties || (properties = [])).push(factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container))));
+ (properties || (properties = [])).push(factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container))));
}
if (shouldAddReturnTypeMetadata(node)) {
- (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node))));
+ (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), serializeReturnTypeOfNode(node))));
}
if (properties) {
decoratorExpressions.push(emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, /*multiLine*/ true)));
@@ -90969,10 +92639,10 @@ var ts;
*/
function shouldAddTypeMetadata(node) {
var kind = node.kind;
- return kind === 168 /* MethodDeclaration */
- || kind === 171 /* GetAccessor */
- || kind === 172 /* SetAccessor */
- || kind === 166 /* PropertyDeclaration */;
+ return kind === 169 /* SyntaxKind.MethodDeclaration */
+ || kind === 172 /* SyntaxKind.GetAccessor */
+ || kind === 173 /* SyntaxKind.SetAccessor */
+ || kind === 167 /* SyntaxKind.PropertyDeclaration */;
}
/**
* Determines whether to emit the "design:returntype" metadata based on the node's kind.
@@ -90982,7 +92652,7 @@ var ts;
* @param node The node to test.
*/
function shouldAddReturnTypeMetadata(node) {
- return node.kind === 168 /* MethodDeclaration */;
+ return node.kind === 169 /* SyntaxKind.MethodDeclaration */;
}
/**
* Determines whether to emit the "design:paramtypes" metadata based on the node's kind.
@@ -90993,12 +92663,12 @@ var ts;
*/
function shouldAddParamTypesMetadata(node) {
switch (node.kind) {
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
return ts.getFirstConstructorWithBody(node) !== undefined;
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
return true;
}
return false;
@@ -91015,15 +92685,15 @@ var ts;
*/
function serializeTypeOfNode(node) {
switch (node.kind) {
- case 166 /* PropertyDeclaration */:
- case 163 /* Parameter */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 164 /* SyntaxKind.Parameter */:
return serializeTypeNode(node.type);
- case 172 /* SetAccessor */:
- case 171 /* GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 172 /* SyntaxKind.GetAccessor */:
return serializeTypeNode(getAccessorTypeNode(node));
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- case 168 /* MethodDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
return factory.createIdentifier("Function");
default:
return factory.createVoidZero();
@@ -91060,7 +92730,7 @@ var ts;
return factory.createArrayLiteralExpression(expressions);
}
function getParametersOfDecoratedDeclaration(node, container) {
- if (container && node.kind === 171 /* GetAccessor */) {
+ if (container && node.kind === 172 /* SyntaxKind.GetAccessor */) {
var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor;
if (setAccessor) {
return setAccessor.parameters;
@@ -91105,83 +92775,83 @@ var ts;
return factory.createIdentifier("Object");
}
switch (node.kind) {
- case 114 /* VoidKeyword */:
- case 152 /* UndefinedKeyword */:
- case 143 /* NeverKeyword */:
+ case 114 /* SyntaxKind.VoidKeyword */:
+ case 153 /* SyntaxKind.UndefinedKeyword */:
+ case 143 /* SyntaxKind.NeverKeyword */:
return factory.createVoidZero();
- case 190 /* ParenthesizedType */:
+ case 191 /* SyntaxKind.ParenthesizedType */:
return serializeTypeNode(node.type);
- case 178 /* FunctionType */:
- case 179 /* ConstructorType */:
+ case 179 /* SyntaxKind.FunctionType */:
+ case 180 /* SyntaxKind.ConstructorType */:
return factory.createIdentifier("Function");
- case 182 /* ArrayType */:
- case 183 /* TupleType */:
+ case 183 /* SyntaxKind.ArrayType */:
+ case 184 /* SyntaxKind.TupleType */:
return factory.createIdentifier("Array");
- case 176 /* TypePredicate */:
- case 133 /* BooleanKeyword */:
+ case 177 /* SyntaxKind.TypePredicate */:
+ case 133 /* SyntaxKind.BooleanKeyword */:
return factory.createIdentifier("Boolean");
- case 197 /* TemplateLiteralType */:
- case 149 /* StringKeyword */:
+ case 198 /* SyntaxKind.TemplateLiteralType */:
+ case 150 /* SyntaxKind.StringKeyword */:
return factory.createIdentifier("String");
- case 147 /* ObjectKeyword */:
+ case 148 /* SyntaxKind.ObjectKeyword */:
return factory.createIdentifier("Object");
- case 195 /* LiteralType */:
+ case 196 /* SyntaxKind.LiteralType */:
switch (node.literal.kind) {
- case 10 /* StringLiteral */:
- case 14 /* NoSubstitutionTemplateLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
return factory.createIdentifier("String");
- case 218 /* PrefixUnaryExpression */:
- case 8 /* NumericLiteral */:
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
+ case 8 /* SyntaxKind.NumericLiteral */:
return factory.createIdentifier("Number");
- case 9 /* BigIntLiteral */:
+ case 9 /* SyntaxKind.BigIntLiteral */:
return getGlobalBigIntNameWithFallback();
- case 110 /* TrueKeyword */:
- case 95 /* FalseKeyword */:
+ case 110 /* SyntaxKind.TrueKeyword */:
+ case 95 /* SyntaxKind.FalseKeyword */:
return factory.createIdentifier("Boolean");
- case 104 /* NullKeyword */:
+ case 104 /* SyntaxKind.NullKeyword */:
return factory.createVoidZero();
default:
return ts.Debug.failBadSyntaxKind(node.literal);
}
- case 146 /* NumberKeyword */:
+ case 147 /* SyntaxKind.NumberKeyword */:
return factory.createIdentifier("Number");
- case 157 /* BigIntKeyword */:
+ case 158 /* SyntaxKind.BigIntKeyword */:
return getGlobalBigIntNameWithFallback();
- case 150 /* SymbolKeyword */:
- return languageVersion < 2 /* ES2015 */
+ case 151 /* SyntaxKind.SymbolKeyword */:
+ return languageVersion < 2 /* ScriptTarget.ES2015 */
? getGlobalSymbolNameWithFallback()
: factory.createIdentifier("Symbol");
- case 177 /* TypeReference */:
+ case 178 /* SyntaxKind.TypeReference */:
return serializeTypeReferenceNode(node);
- case 187 /* IntersectionType */:
- case 186 /* UnionType */:
+ case 188 /* SyntaxKind.IntersectionType */:
+ case 187 /* SyntaxKind.UnionType */:
return serializeTypeList(node.types);
- case 188 /* ConditionalType */:
+ case 189 /* SyntaxKind.ConditionalType */:
return serializeTypeList([node.trueType, node.falseType]);
- case 192 /* TypeOperator */:
- if (node.operator === 144 /* ReadonlyKeyword */) {
+ case 193 /* SyntaxKind.TypeOperator */:
+ if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) {
return serializeTypeNode(node.type);
}
break;
- case 180 /* TypeQuery */:
- case 193 /* IndexedAccessType */:
- case 194 /* MappedType */:
- case 181 /* TypeLiteral */:
- case 130 /* AnyKeyword */:
- case 154 /* UnknownKeyword */:
- case 191 /* ThisType */:
- case 199 /* ImportType */:
+ case 181 /* SyntaxKind.TypeQuery */:
+ case 194 /* SyntaxKind.IndexedAccessType */:
+ case 195 /* SyntaxKind.MappedType */:
+ case 182 /* SyntaxKind.TypeLiteral */:
+ case 130 /* SyntaxKind.AnyKeyword */:
+ case 155 /* SyntaxKind.UnknownKeyword */:
+ case 192 /* SyntaxKind.ThisType */:
+ case 200 /* SyntaxKind.ImportType */:
break;
// handle JSDoc types from an invalid parse
- case 310 /* JSDocAllType */:
- case 311 /* JSDocUnknownType */:
- case 315 /* JSDocFunctionType */:
- case 316 /* JSDocVariadicType */:
- case 317 /* JSDocNamepathType */:
+ case 312 /* SyntaxKind.JSDocAllType */:
+ case 313 /* SyntaxKind.JSDocUnknownType */:
+ case 317 /* SyntaxKind.JSDocFunctionType */:
+ case 318 /* SyntaxKind.JSDocVariadicType */:
+ case 319 /* SyntaxKind.JSDocNamepathType */:
break;
- case 312 /* JSDocNullableType */:
- case 313 /* JSDocNonNullableType */:
- case 314 /* JSDocOptionalType */:
+ case 314 /* SyntaxKind.JSDocNullableType */:
+ case 315 /* SyntaxKind.JSDocNonNullableType */:
+ case 316 /* SyntaxKind.JSDocOptionalType */:
return serializeTypeNode(node.type);
default:
return ts.Debug.failBadSyntaxKind(node);
@@ -91194,13 +92864,13 @@ var ts;
var serializedUnion;
for (var _i = 0, types_23 = types; _i < types_23.length; _i++) {
var typeNode = types_23[_i];
- while (typeNode.kind === 190 /* ParenthesizedType */) {
+ while (typeNode.kind === 191 /* SyntaxKind.ParenthesizedType */) {
typeNode = typeNode.type; // Skip parens if need be
}
- if (typeNode.kind === 143 /* NeverKeyword */) {
+ if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) {
continue; // Always elide `never` from the union/intersection if possible
}
- if (!strictNullChecks && (typeNode.kind === 195 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 152 /* UndefinedKeyword */)) {
+ if (!strictNullChecks && (typeNode.kind === 196 /* SyntaxKind.LiteralType */ && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */ || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) {
continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks
}
var serializedIndividual = serializeTypeNode(typeNode);
@@ -91260,7 +92930,7 @@ var ts;
case ts.TypeReferenceSerializationKind.ArrayLikeType:
return factory.createIdentifier("Array");
case ts.TypeReferenceSerializationKind.ESSymbolType:
- return languageVersion < 2 /* ES2015 */
+ return languageVersion < 2 /* ScriptTarget.ES2015 */
? getGlobalSymbolNameWithFallback()
: factory.createIdentifier("Symbol");
case ts.TypeReferenceSerializationKind.TypeWithCallSignature:
@@ -91282,12 +92952,12 @@ var ts;
* @param node The entity name to serialize.
*/
function serializeEntityNameAsExpressionFallback(node) {
- if (node.kind === 79 /* Identifier */) {
+ if (node.kind === 79 /* SyntaxKind.Identifier */) {
// A -> typeof A !== undefined && A
var copied = serializeEntityNameAsExpression(node);
return createCheckedValue(copied, copied);
}
- if (node.left.kind === 79 /* Identifier */) {
+ if (node.left.kind === 79 /* SyntaxKind.Identifier */) {
// A.B -> typeof A !== undefined && A.B
return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
}
@@ -91303,14 +92973,14 @@ var ts;
*/
function serializeEntityNameAsExpression(node) {
switch (node.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
// Create a clone of the name with a new parent, and treat it as if it were
// a source tree node for the purposes of the checker.
var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent);
name.original = undefined;
ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node.
return name;
- case 160 /* QualifiedName */:
+ case 161 /* SyntaxKind.QualifiedName */:
return serializeQualifiedNameAsExpression(node);
}
}
@@ -91338,7 +93008,7 @@ var ts;
* available.
*/
function getGlobalBigIntNameWithFallback() {
- return languageVersion < 99 /* ESNext */
+ return languageVersion < 99 /* ScriptTarget.ESNext */
? factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("BigInt"), "function"),
/*questionToken*/ undefined, factory.createIdentifier("BigInt"),
/*colonToken*/ undefined, factory.createIdentifier("Object"))
@@ -91401,7 +93071,7 @@ var ts;
* @param node The HeritageClause to transform.
*/
function visitHeritageClause(node) {
- if (node.token === 117 /* ImplementsKeyword */) {
+ if (node.token === 117 /* SyntaxKind.ImplementsKeyword */) {
// implements clauses are elided
return undefined;
}
@@ -91429,7 +93099,7 @@ var ts;
return !ts.nodeIsMissing(node.body);
}
function visitPropertyDeclaration(node) {
- if (node.flags & 8388608 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
+ if (node.flags & 16777216 /* NodeFlags.Ambient */ || ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) {
return undefined;
}
var updated = factory.updatePropertyDeclaration(node,
@@ -91460,11 +93130,11 @@ var ts;
}
var statements = [];
resumeLexicalEnvironment();
- var indexAfterLastPrologueStatement = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
- var superStatementIndex = ts.findSuperStatementIndex(body.statements, indexAfterLastPrologueStatement);
+ var prologueStatementCount = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
+ var superStatementIndex = ts.findSuperStatementIndex(body.statements, prologueStatementCount);
// If there was a super call, visit existing statements up to and including it
if (superStatementIndex >= 0) {
- ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexAfterLastPrologueStatement, superStatementIndex + 1 - indexAfterLastPrologueStatement));
+ ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, prologueStatementCount, superStatementIndex + 1 - prologueStatementCount));
}
// Transform parameters into property assignments. Transforms this:
//
@@ -91483,12 +93153,12 @@ var ts;
if (superStatementIndex >= 0) {
ts.addRange(statements, parameterPropertyAssignments);
}
- // Since there was no super() call, parameter properties are the first statements in the constructor
+ // Since there was no super() call, parameter properties are the first statements in the constructor after any prologue statements
else {
- statements = ts.addRange(parameterPropertyAssignments, statements);
+ statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
}
- // Add remaining statements from the body, skipping the super() call if it was found
- ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1));
+ // Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements
+ ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount));
// End the lexical environment.
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
@@ -91508,10 +93178,10 @@ var ts;
}
// TODO(rbuckton): Does this need to be parented?
var propertyName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent);
- ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */);
+ ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 48 /* EmitFlags.NoSourceMap */);
// TODO(rbuckton): Does this need to be parented?
var localName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent);
- ts.setEmitFlags(localName, 1536 /* NoComments */);
+ ts.setEmitFlags(localName, 1536 /* EmitFlags.NoComments */);
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) {
@@ -91538,7 +93208,7 @@ var ts;
* @param node The declaration node.
*/
function shouldEmitAccessorDeclaration(node) {
- return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* Abstract */));
+ return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */));
}
function visitGetAccessor(node) {
if (!shouldEmitAccessorDeclaration(node)) {
@@ -91614,7 +93284,7 @@ var ts;
ts.setCommentRange(updated, node);
ts.setTextRange(updated, ts.moveRangePastModifiers(node));
ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node));
- ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */);
+ ts.setEmitFlags(updated.name, 32 /* EmitFlags.NoTrailingSourceMap */);
}
return updated;
}
@@ -91634,7 +93304,7 @@ var ts;
function transformInitializedVariable(node) {
var name = node.name;
if (ts.isBindingPattern(name)) {
- return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */,
+ return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */,
/*needsValue*/ false, createNamespaceExportExpression);
}
else {
@@ -91643,12 +93313,16 @@ var ts;
}
}
function visitVariableDeclaration(node) {
- return factory.updateVariableDeclaration(node, ts.visitNode(node.name, visitor, ts.isBindingName),
+ var updated = factory.updateVariableDeclaration(node, ts.visitNode(node.name, visitor, ts.isBindingName),
/*exclamationToken*/ undefined,
/*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
+ if (node.type) {
+ ts.setTypeNode(updated.name, node.type);
+ }
+ return updated;
}
function visitParenthesizedExpression(node) {
- var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* Assertions */);
+ var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* OuterExpressionKinds.Assertions */);
if (ts.isAssertionExpression(innerExpression)) {
// Make sure we consider all nested cast expressions, e.g.:
// (<any><number><any>-A).x;
@@ -91725,7 +93399,7 @@ var ts;
var statements = [];
// We request to be advised when the printer is about to print this node. This allows
// us to set up the correct state for later substitutions.
- var emitFlags = 2 /* AdviseOnEmitNode */;
+ var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */;
// If needed, we should emit a variable declaration for the enum. If we emit
// a leading variable declaration, we should not emit leading comments for the
// enum body.
@@ -91733,7 +93407,7 @@ var ts;
if (varAdded) {
// We should still emit the comments if we are emitting a system module.
if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) {
- emitFlags |= 512 /* NoLeadingComments */;
+ emitFlags |= 512 /* EmitFlags.NoLeadingComments */;
}
}
// `parameterName` is the declaration name used inside of the enum.
@@ -91741,7 +93415,7 @@ var ts;
// `containerName` is the expression used inside of the enum for assignments.
var containerName = getNamespaceContainerName(node);
// `exportName` is the expression used within this node's container for any exported references.
- var exportName = ts.hasSyntacticModifier(node, 1 /* Export */)
+ var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)
? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true)
: factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
// x || (x = {})
@@ -91807,7 +93481,7 @@ var ts;
var name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false);
var valueExpression = transformEnumMemberDeclarationValue(member);
var innerAssignment = factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, name), valueExpression);
- var outerAssignment = valueExpression.kind === 10 /* StringLiteral */ ?
+ var outerAssignment = valueExpression.kind === 10 /* SyntaxKind.StringLiteral */ ?
innerAssignment :
factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, innerAssignment), name);
return ts.setTextRange(factory.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member);
@@ -91895,12 +93569,12 @@ var ts;
// enums in any other scope are emitted as a `let` declaration.
var statement = factory.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.createVariableDeclarationList([
factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))
- ], currentLexicalScope.kind === 303 /* SourceFile */ ? 0 /* None */ : 1 /* Let */));
+ ], currentLexicalScope.kind === 305 /* SyntaxKind.SourceFile */ ? 0 /* NodeFlags.None */ : 1 /* NodeFlags.Let */));
ts.setOriginalNode(statement, node);
recordEmittedDeclarationInScope(node);
if (isFirstEmittedDeclarationInScope(node)) {
// Adjust the source map emit to match the old emitter.
- if (node.kind === 259 /* EnumDeclaration */) {
+ if (node.kind === 260 /* SyntaxKind.EnumDeclaration */) {
ts.setSourceMapRange(statement.declarationList, node);
}
else {
@@ -91925,7 +93599,7 @@ var ts;
// })(m1 || (m1 = {})); // trailing comment module
//
ts.setCommentRange(statement, node);
- ts.addEmitFlags(statement, 1024 /* NoTrailingComments */ | 4194304 /* HasEndOfDeclarationMarker */);
+ ts.addEmitFlags(statement, 1024 /* EmitFlags.NoTrailingComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */);
statements.push(statement);
return true;
}
@@ -91935,7 +93609,7 @@ var ts;
// begin/end semantics of the declararation and to properly handle exports
// we wrap the leading variable declaration in a `MergeDeclarationMarker`.
var mergeMarker = factory.createMergeDeclarationMarker(statement);
- ts.setEmitFlags(mergeMarker, 1536 /* NoComments */ | 4194304 /* HasEndOfDeclarationMarker */);
+ ts.setEmitFlags(mergeMarker, 1536 /* EmitFlags.NoComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */);
statements.push(mergeMarker);
return false;
}
@@ -91956,7 +93630,7 @@ var ts;
var statements = [];
// We request to be advised when the printer is about to print this node. This allows
// us to set up the correct state for later substitutions.
- var emitFlags = 2 /* AdviseOnEmitNode */;
+ var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */;
// If needed, we should emit a variable declaration for the module. If we emit
// a leading variable declaration, we should not emit leading comments for the
// module body.
@@ -91964,7 +93638,7 @@ var ts;
if (varAdded) {
// We should still emit the comments if we are emitting a system module.
if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) {
- emitFlags |= 512 /* NoLeadingComments */;
+ emitFlags |= 512 /* EmitFlags.NoLeadingComments */;
}
}
// `parameterName` is the declaration name used inside of the namespace.
@@ -91972,7 +93646,7 @@ var ts;
// `containerName` is the expression used inside of the namespace for exports.
var containerName = getNamespaceContainerName(node);
// `exportName` is the expression used within this node's container for any exported references.
- var exportName = ts.hasSyntacticModifier(node, 1 /* Export */)
+ var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)
? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true)
: factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
// x || (x = {})
@@ -92025,7 +93699,7 @@ var ts;
var statementsLocation;
var blockLocation;
if (node.body) {
- if (node.body.kind === 261 /* ModuleBlock */) {
+ if (node.body.kind === 262 /* SyntaxKind.ModuleBlock */) {
saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); });
statementsLocation = node.body.statements;
blockLocation = node.body;
@@ -92072,13 +93746,13 @@ var ts;
// })(hi = hello.hi || (hello.hi = {}));
// })(hello || (hello = {}));
// We only want to emit comment on the namespace which contains block body itself, not the containing namespaces.
- if (!node.body || node.body.kind !== 261 /* ModuleBlock */) {
- ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */);
+ if (!node.body || node.body.kind !== 262 /* SyntaxKind.ModuleBlock */) {
+ ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* EmitFlags.NoComments */);
}
return block;
}
function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) {
- if (moduleDeclaration.body.kind === 260 /* ModuleDeclaration */) {
+ if (moduleDeclaration.body.kind === 261 /* SyntaxKind.ModuleDeclaration */) {
var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body);
return recursiveInnerModule || moduleDeclaration.body;
}
@@ -92101,8 +93775,8 @@ var ts;
// Elide the declaration if the import clause was elided.
var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause);
return importClause ||
- compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ ||
- compilerOptions.importsNotUsedAsValues === 2 /* Error */
+ compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ ||
+ compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */
? factory.updateImportDeclaration(node,
/*decorators*/ undefined,
/*modifiers*/ undefined, importClause, node.moduleSpecifier, node.assertClause)
@@ -92126,14 +93800,14 @@ var ts;
* @param node The named import bindings node.
*/
function visitNamedImportBindings(node) {
- if (node.kind === 267 /* NamespaceImport */) {
+ if (node.kind === 268 /* SyntaxKind.NamespaceImport */) {
// Elide a namespace import if it is not referenced.
return shouldEmitAliasDeclaration(node) ? node : undefined;
}
else {
// Elide named imports if all of its import specifiers are elided and settings allow.
- var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ ||
- compilerOptions.importsNotUsedAsValues === 2 /* Error */);
+ var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ ||
+ compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */);
var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier);
return allowEmpty || ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined;
}
@@ -92174,8 +93848,8 @@ var ts;
return node;
}
// Elide the export declaration if all of its named exports are elided.
- var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ ||
- compilerOptions.importsNotUsedAsValues === 2 /* Error */);
+ var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ ||
+ compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */);
var exportClause = ts.visitNode(node.exportClause, function (bindings) { return visitNamedExportBindings(bindings, allowEmpty); }, ts.isNamedExportBindings);
return exportClause
? factory.updateExportDeclaration(node,
@@ -92235,7 +93909,7 @@ var ts;
if (ts.isExternalModuleImportEqualsDeclaration(node)) {
var isReferenced = shouldEmitAliasDeclaration(node);
// If the alias is unreferenced but we want to keep the import, replace with 'import "mod"'.
- if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* Preserve */) {
+ if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */) {
return ts.setOriginalNode(ts.setTextRange(factory.createImportDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined,
@@ -92248,7 +93922,7 @@ var ts;
return undefined;
}
var moduleReference = ts.createExpressionFromEntityName(factory, node.moduleReference);
- ts.setEmitFlags(moduleReference, 1536 /* NoComments */ | 2048 /* NoNestedComments */);
+ ts.setEmitFlags(moduleReference, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */);
if (isNamedExternalModuleExport(node) || !isExportOfNamespace(node)) {
// export var ${name} = ${moduleReference};
// var ${name} = ${moduleReference};
@@ -92269,7 +93943,7 @@ var ts;
* @param node The node to test.
*/
function isExportOfNamespace(node) {
- return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* Export */);
+ return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */);
}
/**
* Gets a value indicating whether the node is exported from an external module.
@@ -92277,7 +93951,7 @@ var ts;
* @param node The node to test.
*/
function isExternalModuleExport(node) {
- return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* Export */);
+ return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */);
}
/**
* Gets a value indicating whether the node is a named export from an external module.
@@ -92286,7 +93960,7 @@ var ts;
*/
function isNamedExternalModuleExport(node) {
return isExternalModuleExport(node)
- && !ts.hasSyntacticModifier(node, 512 /* Default */);
+ && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */);
}
/**
* Gets a value indicating whether the node is the default export of an external module.
@@ -92295,7 +93969,7 @@ var ts;
*/
function isDefaultExternalModuleExport(node) {
return isExternalModuleExport(node)
- && ts.hasSyntacticModifier(node, 512 /* Default */);
+ && ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */);
}
/**
* Creates a statement for the provided expression. This is used in calls to `map`.
@@ -92340,7 +94014,7 @@ var ts;
* double-binding semantics for the class name.
*/
function getClassAliasIfNeeded(node) {
- if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) {
+ if (resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */) {
enableSubstitutionForClassAliases();
var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default");
classAliases[ts.getOriginalNodeId(node)] = classAlias;
@@ -92357,37 +94031,37 @@ var ts;
: getClassPrototype(node);
}
function enableSubstitutionForNonQualifiedEnumMembers() {
- if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) {
- enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */;
- context.enableSubstitution(79 /* Identifier */);
+ if ((enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */) === 0) {
+ enabledSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */;
+ context.enableSubstitution(79 /* SyntaxKind.Identifier */);
}
}
function enableSubstitutionForClassAliases() {
- if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) {
- enabledSubstitutions |= 1 /* ClassAliases */;
+ if ((enabledSubstitutions & 1 /* TypeScriptSubstitutionFlags.ClassAliases */) === 0) {
+ enabledSubstitutions |= 1 /* TypeScriptSubstitutionFlags.ClassAliases */;
// We need to enable substitutions for identifiers. This allows us to
// substitute class names inside of a class declaration.
- context.enableSubstitution(79 /* Identifier */);
+ context.enableSubstitution(79 /* SyntaxKind.Identifier */);
// Keep track of class aliases.
classAliases = [];
}
}
function enableSubstitutionForNamespaceExports() {
- if ((enabledSubstitutions & 2 /* NamespaceExports */) === 0) {
- enabledSubstitutions |= 2 /* NamespaceExports */;
+ if ((enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) === 0) {
+ enabledSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */;
// We need to enable substitutions for identifiers and shorthand property assignments. This allows us to
// substitute the names of exported members of a namespace.
- context.enableSubstitution(79 /* Identifier */);
- context.enableSubstitution(295 /* ShorthandPropertyAssignment */);
+ context.enableSubstitution(79 /* SyntaxKind.Identifier */);
+ context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */);
// We need to be notified when entering and exiting namespaces.
- context.enableEmitNotification(260 /* ModuleDeclaration */);
+ context.enableEmitNotification(261 /* SyntaxKind.ModuleDeclaration */);
}
}
function isTransformedModuleDeclaration(node) {
- return ts.getOriginalNode(node).kind === 260 /* ModuleDeclaration */;
+ return ts.getOriginalNode(node).kind === 261 /* SyntaxKind.ModuleDeclaration */;
}
function isTransformedEnumDeclaration(node) {
- return ts.getOriginalNode(node).kind === 259 /* EnumDeclaration */;
+ return ts.getOriginalNode(node).kind === 260 /* SyntaxKind.EnumDeclaration */;
}
/**
* Hook for node emit.
@@ -92402,11 +94076,11 @@ var ts;
if (ts.isSourceFile(node)) {
currentSourceFile = node;
}
- if (enabledSubstitutions & 2 /* NamespaceExports */ && isTransformedModuleDeclaration(node)) {
- applicableSubstitutions |= 2 /* NamespaceExports */;
+ if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && isTransformedModuleDeclaration(node)) {
+ applicableSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */;
}
- if (enabledSubstitutions & 8 /* NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) {
- applicableSubstitutions |= 8 /* NonQualifiedEnumMembers */;
+ if (enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) {
+ applicableSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */;
}
previousOnEmitNode(hint, node, emitCallback);
applicableSubstitutions = savedApplicableSubstitutions;
@@ -92420,7 +94094,7 @@ var ts;
*/
function onSubstituteNode(hint, node) {
node = previousOnSubstituteNode(hint, node);
- if (hint === 1 /* Expression */) {
+ if (hint === 1 /* EmitHint.Expression */) {
return substituteExpression(node);
}
else if (ts.isShorthandPropertyAssignment(node)) {
@@ -92429,7 +94103,7 @@ var ts;
return node;
}
function substituteShorthandPropertyAssignment(node) {
- if (enabledSubstitutions & 2 /* NamespaceExports */) {
+ if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) {
var name = node.name;
var exportedName = trySubstituteNamespaceExportedName(name);
if (exportedName) {
@@ -92446,11 +94120,11 @@ var ts;
}
function substituteExpression(node) {
switch (node.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return substituteExpressionIdentifier(node);
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
return substitutePropertyAccessExpression(node);
- case 206 /* ElementAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
return substituteElementAccessExpression(node);
}
return node;
@@ -92461,8 +94135,8 @@ var ts;
|| node;
}
function trySubstituteClassAlias(node) {
- if (enabledSubstitutions & 1 /* ClassAliases */) {
- if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) {
+ if (enabledSubstitutions & 1 /* TypeScriptSubstitutionFlags.ClassAliases */) {
+ if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) {
// Due to the emit for class decorators, any reference to the class from inside of the class body
// must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
// behavior of class names in ES6.
@@ -92488,9 +94162,9 @@ var ts;
// If we are nested within a namespace declaration, we may need to qualifiy
// an identifier that is exported from a merged namespace.
var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false);
- if (container && container.kind !== 303 /* SourceFile */) {
- var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 260 /* ModuleDeclaration */) ||
- (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 259 /* EnumDeclaration */);
+ if (container && container.kind !== 305 /* SyntaxKind.SourceFile */) {
+ var substitute = (applicableSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && container.kind === 261 /* SyntaxKind.ModuleDeclaration */) ||
+ (applicableSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && container.kind === 260 /* SyntaxKind.EnumDeclaration */);
if (substitute) {
return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node),
/*location*/ node);
@@ -92505,6 +94179,9 @@ var ts;
function substituteElementAccessExpression(node) {
return substituteConstantValue(node);
}
+ function safeMultiLineComment(value) {
+ return value.replace(/\*\//g, "*_/");
+ }
function substituteConstantValue(node) {
var constantValue = tryGetConstEnumValue(node);
if (constantValue !== undefined) {
@@ -92513,10 +94190,7 @@ var ts;
var substitute = typeof constantValue === "string" ? factory.createStringLiteral(constantValue) : factory.createNumericLiteral(constantValue);
if (!compilerOptions.removeComments) {
var originalNode = ts.getOriginalNode(node, ts.isAccessExpression);
- var propertyName = ts.isPropertyAccessExpression(originalNode)
- ? ts.declarationNameToString(originalNode.name)
- : ts.getTextOfNode(originalNode.argumentExpression);
- ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " ".concat(propertyName, " "));
+ ts.addSyntheticTrailingComment(substitute, 3 /* SyntaxKind.MultiLineCommentTrivia */, " ".concat(safeMultiLineComment(ts.getTextOfNode(originalNode)), " "));
}
return substitute;
}
@@ -92579,13 +94253,13 @@ var ts;
var compilerOptions = context.getCompilerOptions();
var languageVersion = ts.getEmitScriptTarget(compilerOptions);
var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions);
- var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ES2022 */;
+ var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ScriptTarget.ES2022 */;
// We need to transform `this` in a static initializer into a reference to the class
// when targeting < ES2022 since the assignment will be moved outside of the class body.
- var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ES2022 */;
+ var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ScriptTarget.ES2022 */;
// We don't need to transform `super` property access when targeting ES5, ES3 because
// the es2015 transformation handles those.
- var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */;
+ var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ScriptTarget.ES2015 */;
var previousOnSubstituteNode = context.onSubstituteNode;
context.onSubstituteNode = onSubstituteNode;
var previousOnEmitNode = context.onEmitNode;
@@ -92611,7 +94285,7 @@ var ts;
function transformSourceFile(node) {
var options = context.getCompilerOptions();
if (node.isDeclarationFile
- || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ES2022 */) {
+ || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ScriptTarget.ES2022 */) {
return node;
}
var visited = ts.visitEachChild(node, visitor, context);
@@ -92619,50 +94293,50 @@ var ts;
return visited;
}
function visitorWorker(node, valueIsDiscarded) {
- if (node.transformFlags & 8388608 /* ContainsClassFields */) {
+ if (node.transformFlags & 8388608 /* TransformFlags.ContainsClassFields */) {
switch (node.kind) {
- case 225 /* ClassExpression */:
- case 256 /* ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
return visitClassLike(node);
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
return visitPropertyDeclaration(node);
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
return visitVariableStatement(node);
- case 80 /* PrivateIdentifier */:
+ case 80 /* SyntaxKind.PrivateIdentifier */:
return visitPrivateIdentifier(node);
- case 169 /* ClassStaticBlockDeclaration */:
+ case 170 /* SyntaxKind.ClassStaticBlockDeclaration */:
return visitClassStaticBlockDeclaration(node);
}
}
- if (node.transformFlags & 8388608 /* ContainsClassFields */ ||
- node.transformFlags & 33554432 /* ContainsLexicalSuper */ &&
+ if (node.transformFlags & 8388608 /* TransformFlags.ContainsClassFields */ ||
+ node.transformFlags & 33554432 /* TransformFlags.ContainsLexicalSuper */ &&
shouldTransformSuperInStaticInitializers &&
currentStaticPropertyDeclarationOrStaticBlock &&
currentClassLexicalEnvironment) {
switch (node.kind) {
- case 218 /* PrefixUnaryExpression */:
- case 219 /* PostfixUnaryExpression */:
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
+ case 220 /* SyntaxKind.PostfixUnaryExpression */:
return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded);
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return visitBinaryExpression(node, valueIsDiscarded);
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
return visitCallExpression(node);
- case 209 /* TaggedTemplateExpression */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
return visitTaggedTemplateExpression(node);
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
return visitPropertyAccessExpression(node);
- case 206 /* ElementAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
return visitElementAccessExpression(node);
- case 237 /* ExpressionStatement */:
+ case 238 /* SyntaxKind.ExpressionStatement */:
return visitExpressionStatement(node);
- case 241 /* ForStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
return visitForStatement(node);
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 170 /* Constructor */:
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */: {
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */: {
var savedCurrentStaticPropertyDeclarationOrStaticBlock = currentStaticPropertyDeclarationOrStaticBlock;
currentStaticPropertyDeclarationOrStaticBlock = undefined;
var result = ts.visitEachChild(node, visitor, context);
@@ -92681,17 +94355,17 @@ var ts;
}
function heritageClauseVisitor(node) {
switch (node.kind) {
- case 290 /* HeritageClause */:
+ case 291 /* SyntaxKind.HeritageClause */:
return ts.visitEachChild(node, heritageClauseVisitor, context);
- case 227 /* ExpressionWithTypeArguments */:
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
return visitExpressionWithTypeArguments(node);
}
return visitor(node);
}
function visitorDestructuringTarget(node) {
switch (node.kind) {
- case 204 /* ObjectLiteralExpression */:
- case 203 /* ArrayLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
return visitAssignmentPattern(node);
default:
return visitor(node);
@@ -92721,7 +94395,7 @@ var ts;
}
var privId = node.left;
ts.Debug.assertNode(privId, ts.isPrivateIdentifier);
- ts.Debug.assert(node.operatorToken.kind === 101 /* InKeyword */);
+ ts.Debug.assert(node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */);
var info = accessPrivateIdentifier(privId);
if (info) {
var receiver = ts.visitNode(node.right, visitor, ts.isExpression);
@@ -92737,19 +94411,19 @@ var ts;
*/
function classElementVisitor(node) {
switch (node.kind) {
- case 170 /* Constructor */:
+ case 171 /* SyntaxKind.Constructor */:
// Constructors for classes using class fields are transformed in
// `visitClassDeclaration` or `visitClassExpression`.
return undefined;
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 168 /* MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
return visitMethodOrAccessorDeclaration(node);
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
return visitPropertyDeclaration(node);
- case 161 /* ComputedPropertyName */:
+ case 162 /* SyntaxKind.ComputedPropertyName */:
return visitComputedPropertyName(node);
- case 233 /* SemicolonClassElement */:
+ case 234 /* SyntaxKind.SemicolonClassElement */:
return node;
default:
return visitor(node);
@@ -92798,10 +94472,10 @@ var ts;
ts.Debug.assert(ts.isPrivateIdentifier(node.name));
var info = accessPrivateIdentifier(node.name);
ts.Debug.assert(info, "Undeclared private name for property declaration.");
- if (info.kind === "m" /* Method */) {
+ if (info.kind === "m" /* PrivateIdentifierKind.Method */) {
return info.methodName;
}
- if (info.kind === "a" /* Accessor */) {
+ if (info.kind === "a" /* PrivateIdentifierKind.Accessor */) {
if (ts.isGetAccessor(node)) {
return info.getterName;
}
@@ -92863,11 +94537,11 @@ var ts;
function createPrivateIdentifierAccessHelper(info, receiver) {
ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1));
switch (info.kind) {
- case "a" /* Accessor */:
+ case "a" /* PrivateIdentifierKind.Accessor */:
return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.getterName);
- case "m" /* Method */:
+ case "m" /* PrivateIdentifierKind.Method */:
return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.methodName);
- case "f" /* Field */:
+ case "f" /* PrivateIdentifierKind.Field */:
return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.variableName);
default:
ts.Debug.assertNever(info, "Unknown private element type");
@@ -92886,7 +94560,7 @@ var ts;
currentStaticPropertyDeclarationOrStaticBlock &&
currentClassLexicalEnvironment) {
var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts;
- if (facts & 1 /* ClassWasDecorated */) {
+ if (facts & 1 /* ClassFacts.ClassWasDecorated */) {
return visitInvalidSuperProperty(node);
}
if (classConstructor && superClassReference) {
@@ -92905,7 +94579,7 @@ var ts;
currentStaticPropertyDeclarationOrStaticBlock &&
currentClassLexicalEnvironment) {
var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts;
- if (facts & 1 /* ClassWasDecorated */) {
+ if (facts & 1 /* ClassFacts.ClassWasDecorated */) {
return visitInvalidSuperProperty(node);
}
if (classConstructor && superClassReference) {
@@ -92919,7 +94593,7 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) {
- if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) {
+ if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) {
if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) {
var info = void 0;
if (info = accessPrivateIdentifier(node.operand.name)) {
@@ -92928,7 +94602,7 @@ var ts;
var expression = createPrivateIdentifierAccess(info, readExpression);
var temp = ts.isPrefixUnaryExpression(node) || valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration);
expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp);
- expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* EqualsToken */);
+ expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* SyntaxKind.EqualsToken */);
ts.setOriginalNode(expression, node);
ts.setTextRange(expression, node);
if (temp) {
@@ -92951,7 +94625,7 @@ var ts;
// converts `super.a--` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = _a--), _classTemp), _b)`
// converts `super[f()]--` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = _b--), _classTemp), _c)`
var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts;
- if (facts & 1 /* ClassWasDecorated */) {
+ if (facts & 1 /* ClassFacts.ClassWasDecorated */) {
var operand = visitInvalidSuperProperty(node.operand);
return ts.isPrefixUnaryExpression(node) ?
factory.updatePrefixUnaryExpression(node, operand) :
@@ -93067,7 +94741,7 @@ var ts;
var iife = factory.createImmediatelyInvokedArrowFunction(statements);
ts.setOriginalNode(iife, node);
ts.setTextRange(iife, node);
- ts.addEmitFlags(iife, 2 /* AdviseOnEmitNode */);
+ ts.addEmitFlags(iife, 2 /* EmitFlags.AdviseOnEmitNode */);
return iife;
}
}
@@ -93094,7 +94768,7 @@ var ts;
currentStaticPropertyDeclarationOrStaticBlock &&
currentClassLexicalEnvironment) {
var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts;
- if (facts & 1 /* ClassWasDecorated */) {
+ if (facts & 1 /* ClassFacts.ClassWasDecorated */) {
return factory.updateBinaryExpression(node, visitInvalidSuperProperty(node.left), node.operatorToken, ts.visitNode(node.right, visitor, ts.isExpression));
}
if (classConstructor && superClassReference) {
@@ -93136,7 +94810,7 @@ var ts;
}
}
}
- if (node.operatorToken.kind === 101 /* InKeyword */ && ts.isPrivateIdentifier(node.left)) {
+ if (node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ && ts.isPrivateIdentifier(node.left)) {
return visitPrivateIdentifierInInExpression(node);
}
return ts.visitEachChild(node, visitor, context);
@@ -93151,12 +94825,12 @@ var ts;
}
ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1));
switch (info.kind) {
- case "a" /* Accessor */:
+ case "a" /* PrivateIdentifierKind.Accessor */:
return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.setterName);
- case "m" /* Method */:
+ case "m" /* PrivateIdentifierKind.Method */:
return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind,
/* f */ undefined);
- case "f" /* Field */:
+ case "f" /* PrivateIdentifierKind.Field */:
return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.variableName);
default:
ts.Debug.assertNever(info, "Unknown private element type");
@@ -93196,28 +94870,28 @@ var ts;
return ts.filter(node.members, ts.isNonStaticMethodOrAccessorWithPrivateName);
}
function getClassFacts(node) {
- var facts = 0 /* None */;
+ var facts = 0 /* ClassFacts.None */;
var original = ts.getOriginalNode(node);
if (ts.isClassDeclaration(original) && ts.classOrConstructorParameterIsDecorated(original)) {
- facts |= 1 /* ClassWasDecorated */;
+ facts |= 1 /* ClassFacts.ClassWasDecorated */;
}
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
var member = _a[_i];
if (!ts.isStatic(member))
continue;
if (member.name && ts.isPrivateIdentifier(member.name) && shouldTransformPrivateElementsOrClassStaticBlocks) {
- facts |= 2 /* NeedsClassConstructorReference */;
+ facts |= 2 /* ClassFacts.NeedsClassConstructorReference */;
}
if (ts.isPropertyDeclaration(member) || ts.isClassStaticBlockDeclaration(member)) {
- if (shouldTransformThisInStaticInitializers && member.transformFlags & 8192 /* ContainsLexicalThis */) {
- facts |= 8 /* NeedsSubstitutionForThisInClassStaticField */;
- if (!(facts & 1 /* ClassWasDecorated */)) {
- facts |= 2 /* NeedsClassConstructorReference */;
+ if (shouldTransformThisInStaticInitializers && member.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */) {
+ facts |= 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */;
+ if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) {
+ facts |= 2 /* ClassFacts.NeedsClassConstructorReference */;
}
}
- if (shouldTransformSuperInStaticInitializers && member.transformFlags & 33554432 /* ContainsLexicalSuper */) {
- if (!(facts & 1 /* ClassWasDecorated */)) {
- facts |= 2 /* NeedsClassConstructorReference */ | 4 /* NeedsClassSuperReference */;
+ if (shouldTransformSuperInStaticInitializers && member.transformFlags & 33554432 /* TransformFlags.ContainsLexicalSuper */) {
+ if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) {
+ facts |= 2 /* ClassFacts.NeedsClassConstructorReference */ | 4 /* ClassFacts.NeedsClassSuperReference */;
}
}
}
@@ -93225,8 +94899,8 @@ var ts;
return facts;
}
function visitExpressionWithTypeArguments(node) {
- var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* None */;
- if (facts & 4 /* NeedsClassSuperReference */) {
+ var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* ClassFacts.None */;
+ if (facts & 4 /* ClassFacts.NeedsClassSuperReference */) {
var temp = factory.createTempVariable(hoistVariableDeclaration, /*reserveInNestedScopes*/ true);
getClassLexicalEnvironment().superClassReference = temp;
return factory.updateExpressionWithTypeArguments(node, factory.createAssignment(temp, ts.visitNode(node.expression, visitor, ts.isExpression)),
@@ -93239,19 +94913,19 @@ var ts;
if (facts) {
getClassLexicalEnvironment().facts = facts;
}
- if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) {
+ if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) {
enableSubstitutionForClassStaticThisOrSuperReference();
}
// If a class has private static fields, or a static field has a `this` or `super` reference,
// then we need to allocate a temp variable to hold on to that reference.
var pendingClassReferenceAssignment;
- if (facts & 2 /* NeedsClassConstructorReference */) {
+ if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) {
var temp = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true);
getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp);
pendingClassReferenceAssignment = factory.createAssignment(temp, factory.getInternalName(node));
}
var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
- var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */);
+ var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */);
var statements = [
factory.updateClassDeclaration(node,
/*decorators*/ undefined, node.modifiers, node.name,
@@ -93280,7 +94954,7 @@ var ts;
if (facts) {
getClassLexicalEnvironment().facts = facts;
}
- if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) {
+ if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) {
enableSubstitutionForClassStaticThisOrSuperReference();
}
// If this class expression is a transformation of a decorated class declaration,
@@ -93290,19 +94964,19 @@ var ts;
// In this case, we use pendingStatements to produce the same output as the
// class declaration transformation. The VariableStatement visitor will insert
// these statements after the class expression variable statement.
- var isDecoratedClassDeclaration = !!(facts & 1 /* ClassWasDecorated */);
+ var isDecoratedClassDeclaration = !!(facts & 1 /* ClassFacts.ClassWasDecorated */);
var staticPropertiesOrClassStaticBlocks = ts.getStaticPropertiesAndClassStaticBlock(node);
var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
- var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */);
- var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */;
+ var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */);
+ var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */;
var temp;
function createClassTempVar() {
var classCheckFlags = resolver.getNodeCheckFlags(node);
- var isClassWithConstructorReference = classCheckFlags & 16777216 /* ClassWithConstructorReference */;
- var requiresBlockScopedVar = classCheckFlags & 524288 /* BlockScopedBindingInLoop */;
+ var isClassWithConstructorReference = classCheckFlags & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */;
+ var requiresBlockScopedVar = classCheckFlags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */;
return factory.createTempVariable(requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration, !!isClassWithConstructorReference);
}
- if (facts & 2 /* NeedsClassConstructorReference */) {
+ if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) {
temp = createClassTempVar();
getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp);
}
@@ -93331,12 +95005,12 @@ var ts;
// record an alias as the class name is not in scope for statics.
enableSubstitutionForClassAliases();
var alias = factory.cloneNode(temp);
- alias.autoGenerateFlags &= ~8 /* ReservedInNestedScopes */;
+ alias.autoGenerateFlags &= ~8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */;
classAliases[ts.getOriginalNodeId(node)] = alias;
}
// To preserve the behavior of the old emitter, we explicitly indent
// the body of a class with static initializers.
- ts.setEmitFlags(classExpression, 65536 /* Indented */ | ts.getEmitFlags(classExpression));
+ ts.setEmitFlags(classExpression, 65536 /* EmitFlags.Indented */ | ts.getEmitFlags(classExpression));
expressions.push(ts.startOnNewLine(factory.createAssignment(temp, classExpression)));
// Add any pending expressions leftover from elided or relocated computed property names
ts.addRange(expressions, ts.map(pendingExpressions, ts.startOnNewLine));
@@ -93391,13 +95065,13 @@ var ts;
/*typeArguments*/ undefined, [])));
}
function isClassElementThatRequiresConstructorStatement(member) {
- if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) {
+ if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* ModifierFlags.Abstract */)) {
return false;
}
if (useDefineForClassFields) {
// If we are using define semantics and targeting ESNext or higher,
// then we don't need to transform any class properties.
- return languageVersion < 9 /* ES2022 */;
+ return languageVersion < 9 /* ScriptTarget.ES2022 */;
}
return ts.isInitializedProperty(member) || shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierClassElementDeclaration(member);
}
@@ -93430,7 +95104,7 @@ var ts;
}
resumeLexicalEnvironment();
var needsSyntheticConstructor = !constructor && isDerivedClass;
- var indexOfFirstStatementAfterSuper = 0;
+ var indexOfFirstStatementAfterSuperAndPrologue = 0;
var prologueStatementCount = 0;
var superStatementIndex = -1;
var statements = [];
@@ -93439,8 +95113,11 @@ var ts;
superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount);
// If there was a super call, visit existing statements up to and including it
if (superStatementIndex >= 0) {
- indexOfFirstStatementAfterSuper = superStatementIndex + 1;
- statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuper - prologueStatementCount), true), statements.slice(prologueStatementCount), true);
+ indexOfFirstStatementAfterSuperAndPrologue = superStatementIndex + 1;
+ statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuperAndPrologue - prologueStatementCount), true), statements.slice(prologueStatementCount), true);
+ }
+ else if (prologueStatementCount >= 0) {
+ indexOfFirstStatementAfterSuperAndPrologue = prologueStatementCount;
}
}
if (needsSyntheticConstructor) {
@@ -93476,22 +95153,20 @@ var ts;
}
}
if (parameterPropertyDeclarationCount > 0) {
- var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount);
+ var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue, parameterPropertyDeclarationCount);
// If there was a super() call found, add parameter properties immediately after it
if (superStatementIndex >= 0) {
ts.addRange(statements, parameterProperties);
}
- // If a synthetic super() call was added, add them just after it
- else if (needsSyntheticConstructor) {
- statements = __spreadArray(__spreadArray([
- statements[0]
- ], parameterProperties, true), statements.slice(1), true);
- }
- // Since there wasn't a super() call, add them to the top of the constructor
else {
- statements = __spreadArray(__spreadArray([], parameterProperties, true), statements, true);
+ // Add add parameter properties to the top of the constructor after the prologue
+ var superAndPrologueStatementCount = prologueStatementCount;
+ // If a synthetic super() call was added, need to account for that
+ if (needsSyntheticConstructor)
+ superAndPrologueStatementCount++;
+ statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, superAndPrologueStatementCount), true), parameterProperties, true), statements.slice(superAndPrologueStatementCount), true);
}
- indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount;
+ indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount;
}
}
}
@@ -93501,7 +95176,7 @@ var ts;
addPropertyOrClassStaticBlockStatements(statements, properties, receiver);
// Add existing statements after the initial prologues and super call
if (constructor) {
- ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount));
+ ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue));
}
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements),
@@ -93586,7 +95261,7 @@ var ts;
if (transformed && ts.hasStaticModifier(property) && (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts)) {
// capture the lexical environment for the member
ts.setOriginalNode(transformed, property);
- ts.addEmitFlags(transformed, 2 /* AdviseOnEmitNode */);
+ ts.addEmitFlags(transformed, 2 /* EmitFlags.AdviseOnEmitNode */);
classLexicalEnvironmentMap.set(ts.getOriginalNodeId(transformed), currentClassLexicalEnvironment);
}
currentStaticPropertyDeclarationOrStaticBlock = savedCurrentStaticPropertyDeclarationOrStaticBlock;
@@ -93605,7 +95280,7 @@ var ts;
if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifier(propertyName)) {
var privateIdentifierInfo = accessPrivateIdentifier(propertyName);
if (privateIdentifierInfo) {
- if (privateIdentifierInfo.kind === "f" /* Field */) {
+ if (privateIdentifierInfo.kind === "f" /* PrivateIdentifierKind.Field */) {
if (!privateIdentifierInfo.isStatic) {
return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.brandCheckIdentifier);
}
@@ -93625,7 +95300,7 @@ var ts;
return undefined;
}
var propertyOriginalNode = ts.getOriginalNode(property);
- if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* Abstract */)) {
+ if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* ModifierFlags.Abstract */)) {
return undefined;
}
var initializer = property.initializer || emitAssignment ? (_a = ts.visitNode(property.initializer, visitor, ts.isExpression)) !== null && _a !== void 0 ? _a : factory.createVoidZero()
@@ -93644,32 +95319,32 @@ var ts;
}
}
function enableSubstitutionForClassAliases() {
- if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) {
- enabledSubstitutions |= 1 /* ClassAliases */;
+ if ((enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) === 0) {
+ enabledSubstitutions |= 1 /* ClassPropertySubstitutionFlags.ClassAliases */;
// We need to enable substitutions for identifiers. This allows us to
// substitute class names inside of a class declaration.
- context.enableSubstitution(79 /* Identifier */);
+ context.enableSubstitution(79 /* SyntaxKind.Identifier */);
// Keep track of class aliases.
classAliases = [];
}
}
function enableSubstitutionForClassStaticThisOrSuperReference() {
- if ((enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */) === 0) {
- enabledSubstitutions |= 2 /* ClassStaticThisOrSuperReference */;
+ if ((enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */) === 0) {
+ enabledSubstitutions |= 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */;
// substitute `this` in a static field initializer
- context.enableSubstitution(108 /* ThisKeyword */);
+ context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */);
// these push a new lexical environment that is not the class lexical environment
- context.enableEmitNotification(255 /* FunctionDeclaration */);
- context.enableEmitNotification(212 /* FunctionExpression */);
- context.enableEmitNotification(170 /* Constructor */);
+ context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */);
+ context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */);
+ context.enableEmitNotification(171 /* SyntaxKind.Constructor */);
// these push a new lexical environment that is not the class lexical environment, except
// when they have a computed property name
- context.enableEmitNotification(171 /* GetAccessor */);
- context.enableEmitNotification(172 /* SetAccessor */);
- context.enableEmitNotification(168 /* MethodDeclaration */);
- context.enableEmitNotification(166 /* PropertyDeclaration */);
+ context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */);
+ context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */);
+ context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */);
+ context.enableEmitNotification(167 /* SyntaxKind.PropertyDeclaration */);
// class lexical environments are restored when entering a computed property name
- context.enableEmitNotification(161 /* ComputedPropertyName */);
+ context.enableEmitNotification(162 /* SyntaxKind.ComputedPropertyName */);
}
}
/**
@@ -93708,13 +95383,13 @@ var ts;
}
}
switch (node.kind) {
- case 212 /* FunctionExpression */:
- if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */) {
+ case 213 /* SyntaxKind.FunctionExpression */:
+ if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */) {
break;
}
// falls through
- case 255 /* FunctionDeclaration */:
- case 170 /* Constructor */: {
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 171 /* SyntaxKind.Constructor */: {
var savedClassLexicalEnvironment = currentClassLexicalEnvironment;
var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment;
currentClassLexicalEnvironment = undefined;
@@ -93724,10 +95399,10 @@ var ts;
currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment;
return;
}
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 168 /* MethodDeclaration */:
- case 166 /* PropertyDeclaration */: {
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */: {
var savedClassLexicalEnvironment = currentClassLexicalEnvironment;
var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment;
currentComputedPropertyNameClassLexicalEnvironment = currentClassLexicalEnvironment;
@@ -93737,7 +95412,7 @@ var ts;
currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment;
return;
}
- case 161 /* ComputedPropertyName */: {
+ case 162 /* SyntaxKind.ComputedPropertyName */: {
var savedClassLexicalEnvironment = currentClassLexicalEnvironment;
var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment;
currentClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment;
@@ -93758,24 +95433,24 @@ var ts;
*/
function onSubstituteNode(hint, node) {
node = previousOnSubstituteNode(hint, node);
- if (hint === 1 /* Expression */) {
+ if (hint === 1 /* EmitHint.Expression */) {
return substituteExpression(node);
}
return node;
}
function substituteExpression(node) {
switch (node.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return substituteExpressionIdentifier(node);
- case 108 /* ThisKeyword */:
+ case 108 /* SyntaxKind.ThisKeyword */:
return substituteThisExpression(node);
}
return node;
}
function substituteThisExpression(node) {
- if (enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) {
+ if (enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) {
var facts = currentClassLexicalEnvironment.facts, classConstructor = currentClassLexicalEnvironment.classConstructor;
- if (facts & 1 /* ClassWasDecorated */) {
+ if (facts & 1 /* ClassFacts.ClassWasDecorated */) {
return factory.createParenthesizedExpression(factory.createVoidZero());
}
if (classConstructor) {
@@ -93788,8 +95463,8 @@ var ts;
return trySubstituteClassAlias(node) || node;
}
function trySubstituteClassAlias(node) {
- if (enabledSubstitutions & 1 /* ClassAliases */) {
- if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) {
+ if (enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) {
+ if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) {
// Due to the emit for class decorators, any reference to the class from inside of the class body
// must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
// behavior of class names in ES6.
@@ -93822,7 +95497,7 @@ var ts;
var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left);
if (!alreadyTransformed && !inlinable && shouldHoist) {
var generatedName = factory.getGeneratedNameForNode(name);
- if (resolver.getNodeCheckFlags(name) & 524288 /* BlockScopedBindingInLoop */) {
+ if (resolver.getNodeCheckFlags(name) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) {
addBlockScopedVariable(generatedName);
}
else {
@@ -93842,7 +95517,7 @@ var ts;
}
function getClassLexicalEnvironment() {
return currentClassLexicalEnvironment || (currentClassLexicalEnvironment = {
- facts: 0 /* None */,
+ facts: 0 /* ClassFacts.None */,
classConstructor: undefined,
superClassReference: undefined,
privateIdentifierEnvironment: undefined,
@@ -93875,7 +95550,7 @@ var ts;
if (ts.isPropertyDeclaration(node)) {
var variableName = createHoistedVariableForPrivateName(text, node);
privateEnv.identifiers.set(privateName, {
- kind: "f" /* Field */,
+ kind: "f" /* PrivateIdentifierKind.Field */,
variableName: variableName,
brandCheckIdentifier: classConstructor,
isStatic: true,
@@ -93885,7 +95560,7 @@ var ts;
else if (ts.isMethodDeclaration(node)) {
var functionName = createHoistedVariableForPrivateName(text, node);
privateEnv.identifiers.set(privateName, {
- kind: "m" /* Method */,
+ kind: "m" /* PrivateIdentifierKind.Method */,
methodName: functionName,
brandCheckIdentifier: classConstructor,
isStatic: true,
@@ -93894,12 +95569,12 @@ var ts;
}
else if (ts.isGetAccessorDeclaration(node)) {
var getterName = createHoistedVariableForPrivateName(text + "_get", node);
- if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.getterName) {
+ if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.getterName) {
previousInfo.getterName = getterName;
}
else {
privateEnv.identifiers.set(privateName, {
- kind: "a" /* Accessor */,
+ kind: "a" /* PrivateIdentifierKind.Accessor */,
getterName: getterName,
setterName: undefined,
brandCheckIdentifier: classConstructor,
@@ -93910,12 +95585,12 @@ var ts;
}
else if (ts.isSetAccessorDeclaration(node)) {
var setterName = createHoistedVariableForPrivateName(text + "_set", node);
- if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.setterName) {
+ if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.setterName) {
previousInfo.setterName = setterName;
}
else {
privateEnv.identifiers.set(privateName, {
- kind: "a" /* Accessor */,
+ kind: "a" /* PrivateIdentifierKind.Accessor */,
getterName: undefined,
setterName: setterName,
brandCheckIdentifier: classConstructor,
@@ -93931,7 +95606,7 @@ var ts;
else if (ts.isPropertyDeclaration(node)) {
var weakMapName = createHoistedVariableForPrivateName(text, node);
privateEnv.identifiers.set(privateName, {
- kind: "f" /* Field */,
+ kind: "f" /* PrivateIdentifierKind.Field */,
brandCheckIdentifier: weakMapName,
isStatic: false,
variableName: undefined,
@@ -93943,7 +95618,7 @@ var ts;
else if (ts.isMethodDeclaration(node)) {
ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment");
privateEnv.identifiers.set(privateName, {
- kind: "m" /* Method */,
+ kind: "m" /* PrivateIdentifierKind.Method */,
methodName: createHoistedVariableForPrivateName(text, node),
brandCheckIdentifier: weakSetName,
isStatic: false,
@@ -93954,12 +95629,12 @@ var ts;
ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment");
if (ts.isGetAccessor(node)) {
var getterName = createHoistedVariableForPrivateName(text + "_get", node);
- if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) {
+ if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) {
previousInfo.getterName = getterName;
}
else {
privateEnv.identifiers.set(privateName, {
- kind: "a" /* Accessor */,
+ kind: "a" /* PrivateIdentifierKind.Accessor */,
getterName: getterName,
setterName: undefined,
brandCheckIdentifier: weakSetName,
@@ -93970,12 +95645,12 @@ var ts;
}
else {
var setterName = createHoistedVariableForPrivateName(text + "_set", node);
- if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) {
+ if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) {
previousInfo.setterName = setterName;
}
else {
privateEnv.identifiers.set(privateName, {
- kind: "a" /* Accessor */,
+ kind: "a" /* PrivateIdentifierKind.Accessor */,
getterName: undefined,
setterName: setterName,
brandCheckIdentifier: weakSetName,
@@ -93993,8 +95668,8 @@ var ts;
function createHoistedVariableForClass(name, node) {
var className = getPrivateIdentifierEnvironment().className;
var prefix = className ? "_".concat(className) : "";
- var identifier = factory.createUniqueName("".concat(prefix, "_").concat(name), 16 /* Optimistic */);
- if (resolver.getNodeCheckFlags(node) & 524288 /* BlockScopedBindingInLoop */) {
+ var identifier = factory.createUniqueName("".concat(prefix, "_").concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */);
+ if (resolver.getNodeCheckFlags(node) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) {
addBlockScopedVariable(identifier);
}
else {
@@ -94036,9 +95711,9 @@ var ts;
// differently inside the function.
if (ts.isThisProperty(node) || ts.isSuperProperty(node) || !ts.isSimpleCopiableExpression(node.expression)) {
receiver = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true);
- getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression)));
+ getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression)));
}
- return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* EqualsToken */));
+ return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* SyntaxKind.EqualsToken */));
}
function visitArrayAssignmentTarget(node) {
var target = ts.getTargetOfBindingOrAssignmentElement(node);
@@ -94052,7 +95727,7 @@ var ts;
currentStaticPropertyDeclarationOrStaticBlock &&
currentClassLexicalEnvironment) {
var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts;
- if (facts & 1 /* ClassWasDecorated */) {
+ if (facts & 1 /* ClassFacts.ClassWasDecorated */) {
wrapped = visitInvalidSuperProperty(target);
}
else if (classConstructor && superClassReference) {
@@ -94092,7 +95767,7 @@ var ts;
currentStaticPropertyDeclarationOrStaticBlock &&
currentClassLexicalEnvironment) {
var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts;
- if (facts & 1 /* ClassWasDecorated */) {
+ if (facts & 1 /* ClassFacts.ClassWasDecorated */) {
wrapped = visitInvalidSuperProperty(target);
}
else if (classConstructor && superClassReference) {
@@ -94211,8 +95886,8 @@ var ts;
if (node.isDeclarationFile) {
return node;
}
- setContextFlag(1 /* NonTopLevel */, false);
- setContextFlag(2 /* HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions));
+ setContextFlag(1 /* ContextFlags.NonTopLevel */, false);
+ setContextFlag(2 /* ContextFlags.HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions));
var visited = ts.visitEachChild(node, visitor, context);
ts.addEmitHelpers(visited, context.readEmitHelpers());
return visited;
@@ -94224,10 +95899,10 @@ var ts;
return (contextFlags & flags) !== 0;
}
function inTopLevelContext() {
- return !inContext(1 /* NonTopLevel */);
+ return !inContext(1 /* ContextFlags.NonTopLevel */);
}
function inHasLexicalThisContext() {
- return inContext(2 /* HasLexicalThis */);
+ return inContext(2 /* ContextFlags.HasLexicalThis */);
}
function doWithContext(flags, cb, value) {
var contextFlagsToSet = flags & ~contextFlags;
@@ -94243,39 +95918,39 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
function visitor(node) {
- if ((node.transformFlags & 256 /* ContainsES2017 */) === 0) {
+ if ((node.transformFlags & 256 /* TransformFlags.ContainsES2017 */) === 0) {
return node;
}
switch (node.kind) {
- case 131 /* AsyncKeyword */:
+ case 131 /* SyntaxKind.AsyncKeyword */:
// ES2017 async modifier should be elided for targets < ES2017
return undefined;
- case 217 /* AwaitExpression */:
+ case 218 /* SyntaxKind.AwaitExpression */:
return visitAwaitExpression(node);
- case 168 /* MethodDeclaration */:
- return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitMethodDeclaration, node);
- case 255 /* FunctionDeclaration */:
- return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionDeclaration, node);
- case 212 /* FunctionExpression */:
- return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionExpression, node);
- case 213 /* ArrowFunction */:
- return doWithContext(1 /* NonTopLevel */, visitArrowFunction, node);
- case 205 /* PropertyAccessExpression */:
- if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) {
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitMethodDeclaration, node);
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionDeclaration, node);
+ case 213 /* SyntaxKind.FunctionExpression */:
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionExpression, node);
+ case 214 /* SyntaxKind.ArrowFunction */:
+ return doWithContext(1 /* ContextFlags.NonTopLevel */, visitArrowFunction, node);
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) {
capturedSuperProperties.add(node.name.escapedText);
}
return ts.visitEachChild(node, visitor, context);
- case 206 /* ElementAccessExpression */:
- if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) {
+ case 207 /* SyntaxKind.ElementAccessExpression */:
+ if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) {
hasSuperElementAccess = true;
}
return ts.visitEachChild(node, visitor, context);
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 170 /* Constructor */:
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitDefault, node);
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitDefault, node);
default:
return ts.visitEachChild(node, visitor, context);
}
@@ -94283,27 +95958,27 @@ var ts;
function asyncBodyVisitor(node) {
if (ts.isNodeWithPossibleHoistedDeclaration(node)) {
switch (node.kind) {
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
return visitVariableStatementInAsyncBody(node);
- case 241 /* ForStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
return visitForStatementInAsyncBody(node);
- case 242 /* ForInStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
return visitForInStatementInAsyncBody(node);
- case 243 /* ForOfStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
return visitForOfStatementInAsyncBody(node);
- case 291 /* CatchClause */:
+ case 292 /* SyntaxKind.CatchClause */:
return visitCatchClauseInAsyncBody(node);
- case 234 /* Block */:
- case 248 /* SwitchStatement */:
- case 262 /* CaseBlock */:
- case 288 /* CaseClause */:
- case 289 /* DefaultClause */:
- case 251 /* TryStatement */:
- case 239 /* DoStatement */:
- case 240 /* WhileStatement */:
- case 238 /* IfStatement */:
- case 247 /* WithStatement */:
- case 249 /* LabeledStatement */:
+ case 235 /* SyntaxKind.Block */:
+ case 249 /* SyntaxKind.SwitchStatement */:
+ case 263 /* SyntaxKind.CaseBlock */:
+ case 289 /* SyntaxKind.CaseClause */:
+ case 290 /* SyntaxKind.DefaultClause */:
+ case 252 /* SyntaxKind.TryStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
+ case 239 /* SyntaxKind.IfStatement */:
+ case 248 /* SyntaxKind.WithStatement */:
+ case 250 /* SyntaxKind.LabeledStatement */:
return ts.visitEachChild(node, asyncBodyVisitor, context);
default:
return ts.Debug.assertNever(node, "Unhandled node.");
@@ -94386,7 +96061,7 @@ var ts;
/*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name,
/*questionToken*/ undefined,
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
- /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */
+ /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */
? transformAsyncFunctionBody(node)
: ts.visitFunctionBody(node.body, visitor, context));
}
@@ -94402,7 +96077,7 @@ var ts;
return factory.updateFunctionDeclaration(node,
/*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name,
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
- /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */
+ /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */
? transformAsyncFunctionBody(node)
: ts.visitFunctionBody(node.body, visitor, context));
}
@@ -94417,7 +96092,7 @@ var ts;
function visitFunctionExpression(node) {
return factory.updateFunctionExpression(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name,
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
- /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */
+ /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */
? transformAsyncFunctionBody(node)
: ts.visitFunctionBody(node.body, visitor, context));
}
@@ -94432,7 +96107,7 @@ var ts;
function visitArrowFunction(node) {
return factory.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier),
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
- /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* Async */
+ /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */
? transformAsyncFunctionBody(node)
: ts.visitFunctionBody(node.body, visitor, context));
}
@@ -94453,7 +96128,7 @@ var ts;
function isVariableDeclarationListWithCollidingName(node) {
return !!node
&& ts.isVariableDeclarationList(node)
- && !(node.flags & 3 /* BlockScoped */)
+ && !(node.flags & 3 /* NodeFlags.BlockScoped */)
&& node.declarations.some(collidesWithParameterName);
}
function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) {
@@ -94507,9 +96182,9 @@ var ts;
resumeLexicalEnvironment();
var original = ts.getOriginalNode(node, ts.isFunctionLike);
var nodeType = original.type;
- var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined;
- var isArrowFunction = node.kind === 213 /* ArrowFunction */;
- var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0;
+ var promiseConstructor = languageVersion < 2 /* ScriptTarget.ES2015 */ ? getPromiseConstructor(nodeType) : undefined;
+ var isArrowFunction = node.kind === 214 /* SyntaxKind.ArrowFunction */;
+ var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* NodeCheckFlags.CaptureArguments */) !== 0;
// An async function is emit as an outer function that calls an inner
// generator function. To preserve lexical bindings, we pass the current
// `this` and `arguments` objects to `__awaiter`. The generator function
@@ -94535,7 +96210,7 @@ var ts;
ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
// Minor optimization, emit `_super` helper to capture `super` access in an arrow.
// This step isn't needed if we eventually transform this to ES5.
- var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */);
+ var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */);
if (emitSuperHelpers) {
enableSubstitutionForAsyncMethodsWithSuper();
if (capturedSuperProperties.size) {
@@ -94548,10 +96223,10 @@ var ts;
ts.setTextRange(block, node.body);
if (emitSuperHelpers && hasSuperElementAccess) {
// Emit helpers for super element access expressions (`super[x]`).
- if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) {
+ if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
}
- else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) {
+ else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) {
ts.addEmitHelper(block, ts.asyncSuperHelper);
}
}
@@ -94595,21 +96270,21 @@ var ts;
return undefined;
}
function enableSubstitutionForAsyncMethodsWithSuper() {
- if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) {
- enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */;
+ if ((enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */) === 0) {
+ enabledSubstitutions |= 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */;
// We need to enable substitutions for call, property access, and element access
// if we need to rewrite super calls.
- context.enableSubstitution(207 /* CallExpression */);
- context.enableSubstitution(205 /* PropertyAccessExpression */);
- context.enableSubstitution(206 /* ElementAccessExpression */);
+ context.enableSubstitution(208 /* SyntaxKind.CallExpression */);
+ context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */);
+ context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */);
// We need to be notified when entering and exiting declarations that bind super.
- context.enableEmitNotification(256 /* ClassDeclaration */);
- context.enableEmitNotification(168 /* MethodDeclaration */);
- context.enableEmitNotification(171 /* GetAccessor */);
- context.enableEmitNotification(172 /* SetAccessor */);
- context.enableEmitNotification(170 /* Constructor */);
+ context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */);
+ context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */);
+ context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */);
+ context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */);
+ context.enableEmitNotification(171 /* SyntaxKind.Constructor */);
// We need to be notified when entering the generated accessor arrow functions.
- context.enableEmitNotification(236 /* VariableStatement */);
+ context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */);
}
}
/**
@@ -94622,8 +96297,8 @@ var ts;
function onEmitNode(hint, node, emitCallback) {
// If we need to support substitutions for `super` in an async method,
// we should track it here.
- if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) {
- var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */);
+ if (enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) {
+ var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */);
if (superContainerFlags !== enclosingSuperContainerFlags) {
var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
enclosingSuperContainerFlags = superContainerFlags;
@@ -94650,30 +96325,30 @@ var ts;
*/
function onSubstituteNode(hint, node) {
node = previousOnSubstituteNode(hint, node);
- if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) {
+ if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) {
return substituteExpression(node);
}
return node;
}
function substituteExpression(node) {
switch (node.kind) {
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
return substitutePropertyAccessExpression(node);
- case 206 /* ElementAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
return substituteElementAccessExpression(node);
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
return substituteCallExpression(node);
}
return node;
}
function substitutePropertyAccessExpression(node) {
- if (node.expression.kind === 106 /* SuperKeyword */) {
- return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node);
+ if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) {
+ return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node);
}
return node;
}
function substituteElementAccessExpression(node) {
- if (node.expression.kind === 106 /* SuperKeyword */) {
+ if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) {
return createSuperElementAccessInAsyncMethod(node.argumentExpression, node);
}
return node;
@@ -94693,19 +96368,19 @@ var ts;
}
function isSuperContainer(node) {
var kind = node.kind;
- return kind === 256 /* ClassDeclaration */
- || kind === 170 /* Constructor */
- || kind === 168 /* MethodDeclaration */
- || kind === 171 /* GetAccessor */
- || kind === 172 /* SetAccessor */;
+ return kind === 257 /* SyntaxKind.ClassDeclaration */
+ || kind === 171 /* SyntaxKind.Constructor */
+ || kind === 169 /* SyntaxKind.MethodDeclaration */
+ || kind === 172 /* SyntaxKind.GetAccessor */
+ || kind === 173 /* SyntaxKind.SetAccessor */;
}
function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
- if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) {
- return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */),
+ if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
+ return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */),
/*typeArguments*/ undefined, [argumentExpression]), "value"), location);
}
else {
- return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */),
+ return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */),
/*typeArguments*/ undefined, [argumentExpression]), location);
}
}
@@ -94715,7 +96390,7 @@ var ts;
function createSuperAccessVariableStatement(factory, resolver, node, names) {
// Create a variable declaration with a getter/setter (if binding) definition for each name:
// const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... });
- var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) !== 0;
+ var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) !== 0;
var accessors = [];
names.forEach(function (_, key) {
var name = ts.unescapeLeadingUnderscores(key);
@@ -94725,7 +96400,7 @@ var ts;
/* typeParameters */ undefined,
/* parameters */ [],
/* type */ undefined,
- /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */))));
+ /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */))));
if (hasBinding) {
getterAndSetter.push(factory.createPropertyAssignment("set", factory.createArrowFunction(
/* modifiers */ undefined,
@@ -94740,20 +96415,20 @@ var ts;
/* initializer */ undefined)
],
/* type */ undefined,
- /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */), factory.createIdentifier("v")))));
+ /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */), factory.createIdentifier("v")))));
}
accessors.push(factory.createPropertyAssignment(name, factory.createObjectLiteralExpression(getterAndSetter)));
});
return factory.createVariableStatement(
/* modifiers */ undefined, factory.createVariableDeclarationList([
- factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */),
+ factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */),
/*exclamationToken*/ undefined,
/* type */ undefined, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "create"),
/* typeArguments */ undefined, [
factory.createNull(),
factory.createObjectLiteralExpression(accessors, /* multiline */ true)
]))
- ], 2 /* Const */));
+ ], 2 /* NodeFlags.Const */));
}
ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement;
})(ts || (ts = {}));
@@ -94823,7 +96498,7 @@ var ts;
*/
function enterSubtree(excludeFacts, includeFacts) {
var ancestorFacts = hierarchyFacts;
- hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* AncestorFactsMask */;
+ hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* HierarchyFacts.AncestorFactsMask */;
return ancestorFacts;
}
/**
@@ -94855,7 +96530,7 @@ var ts;
return visitorWorker(node, /*expressionResultIsUnused*/ true);
}
function visitorNoAsyncModifier(node) {
- if (node.kind === 131 /* AsyncKeyword */) {
+ if (node.kind === 131 /* SyntaxKind.AsyncKeyword */) {
return undefined;
}
return node;
@@ -94877,88 +96552,88 @@ var ts;
* expression of an `ExpressionStatement`).
*/
function visitorWorker(node, expressionResultIsUnused) {
- if ((node.transformFlags & 128 /* ContainsES2018 */) === 0) {
+ if ((node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) === 0) {
return node;
}
switch (node.kind) {
- case 217 /* AwaitExpression */:
+ case 218 /* SyntaxKind.AwaitExpression */:
return visitAwaitExpression(node);
- case 223 /* YieldExpression */:
+ case 224 /* SyntaxKind.YieldExpression */:
return visitYieldExpression(node);
- case 246 /* ReturnStatement */:
+ case 247 /* SyntaxKind.ReturnStatement */:
return visitReturnStatement(node);
- case 249 /* LabeledStatement */:
+ case 250 /* SyntaxKind.LabeledStatement */:
return visitLabeledStatement(node);
- case 204 /* ObjectLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
return visitObjectLiteralExpression(node);
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return visitBinaryExpression(node, expressionResultIsUnused);
- case 349 /* CommaListExpression */:
+ case 351 /* SyntaxKind.CommaListExpression */:
return visitCommaListExpression(node, expressionResultIsUnused);
- case 291 /* CatchClause */:
+ case 292 /* SyntaxKind.CatchClause */:
return visitCatchClause(node);
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
return visitVariableStatement(node);
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return visitVariableDeclaration(node);
- case 239 /* DoStatement */:
- case 240 /* WhileStatement */:
- case 242 /* ForInStatement */:
- return doWithHierarchyFacts(visitDefault, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */);
- case 243 /* ForOfStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
+ return doWithHierarchyFacts(visitDefault, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */);
+ case 244 /* SyntaxKind.ForOfStatement */:
return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined);
- case 241 /* ForStatement */:
- return doWithHierarchyFacts(visitForStatement, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */);
- case 216 /* VoidExpression */:
+ case 242 /* SyntaxKind.ForStatement */:
+ return doWithHierarchyFacts(visitForStatement, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */);
+ case 217 /* SyntaxKind.VoidExpression */:
return visitVoidExpression(node);
- case 170 /* Constructor */:
- return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */);
- case 168 /* MethodDeclaration */:
- return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */);
- case 171 /* GetAccessor */:
- return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */);
- case 172 /* SetAccessor */:
- return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */);
- case 255 /* FunctionDeclaration */:
- return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */);
- case 212 /* FunctionExpression */:
- return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */);
- case 213 /* ArrowFunction */:
- return doWithHierarchyFacts(visitArrowFunction, node, 2 /* ArrowFunctionExcludes */, 0 /* ArrowFunctionIncludes */);
- case 163 /* Parameter */:
+ case 171 /* SyntaxKind.Constructor */:
+ return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */);
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */);
+ case 172 /* SyntaxKind.GetAccessor */:
+ return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */);
+ case 173 /* SyntaxKind.SetAccessor */:
+ return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */);
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */);
+ case 213 /* SyntaxKind.FunctionExpression */:
+ return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */);
+ case 214 /* SyntaxKind.ArrowFunction */:
+ return doWithHierarchyFacts(visitArrowFunction, node, 2 /* HierarchyFacts.ArrowFunctionExcludes */, 0 /* HierarchyFacts.ArrowFunctionIncludes */);
+ case 164 /* SyntaxKind.Parameter */:
return visitParameter(node);
- case 237 /* ExpressionStatement */:
+ case 238 /* SyntaxKind.ExpressionStatement */:
return visitExpressionStatement(node);
- case 211 /* ParenthesizedExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
return visitParenthesizedExpression(node, expressionResultIsUnused);
- case 209 /* TaggedTemplateExpression */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
return visitTaggedTemplateExpression(node);
- case 205 /* PropertyAccessExpression */:
- if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) {
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) {
capturedSuperProperties.add(node.name.escapedText);
}
return ts.visitEachChild(node, visitor, context);
- case 206 /* ElementAccessExpression */:
- if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) {
+ case 207 /* SyntaxKind.ElementAccessExpression */:
+ if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) {
hasSuperElementAccess = true;
}
return ts.visitEachChild(node, visitor, context);
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- return doWithHierarchyFacts(visitDefault, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */);
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ return doWithHierarchyFacts(visitDefault, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */);
default:
return ts.visitEachChild(node, visitor, context);
}
}
function visitAwaitExpression(node) {
- if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) {
+ if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) {
return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(ts.visitNode(node.expression, visitor, ts.isExpression))),
/*location*/ node), node);
}
return ts.visitEachChild(node, visitor, context);
}
function visitYieldExpression(node) {
- if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) {
+ if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) {
if (node.asteriskToken) {
var expression = ts.visitNode(ts.Debug.checkDefined(node.expression), visitor, ts.isExpression);
return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(
@@ -94972,15 +96647,15 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
function visitReturnStatement(node) {
- if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) {
+ if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) {
return factory.updateReturnStatement(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : factory.createVoidZero()));
}
return ts.visitEachChild(node, visitor, context);
}
function visitLabeledStatement(node) {
- if (enclosingFunctionFlags & 2 /* Async */) {
+ if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */) {
var statement = ts.unwrapInnermostStatementOfLabel(node);
- if (statement.kind === 243 /* ForOfStatement */ && statement.awaitModifier) {
+ if (statement.kind === 244 /* SyntaxKind.ForOfStatement */ && statement.awaitModifier) {
return visitForOfStatement(statement, node);
}
return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node);
@@ -94990,9 +96665,9 @@ var ts;
function chunkObjectLiteralElements(elements) {
var chunkObject;
var objects = [];
- for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) {
- var e = elements_4[_i];
- if (e.kind === 296 /* SpreadAssignment */) {
+ for (var _i = 0, elements_5 = elements; _i < elements_5.length; _i++) {
+ var e = elements_5[_i];
+ if (e.kind === 298 /* SyntaxKind.SpreadAssignment */) {
if (chunkObject) {
objects.push(factory.createObjectLiteralExpression(chunkObject));
chunkObject = undefined;
@@ -95001,7 +96676,7 @@ var ts;
objects.push(ts.visitNode(target, visitor, ts.isExpression));
}
else {
- chunkObject = ts.append(chunkObject, e.kind === 294 /* PropertyAssignment */
+ chunkObject = ts.append(chunkObject, e.kind === 296 /* SyntaxKind.PropertyAssignment */
? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression))
: ts.visitNode(e, visitor, ts.isObjectLiteralElementLike));
}
@@ -95012,7 +96687,7 @@ var ts;
return objects;
}
function visitObjectLiteralExpression(node) {
- if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
+ if (node.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) {
// spread elements emit like so:
// non-spread elements are chunked together into object literals, and then all are passed to __assign:
// { a, ...o, b } => __assign(__assign({a}, o), {b});
@@ -95035,7 +96710,7 @@ var ts;
// If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we
// end up with `{ a: 1, b: 2, c: 3 }`
var objects = chunkObjectLiteralElements(node.properties);
- if (objects.length && objects[0].kind !== 204 /* ObjectLiteralExpression */) {
+ if (objects.length && objects[0].kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) {
objects.unshift(factory.createObjectLiteralExpression());
}
var expression = objects[0];
@@ -95062,9 +96737,9 @@ var ts;
return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context);
}
function visitSourceFile(node) {
- var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ?
- 0 /* StrictModeSourceFileIncludes */ :
- 1 /* SourceFileIncludes */);
+ var ancestorFacts = enterSubtree(2 /* HierarchyFacts.SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ?
+ 0 /* HierarchyFacts.StrictModeSourceFileIncludes */ :
+ 1 /* HierarchyFacts.SourceFileIncludes */);
exportedVariableStatement = false;
var visited = ts.visitEachChild(node, visitor, context);
var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [
@@ -95085,10 +96760,10 @@ var ts;
* expression of an `ExpressionStatement`).
*/
function visitBinaryExpression(node, expressionResultIsUnused) {
- if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
- return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused);
+ if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) {
+ return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* FlattenLevel.ObjectRest */, !expressionResultIsUnused);
}
- if (node.operatorToken.kind === 27 /* CommaToken */) {
+ if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) {
return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression));
}
return ts.visitEachChild(node, visitor, context);
@@ -95116,10 +96791,10 @@ var ts;
function visitCatchClause(node) {
if (node.variableDeclaration &&
ts.isBindingPattern(node.variableDeclaration.name) &&
- node.variableDeclaration.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
+ node.variableDeclaration.name.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) {
var name = factory.getGeneratedNameForNode(node.variableDeclaration.name);
var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*exclamationToken*/ undefined, /*type*/ undefined, name);
- var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */);
+ var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* FlattenLevel.ObjectRest */);
var block = ts.visitNode(node.block, visitor, ts.isBlock);
if (ts.some(visitedBindings)) {
block = factory.updateBlock(block, __spreadArray([
@@ -95131,7 +96806,7 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
function visitVariableStatement(node) {
- if (ts.hasSyntacticModifier(node, 1 /* Export */)) {
+ if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) {
var savedExportedVariableStatement = exportedVariableStatement;
exportedVariableStatement = true;
var visited = ts.visitEachChild(node, visitor, context);
@@ -95157,8 +96832,8 @@ var ts;
}
function visitVariableDeclarationWorker(node, exportedVariableStatement) {
// If we are here it is because the name contains a binding pattern with a rest somewhere in it.
- if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
- return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */,
+ if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) {
+ return ts.flattenDestructuringBinding(node, visitor, context, 1 /* FlattenLevel.ObjectRest */,
/*rval*/ undefined, exportedVariableStatement);
}
return ts.visitEachChild(node, visitor, context);
@@ -95175,8 +96850,8 @@ var ts;
* @param node A ForOfStatement.
*/
function visitForOfStatement(node, outermostLabeledStatement) {
- var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */);
- if (node.initializer.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
+ var ancestorFacts = enterSubtree(0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */);
+ if (node.initializer.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) {
node = transformForOfStatementWithObjectRest(node);
}
var result = node.awaitModifier ?
@@ -95204,7 +96879,7 @@ var ts;
}
return factory.updateForOfStatement(node, node.awaitModifier, ts.setTextRange(factory.createVariableDeclarationList([
ts.setTextRange(factory.createVariableDeclaration(temp), node.initializer)
- ], 1 /* Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation),
+ ], 1 /* NodeFlags.Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation),
/*multiLine*/ true), bodyLocation));
}
return node;
@@ -95224,10 +96899,10 @@ var ts;
statements.push(statement);
}
return ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation),
- /*multiLine*/ true), bodyLocation), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */);
+ /*multiLine*/ true), bodyLocation), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */);
}
function createDownlevelAwait(expression) {
- return enclosingFunctionFlags & 1 /* Generator */
+ return enclosingFunctionFlags & 1 /* FunctionFlags.Generator */
? factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(expression))
: factory.createAwaitExpression(expression);
}
@@ -95246,18 +96921,18 @@ var ts;
hoistVariableDeclaration(errorRecord);
hoistVariableDeclaration(returnMethod);
// if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration
- var initializer = ancestorFacts & 2 /* IterationContainer */ ?
+ var initializer = ancestorFacts & 2 /* HierarchyFacts.IterationContainer */ ?
factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), callValues]) :
callValues;
var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement(
/*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([
ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression),
factory.createVariableDeclaration(result)
- ]), node.expression), 2097152 /* NoHoisting */),
+ ]), node.expression), 2097152 /* EmitFlags.NoHoisting */),
/*condition*/ factory.createComma(factory.createAssignment(result, createDownlevelAwait(callNext)), factory.createLogicalNot(getDone)),
/*incrementor*/ undefined,
/*statement*/ convertForOfStatementHead(node, getValue)),
- /*location*/ node), 256 /* NoTokenTrailingSourceMaps */);
+ /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */);
ts.setOriginalNode(forStatement, node);
return factory.createTryStatement(factory.createBlock([
factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement)
@@ -95265,15 +96940,15 @@ var ts;
factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([
factory.createPropertyAssignment("error", catchVariable)
])))
- ]), 1 /* SingleLine */)), factory.createBlock([
+ ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([
factory.createTryStatement(
/*tryBlock*/ factory.createBlock([
- ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */)
+ ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* EmitFlags.SingleLine */)
]),
/*catchClause*/ undefined,
/*finallyBlock*/ ts.setEmitFlags(factory.createBlock([
- ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */)
- ]), 1 /* SingleLine */))
+ ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */)
+ ]), 1 /* EmitFlags.SingleLine */))
]));
}
function parameterVisitor(node) {
@@ -95289,7 +96964,7 @@ var ts;
/*type*/ undefined,
/*initializer*/ undefined);
}
- if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
+ if (node.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) {
// Binding patterns are converted into a generated name and are
// evaluated inside the function body.
return factory.updateParameterDeclaration(node,
@@ -95307,7 +96982,7 @@ var ts;
if (parameters) {
parameters.add(parameter);
}
- else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
+ else if (parameter.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) {
parameters = new ts.Set();
}
}
@@ -95353,13 +97028,13 @@ var ts;
enclosingFunctionFlags = ts.getFunctionFlags(node);
parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
var updated = factory.updateMethodDeclaration(node,
- /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */
+ /*decorators*/ undefined, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */
? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
- : node.modifiers, enclosingFunctionFlags & 2 /* Async */
+ : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */
? undefined
: node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(/*questionToken*/ undefined, visitor, ts.isToken),
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
- /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
+ /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */
? transformAsyncGeneratorFunctionBody(node)
: transformFunctionBody(node));
enclosingFunctionFlags = savedEnclosingFunctionFlags;
@@ -95372,13 +97047,13 @@ var ts;
enclosingFunctionFlags = ts.getFunctionFlags(node);
parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
var updated = factory.updateFunctionDeclaration(node,
- /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */
+ /*decorators*/ undefined, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */
? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
- : node.modifiers, enclosingFunctionFlags & 2 /* Async */
+ : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */
? undefined
: node.asteriskToken, node.name,
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
- /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
+ /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */
? transformAsyncGeneratorFunctionBody(node)
: transformFunctionBody(node));
enclosingFunctionFlags = savedEnclosingFunctionFlags;
@@ -95402,13 +97077,13 @@ var ts;
var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
enclosingFunctionFlags = ts.getFunctionFlags(node);
parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
- var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */
+ var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */
? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
- : node.modifiers, enclosingFunctionFlags & 2 /* Async */
+ : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */
? undefined
: node.asteriskToken, node.name,
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
- /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
+ /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */
? transformAsyncGeneratorFunctionBody(node)
: transformFunctionBody(node));
enclosingFunctionFlags = savedEnclosingFunctionFlags;
@@ -95425,13 +97100,13 @@ var ts;
capturedSuperProperties = new ts.Set();
hasSuperElementAccess = false;
var returnStatement = factory.createReturnStatement(emitHelpers().createAsyncGeneratorHelper(factory.createFunctionExpression(
- /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name),
+ /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name),
/*typeParameters*/ undefined,
/*parameters*/ [],
- /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HasLexicalThis */)));
+ /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HierarchyFacts.HasLexicalThis */)));
// Minor optimization, emit `_super` helper to capture `super` access in an arrow.
// This step isn't needed if we eventually transform this to ES5.
- var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */);
+ var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */);
if (emitSuperHelpers) {
enableSubstitutionForAsyncMethodsWithSuper();
var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
@@ -95442,10 +97117,10 @@ var ts;
ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
var block = factory.updateBlock(node.body, statements);
if (emitSuperHelpers && hasSuperElementAccess) {
- if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) {
+ if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
}
- else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) {
+ else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) {
ts.addEmitHelper(block, ts.asyncSuperHelper);
}
}
@@ -95484,11 +97159,11 @@ var ts;
//
// NOTE: see `insertDefaultValueAssignmentForBindingPattern` in es2015.ts
if (parameter.name.elements.length > 0) {
- var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter));
+ var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter));
if (ts.some(declarations)) {
var declarationList = factory.createVariableDeclarationList(declarations);
var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList);
- ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
+ ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */);
statements = ts.append(statements, statement);
}
}
@@ -95497,7 +97172,7 @@ var ts;
var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression);
var assignment = factory.createAssignment(name, initializer);
var statement = factory.createExpressionStatement(assignment);
- ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
+ ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */);
statements = ts.append(statements, statement);
}
}
@@ -95513,32 +97188,32 @@ var ts;
// }
var name = factory.cloneNode(parameter.name);
ts.setTextRange(name, parameter.name);
- ts.setEmitFlags(name, 48 /* NoSourceMap */);
+ ts.setEmitFlags(name, 48 /* EmitFlags.NoSourceMap */);
var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression);
- ts.addEmitFlags(initializer, 48 /* NoSourceMap */ | 1536 /* NoComments */);
+ ts.addEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | 1536 /* EmitFlags.NoComments */);
var assignment = factory.createAssignment(name, initializer);
ts.setTextRange(assignment, parameter);
- ts.setEmitFlags(assignment, 1536 /* NoComments */);
+ ts.setEmitFlags(assignment, 1536 /* EmitFlags.NoComments */);
var block = factory.createBlock([factory.createExpressionStatement(assignment)]);
ts.setTextRange(block, parameter);
- ts.setEmitFlags(block, 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */);
+ ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */);
var typeCheck = factory.createTypeCheck(factory.cloneNode(parameter.name), "undefined");
var statement = factory.createIfStatement(typeCheck, block);
ts.startOnNewLine(statement);
ts.setTextRange(statement, parameter);
- ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */);
+ ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */);
statements = ts.append(statements, statement);
}
}
- else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
+ else if (parameter.transformFlags & 32768 /* TransformFlags.ContainsObjectRestOrSpread */) {
containsPrecedingObjectRestOrSpread = true;
- var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter),
+ var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* FlattenLevel.ObjectRest */, factory.getGeneratedNameForNode(parameter),
/*doNotRecordTempVariablesInLine*/ false,
/*skipInitializer*/ true);
if (ts.some(declarations)) {
var declarationList = factory.createVariableDeclarationList(declarations);
var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList);
- ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
+ ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */);
statements = ts.append(statements, statement);
}
}
@@ -95546,21 +97221,21 @@ var ts;
return statements;
}
function enableSubstitutionForAsyncMethodsWithSuper() {
- if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) {
- enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */;
+ if ((enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */) === 0) {
+ enabledSubstitutions |= 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */;
// We need to enable substitutions for call, property access, and element access
// if we need to rewrite super calls.
- context.enableSubstitution(207 /* CallExpression */);
- context.enableSubstitution(205 /* PropertyAccessExpression */);
- context.enableSubstitution(206 /* ElementAccessExpression */);
+ context.enableSubstitution(208 /* SyntaxKind.CallExpression */);
+ context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */);
+ context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */);
// We need to be notified when entering and exiting declarations that bind super.
- context.enableEmitNotification(256 /* ClassDeclaration */);
- context.enableEmitNotification(168 /* MethodDeclaration */);
- context.enableEmitNotification(171 /* GetAccessor */);
- context.enableEmitNotification(172 /* SetAccessor */);
- context.enableEmitNotification(170 /* Constructor */);
+ context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */);
+ context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */);
+ context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */);
+ context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */);
+ context.enableEmitNotification(171 /* SyntaxKind.Constructor */);
// We need to be notified when entering the generated accessor arrow functions.
- context.enableEmitNotification(236 /* VariableStatement */);
+ context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */);
}
}
/**
@@ -95573,8 +97248,8 @@ var ts;
function onEmitNode(hint, node, emitCallback) {
// If we need to support substitutions for `super` in an async method,
// we should track it here.
- if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) {
- var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */);
+ if (enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) {
+ var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */);
if (superContainerFlags !== enclosingSuperContainerFlags) {
var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
enclosingSuperContainerFlags = superContainerFlags;
@@ -95601,30 +97276,30 @@ var ts;
*/
function onSubstituteNode(hint, node) {
node = previousOnSubstituteNode(hint, node);
- if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) {
+ if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) {
return substituteExpression(node);
}
return node;
}
function substituteExpression(node) {
switch (node.kind) {
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
return substitutePropertyAccessExpression(node);
- case 206 /* ElementAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
return substituteElementAccessExpression(node);
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
return substituteCallExpression(node);
}
return node;
}
function substitutePropertyAccessExpression(node) {
- if (node.expression.kind === 106 /* SuperKeyword */) {
- return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node);
+ if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) {
+ return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node);
}
return node;
}
function substituteElementAccessExpression(node) {
- if (node.expression.kind === 106 /* SuperKeyword */) {
+ if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) {
return createSuperElementAccessInAsyncMethod(node.argumentExpression, node);
}
return node;
@@ -95644,14 +97319,14 @@ var ts;
}
function isSuperContainer(node) {
var kind = node.kind;
- return kind === 256 /* ClassDeclaration */
- || kind === 170 /* Constructor */
- || kind === 168 /* MethodDeclaration */
- || kind === 171 /* GetAccessor */
- || kind === 172 /* SetAccessor */;
+ return kind === 257 /* SyntaxKind.ClassDeclaration */
+ || kind === 171 /* SyntaxKind.Constructor */
+ || kind === 169 /* SyntaxKind.MethodDeclaration */
+ || kind === 172 /* SyntaxKind.GetAccessor */
+ || kind === 173 /* SyntaxKind.SetAccessor */;
}
function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
- if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) {
+ if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"),
/*typeArguments*/ undefined, [argumentExpression]), "value"), location);
}
@@ -95676,11 +97351,11 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
function visitor(node) {
- if ((node.transformFlags & 64 /* ContainsES2019 */) === 0) {
+ if ((node.transformFlags & 64 /* TransformFlags.ContainsES2019 */) === 0) {
return node;
}
switch (node.kind) {
- case 291 /* CatchClause */:
+ case 292 /* SyntaxKind.CatchClause */:
return visitCatchClause(node);
default:
return ts.visitEachChild(node, visitor, context);
@@ -95708,29 +97383,29 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
function visitor(node) {
- if ((node.transformFlags & 32 /* ContainsES2020 */) === 0) {
+ if ((node.transformFlags & 32 /* TransformFlags.ContainsES2020 */) === 0) {
return node;
}
switch (node.kind) {
- case 207 /* CallExpression */: {
+ case 208 /* SyntaxKind.CallExpression */: {
var updated = visitNonOptionalCallExpression(node, /*captureThisArg*/ false);
ts.Debug.assertNotNode(updated, ts.isSyntheticReference);
return updated;
}
- case 205 /* PropertyAccessExpression */:
- case 206 /* ElementAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
if (ts.isOptionalChain(node)) {
var updated = visitOptionalExpression(node, /*captureThisArg*/ false, /*isDelete*/ false);
ts.Debug.assertNotNode(updated, ts.isSyntheticReference);
return updated;
}
return ts.visitEachChild(node, visitor, context);
- case 220 /* BinaryExpression */:
- if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) {
+ case 221 /* SyntaxKind.BinaryExpression */:
+ if (node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) {
return transformNullishCoalescingExpression(node);
}
return ts.visitEachChild(node, visitor, context);
- case 214 /* DeleteExpression */:
+ case 215 /* SyntaxKind.DeleteExpression */:
return visitDeleteExpression(node);
default:
return ts.visitEachChild(node, visitor, context);
@@ -95772,7 +97447,7 @@ var ts;
thisArg = expression;
}
}
- expression = node.kind === 205 /* PropertyAccessExpression */
+ expression = node.kind === 206 /* SyntaxKind.PropertyAccessExpression */
? factory.updatePropertyAccessExpression(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier))
: factory.updateElementAccessExpression(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression));
return thisArg ? factory.createSyntheticReferenceExpression(expression, thisArg) : expression;
@@ -95795,10 +97470,10 @@ var ts;
}
function visitNonOptionalExpression(node, captureThisArg, isDelete) {
switch (node.kind) {
- case 211 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete);
- case 205 /* PropertyAccessExpression */:
- case 206 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete);
- case 207 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg);
+ case 212 /* SyntaxKind.ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete);
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete);
+ case 208 /* SyntaxKind.CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg);
default: return ts.visitNode(node, visitor, ts.isExpression);
}
}
@@ -95807,7 +97482,7 @@ var ts;
var left = visitNonOptionalExpression(ts.skipPartiallyEmittedExpressions(expression), ts.isCallChain(chain[0]), /*isDelete*/ false);
var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined;
var capturedLeft = ts.isSyntheticReference(left) ? left.expression : left;
- var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* PartiallyEmittedExpressions */);
+ var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */);
if (!ts.isSimpleCopiableExpression(capturedLeft)) {
capturedLeft = factory.createTempVariable(hoistVariableDeclaration);
leftExpression = factory.createAssignment(capturedLeft, leftExpression);
@@ -95817,8 +97492,8 @@ var ts;
for (var i = 0; i < chain.length; i++) {
var segment = chain[i];
switch (segment.kind) {
- case 205 /* PropertyAccessExpression */:
- case 206 /* ElementAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
if (i === chain.length - 1 && captureThisArg) {
if (!ts.isSimpleCopiableExpression(rightExpression)) {
thisArg = factory.createTempVariable(hoistVariableDeclaration);
@@ -95828,17 +97503,17 @@ var ts;
thisArg = rightExpression;
}
}
- rightExpression = segment.kind === 205 /* PropertyAccessExpression */
+ rightExpression = segment.kind === 206 /* SyntaxKind.PropertyAccessExpression */
? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier))
: factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression));
break;
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
if (i === 0 && leftThisArg) {
if (!ts.isGeneratedIdentifier(leftThisArg)) {
leftThisArg = factory.cloneNode(leftThisArg);
- ts.addEmitFlags(leftThisArg, 1536 /* NoComments */);
+ ts.addEmitFlags(leftThisArg, 1536 /* EmitFlags.NoComments */);
}
- rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression));
+ rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SyntaxKind.SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression));
}
else {
rightExpression = factory.createCallExpression(rightExpression,
@@ -95855,7 +97530,7 @@ var ts;
return thisArg ? factory.createSyntheticReferenceExpression(target, thisArg) : target;
}
function createNotNullCondition(left, right, invert) {
- return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* BarBarToken */ : 55 /* AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createVoidZero()));
+ return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* SyntaxKind.BarBarToken */ : 55 /* SyntaxKind.AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createVoidZero()));
}
function transformNullishCoalescingExpression(node) {
var left = ts.visitNode(node.left, visitor, ts.isExpression);
@@ -95889,11 +97564,11 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
function visitor(node) {
- if ((node.transformFlags & 16 /* ContainsES2021 */) === 0) {
+ if ((node.transformFlags & 16 /* TransformFlags.ContainsES2021 */) === 0) {
return node;
}
switch (node.kind) {
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
var binaryExpression = node;
if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) {
return transformLogicalAssignment(binaryExpression);
@@ -95943,7 +97618,7 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
function visitor(node) {
- if ((node.transformFlags & 4 /* ContainsESNext */) === 0) {
+ if ((node.transformFlags & 4 /* TransformFlags.ContainsESNext */) === 0) {
return node;
}
switch (node.kind) {
@@ -95967,12 +97642,12 @@ var ts;
if (currentFileState.filenameDeclaration) {
return currentFileState.filenameDeclaration.name;
}
- var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* Optimistic */ | 32 /* FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName));
+ var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName));
currentFileState.filenameDeclaration = declaration;
return currentFileState.filenameDeclaration.name;
}
function getJsxFactoryCalleePrimitive(isStaticChildren) {
- return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx";
+ return compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx";
}
function getJsxFactoryCallee(isStaticChildren) {
var type = getJsxFactoryCalleePrimitive(isStaticChildren);
@@ -95998,7 +97673,7 @@ var ts;
specifierSourceImports = new ts.Map();
currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports);
}
- var generatedName = factory.createUniqueName("_".concat(name), 16 /* Optimistic */ | 32 /* FileLevel */ | 64 /* AllowNameSubstitution */);
+ var generatedName = factory.createUniqueName("_".concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */ | 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */);
var specifier = factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier(name), generatedName);
generatedName.generatedImportReference = specifier;
specifierSourceImports.set(name, specifier);
@@ -96020,7 +97695,7 @@ var ts;
ts.addEmitHelpers(visited, context.readEmitHelpers());
var statements = visited.statements;
if (currentFileState.filenameDeclaration) {
- statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* Const */)));
+ statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* NodeFlags.Const */)));
}
if (currentFileState.utilizedImplicitRuntimeImports) {
for (var _i = 0, _a = ts.arrayFrom(currentFileState.utilizedImplicitRuntimeImports.entries()); _i < _a.length; _i++) {
@@ -96037,7 +97712,7 @@ var ts;
factory.createVariableDeclaration(factory.createObjectBindingPattern(ts.map(ts.arrayFrom(importSpecifiersMap.values()), function (s) { return factory.createBindingElement(/*dotdotdot*/ undefined, s.propertyName, s.name); })),
/*exclaimationToken*/ undefined,
/*type*/ undefined, factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, [factory.createStringLiteral(importSource)]))
- ], 2 /* Const */));
+ ], 2 /* NodeFlags.Const */));
ts.setParentRecursive(requireStatement, /*incremental*/ false);
statements = ts.insertStatementAfterCustomPrologue(statements.slice(), requireStatement);
}
@@ -96053,7 +97728,7 @@ var ts;
return visited;
}
function visitor(node) {
- if (node.transformFlags & 2 /* ContainsJsx */) {
+ if (node.transformFlags & 2 /* TransformFlags.ContainsJsx */) {
return visitorWorker(node);
}
else {
@@ -96062,13 +97737,13 @@ var ts;
}
function visitorWorker(node) {
switch (node.kind) {
- case 277 /* JsxElement */:
+ case 278 /* SyntaxKind.JsxElement */:
return visitJsxElement(node, /*isChild*/ false);
- case 278 /* JsxSelfClosingElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
return visitJsxSelfClosingElement(node, /*isChild*/ false);
- case 281 /* JsxFragment */:
+ case 282 /* SyntaxKind.JsxFragment */:
return visitJsxFragment(node, /*isChild*/ false);
- case 287 /* JsxExpression */:
+ case 288 /* SyntaxKind.JsxExpression */:
return visitJsxExpression(node);
default:
return ts.visitEachChild(node, visitor, context);
@@ -96076,15 +97751,15 @@ var ts;
}
function transformJsxChildToExpression(node) {
switch (node.kind) {
- case 11 /* JsxText */:
+ case 11 /* SyntaxKind.JsxText */:
return visitJsxText(node);
- case 287 /* JsxExpression */:
+ case 288 /* SyntaxKind.JsxExpression */:
return visitJsxExpression(node);
- case 277 /* JsxElement */:
+ case 278 /* SyntaxKind.JsxElement */:
return visitJsxElement(node, /*isChild*/ true);
- case 278 /* JsxSelfClosingElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
return visitJsxSelfClosingElement(node, /*isChild*/ true);
- case 281 /* JsxFragment */:
+ case 282 /* SyntaxKind.JsxFragment */:
return visitJsxFragment(node, /*isChild*/ true);
default:
return ts.Debug.failBadSyntaxKind(node);
@@ -96128,8 +97803,8 @@ var ts;
function convertJsxChildrenToChildrenPropAssignment(children) {
var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
if (ts.length(nonWhitespaceChildren) === 1 && !nonWhitespaceChildren[0].dotDotDotToken) {
- var result_12 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
- return result_12 && factory.createPropertyAssignment("children", result_12);
+ var result_13 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
+ return result_13 && factory.createPropertyAssignment("children", result_13);
}
var result = ts.mapDefined(children, transformJsxChildToExpression);
return ts.length(result) ? factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result)) : undefined;
@@ -96153,7 +97828,7 @@ var ts;
if (keyAttr) {
args.push(transformJsxAttributeInitializer(keyAttr.initializer));
}
- if (compilerOptions.jsx === 5 /* ReactJSXDev */) {
+ if (compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */) {
var originalFile = ts.getOriginalNode(currentSourceFile);
if (originalFile && ts.isSourceFile(originalFile)) {
// "maybeKey" has to be replaced with "void 0" to not break the jsxDEV signature
@@ -96218,7 +97893,7 @@ var ts;
}
function transformJsxAttributesToObjectProps(attrs, children) {
var target = ts.getEmitScriptTarget(compilerOptions);
- return target && target >= 5 /* ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) :
+ return target && target >= 5 /* ScriptTarget.ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) :
transformJsxAttributesToExpression(attrs, children);
}
function transformJsxAttributesToProps(attrs, children) {
@@ -96258,14 +97933,14 @@ var ts;
if (node === undefined) {
return factory.createTrue();
}
- else if (node.kind === 10 /* StringLiteral */) {
+ else if (node.kind === 10 /* SyntaxKind.StringLiteral */) {
// Always recreate the literal to escape any escape sequences or newlines which may be in the original jsx string and which
// Need to be escaped to be handled correctly in a normal string
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 === 287 /* JsxExpression */) {
+ else if (node.kind === 288 /* SyntaxKind.JsxExpression */) {
if (node.expression === undefined) {
return factory.createTrue();
}
@@ -96359,7 +98034,7 @@ var ts;
return decoded === text ? undefined : decoded;
}
function getTagName(node) {
- if (node.kind === 277 /* JsxElement */) {
+ if (node.kind === 278 /* SyntaxKind.JsxElement */) {
return getTagName(node.openingElement);
}
else {
@@ -96662,11 +98337,11 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
function visitor(node) {
- if ((node.transformFlags & 512 /* ContainsES2016 */) === 0) {
+ if ((node.transformFlags & 512 /* TransformFlags.ContainsES2016 */) === 0) {
return node;
}
switch (node.kind) {
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return visitBinaryExpression(node);
default:
return ts.visitEachChild(node, visitor, context);
@@ -96674,9 +98349,9 @@ var ts;
}
function visitBinaryExpression(node) {
switch (node.operatorToken.kind) {
- case 67 /* AsteriskAsteriskEqualsToken */:
+ case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */:
return visitExponentiationAssignmentExpression(node);
- case 42 /* AsteriskAsteriskToken */:
+ case 42 /* SyntaxKind.AsteriskAsteriskToken */:
return visitExponentiationExpression(node);
default:
return ts.visitEachChild(node, visitor, context);
@@ -96866,7 +98541,7 @@ var ts;
currentSourceFile = undefined;
currentText = undefined;
taggedTemplateStringDeclarations = undefined;
- hierarchyFacts = 0 /* None */;
+ hierarchyFacts = 0 /* HierarchyFacts.None */;
return visited;
}
/**
@@ -96876,7 +98551,7 @@ var ts;
*/
function enterSubtree(excludeFacts, includeFacts) {
var ancestorFacts = hierarchyFacts;
- hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* AncestorFactsMask */;
+ hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* HierarchyFacts.AncestorFactsMask */;
return ancestorFacts;
}
/**
@@ -96887,15 +98562,15 @@ var ts;
* @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated.
*/
function exitSubtree(ancestorFacts, excludeFacts, includeFacts) {
- hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts;
+ hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* HierarchyFacts.SubtreeFactsMask */ | ancestorFacts;
}
function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
- return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0
- && node.kind === 246 /* ReturnStatement */
+ return (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */) !== 0
+ && node.kind === 247 /* SyntaxKind.ReturnStatement */
&& !node.expression;
}
function isOrMayContainReturnCompletion(node) {
- return node.transformFlags & 2097152 /* ContainsHoistedDeclarationOrCompletion */
+ return node.transformFlags & 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */
&& (ts.isReturnStatement(node)
|| ts.isIfStatement(node)
|| ts.isWithStatement(node)
@@ -96910,11 +98585,11 @@ var ts;
|| ts.isBlock(node));
}
function shouldVisitNode(node) {
- return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0
+ return (node.transformFlags & 1024 /* TransformFlags.ContainsES2015 */) !== 0
|| convertedLoopState !== undefined
- || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node))
+ || (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node))
|| (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node))
- || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0;
+ || (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) !== 0;
}
function visitor(node) {
return shouldVisitNode(node) ? visitorWorker(node, /*expressionResultIsUnused*/ false) : node;
@@ -96926,9 +98601,9 @@ var ts;
if (shouldVisitNode(node)) {
var original = ts.getOriginalNode(node);
if (ts.isPropertyDeclaration(original) && ts.hasStaticModifier(original)) {
- var ancestorFacts = enterSubtree(32670 /* StaticInitializerExcludes */, 16449 /* StaticInitializerIncludes */);
+ var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.StaticInitializerExcludes */, 16449 /* HierarchyFacts.StaticInitializerIncludes */);
var result = visitorWorker(node, /*expressionResultIsUnused*/ false);
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */);
return result;
}
return visitorWorker(node, /*expressionResultIsUnused*/ false);
@@ -96936,115 +98611,115 @@ var ts;
return node;
}
function callExpressionVisitor(node) {
- if (node.kind === 106 /* SuperKeyword */) {
+ if (node.kind === 106 /* SyntaxKind.SuperKeyword */) {
return visitSuperKeyword(/*isExpressionOfCall*/ true);
}
return visitor(node);
}
function visitorWorker(node, expressionResultIsUnused) {
switch (node.kind) {
- case 124 /* StaticKeyword */:
+ case 124 /* SyntaxKind.StaticKeyword */:
return undefined; // elide static keyword
- case 256 /* ClassDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
return visitClassDeclaration(node);
- case 225 /* ClassExpression */:
+ case 226 /* SyntaxKind.ClassExpression */:
return visitClassExpression(node);
- case 163 /* Parameter */:
+ case 164 /* SyntaxKind.Parameter */:
return visitParameter(node);
- case 255 /* FunctionDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
return visitFunctionDeclaration(node);
- case 213 /* ArrowFunction */:
+ case 214 /* SyntaxKind.ArrowFunction */:
return visitArrowFunction(node);
- case 212 /* FunctionExpression */:
+ case 213 /* SyntaxKind.FunctionExpression */:
return visitFunctionExpression(node);
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return visitVariableDeclaration(node);
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return visitIdentifier(node);
- case 254 /* VariableDeclarationList */:
+ case 255 /* SyntaxKind.VariableDeclarationList */:
return visitVariableDeclarationList(node);
- case 248 /* SwitchStatement */:
+ case 249 /* SyntaxKind.SwitchStatement */:
return visitSwitchStatement(node);
- case 262 /* CaseBlock */:
+ case 263 /* SyntaxKind.CaseBlock */:
return visitCaseBlock(node);
- case 234 /* Block */:
+ case 235 /* SyntaxKind.Block */:
return visitBlock(node, /*isFunctionBody*/ false);
- case 245 /* BreakStatement */:
- case 244 /* ContinueStatement */:
+ case 246 /* SyntaxKind.BreakStatement */:
+ case 245 /* SyntaxKind.ContinueStatement */:
return visitBreakOrContinueStatement(node);
- case 249 /* LabeledStatement */:
+ case 250 /* SyntaxKind.LabeledStatement */:
return visitLabeledStatement(node);
- case 239 /* DoStatement */:
- case 240 /* WhileStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined);
- case 241 /* ForStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
return visitForStatement(node, /*outermostLabeledStatement*/ undefined);
- case 242 /* ForInStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
return visitForInStatement(node, /*outermostLabeledStatement*/ undefined);
- case 243 /* ForOfStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined);
- case 237 /* ExpressionStatement */:
+ case 238 /* SyntaxKind.ExpressionStatement */:
return visitExpressionStatement(node);
- case 204 /* ObjectLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
return visitObjectLiteralExpression(node);
- case 291 /* CatchClause */:
+ case 292 /* SyntaxKind.CatchClause */:
return visitCatchClause(node);
- case 295 /* ShorthandPropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
return visitShorthandPropertyAssignment(node);
- case 161 /* ComputedPropertyName */:
+ case 162 /* SyntaxKind.ComputedPropertyName */:
return visitComputedPropertyName(node);
- case 203 /* ArrayLiteralExpression */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
return visitArrayLiteralExpression(node);
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
return visitCallExpression(node);
- case 208 /* NewExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
return visitNewExpression(node);
- case 211 /* ParenthesizedExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
return visitParenthesizedExpression(node, expressionResultIsUnused);
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return visitBinaryExpression(node, expressionResultIsUnused);
- case 349 /* CommaListExpression */:
+ case 351 /* SyntaxKind.CommaListExpression */:
return visitCommaListExpression(node, expressionResultIsUnused);
- case 14 /* NoSubstitutionTemplateLiteral */:
- case 15 /* TemplateHead */:
- case 16 /* TemplateMiddle */:
- case 17 /* TemplateTail */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
+ case 15 /* SyntaxKind.TemplateHead */:
+ case 16 /* SyntaxKind.TemplateMiddle */:
+ case 17 /* SyntaxKind.TemplateTail */:
return visitTemplateLiteral(node);
- case 10 /* StringLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
return visitStringLiteral(node);
- case 8 /* NumericLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
return visitNumericLiteral(node);
- case 209 /* TaggedTemplateExpression */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
return visitTaggedTemplateExpression(node);
- case 222 /* TemplateExpression */:
+ case 223 /* SyntaxKind.TemplateExpression */:
return visitTemplateExpression(node);
- case 223 /* YieldExpression */:
+ case 224 /* SyntaxKind.YieldExpression */:
return visitYieldExpression(node);
- case 224 /* SpreadElement */:
+ case 225 /* SyntaxKind.SpreadElement */:
return visitSpreadElement(node);
- case 106 /* SuperKeyword */:
+ case 106 /* SyntaxKind.SuperKeyword */:
return visitSuperKeyword(/*isExpressionOfCall*/ false);
- case 108 /* ThisKeyword */:
+ case 108 /* SyntaxKind.ThisKeyword */:
return visitThisKeyword(node);
- case 230 /* MetaProperty */:
+ case 231 /* SyntaxKind.MetaProperty */:
return visitMetaProperty(node);
- case 168 /* MethodDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
return visitMethodDeclaration(node);
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
return visitAccessorDeclaration(node);
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
return visitVariableStatement(node);
- case 246 /* ReturnStatement */:
+ case 247 /* SyntaxKind.ReturnStatement */:
return visitReturnStatement(node);
- case 216 /* VoidExpression */:
+ case 217 /* SyntaxKind.VoidExpression */:
return visitVoidExpression(node);
default:
return ts.visitEachChild(node, visitor, context);
}
}
function visitSourceFile(node) {
- var ancestorFacts = enterSubtree(8064 /* SourceFileExcludes */, 64 /* SourceFileIncludes */);
+ var ancestorFacts = enterSubtree(8064 /* HierarchyFacts.SourceFileExcludes */, 64 /* HierarchyFacts.SourceFileIncludes */);
var prologue = [];
var statements = [];
startLexicalEnvironment();
@@ -97055,14 +98730,14 @@ var ts;
}
factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
insertCaptureThisForNodeIfNeeded(prologue, node);
- exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
+ exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */);
return factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(ts.concatenate(prologue, statements)), node.statements));
}
function visitSwitchStatement(node) {
if (convertedLoopState !== undefined) {
var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps;
// for switch statement allow only non-labeled break
- convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */;
+ convertedLoopState.allowedNonLabeledJumps |= 2 /* Jump.Break */;
var result = ts.visitEachChild(node, visitor, context);
convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps;
return result;
@@ -97070,17 +98745,17 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
function visitCaseBlock(node) {
- var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
+ var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */);
var updated = ts.visitEachChild(node, visitor, context);
- exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
+ exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */);
return updated;
}
function returnCapturedThis(node) {
- return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)), node);
+ return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)), node);
}
function visitReturnStatement(node) {
if (convertedLoopState) {
- convertedLoopState.nonLocalJumps |= 8 /* Return */;
+ convertedLoopState.nonLocalJumps |= 8 /* Jump.Return */;
if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) {
node = returnCapturedThis(node);
}
@@ -97096,11 +98771,11 @@ var ts;
return ts.visitEachChild(node, visitor, context);
}
function visitThisKeyword(node) {
- if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
- hierarchyFacts |= 65536 /* CapturedLexicalThis */;
+ if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) {
+ hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */;
}
if (convertedLoopState) {
- if (hierarchyFacts & 2 /* ArrowFunction */) {
+ if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */) {
// if the enclosing function is an ArrowFunction then we use the captured 'this' keyword.
convertedLoopState.containsLexicalThis = true;
return node;
@@ -97127,25 +98802,25 @@ var ts;
// it is possible if either
// - break/continue is labeled and label is located inside the converted loop
// - break/continue is non-labeled and located in non-converted loop/switch statement
- var jump = node.kind === 245 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */;
+ var jump = node.kind === 246 /* SyntaxKind.BreakStatement */ ? 2 /* Jump.Break */ : 4 /* Jump.Continue */;
var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) ||
(!node.label && (convertedLoopState.allowedNonLabeledJumps & jump));
if (!canUseBreakOrContinue) {
var labelMarker = void 0;
var label = node.label;
if (!label) {
- if (node.kind === 245 /* BreakStatement */) {
- convertedLoopState.nonLocalJumps |= 2 /* Break */;
+ if (node.kind === 246 /* SyntaxKind.BreakStatement */) {
+ convertedLoopState.nonLocalJumps |= 2 /* Jump.Break */;
labelMarker = "break";
}
else {
- convertedLoopState.nonLocalJumps |= 4 /* Continue */;
+ convertedLoopState.nonLocalJumps |= 4 /* Jump.Continue */;
// note: return value is emitted only to simplify debugging, call to converted loop body does not do any dispatching on it.
labelMarker = "continue";
}
}
else {
- if (node.kind === 245 /* BreakStatement */) {
+ if (node.kind === 246 /* SyntaxKind.BreakStatement */) {
labelMarker = "break-".concat(label.escapedText);
setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker);
}
@@ -97159,15 +98834,15 @@ var ts;
var outParams = convertedLoopState.loopOutParameters;
var expr = void 0;
for (var i = 0; i < outParams.length; i++) {
- var copyExpr = copyOutParameter(outParams[i], 1 /* ToOutParameter */);
+ var copyExpr = copyOutParameter(outParams[i], 1 /* CopyDirection.ToOutParameter */);
if (i === 0) {
expr = copyExpr;
}
else {
- expr = factory.createBinaryExpression(expr, 27 /* CommaToken */, copyExpr);
+ expr = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, copyExpr);
}
}
- returnExpression = factory.createBinaryExpression(expr, 27 /* CommaToken */, returnExpression);
+ returnExpression = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, returnExpression);
}
return factory.createReturnStatement(returnExpression);
}
@@ -97200,18 +98875,18 @@ var ts;
ts.startOnNewLine(statement);
statements.push(statement);
// Add an `export default` statement for default exports (for `--target es5 --module es6`)
- if (ts.hasSyntacticModifier(node, 1 /* Export */)) {
- var exportStatement = ts.hasSyntacticModifier(node, 512 /* Default */)
+ if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) {
+ var exportStatement = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)
? factory.createExportDefault(factory.getLocalName(node))
: factory.createExternalModuleExport(factory.getLocalName(node));
ts.setOriginalNode(exportStatement, statement);
statements.push(exportStatement);
}
var emitFlags = ts.getEmitFlags(node);
- if ((emitFlags & 4194304 /* HasEndOfDeclarationMarker */) === 0) {
+ if ((emitFlags & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) === 0) {
// Add a DeclarationMarker as a marker for the end of the declaration
statements.push(factory.createEndOfDeclarationMarker(node));
- ts.setEmitFlags(statement, emitFlags | 4194304 /* HasEndOfDeclarationMarker */);
+ ts.setEmitFlags(statement, emitFlags | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */);
}
return ts.singleOrMany(statements);
}
@@ -97268,25 +98943,25 @@ var ts;
/*modifiers*/ undefined,
/*asteriskToken*/ undefined,
/*name*/ undefined,
- /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */))] : [],
+ /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */))] : [],
/*type*/ undefined, transformClassBody(node, extendsClauseElement));
// To preserve the behavior of the old emitter, we explicitly indent
// the body of the function here if it was requested in an earlier
// transformation.
- ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* Indented */) | 524288 /* ReuseTempVariableScope */);
+ ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */) | 524288 /* EmitFlags.ReuseTempVariableScope */);
// "inner" and "outer" below are added purely to preserve source map locations from
// the old emitter
var inner = factory.createPartiallyEmittedExpression(classFunction);
ts.setTextRangeEnd(inner, node.end);
- ts.setEmitFlags(inner, 1536 /* NoComments */);
+ ts.setEmitFlags(inner, 1536 /* EmitFlags.NoComments */);
var outer = factory.createPartiallyEmittedExpression(inner);
ts.setTextRangeEnd(outer, ts.skipTrivia(currentText, node.pos));
- ts.setEmitFlags(outer, 1536 /* NoComments */);
+ ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */);
var result = factory.createParenthesizedExpression(factory.createCallExpression(outer,
/*typeArguments*/ undefined, extendsClauseElement
? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)]
: []));
- ts.addSyntheticLeadingComment(result, 3 /* MultiLineCommentTrivia */, "* @class ");
+ ts.addSyntheticLeadingComment(result, 3 /* SyntaxKind.MultiLineCommentTrivia */, "* @class ");
return result;
}
/**
@@ -97304,19 +98979,19 @@ var ts;
addConstructor(statements, node, constructorLikeName, extendsClauseElement);
addClassMembers(statements, node);
// Create a synthetic text range for the return statement.
- var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* CloseBraceToken */);
+ var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* SyntaxKind.CloseBraceToken */);
// The following partially-emitted expression exists purely to align our sourcemap
// emit with the original emitter.
var outer = factory.createPartiallyEmittedExpression(constructorLikeName);
ts.setTextRangeEnd(outer, closingBraceLocation.end);
- ts.setEmitFlags(outer, 1536 /* NoComments */);
+ ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */);
var statement = factory.createReturnStatement(outer);
ts.setTextRangePos(statement, closingBraceLocation.pos);
- ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */);
+ ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */);
statements.push(statement);
ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true);
- ts.setEmitFlags(block, 1536 /* NoComments */);
+ ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */);
return block;
}
/**
@@ -97342,7 +99017,7 @@ var ts;
function addConstructor(statements, node, name, extendsClauseElement) {
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(32662 /* ConstructorExcludes */, 73 /* ConstructorIncludes */);
+ var ancestorFacts = enterSubtree(32662 /* HierarchyFacts.ConstructorExcludes */, 73 /* HierarchyFacts.ConstructorIncludes */);
var constructor = ts.getFirstConstructorWithBody(node);
var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined);
var constructorFunction = factory.createFunctionDeclaration(
@@ -97353,10 +99028,10 @@ var ts;
/*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper));
ts.setTextRange(constructorFunction, constructor || node);
if (extendsClauseElement) {
- ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */);
+ ts.setEmitFlags(constructorFunction, 8 /* EmitFlags.CapturesThis */);
}
statements.push(constructorFunction);
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */);
convertedLoopState = savedConvertedLoopState;
}
/**
@@ -97390,7 +99065,7 @@ var ts;
ts.setTextRange(statementsArray, node.members);
var block = factory.createBlock(statementsArray, /*multiLine*/ true);
ts.setTextRange(block, node);
- ts.setEmitFlags(block, 1536 /* NoComments */);
+ ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */);
return block;
}
/**
@@ -97405,7 +99080,7 @@ var ts;
function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) {
// determine whether the class is known syntactically to be a derived class (e.g. a
// class that extends a value that is not syntactically known to be `null`).
- var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */;
+ var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */;
// When the subclass does not have a constructor, we synthesize a *default* constructor using the following
// representation:
//
@@ -97449,7 +99124,7 @@ var ts;
superCallExpression = visitSuperCallInBody(superCall);
}
if (superCallExpression) {
- hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
+ hierarchyFacts |= 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */;
}
// Add parameter defaults at the beginning of the output, with prologue statements
addDefaultValueAssignmentsIfNeeded(prologue, constructor);
@@ -97459,7 +99134,7 @@ var ts;
factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false);
if (isDerivedClass || superCallExpression) {
- if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) {
+ if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */)) {
// If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the
// following representation:
//
@@ -97482,7 +99157,7 @@ var ts;
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));
- ts.setEmitFlags(superCall_1, 1536 /* NoComments */);
+ ts.setEmitFlags(superCall_1, 1536 /* EmitFlags.NoComments */);
statements.push(returnStatement);
}
else {
@@ -97521,7 +99196,7 @@ var ts;
}
}
if (!isSufficientlyCoveredByReturnStatements(constructor.body)) {
- statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)));
+ statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)));
}
}
}
@@ -97542,7 +99217,7 @@ var ts;
// ```
insertCaptureThisForNodeIfNeeded(prologue, constructor);
}
- var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex)), true), statements, true)),
+ var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex - existingPrologue.length)), true), statements, true)),
/*location*/ constructor.body.statements),
/*multiLine*/ true);
ts.setTextRange(body, constructor.body);
@@ -97571,11 +99246,11 @@ var ts;
*/
function isSufficientlyCoveredByReturnStatements(statement) {
// A return statement is considered covered.
- if (statement.kind === 246 /* ReturnStatement */) {
+ if (statement.kind === 247 /* SyntaxKind.ReturnStatement */) {
return true;
}
// An if-statement with two covered branches is covered.
- else if (statement.kind === 238 /* IfStatement */) {
+ else if (statement.kind === 239 /* SyntaxKind.IfStatement */) {
var ifStatement = statement;
if (ifStatement.elseStatement) {
return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) &&
@@ -97583,7 +99258,7 @@ var ts;
}
}
// A block is covered if it has a last statement which is covered.
- else if (statement.kind === 234 /* Block */) {
+ else if (statement.kind === 235 /* SyntaxKind.Block */) {
var lastStatement = ts.lastOrUndefined(statement.statements);
if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) {
return true;
@@ -97592,10 +99267,10 @@ var ts;
return false;
}
function createActualThis() {
- return ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */);
+ return ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */);
}
function createDefaultSuperCallOrThis() {
- return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis());
+ return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis());
}
/**
* Visits a parameter declaration.
@@ -97684,11 +99359,11 @@ var ts;
// of an initializer, we must emit that expression to preserve side effects.
if (name.elements.length > 0) {
ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createVariableStatement(
- /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* CustomPrologue */));
+ /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* EmitFlags.CustomPrologue */));
return true;
}
else if (initializer) {
- ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */));
+ ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* EmitFlags.CustomPrologue */));
return true;
}
return false;
@@ -97706,11 +99381,11 @@ var ts;
var statement = factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([
factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(
// TODO(rbuckton): Does this need to be parented?
- ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */))
- ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */));
+ ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */))
+ ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */));
ts.startOnNewLine(statement);
ts.setTextRange(statement, parameter);
- ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */);
+ ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */);
ts.insertStatementAfterCustomPrologue(statements, statement);
}
/**
@@ -97741,10 +99416,10 @@ var ts;
}
// `declarationName` is the name of the local declaration for the parameter.
// TODO(rbuckton): Does this need to be parented?
- var declarationName = parameter.name.kind === 79 /* Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined);
- ts.setEmitFlags(declarationName, 48 /* NoSourceMap */);
+ var declarationName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined);
+ ts.setEmitFlags(declarationName, 48 /* EmitFlags.NoSourceMap */);
// `expressionName` is the name of the parameter used in expressions.
- var expressionName = parameter.name.kind === 79 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName;
+ var expressionName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? factory.cloneNode(parameter.name) : declarationName;
var restIndex = node.parameters.length - 1;
var temp = factory.createLoopVariable();
// var param = [];
@@ -97754,7 +99429,7 @@ var ts;
/*exclamationToken*/ undefined,
/*type*/ undefined, factory.createArrayLiteralExpression([]))
])),
- /*location*/ parameter), 1048576 /* CustomPrologue */));
+ /*location*/ parameter), 1048576 /* EmitFlags.CustomPrologue */));
// for (var _i = restIndex; _i < arguments.length; _i++) {
// param[_i - restIndex] = arguments[_i];
// }
@@ -97766,13 +99441,13 @@ var ts;
: factory.createSubtract(temp, factory.createNumericLiteral(restIndex))), factory.createElementAccessExpression(factory.createIdentifier("arguments"), temp))),
/*location*/ parameter))
]));
- ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */);
+ ts.setEmitFlags(forStatement, 1048576 /* EmitFlags.CustomPrologue */);
ts.startOnNewLine(forStatement);
prologueStatements.push(forStatement);
- if (parameter.name.kind !== 79 /* Identifier */) {
+ if (parameter.name.kind !== 79 /* SyntaxKind.Identifier */) {
// do the actual destructuring of the rest parameter if necessary
prologueStatements.push(ts.setEmitFlags(ts.setTextRange(factory.createVariableStatement(
- /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */));
+ /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, expressionName))), parameter), 1048576 /* EmitFlags.CustomPrologue */));
}
ts.insertStatementsAfterCustomPrologue(statements, prologueStatements);
return true;
@@ -97785,7 +99460,7 @@ var ts;
* @param node A node.
*/
function insertCaptureThisForNodeIfNeeded(statements, node) {
- if (hierarchyFacts & 65536 /* CapturedLexicalThis */ && node.kind !== 213 /* ArrowFunction */) {
+ if (hierarchyFacts & 65536 /* HierarchyFacts.CapturedLexicalThis */ && node.kind !== 214 /* SyntaxKind.ArrowFunction */) {
insertCaptureThisForNode(statements, node, factory.createThis());
return true;
}
@@ -97799,7 +99474,7 @@ var ts;
*/
function insertSuperThisCaptureThisForNode(statements, superExpression) {
enableSubstitutionsForCapturedThis();
- var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* EqualsToken */, superExpression));
+ var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* SyntaxKind.EqualsToken */, superExpression));
ts.insertStatementAfterCustomPrologue(statements, assignSuperExpression);
ts.setCommentRange(assignSuperExpression, ts.getOriginalNode(superExpression).parent);
}
@@ -97807,38 +99482,38 @@ var ts;
enableSubstitutionsForCapturedThis();
var captureThisStatement = factory.createVariableStatement(
/*modifiers*/ undefined, factory.createVariableDeclarationList([
- factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */),
+ factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */),
/*exclamationToken*/ undefined,
/*type*/ undefined, initializer)
]));
- ts.setEmitFlags(captureThisStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */);
+ ts.setEmitFlags(captureThisStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */);
ts.setSourceMapRange(captureThisStatement, node);
ts.insertStatementAfterCustomPrologue(statements, captureThisStatement);
}
function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) {
- if (hierarchyFacts & 32768 /* NewTarget */) {
+ if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */) {
var newTarget = void 0;
switch (node.kind) {
- case 213 /* ArrowFunction */:
+ case 214 /* SyntaxKind.ArrowFunction */:
return statements;
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
// Methods and accessors cannot be constructors, so 'new.target' will
// always return 'undefined'.
newTarget = factory.createVoidZero();
break;
- case 170 /* Constructor */:
+ case 171 /* SyntaxKind.Constructor */:
// Class constructors can only be called with `new`, so `this.constructor`
// should be relatively safe to use.
- newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor");
+ newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor");
break;
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
// Functions can be called or constructed, and may have a `this` due to
// being a member or when calling an imported function via `other_1.f()`.
- newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), 102 /* InstanceOfKeyword */, factory.getLocalName(node))),
- /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"),
+ newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), 102 /* SyntaxKind.InstanceOfKeyword */, factory.getLocalName(node))),
+ /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor"),
/*colonToken*/ undefined, factory.createVoidZero());
break;
default:
@@ -97846,11 +99521,11 @@ var ts;
}
var captureNewTargetStatement = factory.createVariableStatement(
/*modifiers*/ undefined, factory.createVariableDeclarationList([
- factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */),
+ factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */),
/*exclamationToken*/ undefined,
/*type*/ undefined, newTarget)
]));
- ts.setEmitFlags(captureNewTargetStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */);
+ ts.setEmitFlags(captureNewTargetStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */);
if (copyOnWrite) {
statements = statements.slice();
}
@@ -97869,21 +99544,21 @@ var ts;
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
var member = _a[_i];
switch (member.kind) {
- case 233 /* SemicolonClassElement */:
+ case 234 /* SyntaxKind.SemicolonClassElement */:
statements.push(transformSemicolonClassElementToStatement(member));
break;
- case 168 /* MethodDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node));
break;
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
var accessors = ts.getAllAccessorDeclarations(node.members, member);
if (member === accessors.firstAccessor) {
statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node));
}
break;
- case 170 /* Constructor */:
- case 169 /* ClassStaticBlockDeclaration */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 170 /* SyntaxKind.ClassStaticBlockDeclaration */:
// Constructors are handled in visitClassExpression/visitClassDeclaration
break;
default:
@@ -97922,7 +99597,7 @@ var ts;
var memberName = ts.createMemberAccessForPropertyName(factory, receiver, propertyName, /*location*/ member.name);
e = factory.createAssignment(memberName, memberFunction);
}
- ts.setEmitFlags(memberFunction, 1536 /* NoComments */);
+ ts.setEmitFlags(memberFunction, 1536 /* EmitFlags.NoComments */);
ts.setSourceMapRange(memberFunction, sourceMapRange);
var statement = ts.setTextRange(factory.createExpressionStatement(e), /*location*/ member);
ts.setOriginalNode(statement, member);
@@ -97930,7 +99605,7 @@ var ts;
// The location for the statement is used to emit comments only.
// No source map should be emitted for this statement to align with the
// old emitter.
- ts.setEmitFlags(statement, 48 /* NoSourceMap */);
+ ts.setEmitFlags(statement, 48 /* EmitFlags.NoSourceMap */);
return statement;
}
/**
@@ -97944,7 +99619,7 @@ var ts;
// The location for the statement is used to emit source maps only.
// No comments should be emitted for this statement to align with the
// old emitter.
- ts.setEmitFlags(statement, 1536 /* NoComments */);
+ ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */);
ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor));
return statement;
}
@@ -97960,20 +99635,20 @@ var ts;
// arguments are both mapped contiguously to the accessor name.
// TODO(rbuckton): Does this need to be parented?
var target = ts.setParent(ts.setTextRange(factory.cloneNode(receiver), receiver), receiver.parent);
- ts.setEmitFlags(target, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */);
+ ts.setEmitFlags(target, 1536 /* EmitFlags.NoComments */ | 32 /* EmitFlags.NoTrailingSourceMap */);
ts.setSourceMapRange(target, firstAccessor.name);
var visitedAccessorName = ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName);
if (ts.isPrivateIdentifier(visitedAccessorName)) {
return ts.Debug.failBadSyntaxKind(visitedAccessorName, "Encountered unhandled private identifier while transforming ES2015.");
}
var propertyName = ts.createExpressionForPropertyName(factory, visitedAccessorName);
- ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 16 /* NoLeadingSourceMap */);
+ ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 16 /* EmitFlags.NoLeadingSourceMap */);
ts.setSourceMapRange(propertyName, firstAccessor.name);
var properties = [];
if (getAccessor) {
var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container);
ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor));
- ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */);
+ ts.setEmitFlags(getterFunction, 512 /* EmitFlags.NoLeadingComments */);
var getter = factory.createPropertyAssignment("get", getterFunction);
ts.setCommentRange(getter, ts.getCommentRange(getAccessor));
properties.push(getter);
@@ -97981,7 +99656,7 @@ var ts;
if (setAccessor) {
var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container);
ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor));
- ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */);
+ ts.setEmitFlags(setterFunction, 512 /* EmitFlags.NoLeadingComments */);
var setter = factory.createPropertyAssignment("set", setterFunction);
ts.setCommentRange(setter, ts.getCommentRange(setAccessor));
properties.push(setter);
@@ -98004,12 +99679,12 @@ var ts;
* @param node An ArrowFunction node.
*/
function visitArrowFunction(node) {
- if (node.transformFlags & 8192 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
- hierarchyFacts |= 65536 /* CapturedLexicalThis */;
+ if (node.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) {
+ hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */;
}
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(15232 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */);
+ var ancestorFacts = enterSubtree(15232 /* HierarchyFacts.ArrowFunctionExcludes */, 66 /* HierarchyFacts.ArrowFunctionIncludes */);
var func = factory.createFunctionExpression(
/*modifiers*/ undefined,
/*asteriskToken*/ undefined,
@@ -98018,9 +99693,9 @@ var ts;
/*type*/ undefined, transformFunctionBody(node));
ts.setTextRange(func, node);
ts.setOriginalNode(func, node);
- ts.setEmitFlags(func, 8 /* CapturesThis */);
+ ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */);
// If an arrow function contains
- exitSubtree(ancestorFacts, 0 /* ArrowFunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 0 /* HierarchyFacts.ArrowFunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */);
convertedLoopState = savedConvertedLoopState;
return func;
}
@@ -98030,17 +99705,17 @@ var ts;
* @param node a FunctionExpression node.
*/
function visitFunctionExpression(node) {
- var ancestorFacts = ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */
- ? enterSubtree(32662 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */)
- : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ var ancestorFacts = ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */
+ ? enterSubtree(32662 /* HierarchyFacts.AsyncFunctionBodyExcludes */, 69 /* HierarchyFacts.AsyncFunctionBodyIncludes */)
+ : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */);
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- var name = hierarchyFacts & 32768 /* NewTarget */
+ var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */
? factory.getLocalName(node)
: node.name;
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */);
convertedLoopState = savedConvertedLoopState;
return factory.updateFunctionExpression(node,
/*modifiers*/ undefined, node.asteriskToken, name,
@@ -98055,13 +99730,13 @@ var ts;
function visitFunctionDeclaration(node) {
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */);
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- var name = hierarchyFacts & 32768 /* NewTarget */
+ var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */
? factory.getLocalName(node)
: node.name;
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */);
convertedLoopState = savedConvertedLoopState;
return factory.updateFunctionDeclaration(node,
/*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name,
@@ -98079,14 +99754,14 @@ var ts;
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
var ancestorFacts = container && ts.isClassLike(container) && !ts.isStatic(node)
- ? enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */)
- : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ ? enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */ | 8 /* HierarchyFacts.NonStaticClassElement */)
+ : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */);
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 255 /* FunctionDeclaration */ || node.kind === 212 /* FunctionExpression */)) {
+ if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ && !name && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) {
name = factory.getGeneratedNameForNode(node);
}
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */);
convertedLoopState = savedConvertedLoopState;
return ts.setOriginalNode(ts.setTextRange(factory.createFunctionExpression(
/*modifiers*/ undefined, node.asteriskToken, name,
@@ -98129,7 +99804,7 @@ var ts;
}
}
else {
- ts.Debug.assert(node.kind === 213 /* ArrowFunction */);
+ ts.Debug.assert(node.kind === 214 /* SyntaxKind.ArrowFunction */);
// To align with the old emitter, we use a synthetic end position on the location
// for the statement list we synthesize when we down-level an arrow function with
// an expression function body. This prevents both comments and source maps from
@@ -98148,7 +99823,7 @@ var ts;
var returnStatement = factory.createReturnStatement(expression);
ts.setTextRange(returnStatement, body);
ts.moveSyntheticComments(returnStatement, body);
- ts.setEmitFlags(returnStatement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1024 /* NoTrailingComments */);
+ ts.setEmitFlags(returnStatement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1024 /* EmitFlags.NoTrailingComments */);
statements.push(returnStatement);
// To align with the source map emit for the old emitter, we set a custom
// source map location for the close brace.
@@ -98169,10 +99844,10 @@ var ts;
var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), multiLine);
ts.setTextRange(block, node.body);
if (!multiLine && singleLine) {
- ts.setEmitFlags(block, 1 /* SingleLine */);
+ ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */);
}
if (closeBraceLocation) {
- ts.setTokenSourceMapRange(block, 19 /* CloseBraceToken */, closeBraceLocation);
+ ts.setTokenSourceMapRange(block, 19 /* SyntaxKind.CloseBraceToken */, closeBraceLocation);
}
ts.setOriginalNode(block, node.body);
return block;
@@ -98182,11 +99857,11 @@ var ts;
// A function body is not a block scope.
return ts.visitEachChild(node, visitor, context);
}
- var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */
- ? enterSubtree(7104 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */)
- : enterSubtree(6976 /* BlockExcludes */, 128 /* BlockIncludes */);
+ var ancestorFacts = hierarchyFacts & 256 /* HierarchyFacts.IterationStatement */
+ ? enterSubtree(7104 /* HierarchyFacts.IterationStatementBlockExcludes */, 512 /* HierarchyFacts.IterationStatementBlockIncludes */)
+ : enterSubtree(6976 /* HierarchyFacts.BlockExcludes */, 128 /* HierarchyFacts.BlockIncludes */);
var updated = ts.visitEachChild(node, visitor, context);
- exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
+ exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */);
return updated;
}
/**
@@ -98217,9 +99892,9 @@ var ts;
function visitBinaryExpression(node, expressionResultIsUnused) {
// If we are here it is because this is a destructuring assignment.
if (ts.isDestructuringAssignment(node)) {
- return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !expressionResultIsUnused);
+ return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !expressionResultIsUnused);
}
- if (node.operatorToken.kind === 27 /* CommaToken */) {
+ if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) {
return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression));
}
return ts.visitEachChild(node, visitor, context);
@@ -98247,12 +99922,12 @@ var ts;
function isVariableStatementOfTypeScriptClassWrapper(node) {
return node.declarationList.declarations.length === 1
&& !!node.declarationList.declarations[0].initializer
- && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* TypeScriptClassWrapper */);
+ && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* EmitFlags.TypeScriptClassWrapper */);
}
function visitVariableStatement(node) {
- var ancestorFacts = enterSubtree(0 /* None */, ts.hasSyntacticModifier(node, 1 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */);
+ var ancestorFacts = enterSubtree(0 /* HierarchyFacts.None */, ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? 32 /* HierarchyFacts.ExportedVariableStatement */ : 0 /* HierarchyFacts.None */);
var updated;
- if (convertedLoopState && (node.declarationList.flags & 3 /* BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) {
+ if (convertedLoopState && (node.declarationList.flags & 3 /* NodeFlags.BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) {
// we are inside a converted loop - hoist variable declarations
var assignments = void 0;
for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
@@ -98261,10 +99936,10 @@ var ts;
if (decl.initializer) {
var assignment = void 0;
if (ts.isBindingPattern(decl.name)) {
- assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */);
+ assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* FlattenLevel.All */);
}
else {
- assignment = factory.createBinaryExpression(decl.name, 63 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression));
+ assignment = factory.createBinaryExpression(decl.name, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression));
ts.setTextRange(assignment, decl);
}
assignments = ts.append(assignments, assignment);
@@ -98281,7 +99956,7 @@ var ts;
else {
updated = ts.visitEachChild(node, visitor, context);
}
- exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
+ exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */);
return updated;
}
/**
@@ -98290,11 +99965,11 @@ var ts;
* @param node A VariableDeclarationList node.
*/
function visitVariableDeclarationList(node) {
- if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 262144 /* ContainsBindingPattern */) {
- if (node.flags & 3 /* BlockScoped */) {
+ if (node.flags & 3 /* NodeFlags.BlockScoped */ || node.transformFlags & 262144 /* TransformFlags.ContainsBindingPattern */) {
+ if (node.flags & 3 /* NodeFlags.BlockScoped */) {
enableSubstitutionsForBlockScopedBindings();
}
- var declarations = ts.flatMap(node.declarations, node.flags & 1 /* Let */
+ var declarations = ts.flatMap(node.declarations, node.flags & 1 /* NodeFlags.Let */
? visitVariableDeclarationInLetDeclarationList
: visitVariableDeclaration);
var declarationList = factory.createVariableDeclarationList(declarations);
@@ -98303,7 +99978,7 @@ var ts;
ts.setCommentRange(declarationList, node);
// If the first or last declaration is a binding pattern, we need to modify
// the source map range for the declaration list.
- if (node.transformFlags & 262144 /* ContainsBindingPattern */
+ if (node.transformFlags & 262144 /* TransformFlags.ContainsBindingPattern */
&& (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) {
ts.setSourceMapRange(declarationList, getRangeUnion(declarations));
}
@@ -98315,8 +99990,8 @@ var ts;
// declarations may not be sorted by position.
// pos should be the minimum* position over all nodes (that's not -1), end should be the maximum end over all nodes.
var pos = -1, end = -1;
- for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
- var node = declarations_9[_i];
+ for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) {
+ var node = declarations_10[_i];
pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos);
end = Math.max(end, node.end);
}
@@ -98369,18 +100044,18 @@ var ts;
// * Why loop initializer is excluded?
// - Since we've introduced a fresh name it already will be undefined.
var flags = resolver.getNodeCheckFlags(node);
- var isCapturedInFunction = flags & 262144 /* CapturedBlockScopedBinding */;
- var isDeclaredInLoop = flags & 524288 /* BlockScopedBindingInLoop */;
- var emittedAsTopLevel = (hierarchyFacts & 64 /* TopLevel */) !== 0
+ var isCapturedInFunction = flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */;
+ var isDeclaredInLoop = flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */;
+ var emittedAsTopLevel = (hierarchyFacts & 64 /* HierarchyFacts.TopLevel */) !== 0
|| (isCapturedInFunction
&& isDeclaredInLoop
- && (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0);
+ && (hierarchyFacts & 512 /* HierarchyFacts.IterationStatementBlock */) !== 0);
var emitExplicitInitializer = !emittedAsTopLevel
- && (hierarchyFacts & 4096 /* ForInOrForOfStatement */) === 0
+ && (hierarchyFacts & 4096 /* HierarchyFacts.ForInOrForOfStatement */) === 0
&& (!resolver.isDeclarationWithCollidingName(node)
|| (isDeclaredInLoop
&& !isCapturedInFunction
- && (hierarchyFacts & (2048 /* ForStatement */ | 4096 /* ForInOrForOfStatement */)) === 0));
+ && (hierarchyFacts & (2048 /* HierarchyFacts.ForStatement */ | 4096 /* HierarchyFacts.ForInOrForOfStatement */)) === 0));
return emitExplicitInitializer;
}
/**
@@ -98407,16 +100082,16 @@ var ts;
* @param node A VariableDeclaration node.
*/
function visitVariableDeclaration(node) {
- var ancestorFacts = enterSubtree(32 /* ExportedVariableStatement */, 0 /* None */);
+ var ancestorFacts = enterSubtree(32 /* HierarchyFacts.ExportedVariableStatement */, 0 /* HierarchyFacts.None */);
var updated;
if (ts.isBindingPattern(node.name)) {
- updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */,
- /*value*/ undefined, (ancestorFacts & 32 /* ExportedVariableStatement */) !== 0);
+ updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* FlattenLevel.All */,
+ /*value*/ undefined, (ancestorFacts & 32 /* HierarchyFacts.ExportedVariableStatement */) !== 0);
}
else {
updated = ts.visitEachChild(node, visitor, context);
}
- exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
+ exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */);
return updated;
}
function recordLabel(node) {
@@ -98436,50 +100111,50 @@ var ts;
}
function visitIterationStatement(node, outermostLabeledStatement) {
switch (node.kind) {
- case 239 /* DoStatement */:
- case 240 /* WhileStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
return visitDoOrWhileStatement(node, outermostLabeledStatement);
- case 241 /* ForStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
return visitForStatement(node, outermostLabeledStatement);
- case 242 /* ForInStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
return visitForInStatement(node, outermostLabeledStatement);
- case 243 /* ForOfStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
return visitForOfStatement(node, outermostLabeledStatement);
}
}
function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) {
var ancestorFacts = enterSubtree(excludeFacts, includeFacts);
var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert);
- exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
+ exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */);
return updated;
}
function visitDoOrWhileStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 1280 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement);
+ return visitIterationStatementWithFacts(0 /* HierarchyFacts.DoOrWhileStatementExcludes */, 1280 /* HierarchyFacts.DoOrWhileStatementIncludes */, node, outermostLabeledStatement);
}
function visitForStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(5056 /* ForStatementExcludes */, 3328 /* ForStatementIncludes */, node, outermostLabeledStatement);
+ return visitIterationStatementWithFacts(5056 /* HierarchyFacts.ForStatementExcludes */, 3328 /* HierarchyFacts.ForStatementIncludes */, node, outermostLabeledStatement);
}
function visitEachChildOfForStatement(node) {
return factory.updateForStatement(node, ts.visitNode(node.initializer, visitorWithUnusedExpressionResult, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitorWithUnusedExpressionResult, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock));
}
function visitForInStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement);
+ return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement);
}
function visitForOfStatement(node, outermostLabeledStatement) {
- return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray);
+ return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray);
}
function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) {
var statements = [];
var initializer = node.initializer;
if (ts.isVariableDeclarationList(initializer)) {
- if (node.initializer.flags & 3 /* BlockScoped */) {
+ if (node.initializer.flags & 3 /* NodeFlags.BlockScoped */) {
enableSubstitutionsForBlockScopedBindings();
}
var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations);
if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) {
// This works whether the declaration is a var, let, or const.
// It will use rhsIterationValue _a[_i] as the initializer.
- var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* All */, boundValue);
+ var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* FlattenLevel.All */, boundValue);
var declarationList = ts.setTextRange(factory.createVariableDeclarationList(declarations), node.initializer);
ts.setOriginalNode(declarationList, node.initializer);
// Adjust the source map range for the first declaration to align with the old
@@ -98527,7 +100202,7 @@ var ts;
}
function createSyntheticBlockForConvertedStatements(statements) {
return ts.setEmitFlags(factory.createBlock(factory.createNodeArray(statements),
- /*multiLine*/ true), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */);
+ /*multiLine*/ true), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */);
}
function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) {
// The following ES6 code:
@@ -98559,18 +100234,18 @@ var ts;
var counter = factory.createLoopVariable();
var rhsReference = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(/*recordTempVariable*/ undefined);
// The old emitter does not emit source maps for the expression
- ts.setEmitFlags(expression, 48 /* NoSourceMap */ | ts.getEmitFlags(expression));
+ ts.setEmitFlags(expression, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(expression));
var forStatement = ts.setTextRange(factory.createForStatement(
/*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([
ts.setTextRange(factory.createVariableDeclaration(counter, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createNumericLiteral(0)), ts.moveRangePos(node.expression, -1)),
ts.setTextRange(factory.createVariableDeclaration(rhsReference, /*exclamationToken*/ undefined, /*type*/ undefined, expression), node.expression)
- ]), node.expression), 2097152 /* NoHoisting */),
+ ]), node.expression), 2097152 /* EmitFlags.NoHoisting */),
/*condition*/ ts.setTextRange(factory.createLessThan(counter, factory.createPropertyAccessExpression(rhsReference, "length")), node.expression),
/*incrementor*/ ts.setTextRange(factory.createPostfixIncrement(counter), node.expression),
/*statement*/ convertForOfStatementHead(node, factory.createElementAccessExpression(rhsReference, counter), convertedLoopBodyStatements)),
/*location*/ node);
// Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter.
- ts.setEmitFlags(forStatement, 256 /* NoTokenTrailingSourceMaps */);
+ ts.setEmitFlags(forStatement, 256 /* EmitFlags.NoTokenTrailingSourceMaps */);
ts.setTextRange(forStatement, node);
return factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel);
}
@@ -98586,33 +100261,33 @@ var ts;
hoistVariableDeclaration(errorRecord);
hoistVariableDeclaration(returnMethod);
// if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration
- var initializer = ancestorFacts & 1024 /* IterationContainer */
+ var initializer = ancestorFacts & 1024 /* HierarchyFacts.IterationContainer */
? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), values])
: values;
var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement(
/*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([
ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression),
factory.createVariableDeclaration(result, /*exclamationToken*/ undefined, /*type*/ undefined, next)
- ]), node.expression), 2097152 /* NoHoisting */),
+ ]), node.expression), 2097152 /* EmitFlags.NoHoisting */),
/*condition*/ factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done")),
/*incrementor*/ factory.createAssignment(result, next),
/*statement*/ convertForOfStatementHead(node, factory.createPropertyAccessExpression(result, "value"), convertedLoopBodyStatements)),
- /*location*/ node), 256 /* NoTokenTrailingSourceMaps */);
+ /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */);
return factory.createTryStatement(factory.createBlock([
factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel)
]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([
factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([
factory.createPropertyAssignment("error", catchVariable)
])))
- ]), 1 /* SingleLine */)), factory.createBlock([
+ ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([
factory.createTryStatement(
/*tryBlock*/ factory.createBlock([
- ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* SingleLine */),
+ ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* EmitFlags.SingleLine */),
]),
/*catchClause*/ undefined,
/*finallyBlock*/ ts.setEmitFlags(factory.createBlock([
- ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */)
- ]), 1 /* SingleLine */))
+ ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */)
+ ]), 1 /* EmitFlags.SingleLine */))
]));
}
/**
@@ -98627,9 +100302,9 @@ var ts;
var numInitialProperties = -1, hasComputed = false;
for (var i = 0; i < properties.length; i++) {
var property = properties[i];
- if ((property.transformFlags & 524288 /* ContainsYield */ &&
- hierarchyFacts & 4 /* AsyncFunctionBody */)
- || (hasComputed = ts.Debug.checkDefined(property.name).kind === 161 /* ComputedPropertyName */)) {
+ if ((property.transformFlags & 524288 /* TransformFlags.ContainsYield */ &&
+ hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */)
+ || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* SyntaxKind.ComputedPropertyName */)) {
numInitialProperties = i;
break;
}
@@ -98642,7 +100317,7 @@ var ts;
var temp = factory.createTempVariable(hoistVariableDeclaration);
// Write out the first non-computed properties, then emit the rest through indexing on the temp variable.
var expressions = [];
- var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* Indented */ : 0));
+ var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* EmitFlags.Indented */ : 0));
if (node.multiLine) {
ts.startOnNewLine(assignment);
}
@@ -98654,7 +100329,7 @@ var ts;
return factory.inlineExpressions(expressions);
}
function shouldConvertPartOfIterationStatement(node) {
- return (resolver.getNodeCheckFlags(node) & 131072 /* ContainsCapturedBlockScopeBinding */) !== 0;
+ return (resolver.getNodeCheckFlags(node) & 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */) !== 0;
}
function shouldConvertInitializerOfForStatement(node) {
return ts.isForStatement(node) && !!node.initializer && shouldConvertPartOfIterationStatement(node.initializer);
@@ -98670,7 +100345,7 @@ var ts;
|| shouldConvertInitializerOfForStatement(node);
}
function shouldConvertBodyOfIterationStatement(node) {
- return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0;
+ return (resolver.getNodeCheckFlags(node) & 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */) !== 0;
}
/**
* Records constituents of name for the given variable to be hoisted in the outer scope.
@@ -98681,7 +100356,7 @@ var ts;
}
visit(node.name);
function visit(node) {
- if (node.kind === 79 /* Identifier */) {
+ if (node.kind === 79 /* SyntaxKind.Identifier */) {
state.hoistedLocalVariables.push(node);
}
else {
@@ -98701,7 +100376,7 @@ var ts;
// we get here if we are trying to emit normal loop loop inside converted loop
// set allowedNonLabeledJumps to Break | Continue to mark that break\continue inside the loop should be emitted as is
saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps;
- convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */;
+ convertedLoopState.allowedNonLabeledJumps = 2 /* Jump.Break */ | 4 /* Jump.Continue */;
}
var result = convert
? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined, ancestorFacts)
@@ -98745,11 +100420,11 @@ var ts;
}
function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) {
switch (node.kind) {
- case 241 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody);
- case 242 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody);
- case 243 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody);
- case 239 /* DoStatement */: return convertDoStatement(node, convertedLoopBody);
- case 240 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody);
+ case 242 /* SyntaxKind.ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody);
+ case 243 /* SyntaxKind.ForInStatement */: return convertForInStatement(node, convertedLoopBody);
+ case 244 /* SyntaxKind.ForOfStatement */: return convertForOfStatement(node, convertedLoopBody);
+ case 240 /* SyntaxKind.DoStatement */: return convertDoStatement(node, convertedLoopBody);
+ case 241 /* SyntaxKind.WhileStatement */: return convertWhileStatement(node, convertedLoopBody);
default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected");
}
}
@@ -98774,11 +100449,11 @@ var ts;
function createConvertedLoopState(node) {
var loopInitializer;
switch (node.kind) {
- case 241 /* ForStatement */:
- case 242 /* ForInStatement */:
- case 243 /* ForOfStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
var initializer = node.initializer;
- if (initializer && initializer.kind === 254 /* VariableDeclarationList */) {
+ if (initializer && initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) {
loopInitializer = initializer;
}
break;
@@ -98787,7 +100462,7 @@ var ts;
var loopParameters = [];
// variables declared in the loop initializer that will be changed inside the loop
var loopOutParameters = [];
- if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) {
+ if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* NodeFlags.BlockScoped */)) {
var hasCapturedBindingsInForHead = shouldConvertInitializerOfForStatement(node) ||
shouldConvertConditionOfForStatement(node) ||
shouldConvertIncrementorOfForStatement(node);
@@ -98900,15 +100575,15 @@ var ts;
*/
function createFunctionForInitializerOfForStatement(node, currentState) {
var functionName = factory.createUniqueName("_loop_init");
- var containsYield = (node.initializer.transformFlags & 524288 /* ContainsYield */) !== 0;
- var emitFlags = 0 /* None */;
+ var containsYield = (node.initializer.transformFlags & 524288 /* TransformFlags.ContainsYield */) !== 0;
+ var emitFlags = 0 /* EmitFlags.None */;
if (currentState.containsLexicalThis)
- emitFlags |= 8 /* CapturesThis */;
- if (containsYield && hierarchyFacts & 4 /* AsyncFunctionBody */)
- emitFlags |= 262144 /* AsyncFunctionBody */;
+ emitFlags |= 8 /* EmitFlags.CapturesThis */;
+ if (containsYield && hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */)
+ emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */;
var statements = [];
statements.push(factory.createVariableStatement(/*modifiers*/ undefined, node.initializer));
- copyOutParameters(currentState.loopOutParameters, 2 /* Initializer */, 1 /* ToOutParameter */, statements);
+ copyOutParameters(currentState.loopOutParameters, 2 /* LoopOutParameterFlags.Initializer */, 1 /* CopyDirection.ToOutParameter */, statements);
// This transforms the following ES2015 syntax:
//
// for (let i = (setImmediate(() => console.log(i)), 0); i < 2; i++) {
@@ -98934,12 +100609,12 @@ var ts;
factory.createVariableDeclaration(functionName,
/*exclamationToken*/ undefined,
/*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression(
- /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined,
+ /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined,
/*name*/ undefined,
/*typeParameters*/ undefined,
/*parameters*/ undefined,
/*type*/ undefined, ts.visitNode(factory.createBlock(statements, /*multiLine*/ true), visitor, ts.isBlock)), emitFlags))
- ]), 2097152 /* NoHoisting */));
+ ]), 2097152 /* EmitFlags.NoHoisting */));
var part = factory.createVariableDeclarationList(ts.map(currentState.loopOutParameters, createOutVariable));
return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part };
}
@@ -99001,7 +100676,7 @@ var ts;
statements.push(factory.createIfStatement(factory.createLogicalNot(currentState.conditionVariable), factory.createExpressionStatement(factory.createAssignment(currentState.conditionVariable, factory.createTrue()))));
}
if (shouldConvertConditionOfForStatement(node)) {
- statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement)));
+ statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* SyntaxKind.ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement)));
}
}
if (ts.isBlock(statement)) {
@@ -99010,17 +100685,17 @@ var ts;
else {
statements.push(statement);
}
- copyOutParameters(currentState.loopOutParameters, 1 /* Body */, 1 /* ToOutParameter */, statements);
+ copyOutParameters(currentState.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 1 /* CopyDirection.ToOutParameter */, statements);
ts.insertStatementsAfterStandardPrologue(statements, lexicalEnvironment);
var loopBody = factory.createBlock(statements, /*multiLine*/ true);
if (ts.isBlock(statement))
ts.setOriginalNode(loopBody, statement);
- var containsYield = (node.statement.transformFlags & 524288 /* ContainsYield */) !== 0;
- var emitFlags = 524288 /* ReuseTempVariableScope */;
+ var containsYield = (node.statement.transformFlags & 524288 /* TransformFlags.ContainsYield */) !== 0;
+ var emitFlags = 524288 /* EmitFlags.ReuseTempVariableScope */;
if (currentState.containsLexicalThis)
- emitFlags |= 8 /* CapturesThis */;
- if (containsYield && (hierarchyFacts & 4 /* AsyncFunctionBody */) !== 0)
- emitFlags |= 262144 /* AsyncFunctionBody */;
+ emitFlags |= 8 /* EmitFlags.CapturesThis */;
+ if (containsYield && (hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) !== 0)
+ emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */;
// This transforms the following ES2015 syntax (in addition to other variations):
//
// for (let i = 0; i < 2; i++) {
@@ -99040,18 +100715,18 @@ var ts;
factory.createVariableDeclaration(functionName,
/*exclamationToken*/ undefined,
/*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression(
- /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined,
+ /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined,
/*name*/ undefined,
/*typeParameters*/ undefined, currentState.loopParameters,
/*type*/ undefined, loopBody), emitFlags))
- ]), 2097152 /* NoHoisting */));
+ ]), 2097152 /* EmitFlags.NoHoisting */));
var part = generateCallToConvertedLoop(functionName, currentState, outerState, containsYield);
return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part };
}
function copyOutParameter(outParam, copyDirection) {
- var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName;
- var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName;
- return factory.createBinaryExpression(target, 63 /* EqualsToken */, source);
+ var source = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.outParamName : outParam.originalName;
+ var target = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.originalName : outParam.outParamName;
+ return factory.createBinaryExpression(target, 63 /* SyntaxKind.EqualsToken */, source);
}
function copyOutParameters(outParams, partFlags, copyDirection, statements) {
for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) {
@@ -99064,7 +100739,7 @@ var ts;
function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) {
var call = factory.createCallExpression(initFunctionExpressionName, /*typeArguments*/ undefined, []);
var callResult = containsYield
- ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */))
+ ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */))
: call;
return factory.createExpressionStatement(callResult);
}
@@ -99073,27 +100748,27 @@ var ts;
// loop is considered simple if it does not have any return statements or break\continue that transfer control outside of the loop
// simple loops are emitted as just 'loop()';
// NOTE: if loop uses only 'continue' it still will be emitted as simple loop
- var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Continue */) &&
+ var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Jump.Continue */) &&
!state.labeledNonLocalBreaks &&
!state.labeledNonLocalContinues;
var call = factory.createCallExpression(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(state.loopParameters, function (p) { return p.name; }));
var callResult = containsYield
- ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */))
+ ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */))
: call;
if (isSimpleLoop) {
statements.push(factory.createExpressionStatement(callResult));
- copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements);
+ copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements);
}
else {
var loopResultName = factory.createUniqueName("state");
var stateVariable = factory.createVariableStatement(
/*modifiers*/ undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(loopResultName, /*exclamationToken*/ undefined, /*type*/ undefined, callResult)]));
statements.push(stateVariable);
- copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements);
- if (state.nonLocalJumps & 8 /* Return */) {
+ copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements);
+ if (state.nonLocalJumps & 8 /* Jump.Return */) {
var returnStatement = void 0;
if (outerState) {
- outerState.nonLocalJumps |= 8 /* Return */;
+ outerState.nonLocalJumps |= 8 /* Jump.Return */;
returnStatement = factory.createReturnStatement(loopResultName);
}
else {
@@ -99101,7 +100776,7 @@ var ts;
}
statements.push(factory.createIfStatement(factory.createTypeCheck(loopResultName, "object"), returnStatement));
}
- if (state.nonLocalJumps & 2 /* Break */) {
+ if (state.nonLocalJumps & 2 /* Jump.Break */) {
statements.push(factory.createIfStatement(factory.createStrictEquality(loopResultName, factory.createStringLiteral("break")), factory.createBreakStatement()));
}
if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) {
@@ -99160,19 +100835,19 @@ var ts;
else {
loopParameters.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name));
var checkFlags = resolver.getNodeCheckFlags(decl);
- if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) {
+ if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) {
var outParamName = factory.createUniqueName("out_" + ts.idText(name));
var flags = 0;
- if (checkFlags & 4194304 /* NeedsLoopOutParameter */) {
- flags |= 1 /* Body */;
+ if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */) {
+ flags |= 1 /* LoopOutParameterFlags.Body */;
}
if (ts.isForStatement(container)) {
if (container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
- flags |= 2 /* Initializer */;
+ flags |= 2 /* LoopOutParameterFlags.Initializer */;
}
if (container.condition && resolver.isBindingCapturedByNode(container.condition, decl) ||
container.incrementor && resolver.isBindingCapturedByNode(container.incrementor, decl)) {
- flags |= 1 /* Body */;
+ flags |= 1 /* LoopOutParameterFlags.Body */;
}
}
loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName });
@@ -99194,20 +100869,20 @@ var ts;
for (var i = start; i < numProperties; i++) {
var property = properties[i];
switch (property.kind) {
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
var accessors = ts.getAllAccessorDeclarations(node.properties, property);
if (property === accessors.firstAccessor) {
expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine));
}
break;
- case 168 /* MethodDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine));
break;
- case 294 /* PropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine));
break;
- case 295 /* ShorthandPropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine));
break;
default:
@@ -99262,14 +100937,14 @@ var ts;
return expression;
}
function visitCatchClause(node) {
- var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
+ var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */);
var updated;
ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015.");
if (ts.isBindingPattern(node.variableDeclaration.name)) {
var temp = factory.createTempVariable(/*recordTempVariable*/ undefined);
var newVariableDeclaration = factory.createVariableDeclaration(temp);
ts.setTextRange(newVariableDeclaration, node.variableDeclaration);
- var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp);
+ var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* FlattenLevel.All */, temp);
var list = factory.createVariableDeclarationList(vars);
ts.setTextRange(list, node.variableDeclaration);
var destructure = factory.createVariableStatement(/*modifiers*/ undefined, list);
@@ -99278,7 +100953,7 @@ var ts;
else {
updated = ts.visitEachChild(node, visitor, context);
}
- exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
+ exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */);
return updated;
}
function addStatementToStartOfBlock(block, statement) {
@@ -99297,7 +100972,7 @@ var ts;
// Methods with computed property names are handled in visitObjectLiteralExpression.
ts.Debug.assert(!ts.isComputedPropertyName(node.name));
var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined, /*container*/ undefined);
- ts.setEmitFlags(functionExpression, 512 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression));
+ ts.setEmitFlags(functionExpression, 512 /* EmitFlags.NoLeadingComments */ | ts.getEmitFlags(functionExpression));
return ts.setTextRange(factory.createPropertyAssignment(node.name, functionExpression),
/*location*/ node);
}
@@ -99310,17 +100985,17 @@ var ts;
ts.Debug.assert(!ts.isComputedPropertyName(node.name));
var savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
- var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */);
+ var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */);
var updated;
var parameters = ts.visitParameterList(node.parameters, visitor, context);
var body = transformFunctionBody(node);
- if (node.kind === 171 /* GetAccessor */) {
+ if (node.kind === 172 /* SyntaxKind.GetAccessor */) {
updated = factory.updateGetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, node.type, body);
}
else {
updated = factory.updateSetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, body);
}
- exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */);
+ exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */);
convertedLoopState = savedConvertedLoopState;
return updated;
}
@@ -99363,11 +101038,11 @@ var ts;
* @param node a CallExpression.
*/
function visitCallExpression(node) {
- if (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) {
+ if (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) {
return visitTypeScriptClassWrapper(node);
}
var expression = ts.skipOuterExpressions(node.expression);
- if (expression.kind === 106 /* SuperKeyword */ ||
+ if (expression.kind === 106 /* SyntaxKind.SuperKeyword */ ||
ts.isSuperProperty(expression) ||
ts.some(node.arguments, ts.isSpreadElement)) {
return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true);
@@ -99440,7 +101115,7 @@ var ts;
// }())
//
var aliasAssignment = ts.tryCast(initializer, ts.isAssignmentExpression);
- if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* CommaToken */) {
+ if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) {
aliasAssignment = ts.tryCast(initializer.left, ts.isAssignmentExpression);
}
// The underlying call (3) is another IIFE that may contain a '_super' argument.
@@ -99497,15 +101172,15 @@ var ts;
function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
// We are here either because SuperKeyword was used somewhere in the expression, or
// because we contain a SpreadElementExpression.
- if (node.transformFlags & 16384 /* ContainsRestOrSpread */ ||
- node.expression.kind === 106 /* SuperKeyword */ ||
+ if (node.transformFlags & 16384 /* TransformFlags.ContainsRestOrSpread */ ||
+ node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ||
ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) {
var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
- if (node.expression.kind === 106 /* SuperKeyword */) {
- ts.setEmitFlags(thisArg, 4 /* NoSubstitution */);
+ if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) {
+ ts.setEmitFlags(thisArg, 4 /* EmitFlags.NoSubstitution */);
}
var resultingCall = void 0;
- if (node.transformFlags & 16384 /* ContainsRestOrSpread */) {
+ if (node.transformFlags & 16384 /* TransformFlags.ContainsRestOrSpread */) {
// [source]
// f(...a, b)
// x.m(...a, b)
@@ -99519,7 +101194,7 @@ var ts;
// _super.apply(this, a.concat([b]))
// _super.m.apply(this, a.concat([b]))
// _super.prototype.m.apply(this, a.concat([b]))
- resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false));
+ resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false));
}
else {
// [source]
@@ -99531,12 +101206,12 @@ var ts;
// _super.call(this, a)
// _super.m.call(this, a)
// _super.prototype.m.call(this, a)
- resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node);
+ resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node);
}
- if (node.expression.kind === 106 /* SuperKeyword */) {
+ if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) {
var initializer = factory.createLogicalOr(resultingCall, createActualThis());
resultingCall = assignToCapturedThis
- ? factory.createAssignment(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer)
+ ? factory.createAssignment(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), initializer)
: initializer;
}
return ts.setOriginalNode(resultingCall, node);
@@ -99625,13 +101300,13 @@ var ts;
}
}
var helpers = emitHelpers();
- var startsWithSpread = segments[0].kind !== 0 /* None */;
+ var startsWithSpread = segments[0].kind !== 0 /* SpreadSegmentKind.None */;
var expression = startsWithSpread ? factory.createArrayLiteralExpression() :
segments[0].expression;
for (var i = startsWithSpread ? 0 : 1; i < segments.length; i++) {
var segment = segments[i];
// If this is for an argument list, it doesn't matter if the array is packed or sparse
- expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* UnpackedSpread */ && !isArgumentList);
+ expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !isArgumentList);
}
return expression;
}
@@ -99647,12 +101322,12 @@ var ts;
var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
// We don't need to pack already packed array literals, or existing calls to the `__read` helper.
var isCallToReadHelper = ts.isCallToHelper(expression, "___read");
- var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* PackedSpread */ : 1 /* UnpackedSpread */;
+ var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* SpreadSegmentKind.PackedSpread */ : 1 /* SpreadSegmentKind.UnpackedSpread */;
// We don't need the `__read` helper for array literals. Array packing will be performed by `__spreadArray`.
- if (compilerOptions.downlevelIteration && kind === 1 /* UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) {
+ if (compilerOptions.downlevelIteration && kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) {
expression = emitHelpers().createReadHelper(expression, /*count*/ undefined);
// the `__read` helper returns a packed array, so we don't need to ensure a packed array
- kind = 2 /* PackedSpread */;
+ kind = 2 /* SpreadSegmentKind.PackedSpread */;
}
return createSpreadSegment(kind, expression);
}
@@ -99660,7 +101335,7 @@ var ts;
var expression = factory.createArrayLiteralExpression(ts.visitNodes(factory.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine);
// We do not pack non-spread segments, this is so that `[1, , ...[2, , 3], , 4]` is properly downleveled to
// `[1, , 2, undefined, 3, , 4]`. See the NOTE in `transformAndSpreadElements`
- return createSpreadSegment(0 /* None */, expression);
+ return createSpreadSegment(0 /* SpreadSegmentKind.None */, expression);
}
function visitSpreadElement(node) {
return ts.visitNode(node.expression, visitor, ts.isExpression);
@@ -99690,7 +101365,7 @@ var ts;
* @param node A string literal.
*/
function visitNumericLiteral(node) {
- if (node.numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) {
+ if (node.numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) {
return ts.setTextRange(factory.createNumericLiteral(node.text), node);
}
return node;
@@ -99725,15 +101400,15 @@ var ts;
* Visits the `super` keyword
*/
function visitSuperKeyword(isExpressionOfCall) {
- return hierarchyFacts & 8 /* NonStaticClassElement */
+ return hierarchyFacts & 8 /* HierarchyFacts.NonStaticClassElement */
&& !isExpressionOfCall
- ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), "prototype")
- : factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */);
+ ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), "prototype")
+ : factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */);
}
function visitMetaProperty(node) {
- if (node.keywordToken === 103 /* NewKeyword */ && node.name.escapedText === "target") {
- hierarchyFacts |= 32768 /* NewTarget */;
- return factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */);
+ if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */ && node.name.escapedText === "target") {
+ hierarchyFacts |= 32768 /* HierarchyFacts.NewTarget */;
+ return factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */);
}
return node;
}
@@ -99745,13 +101420,13 @@ var ts;
* @param emitCallback The callback used to emit the node.
*/
function onEmitNode(hint, node, emitCallback) {
- if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) {
+ if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */ && ts.isFunctionLike(node)) {
// If we are tracking a captured `this`, keep track of the enclosing function.
- var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */
- ? 65 /* FunctionIncludes */ | 16 /* CapturesThis */
- : 65 /* FunctionIncludes */);
+ var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, ts.getEmitFlags(node) & 8 /* EmitFlags.CapturesThis */
+ ? 65 /* HierarchyFacts.FunctionIncludes */ | 16 /* HierarchyFacts.CapturesThis */
+ : 65 /* HierarchyFacts.FunctionIncludes */);
previousOnEmitNode(hint, node, emitCallback);
- exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */);
+ exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */);
return;
}
previousOnEmitNode(hint, node, emitCallback);
@@ -99761,9 +101436,9 @@ var ts;
* contains block-scoped bindings (e.g. `let` or `const`).
*/
function enableSubstitutionsForBlockScopedBindings() {
- if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) {
- enabledSubstitutions |= 2 /* BlockScopedBindings */;
- context.enableSubstitution(79 /* Identifier */);
+ if ((enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */) === 0) {
+ enabledSubstitutions |= 2 /* ES2015SubstitutionFlags.BlockScopedBindings */;
+ context.enableSubstitution(79 /* SyntaxKind.Identifier */);
}
}
/**
@@ -99771,16 +101446,16 @@ var ts;
* contains a captured `this`.
*/
function enableSubstitutionsForCapturedThis() {
- if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) {
- enabledSubstitutions |= 1 /* CapturedThis */;
- context.enableSubstitution(108 /* ThisKeyword */);
- context.enableEmitNotification(170 /* Constructor */);
- context.enableEmitNotification(168 /* MethodDeclaration */);
- context.enableEmitNotification(171 /* GetAccessor */);
- context.enableEmitNotification(172 /* SetAccessor */);
- context.enableEmitNotification(213 /* ArrowFunction */);
- context.enableEmitNotification(212 /* FunctionExpression */);
- context.enableEmitNotification(255 /* FunctionDeclaration */);
+ if ((enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */) === 0) {
+ enabledSubstitutions |= 1 /* ES2015SubstitutionFlags.CapturedThis */;
+ context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */);
+ context.enableEmitNotification(171 /* SyntaxKind.Constructor */);
+ context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */);
+ context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */);
+ context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */);
+ context.enableEmitNotification(214 /* SyntaxKind.ArrowFunction */);
+ context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */);
+ context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */);
}
}
/**
@@ -99791,7 +101466,7 @@ var ts;
*/
function onSubstituteNode(hint, node) {
node = previousOnSubstituteNode(hint, node);
- if (hint === 1 /* Expression */) {
+ if (hint === 1 /* EmitHint.Expression */) {
return substituteExpression(node);
}
if (ts.isIdentifier(node)) {
@@ -99805,7 +101480,7 @@ var ts;
function substituteIdentifier(node) {
// Only substitute the identifier if we have enabled substitutions for block-scoped
// bindings.
- if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) {
+ if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) {
var original = ts.getParseTreeNode(node, ts.isIdentifier);
if (original && isNameOfDeclarationWithCollidingName(original)) {
return ts.setTextRange(factory.getGeneratedNameForNode(original), node);
@@ -99821,10 +101496,10 @@ var ts;
*/
function isNameOfDeclarationWithCollidingName(node) {
switch (node.parent.kind) {
- case 202 /* BindingElement */:
- case 256 /* ClassDeclaration */:
- case 259 /* EnumDeclaration */:
- case 253 /* VariableDeclaration */:
+ case 203 /* SyntaxKind.BindingElement */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return node.parent.name === node
&& resolver.isDeclarationWithCollidingName(node.parent);
}
@@ -99837,9 +101512,9 @@ var ts;
*/
function substituteExpression(node) {
switch (node.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return substituteExpressionIdentifier(node);
- case 108 /* ThisKeyword */:
+ case 108 /* SyntaxKind.ThisKeyword */:
return substituteThisKeyword(node);
}
return node;
@@ -99850,7 +101525,7 @@ var ts;
* @param node An Identifier node.
*/
function substituteExpressionIdentifier(node) {
- if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) {
+ if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) {
var declaration = resolver.getReferencedDeclarationWithCollidingName(node);
if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) {
return ts.setTextRange(factory.getGeneratedNameForNode(ts.getNameOfDeclaration(declaration)), node);
@@ -99887,9 +101562,9 @@ var ts;
* @param node The ThisKeyword node.
*/
function substituteThisKeyword(node) {
- if (enabledSubstitutions & 1 /* CapturedThis */
- && hierarchyFacts & 16 /* CapturesThis */) {
- return ts.setTextRange(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), node);
+ if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */
+ && hierarchyFacts & 16 /* HierarchyFacts.CapturesThis */) {
+ return ts.setTextRange(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node);
}
return node;
}
@@ -99906,19 +101581,19 @@ var ts;
return false;
}
var statement = ts.firstOrUndefined(constructor.body.statements);
- if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 237 /* ExpressionStatement */) {
+ if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 238 /* SyntaxKind.ExpressionStatement */) {
return false;
}
var statementExpression = statement.expression;
- if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 207 /* CallExpression */) {
+ if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 208 /* SyntaxKind.CallExpression */) {
return false;
}
var callTarget = statementExpression.expression;
- if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SuperKeyword */) {
+ if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SyntaxKind.SuperKeyword */) {
return false;
}
var callArgument = ts.singleOrUndefined(statementExpression.arguments);
- if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 224 /* SpreadElement */) {
+ if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 225 /* SyntaxKind.SpreadElement */) {
return false;
}
var expression = callArgument.expression;
@@ -99941,18 +101616,18 @@ var ts;
// enable emit notification only if using --jsx preserve or react-native
var previousOnEmitNode;
var noSubstitution;
- if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) {
+ if (compilerOptions.jsx === 1 /* JsxEmit.Preserve */ || compilerOptions.jsx === 3 /* JsxEmit.ReactNative */) {
previousOnEmitNode = context.onEmitNode;
context.onEmitNode = onEmitNode;
- context.enableEmitNotification(279 /* JsxOpeningElement */);
- context.enableEmitNotification(280 /* JsxClosingElement */);
- context.enableEmitNotification(278 /* JsxSelfClosingElement */);
+ context.enableEmitNotification(280 /* SyntaxKind.JsxOpeningElement */);
+ context.enableEmitNotification(281 /* SyntaxKind.JsxClosingElement */);
+ context.enableEmitNotification(279 /* SyntaxKind.JsxSelfClosingElement */);
noSubstitution = [];
}
var previousOnSubstituteNode = context.onSubstituteNode;
context.onSubstituteNode = onSubstituteNode;
- context.enableSubstitution(205 /* PropertyAccessExpression */);
- context.enableSubstitution(294 /* PropertyAssignment */);
+ context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */);
+ context.enableSubstitution(296 /* SyntaxKind.PropertyAssignment */);
return ts.chainBundle(context, transformSourceFile);
/**
* Transforms an ES5 source file to ES3.
@@ -99971,9 +101646,9 @@ var ts;
*/
function onEmitNode(hint, node, emitCallback) {
switch (node.kind) {
- case 279 /* JsxOpeningElement */:
- case 280 /* JsxClosingElement */:
- case 278 /* JsxSelfClosingElement */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
+ case 281 /* SyntaxKind.JsxClosingElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
var tagName = node.tagName;
noSubstitution[ts.getOriginalNodeId(tagName)] = true;
break;
@@ -100033,7 +101708,7 @@ var ts;
*/
function trySubstituteReservedName(name) {
var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined);
- if (token !== undefined && token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */) {
+ if (token !== undefined && token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */) {
return ts.setTextRange(factory.createStringLiteralFromNode(name), name);
}
return undefined;
@@ -100213,11 +101888,11 @@ var ts;
})(Instruction || (Instruction = {}));
function getInstructionName(instruction) {
switch (instruction) {
- case 2 /* Return */: return "return";
- case 3 /* Break */: return "break";
- case 4 /* Yield */: return "yield";
- case 5 /* YieldStar */: return "yield*";
- case 7 /* Endfinally */: return "endfinally";
+ case 2 /* Instruction.Return */: return "return";
+ case 3 /* Instruction.Break */: return "break";
+ case 4 /* Instruction.Yield */: return "yield";
+ case 5 /* Instruction.YieldStar */: return "yield*";
+ case 7 /* Instruction.Endfinally */: return "endfinally";
default: return undefined; // TODO: GH#18217
}
}
@@ -100271,7 +101946,7 @@ var ts;
var withBlockStack; // A stack containing `with` blocks.
return ts.chainBundle(context, transformSourceFile);
function transformSourceFile(node) {
- if (node.isDeclarationFile || (node.transformFlags & 2048 /* ContainsGenerator */) === 0) {
+ if (node.isDeclarationFile || (node.transformFlags & 2048 /* TransformFlags.ContainsGenerator */) === 0) {
return node;
}
var visited = ts.visitEachChild(node, visitor, context);
@@ -100294,7 +101969,7 @@ var ts;
else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) {
return visitGenerator(node);
}
- else if (transformFlags & 2048 /* ContainsGenerator */) {
+ else if (transformFlags & 2048 /* TransformFlags.ContainsGenerator */) {
return ts.visitEachChild(node, visitor, context);
}
else {
@@ -100308,13 +101983,13 @@ var ts;
*/
function visitJavaScriptInStatementContainingYield(node) {
switch (node.kind) {
- case 239 /* DoStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
return visitDoStatement(node);
- case 240 /* WhileStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
return visitWhileStatement(node);
- case 248 /* SwitchStatement */:
+ case 249 /* SyntaxKind.SwitchStatement */:
return visitSwitchStatement(node);
- case 249 /* LabeledStatement */:
+ case 250 /* SyntaxKind.LabeledStatement */:
return visitLabeledStatement(node);
default:
return visitJavaScriptInGeneratorFunctionBody(node);
@@ -100327,30 +102002,30 @@ var ts;
*/
function visitJavaScriptInGeneratorFunctionBody(node) {
switch (node.kind) {
- case 255 /* FunctionDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
return visitFunctionDeclaration(node);
- case 212 /* FunctionExpression */:
+ case 213 /* SyntaxKind.FunctionExpression */:
return visitFunctionExpression(node);
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
return visitAccessorDeclaration(node);
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
return visitVariableStatement(node);
- case 241 /* ForStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
return visitForStatement(node);
- case 242 /* ForInStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
return visitForInStatement(node);
- case 245 /* BreakStatement */:
+ case 246 /* SyntaxKind.BreakStatement */:
return visitBreakStatement(node);
- case 244 /* ContinueStatement */:
+ case 245 /* SyntaxKind.ContinueStatement */:
return visitContinueStatement(node);
- case 246 /* ReturnStatement */:
+ case 247 /* SyntaxKind.ReturnStatement */:
return visitReturnStatement(node);
default:
- if (node.transformFlags & 524288 /* ContainsYield */) {
+ if (node.transformFlags & 524288 /* TransformFlags.ContainsYield */) {
return visitJavaScriptContainingYield(node);
}
- else if (node.transformFlags & (2048 /* ContainsGenerator */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */)) {
+ else if (node.transformFlags & (2048 /* TransformFlags.ContainsGenerator */ | 2097152 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */)) {
return ts.visitEachChild(node, visitor, context);
}
else {
@@ -100365,23 +102040,23 @@ var ts;
*/
function visitJavaScriptContainingYield(node) {
switch (node.kind) {
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return visitBinaryExpression(node);
- case 349 /* CommaListExpression */:
+ case 351 /* SyntaxKind.CommaListExpression */:
return visitCommaListExpression(node);
- case 221 /* ConditionalExpression */:
+ case 222 /* SyntaxKind.ConditionalExpression */:
return visitConditionalExpression(node);
- case 223 /* YieldExpression */:
+ case 224 /* SyntaxKind.YieldExpression */:
return visitYieldExpression(node);
- case 203 /* ArrayLiteralExpression */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
return visitArrayLiteralExpression(node);
- case 204 /* ObjectLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
return visitObjectLiteralExpression(node);
- case 206 /* ElementAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
return visitElementAccessExpression(node);
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
return visitCallExpression(node);
- case 208 /* NewExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
return visitNewExpression(node);
default:
return ts.visitEachChild(node, visitor, context);
@@ -100394,9 +102069,9 @@ var ts;
*/
function visitGenerator(node) {
switch (node.kind) {
- case 255 /* FunctionDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
return visitFunctionDeclaration(node);
- case 212 /* FunctionExpression */:
+ case 213 /* SyntaxKind.FunctionExpression */:
return visitFunctionExpression(node);
default:
return ts.Debug.failBadSyntaxKind(node);
@@ -100555,13 +102230,13 @@ var ts;
* @param node The node to visit.
*/
function visitVariableStatement(node) {
- if (node.transformFlags & 524288 /* ContainsYield */) {
+ if (node.transformFlags & 524288 /* TransformFlags.ContainsYield */) {
transformAndEmitVariableDeclarationList(node.declarationList);
return undefined;
}
else {
// Do not hoist custom prologues.
- if (ts.getEmitFlags(node) & 1048576 /* CustomPrologue */) {
+ if (ts.getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */) {
return node;
}
for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
@@ -100586,9 +102261,9 @@ var ts;
function visitBinaryExpression(node) {
var assoc = ts.getExpressionAssociativity(node);
switch (assoc) {
- case 0 /* Left */:
+ case 0 /* Associativity.Left */:
return visitLeftAssociativeBinaryExpression(node);
- case 1 /* Right */:
+ case 1 /* Associativity.Right */:
return visitRightAssociativeBinaryExpression(node);
default:
return ts.Debug.assertNever(assoc);
@@ -100604,7 +102279,7 @@ var ts;
if (containsYield(right)) {
var target = void 0;
switch (left.kind) {
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
// [source]
// a.b = yield;
//
@@ -100616,7 +102291,7 @@ var ts;
// _a.b = %sent%;
target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name);
break;
- case 206 /* ElementAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
// [source]
// a[b] = yield;
//
@@ -100648,7 +102323,7 @@ var ts;
if (ts.isLogicalOperator(node.operatorToken.kind)) {
return visitLogicalBinaryExpression(node);
}
- else if (node.operatorToken.kind === 27 /* CommaToken */) {
+ else if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) {
return visitCommaExpression(node);
}
// [source]
@@ -100682,13 +102357,13 @@ var ts;
visit(node.right);
return factory.inlineExpressions(pendingExpressions);
function visit(node) {
- if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) {
+ if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) {
visit(node.left);
visit(node.right);
}
else {
if (containsYield(node) && pendingExpressions.length > 0) {
- emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]);
+ emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]);
pendingExpressions = [];
}
pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression));
@@ -100705,12 +102380,12 @@ var ts;
var pendingExpressions = [];
for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
var elem = _a[_i];
- if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* CommaToken */) {
+ if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) {
pendingExpressions.push(visitCommaExpression(elem));
}
else {
if (containsYield(elem) && pendingExpressions.length > 0) {
- emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]);
+ emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]);
pendingExpressions = [];
}
pendingExpressions.push(ts.visitNode(elem, visitor, ts.isExpression));
@@ -100755,7 +102430,7 @@ var ts;
var resultLabel = defineLabel();
var resultLocal = declareLocal();
emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left);
- if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) {
+ if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) {
// Logical `&&` shortcuts when the left-hand operand is falsey.
emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left);
}
@@ -100821,7 +102496,7 @@ var ts;
var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
if (node.asteriskToken) {
// NOTE: `expression` must be defined for `yield*`.
- var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* Iterator */) === 0
+ var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* EmitFlags.Iterator */) === 0
? ts.setTextRange(emitHelpers().createValuesHelper(expression), node)
: expression;
emitYieldStar(iterator, /*location*/ node);
@@ -101010,35 +102685,35 @@ var ts;
}
function transformAndEmitStatementWorker(node) {
switch (node.kind) {
- case 234 /* Block */:
+ case 235 /* SyntaxKind.Block */:
return transformAndEmitBlock(node);
- case 237 /* ExpressionStatement */:
+ case 238 /* SyntaxKind.ExpressionStatement */:
return transformAndEmitExpressionStatement(node);
- case 238 /* IfStatement */:
+ case 239 /* SyntaxKind.IfStatement */:
return transformAndEmitIfStatement(node);
- case 239 /* DoStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
return transformAndEmitDoStatement(node);
- case 240 /* WhileStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
return transformAndEmitWhileStatement(node);
- case 241 /* ForStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
return transformAndEmitForStatement(node);
- case 242 /* ForInStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
return transformAndEmitForInStatement(node);
- case 244 /* ContinueStatement */:
+ case 245 /* SyntaxKind.ContinueStatement */:
return transformAndEmitContinueStatement(node);
- case 245 /* BreakStatement */:
+ case 246 /* SyntaxKind.BreakStatement */:
return transformAndEmitBreakStatement(node);
- case 246 /* ReturnStatement */:
+ case 247 /* SyntaxKind.ReturnStatement */:
return transformAndEmitReturnStatement(node);
- case 247 /* WithStatement */:
+ case 248 /* SyntaxKind.WithStatement */:
return transformAndEmitWithStatement(node);
- case 248 /* SwitchStatement */:
+ case 249 /* SyntaxKind.SwitchStatement */:
return transformAndEmitSwitchStatement(node);
- case 249 /* LabeledStatement */:
+ case 250 /* SyntaxKind.LabeledStatement */:
return transformAndEmitLabeledStatement(node);
- case 250 /* ThrowStatement */:
+ case 251 /* SyntaxKind.ThrowStatement */:
return transformAndEmitThrowStatement(node);
- case 251 /* TryStatement */:
+ case 252 /* SyntaxKind.TryStatement */:
return transformAndEmitTryStatement(node);
default:
return emitStatement(ts.visitNode(node, visitor, ts.isStatement));
@@ -101468,7 +103143,7 @@ var ts;
for (var i = 0; i < numClauses; i++) {
var clause = caseBlock.clauses[i];
clauseLabels.push(defineLabel());
- if (clause.kind === 289 /* DefaultClause */ && defaultClauseIndex === -1) {
+ if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && defaultClauseIndex === -1) {
defaultClauseIndex = i;
}
}
@@ -101481,7 +103156,7 @@ var ts;
var defaultClausesSkipped = 0;
for (var i = clausesWritten; i < numClauses; i++) {
var clause = caseBlock.clauses[i];
- if (clause.kind === 288 /* CaseClause */) {
+ if (clause.kind === 289 /* SyntaxKind.CaseClause */) {
if (containsYield(clause.expression) && pendingClauses.length > 0) {
break;
}
@@ -101613,7 +103288,7 @@ var ts;
}
}
function containsYield(node) {
- return !!node && (node.transformFlags & 524288 /* ContainsYield */) !== 0;
+ return !!node && (node.transformFlags & 524288 /* TransformFlags.ContainsYield */) !== 0;
}
function countInitialNodesWithoutYield(nodes) {
var numNodes = nodes.length;
@@ -101626,7 +103301,7 @@ var ts;
}
function onSubstituteNode(hint, node) {
node = previousOnSubstituteNode(hint, node);
- if (hint === 1 /* Expression */) {
+ if (hint === 1 /* EmitHint.Expression */) {
return substituteExpression(node);
}
return node;
@@ -101657,7 +103332,7 @@ var ts;
return node;
}
function cacheExpression(node) {
- if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) {
+ if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) {
return node;
}
var temp = factory.createTempVariable(hoistVariableDeclaration);
@@ -101703,7 +103378,7 @@ var ts;
blockStack = [];
}
var index = blockActions.length;
- blockActions[index] = 0 /* Open */;
+ blockActions[index] = 0 /* BlockAction.Open */;
blockOffsets[index] = operations ? operations.length : 0;
blocks[index] = block;
blockStack.push(block);
@@ -101717,7 +103392,7 @@ var ts;
if (block === undefined)
return ts.Debug.fail("beginBlock was never called.");
var index = blockActions.length;
- blockActions[index] = 1 /* Close */;
+ blockActions[index] = 1 /* BlockAction.Close */;
blockOffsets[index] = operations ? operations.length : 0;
blocks[index] = block;
blockStack.pop();
@@ -101746,7 +103421,7 @@ var ts;
var endLabel = defineLabel();
markLabel(startLabel);
beginBlock({
- kind: 1 /* With */,
+ kind: 1 /* CodeBlockKind.With */,
expression: expression,
startLabel: startLabel,
endLabel: endLabel
@@ -101756,7 +103431,7 @@ var ts;
* Ends a code block for a generated `with` statement.
*/
function endWithBlock() {
- ts.Debug.assert(peekBlockKind() === 1 /* With */);
+ ts.Debug.assert(peekBlockKind() === 1 /* CodeBlockKind.With */);
var block = endBlock();
markLabel(block.endLabel);
}
@@ -101768,8 +103443,8 @@ var ts;
var endLabel = defineLabel();
markLabel(startLabel);
beginBlock({
- kind: 0 /* Exception */,
- state: 0 /* Try */,
+ kind: 0 /* CodeBlockKind.Exception */,
+ state: 0 /* ExceptionBlockState.Try */,
startLabel: startLabel,
endLabel: endLabel
});
@@ -101782,7 +103457,7 @@ var ts;
* @param variable The catch variable.
*/
function beginCatchBlock(variable) {
- ts.Debug.assert(peekBlockKind() === 0 /* Exception */);
+ ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */);
// generated identifiers should already be unique within a file
var name;
if (ts.isGeneratedIdentifier(variable.name)) {
@@ -101795,18 +103470,18 @@ var ts;
if (!renamedCatchVariables) {
renamedCatchVariables = new ts.Map();
renamedCatchVariableDeclarations = [];
- context.enableSubstitution(79 /* Identifier */);
+ context.enableSubstitution(79 /* SyntaxKind.Identifier */);
}
renamedCatchVariables.set(text, true);
renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name;
}
var exception = peekBlock();
- ts.Debug.assert(exception.state < 1 /* Catch */);
+ ts.Debug.assert(exception.state < 1 /* ExceptionBlockState.Catch */);
var endLabel = exception.endLabel;
emitBreak(endLabel);
var catchLabel = defineLabel();
markLabel(catchLabel);
- exception.state = 1 /* Catch */;
+ exception.state = 1 /* ExceptionBlockState.Catch */;
exception.catchVariable = name;
exception.catchLabel = catchLabel;
emitAssignment(name, factory.createCallExpression(factory.createPropertyAccessExpression(state, "sent"), /*typeArguments*/ undefined, []));
@@ -101816,24 +103491,24 @@ var ts;
* Enters the `finally` block of a generated `try` statement.
*/
function beginFinallyBlock() {
- ts.Debug.assert(peekBlockKind() === 0 /* Exception */);
+ ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */);
var exception = peekBlock();
- ts.Debug.assert(exception.state < 2 /* Finally */);
+ ts.Debug.assert(exception.state < 2 /* ExceptionBlockState.Finally */);
var endLabel = exception.endLabel;
emitBreak(endLabel);
var finallyLabel = defineLabel();
markLabel(finallyLabel);
- exception.state = 2 /* Finally */;
+ exception.state = 2 /* ExceptionBlockState.Finally */;
exception.finallyLabel = finallyLabel;
}
/**
* Ends the code block for a generated `try` statement.
*/
function endExceptionBlock() {
- ts.Debug.assert(peekBlockKind() === 0 /* Exception */);
+ ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */);
var exception = endBlock();
var state = exception.state;
- if (state < 2 /* Finally */) {
+ if (state < 2 /* ExceptionBlockState.Finally */) {
emitBreak(exception.endLabel);
}
else {
@@ -101841,7 +103516,7 @@ var ts;
}
markLabel(exception.endLabel);
emitNop();
- exception.state = 3 /* Done */;
+ exception.state = 3 /* ExceptionBlockState.Done */;
}
/**
* Begins a code block that supports `break` or `continue` statements that are defined in
@@ -101851,7 +103526,7 @@ var ts;
*/
function beginScriptLoopBlock() {
beginBlock({
- kind: 3 /* Loop */,
+ kind: 3 /* CodeBlockKind.Loop */,
isScript: true,
breakLabel: -1,
continueLabel: -1
@@ -101868,7 +103543,7 @@ var ts;
function beginLoopBlock(continueLabel) {
var breakLabel = defineLabel();
beginBlock({
- kind: 3 /* Loop */,
+ kind: 3 /* CodeBlockKind.Loop */,
isScript: false,
breakLabel: breakLabel,
continueLabel: continueLabel,
@@ -101880,7 +103555,7 @@ var ts;
* generated code or in the source tree.
*/
function endLoopBlock() {
- ts.Debug.assert(peekBlockKind() === 3 /* Loop */);
+ ts.Debug.assert(peekBlockKind() === 3 /* CodeBlockKind.Loop */);
var block = endBlock();
var breakLabel = block.breakLabel;
if (!block.isScript) {
@@ -101894,7 +103569,7 @@ var ts;
*/
function beginScriptSwitchBlock() {
beginBlock({
- kind: 2 /* Switch */,
+ kind: 2 /* CodeBlockKind.Switch */,
isScript: true,
breakLabel: -1
});
@@ -101907,7 +103582,7 @@ var ts;
function beginSwitchBlock() {
var breakLabel = defineLabel();
beginBlock({
- kind: 2 /* Switch */,
+ kind: 2 /* CodeBlockKind.Switch */,
isScript: false,
breakLabel: breakLabel,
});
@@ -101917,7 +103592,7 @@ var ts;
* Ends a code block that supports `break` statements that are defined in generated code.
*/
function endSwitchBlock() {
- ts.Debug.assert(peekBlockKind() === 2 /* Switch */);
+ ts.Debug.assert(peekBlockKind() === 2 /* CodeBlockKind.Switch */);
var block = endBlock();
var breakLabel = block.breakLabel;
if (!block.isScript) {
@@ -101926,7 +103601,7 @@ var ts;
}
function beginScriptLabeledBlock(labelText) {
beginBlock({
- kind: 4 /* Labeled */,
+ kind: 4 /* CodeBlockKind.Labeled */,
isScript: true,
labelText: labelText,
breakLabel: -1
@@ -101935,14 +103610,14 @@ var ts;
function beginLabeledBlock(labelText) {
var breakLabel = defineLabel();
beginBlock({
- kind: 4 /* Labeled */,
+ kind: 4 /* CodeBlockKind.Labeled */,
isScript: false,
labelText: labelText,
breakLabel: breakLabel
});
}
function endLabeledBlock() {
- ts.Debug.assert(peekBlockKind() === 4 /* Labeled */);
+ ts.Debug.assert(peekBlockKind() === 4 /* CodeBlockKind.Labeled */);
var block = endBlock();
if (!block.isScript) {
markLabel(block.breakLabel);
@@ -101954,8 +103629,8 @@ var ts;
* @param block A code block.
*/
function supportsUnlabeledBreak(block) {
- return block.kind === 2 /* Switch */
- || block.kind === 3 /* Loop */;
+ return block.kind === 2 /* CodeBlockKind.Switch */
+ || block.kind === 3 /* CodeBlockKind.Loop */;
}
/**
* Indicates whether the provided block supports `break` statements with labels.
@@ -101963,7 +103638,7 @@ var ts;
* @param block A code block.
*/
function supportsLabeledBreakOrContinue(block) {
- return block.kind === 4 /* Labeled */;
+ return block.kind === 4 /* CodeBlockKind.Labeled */;
}
/**
* Indicates whether the provided block supports `continue` statements.
@@ -101971,7 +103646,7 @@ var ts;
* @param block A code block.
*/
function supportsUnlabeledContinue(block) {
- return block.kind === 3 /* Loop */;
+ return block.kind === 3 /* CodeBlockKind.Loop */;
}
function hasImmediateContainingLabeledBlock(labelText, start) {
for (var j = start; j >= 0; j--) {
@@ -102068,7 +103743,7 @@ var ts;
*/
function createInstruction(instruction) {
var literal = factory.createNumericLiteral(instruction);
- ts.addSyntheticTrailingComment(literal, 3 /* MultiLineCommentTrivia */, getInstructionName(instruction));
+ ts.addSyntheticTrailingComment(literal, 3 /* SyntaxKind.MultiLineCommentTrivia */, getInstructionName(instruction));
return literal;
}
/**
@@ -102080,7 +103755,7 @@ var ts;
function createInlineBreak(label, location) {
ts.Debug.assertLessThan(0, label, "Invalid label");
return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([
- createInstruction(3 /* Break */),
+ createInstruction(3 /* Instruction.Break */),
createLabel(label)
])), location);
}
@@ -102092,8 +103767,8 @@ var ts;
*/
function createInlineReturn(expression, location) {
return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression
- ? [createInstruction(2 /* Return */), expression]
- : [createInstruction(2 /* Return */)])), location);
+ ? [createInstruction(2 /* Instruction.Return */), expression]
+ : [createInstruction(2 /* Instruction.Return */)])), location);
}
/**
* Creates an expression that can be used to resume from a Yield operation.
@@ -102106,7 +103781,7 @@ var ts;
* Emits an empty instruction.
*/
function emitNop() {
- emitWorker(0 /* Nop */);
+ emitWorker(0 /* OpCode.Nop */);
}
/**
* Emits a Statement.
@@ -102115,7 +103790,7 @@ var ts;
*/
function emitStatement(node) {
if (node) {
- emitWorker(1 /* Statement */, [node]);
+ emitWorker(1 /* OpCode.Statement */, [node]);
}
else {
emitNop();
@@ -102129,7 +103804,7 @@ var ts;
* @param location An optional source map location for the assignment.
*/
function emitAssignment(left, right, location) {
- emitWorker(2 /* Assign */, [left, right], location);
+ emitWorker(2 /* OpCode.Assign */, [left, right], location);
}
/**
* Emits a Break operation to the specified label.
@@ -102138,7 +103813,7 @@ var ts;
* @param location An optional source map location for the assignment.
*/
function emitBreak(label, location) {
- emitWorker(3 /* Break */, [label], location);
+ emitWorker(3 /* OpCode.Break */, [label], location);
}
/**
* Emits a Break operation to the specified label when a condition evaluates to a truthy
@@ -102149,7 +103824,7 @@ var ts;
* @param location An optional source map location for the assignment.
*/
function emitBreakWhenTrue(label, condition, location) {
- emitWorker(4 /* BreakWhenTrue */, [label, condition], location);
+ emitWorker(4 /* OpCode.BreakWhenTrue */, [label, condition], location);
}
/**
* Emits a Break to the specified label when a condition evaluates to a falsey value at
@@ -102160,7 +103835,7 @@ var ts;
* @param location An optional source map location for the assignment.
*/
function emitBreakWhenFalse(label, condition, location) {
- emitWorker(5 /* BreakWhenFalse */, [label, condition], location);
+ emitWorker(5 /* OpCode.BreakWhenFalse */, [label, condition], location);
}
/**
* Emits a YieldStar operation for the provided expression.
@@ -102169,7 +103844,7 @@ var ts;
* @param location An optional source map location for the assignment.
*/
function emitYieldStar(expression, location) {
- emitWorker(7 /* YieldStar */, [expression], location);
+ emitWorker(7 /* OpCode.YieldStar */, [expression], location);
}
/**
* Emits a Yield operation for the provided expression.
@@ -102178,7 +103853,7 @@ var ts;
* @param location An optional source map location for the assignment.
*/
function emitYield(expression, location) {
- emitWorker(6 /* Yield */, [expression], location);
+ emitWorker(6 /* OpCode.Yield */, [expression], location);
}
/**
* Emits a Return operation for the provided expression.
@@ -102187,7 +103862,7 @@ var ts;
* @param location An optional source map location for the assignment.
*/
function emitReturn(expression, location) {
- emitWorker(8 /* Return */, [expression], location);
+ emitWorker(8 /* OpCode.Return */, [expression], location);
}
/**
* Emits a Throw operation for the provided expression.
@@ -102196,13 +103871,13 @@ var ts;
* @param location An optional source map location for the assignment.
*/
function emitThrow(expression, location) {
- emitWorker(9 /* Throw */, [expression], location);
+ emitWorker(9 /* OpCode.Throw */, [expression], location);
}
/**
* Emits an Endfinally operation. This is used to handle `finally` block semantics.
*/
function emitEndfinally() {
- emitWorker(10 /* Endfinally */);
+ emitWorker(10 /* OpCode.Endfinally */);
}
/**
* Emits an operation.
@@ -102246,7 +103921,7 @@ var ts;
/*name*/ undefined,
/*typeParameters*/ undefined, [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)],
/*type*/ undefined, factory.createBlock(buildResult,
- /*multiLine*/ buildResult.length > 0)), 524288 /* ReuseTempVariableScope */));
+ /*multiLine*/ buildResult.length > 0)), 524288 /* EmitFlags.ReuseTempVariableScope */));
}
/**
* Builds the statements for the generator function body.
@@ -102419,8 +104094,8 @@ var ts;
var block = blocks[blockIndex];
var blockAction = blockActions[blockIndex];
switch (block.kind) {
- case 0 /* Exception */:
- if (blockAction === 0 /* Open */) {
+ case 0 /* CodeBlockKind.Exception */:
+ if (blockAction === 0 /* BlockAction.Open */) {
if (!exceptionBlockStack) {
exceptionBlockStack = [];
}
@@ -102430,18 +104105,18 @@ var ts;
exceptionBlockStack.push(currentExceptionBlock);
currentExceptionBlock = block;
}
- else if (blockAction === 1 /* Close */) {
+ else if (blockAction === 1 /* BlockAction.Close */) {
currentExceptionBlock = exceptionBlockStack.pop();
}
break;
- case 1 /* With */:
- if (blockAction === 0 /* Open */) {
+ case 1 /* CodeBlockKind.With */:
+ if (blockAction === 0 /* BlockAction.Open */) {
if (!withBlockStack) {
withBlockStack = [];
}
withBlockStack.push(block);
}
- else if (blockAction === 1 /* Close */) {
+ else if (blockAction === 1 /* BlockAction.Close */) {
withBlockStack.pop();
}
break;
@@ -102465,33 +104140,33 @@ var ts;
lastOperationWasAbrupt = false;
lastOperationWasCompletion = false;
var opcode = operations[operationIndex];
- if (opcode === 0 /* Nop */) {
+ if (opcode === 0 /* OpCode.Nop */) {
return;
}
- else if (opcode === 10 /* Endfinally */) {
+ else if (opcode === 10 /* OpCode.Endfinally */) {
return writeEndfinally();
}
var args = operationArguments[operationIndex];
- if (opcode === 1 /* Statement */) {
+ if (opcode === 1 /* OpCode.Statement */) {
return writeStatement(args[0]);
}
var location = operationLocations[operationIndex];
switch (opcode) {
- case 2 /* Assign */:
+ case 2 /* OpCode.Assign */:
return writeAssign(args[0], args[1], location);
- case 3 /* Break */:
+ case 3 /* OpCode.Break */:
return writeBreak(args[0], location);
- case 4 /* BreakWhenTrue */:
+ case 4 /* OpCode.BreakWhenTrue */:
return writeBreakWhenTrue(args[0], args[1], location);
- case 5 /* BreakWhenFalse */:
+ case 5 /* OpCode.BreakWhenFalse */:
return writeBreakWhenFalse(args[0], args[1], location);
- case 6 /* Yield */:
+ case 6 /* OpCode.Yield */:
return writeYield(args[0], location);
- case 7 /* YieldStar */:
+ case 7 /* OpCode.YieldStar */:
return writeYieldStar(args[0], location);
- case 8 /* Return */:
+ case 8 /* OpCode.Return */:
return writeReturn(args[0], location);
- case 9 /* Throw */:
+ case 9 /* OpCode.Throw */:
return writeThrow(args[0], location);
}
}
@@ -102541,8 +104216,8 @@ var ts;
lastOperationWasAbrupt = true;
lastOperationWasCompletion = true;
writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression
- ? [createInstruction(2 /* Return */), expression]
- : [createInstruction(2 /* Return */)])), operationLocation), 384 /* NoTokenSourceMaps */));
+ ? [createInstruction(2 /* Instruction.Return */), expression]
+ : [createInstruction(2 /* Instruction.Return */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */));
}
/**
* Writes a Break operation to the current label's statement list.
@@ -102553,9 +104228,9 @@ var ts;
function writeBreak(label, operationLocation) {
lastOperationWasAbrupt = true;
writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([
- createInstruction(3 /* Break */),
+ createInstruction(3 /* Instruction.Break */),
createLabel(label)
- ])), operationLocation), 384 /* NoTokenSourceMaps */));
+ ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */));
}
/**
* Writes a BreakWhenTrue operation to the current label's statement list.
@@ -102566,9 +104241,9 @@ var ts;
*/
function writeBreakWhenTrue(label, condition, operationLocation) {
writeStatement(ts.setEmitFlags(factory.createIfStatement(condition, ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([
- createInstruction(3 /* Break */),
+ createInstruction(3 /* Instruction.Break */),
createLabel(label)
- ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */));
+ ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */));
}
/**
* Writes a BreakWhenFalse operation to the current label's statement list.
@@ -102579,9 +104254,9 @@ var ts;
*/
function writeBreakWhenFalse(label, condition, operationLocation) {
writeStatement(ts.setEmitFlags(factory.createIfStatement(factory.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([
- createInstruction(3 /* Break */),
+ createInstruction(3 /* Instruction.Break */),
createLabel(label)
- ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */));
+ ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */));
}
/**
* Writes a Yield operation to the current label's statement list.
@@ -102592,8 +104267,8 @@ var ts;
function writeYield(expression, operationLocation) {
lastOperationWasAbrupt = true;
writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression
- ? [createInstruction(4 /* Yield */), expression]
- : [createInstruction(4 /* Yield */)])), operationLocation), 384 /* NoTokenSourceMaps */));
+ ? [createInstruction(4 /* Instruction.Yield */), expression]
+ : [createInstruction(4 /* Instruction.Yield */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */));
}
/**
* Writes a YieldStar instruction to the current label's statement list.
@@ -102604,9 +104279,9 @@ var ts;
function writeYieldStar(expression, operationLocation) {
lastOperationWasAbrupt = true;
writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([
- createInstruction(5 /* YieldStar */),
+ createInstruction(5 /* Instruction.YieldStar */),
expression
- ])), operationLocation), 384 /* NoTokenSourceMaps */));
+ ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */));
}
/**
* Writes an Endfinally instruction to the current label's statement list.
@@ -102614,7 +104289,7 @@ var ts;
function writeEndfinally() {
lastOperationWasAbrupt = true;
writeStatement(factory.createReturnStatement(factory.createArrayLiteralExpression([
- createInstruction(7 /* Endfinally */)
+ createInstruction(7 /* Instruction.Endfinally */)
])));
}
}
@@ -102641,12 +104316,12 @@ var ts;
var previousOnEmitNode = context.onEmitNode;
context.onSubstituteNode = onSubstituteNode;
context.onEmitNode = onEmitNode;
- context.enableSubstitution(207 /* CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`.
- context.enableSubstitution(209 /* TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`.
- context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols.
- context.enableSubstitution(220 /* BinaryExpression */); // Substitutes assignments to exported symbols.
- context.enableSubstitution(295 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols.
- context.enableEmitNotification(303 /* SourceFile */); // Restore state when substituting nodes in a file.
+ context.enableSubstitution(208 /* SyntaxKind.CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`.
+ context.enableSubstitution(210 /* SyntaxKind.TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`.
+ context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers with imported/exported symbols.
+ context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols.
+ context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols.
+ context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file.
var moduleInfoMap = []; // The ExternalModuleInfo for each file.
var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found.
var currentSourceFile; // The current file.
@@ -102662,7 +104337,7 @@ var ts;
function transformSourceFile(node) {
if (node.isDeclarationFile ||
!(ts.isEffectiveExternalModule(node, compilerOptions) ||
- node.transformFlags & 4194304 /* ContainsDynamicImport */ ||
+ node.transformFlags & 4194304 /* TransformFlags.ContainsDynamicImport */ ||
(ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) {
return node;
}
@@ -102798,7 +104473,7 @@ var ts;
factory.createIdentifier("exports")
]))
]),
- ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* SingleLine */)
+ ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* EmitFlags.SingleLine */)
]), factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("define"), "function"), factory.createPropertyAccessExpression(factory.createIdentifier("define"), "amd")), factory.createBlock([
factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("define"),
/*typeArguments*/ undefined, __spreadArray(__spreadArray([], (moduleName ? [moduleName] : []), true), [
@@ -102883,7 +104558,7 @@ var ts;
if (includeNonAmdDependencies && importAliasName) {
// Set emitFlags on the name of the classDeclaration
// This is so that when printer will not substitute the identifier
- ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */);
+ ts.setEmitFlags(importAliasName, 4 /* EmitFlags.NoSubstitution */);
aliasedModuleNames.push(externalModuleName);
importAliasNames.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName));
}
@@ -102952,13 +104627,13 @@ var ts;
if (emitAsReturn) {
var statement = factory.createReturnStatement(expressionResult);
ts.setTextRange(statement, currentModuleInfo.exportEquals);
- ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */);
+ ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */);
statements.push(statement);
}
else {
var statement = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), expressionResult));
ts.setTextRange(statement, currentModuleInfo.exportEquals);
- ts.setEmitFlags(statement, 1536 /* NoComments */);
+ ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */);
statements.push(statement);
}
}
@@ -102974,23 +104649,23 @@ var ts;
*/
function topLevelVisitor(node) {
switch (node.kind) {
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
return visitImportDeclaration(node);
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return visitImportEqualsDeclaration(node);
- case 271 /* ExportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
return visitExportDeclaration(node);
- case 270 /* ExportAssignment */:
+ case 271 /* SyntaxKind.ExportAssignment */:
return visitExportAssignment(node);
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
return visitVariableStatement(node);
- case 255 /* FunctionDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
return visitFunctionDeclaration(node);
- case 256 /* ClassDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
return visitClassDeclaration(node);
- case 350 /* MergeDeclarationMarker */:
+ case 352 /* SyntaxKind.MergeDeclarationMarker */:
return visitMergeDeclarationMarker(node);
- case 351 /* EndOfDeclarationMarker */:
+ case 353 /* SyntaxKind.EndOfDeclarationMarker */:
return visitEndOfDeclarationMarker(node);
default:
return visitor(node);
@@ -102999,30 +104674,30 @@ var ts;
function visitorWorker(node, valueIsDiscarded) {
// This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression
// as export/import statements are only transformed at the top level of a file.
- if (!(node.transformFlags & (4194304 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) {
+ if (!(node.transformFlags & (4194304 /* TransformFlags.ContainsDynamicImport */ | 4096 /* TransformFlags.ContainsDestructuringAssignment */ | 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) {
return node;
}
switch (node.kind) {
- case 241 /* ForStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
return visitForStatement(node);
- case 237 /* ExpressionStatement */:
+ case 238 /* SyntaxKind.ExpressionStatement */:
return visitExpressionStatement(node);
- case 211 /* ParenthesizedExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
return visitParenthesizedExpression(node, valueIsDiscarded);
- case 348 /* PartiallyEmittedExpression */:
+ case 350 /* SyntaxKind.PartiallyEmittedExpression */:
return visitPartiallyEmittedExpression(node, valueIsDiscarded);
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
if (ts.isImportCall(node) && currentSourceFile.impliedNodeFormat === undefined) {
return visitImportCallExpression(node);
}
break;
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
if (ts.isDestructuringAssignment(node)) {
return visitDestructuringAssignment(node, valueIsDiscarded);
}
break;
- case 218 /* PrefixUnaryExpression */:
- case 219 /* PostfixUnaryExpression */:
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
+ case 220 /* SyntaxKind.PostfixUnaryExpression */:
return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded);
}
return ts.visitEachChild(node, visitor, context);
@@ -103038,24 +104713,24 @@ var ts;
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
var elem = _a[_i];
switch (elem.kind) {
- case 294 /* PropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
if (destructuringNeedsFlattening(elem.initializer)) {
return true;
}
break;
- case 295 /* ShorthandPropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
if (destructuringNeedsFlattening(elem.name)) {
return true;
}
break;
- case 296 /* SpreadAssignment */:
+ case 298 /* SyntaxKind.SpreadAssignment */:
if (destructuringNeedsFlattening(elem.expression)) {
return true;
}
break;
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
return false;
default: ts.Debug.assertNever(elem, "Unhandled object member kind");
}
@@ -103081,7 +104756,7 @@ var ts;
}
function visitDestructuringAssignment(node, valueIsDiscarded) {
if (destructuringNeedsFlattening(node.left)) {
- return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded, createAllExportExpressions);
+ return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded, createAllExportExpressions);
}
return ts.visitEachChild(node, visitor, context);
}
@@ -103107,7 +104782,7 @@ var ts;
// - We do not transform identifiers that were originally the name of an enum or
// namespace due to how they are transformed in TypeScript.
// - We only transform identifiers that are exported at the top level.
- if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */)
+ if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */)
&& ts.isIdentifier(node.operand)
&& !ts.isGeneratedIdentifier(node.operand)
&& !ts.isLocalName(node.operand)
@@ -103150,7 +104825,7 @@ var ts;
var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor);
// Only use the external module name if it differs from the first argument. This allows us to preserve the quote style of the argument on output.
var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument;
- var containsLexicalThis = !!(node.transformFlags & 8192 /* ContainsLexicalThis */);
+ var containsLexicalThis = !!(node.transformFlags & 8192 /* TransformFlags.ContainsLexicalThis */);
switch (compilerOptions.module) {
case ts.ModuleKind.AMD:
return createImportCallExpressionAMD(argument, containsLexicalThis);
@@ -103177,7 +104852,7 @@ var ts;
// });
needUMDDynamicImportHelper = true;
if (ts.isSimpleCopiableExpression(arg)) {
- var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* NoComments */);
+ var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* EmitFlags.NoComments */);
return factory.createConditionalExpression(
/*condition*/ factory.createIdentifier("__syncRequire"),
/*questionToken*/ undefined,
@@ -103213,7 +104888,7 @@ var ts;
/*typeArguments*/ undefined, [factory.createArrayLiteralExpression([arg || factory.createOmittedExpression()]), resolve, reject]))
]);
var func;
- if (languageVersion >= 2 /* ES2015 */) {
+ if (languageVersion >= 2 /* ScriptTarget.ES2015 */) {
func = factory.createArrowFunction(
/*modifiers*/ undefined,
/*typeParameters*/ undefined, parameters,
@@ -103231,7 +104906,7 @@ var ts;
// that this new function expression indicates it captures 'this' so that the
// es2015 transformer will properly substitute 'this' with '_this'.
if (containsLexicalThis) {
- ts.setEmitFlags(func, 8 /* CapturesThis */);
+ ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */);
}
}
var promise = factory.createNewExpression(factory.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]);
@@ -103252,7 +104927,7 @@ var ts;
requireCall = emitHelpers().createImportStarHelper(requireCall);
}
var func;
- if (languageVersion >= 2 /* ES2015 */) {
+ if (languageVersion >= 2 /* ScriptTarget.ES2015 */) {
func = factory.createArrowFunction(
/*modifiers*/ undefined,
/*typeParameters*/ undefined,
@@ -103272,13 +104947,13 @@ var ts;
// that this new function expression indicates it captures 'this' so that the
// es2015 transformer will properly substitute 'this' with '_this'.
if (containsLexicalThis) {
- ts.setEmitFlags(func, 8 /* CapturesThis */);
+ ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */);
}
}
return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
}
function getHelperExpressionForExport(node, innerExpr) {
- if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) {
+ if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) {
return innerExpr;
}
if (ts.getExportNeedsImportStarHelper(node)) {
@@ -103287,7 +104962,7 @@ var ts;
return innerExpr;
}
function getHelperExpressionForImport(node, innerExpr) {
- if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) {
+ if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) {
return innerExpr;
}
if (ts.getImportNeedsImportStarHelper(node)) {
@@ -103334,7 +105009,7 @@ var ts;
}
}
statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement(
- /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)),
+ /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)),
/*location*/ node),
/*original*/ node));
}
@@ -103348,7 +105023,7 @@ var ts;
/*type*/ undefined, factory.getGeneratedNameForNode(node)),
/*location*/ node),
/*original*/ node)
- ], languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)));
+ ], languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)));
}
if (hasAssociatedEndOfDeclarationMarker(node)) {
// Defer exports until we encounter an EndOfDeclarationMarker node
@@ -103382,7 +105057,7 @@ var ts;
ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer.");
var statements;
if (moduleKind !== ts.ModuleKind.AMD) {
- if (ts.hasSyntacticModifier(node, 1 /* Export */)) {
+ if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) {
statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node));
}
else {
@@ -103392,11 +105067,11 @@ var ts;
/*exclamationToken*/ undefined,
/*type*/ undefined, createRequireCall(node))
],
- /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node));
+ /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node));
}
}
else {
- if (ts.hasSyntacticModifier(node, 1 /* Export */)) {
+ if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) {
statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(node), factory.getLocalName(node))), node), node));
}
}
@@ -103437,12 +105112,12 @@ var ts;
}
for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) {
var specifier = _a[_i];
- if (languageVersion === 0 /* ES3 */) {
+ if (languageVersion === 0 /* ScriptTarget.ES3 */) {
statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createCreateBindingHelper(generatedName, factory.createStringLiteralFromNode(specifier.propertyName || specifier.name), specifier.propertyName ? factory.createStringLiteralFromNode(specifier.name) : undefined)), specifier), specifier));
}
else {
var exportNeedsImportDefault = !!ts.getESModuleInterop(compilerOptions) &&
- !(ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) &&
+ !(ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) &&
ts.idText(specifier.propertyName || specifier.name) === "default";
var exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name);
statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(specifier), exportedValue, /* location */ undefined, /* liveBinding */ true)), specifier), specifier));
@@ -103493,7 +105168,7 @@ var ts;
*/
function visitFunctionDeclaration(node) {
var statements;
- if (ts.hasSyntacticModifier(node, 1 /* Export */)) {
+ if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) {
statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createFunctionDeclaration(
/*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true),
/*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor),
@@ -103521,7 +105196,7 @@ var ts;
*/
function visitClassDeclaration(node) {
var statements;
- if (ts.hasSyntacticModifier(node, 1 /* Export */)) {
+ if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) {
statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createClassDeclaration(
/*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true),
/*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor), ts.visitNodes(node.members, visitor)), node), node));
@@ -103548,7 +105223,7 @@ var ts;
var statements;
var variables;
var expressions;
- if (ts.hasSyntacticModifier(node, 1 /* Export */)) {
+ if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) {
var modifiers = void 0;
var removeCommentsOnExpressions = false;
// If we're exporting these variables, then these just become assignments to 'exports.x'.
@@ -103606,7 +105281,7 @@ var ts;
for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) {
var exportName = exportedNames_2[_i];
// Mark the node to prevent triggering substitution.
- ts.setEmitFlags(expression, 4 /* NoSubstitution */);
+ ts.setEmitFlags(expression, 4 /* EmitFlags.NoSubstitution */);
expression = createExportExpression(exportName, expression, /*location*/ location);
}
return expression;
@@ -103621,7 +105296,7 @@ var ts;
function transformInitializedVariable(node) {
if (ts.isBindingPattern(node.name)) {
return ts.flattenDestructuringAssignment(ts.visitNode(node, visitor),
- /*visitor*/ undefined, context, 0 /* All */,
+ /*visitor*/ undefined, context, 0 /* FlattenLevel.All */,
/*needsValue*/ false, createAllExportExpressions);
}
else {
@@ -103643,7 +105318,7 @@ var ts;
//
// To balance the declaration, add the exports of the elided variable
// statement.
- if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 236 /* VariableStatement */) {
+ if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) {
var id = ts.getOriginalNodeId(node);
deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original);
}
@@ -103655,7 +105330,7 @@ var ts;
* @param node The node to test.
*/
function hasAssociatedEndOfDeclarationMarker(node) {
- return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0;
+ return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0;
}
/**
* Visits a DeclarationMarker used as a placeholder for the end of a transformed
@@ -103698,10 +105373,10 @@ var ts;
var namedBindings = importClause.namedBindings;
if (namedBindings) {
switch (namedBindings.kind) {
- case 267 /* NamespaceImport */:
+ case 268 /* SyntaxKind.NamespaceImport */:
statements = appendExportsOfDeclaration(statements, namedBindings);
break;
- case 268 /* NamedImports */:
+ case 269 /* SyntaxKind.NamedImports */:
for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) {
var importBinding = _a[_i];
statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true);
@@ -103784,8 +105459,8 @@ var ts;
if (currentModuleInfo.exportEquals) {
return statements;
}
- if (ts.hasSyntacticModifier(decl, 1 /* Export */)) {
- var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl);
+ if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) {
+ var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl);
statements = appendExportStatement(statements, exportName, factory.getLocalName(decl), /*location*/ decl);
}
if (decl.name) {
@@ -103830,7 +105505,7 @@ var ts;
}
function createUnderscoreUnderscoreESModule() {
var statement;
- if (languageVersion === 0 /* ES3 */) {
+ if (languageVersion === 0 /* ScriptTarget.ES3 */) {
statement = factory.createExpressionStatement(createExportExpression(factory.createIdentifier("__esModule"), factory.createTrue()));
}
else {
@@ -103843,7 +105518,7 @@ var ts;
])
]));
}
- ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
+ ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */);
return statement;
}
/**
@@ -103858,7 +105533,7 @@ var ts;
var statement = ts.setTextRange(factory.createExpressionStatement(createExportExpression(name, value, /* location */ undefined, liveBinding)), location);
ts.startOnNewLine(statement);
if (!allowComments) {
- ts.setEmitFlags(statement, 1536 /* NoComments */);
+ ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */);
}
return statement;
}
@@ -103870,7 +105545,7 @@ var ts;
* @param location The location to use for source maps and comments for the export.
*/
function createExportExpression(name, value, location, liveBinding) {
- return ts.setTextRange(liveBinding && languageVersion !== 0 /* ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"),
+ return ts.setTextRange(liveBinding && languageVersion !== 0 /* ScriptTarget.ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"),
/*typeArguments*/ undefined, [
factory.createIdentifier("exports"),
factory.createStringLiteralFromNode(name),
@@ -103897,8 +105572,8 @@ var ts;
function modifierVisitor(node) {
// Elide module-specific modifiers.
switch (node.kind) {
- case 93 /* ExportKeyword */:
- case 88 /* DefaultKeyword */:
+ case 93 /* SyntaxKind.ExportKeyword */:
+ case 88 /* SyntaxKind.DefaultKeyword */:
return undefined;
}
return node;
@@ -103914,7 +105589,7 @@ var ts;
* @param emit A callback used to emit the node in the printer.
*/
function onEmitNode(hint, node, emitCallback) {
- if (node.kind === 303 /* SourceFile */) {
+ if (node.kind === 305 /* SyntaxKind.SourceFile */) {
currentSourceFile = node;
currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)];
previousOnEmitNode(hint, node, emitCallback);
@@ -103939,7 +105614,7 @@ var ts;
if (node.id && noSubstitution[node.id]) {
return node;
}
- if (hint === 1 /* Expression */) {
+ if (hint === 1 /* EmitHint.Expression */) {
return substituteExpression(node);
}
else if (ts.isShorthandPropertyAssignment(node)) {
@@ -103974,13 +105649,13 @@ var ts;
*/
function substituteExpression(node) {
switch (node.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return substituteExpressionIdentifier(node);
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
return substituteCallExpression(node);
- case 209 /* TaggedTemplateExpression */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
return substituteTaggedTemplateExpression(node);
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return substituteBinaryExpression(node);
}
return node;
@@ -103989,9 +105664,9 @@ var ts;
if (ts.isIdentifier(node.expression)) {
var expression = substituteExpressionIdentifier(node.expression);
noSubstitution[ts.getNodeId(expression)] = true;
- if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* HelperName */)) {
+ if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* EmitFlags.HelperName */)) {
return ts.addEmitFlags(factory.updateCallExpression(node, expression,
- /*typeArguments*/ undefined, node.arguments), 536870912 /* IndirectCall */);
+ /*typeArguments*/ undefined, node.arguments), 536870912 /* EmitFlags.IndirectCall */);
}
}
return node;
@@ -104000,9 +105675,9 @@ var ts;
if (ts.isIdentifier(node.tag)) {
var tag = substituteExpressionIdentifier(node.tag);
noSubstitution[ts.getNodeId(tag)] = true;
- if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* HelperName */)) {
+ if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* EmitFlags.HelperName */)) {
return ts.addEmitFlags(factory.updateTaggedTemplateExpression(node, tag,
- /*typeArguments*/ undefined, node.template), 536870912 /* IndirectCall */);
+ /*typeArguments*/ undefined, node.template), 536870912 /* EmitFlags.IndirectCall */);
}
}
return node;
@@ -104015,16 +105690,16 @@ var ts;
*/
function substituteExpressionIdentifier(node) {
var _a, _b;
- if (ts.getEmitFlags(node) & 4096 /* HelperName */) {
+ if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) {
var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile);
if (externalHelpersModuleName) {
return factory.createPropertyAccessExpression(externalHelpersModuleName, node);
}
return node;
}
- else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) {
+ else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */)) && !ts.isLocalName(node)) {
var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node));
- if (exportContainer && exportContainer.kind === 303 /* SourceFile */) {
+ if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) {
return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)),
/*location*/ node);
}
@@ -104113,11 +105788,11 @@ var ts;
var previousOnEmitNode = context.onEmitNode;
context.onSubstituteNode = onSubstituteNode;
context.onEmitNode = onEmitNode;
- context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers for imported symbols.
- context.enableSubstitution(295 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols
- context.enableSubstitution(220 /* BinaryExpression */); // Substitutes assignments to exported symbols.
- context.enableSubstitution(230 /* MetaProperty */); // Substitutes 'import.meta'
- context.enableEmitNotification(303 /* SourceFile */); // Restore state when substituting nodes in a file.
+ context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers for imported symbols.
+ context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols
+ context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols.
+ context.enableSubstitution(231 /* SyntaxKind.MetaProperty */); // Substitutes 'import.meta'
+ context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file.
var moduleInfoMap = []; // The ExternalModuleInfo for each file.
var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found.
var exportFunctionsMap = []; // The export function associated with a source file.
@@ -104137,7 +105812,7 @@ var ts;
* @param node The SourceFile node.
*/
function transformSourceFile(node) {
- if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* ContainsDynamicImport */)) {
+ if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* TransformFlags.ContainsDynamicImport */)) {
return node;
}
var id = ts.getOriginalNodeId(node);
@@ -104184,7 +105859,7 @@ var ts;
/*typeArguments*/ undefined, moduleName
? [moduleName, dependencies, moduleBodyFunction]
: [dependencies, moduleBodyFunction]))
- ]), node.statements)), 1024 /* NoTrailingComments */);
+ ]), node.statements)), 1024 /* EmitFlags.NoTrailingComments */);
if (!ts.outFile(compilerOptions)) {
ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; });
}
@@ -104306,8 +105981,8 @@ var ts;
// - Temporary variables will appear at the top rather than at the bottom of the file
ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217
- var modifiers = node.transformFlags & 1048576 /* ContainsAwait */ ?
- factory.createModifiersFromModifierFlags(256 /* Async */) :
+ var modifiers = node.transformFlags & 1048576 /* TransformFlags.ContainsAwait */ ?
+ factory.createModifiersFromModifierFlags(256 /* ModifierFlags.Async */) :
undefined;
var moduleObject = factory.createObjectLiteralExpression([
factory.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)),
@@ -104341,7 +106016,7 @@ var ts;
var hasExportDeclarationWithExportClause = false;
for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) {
var externalImport = _a[_i];
- if (externalImport.kind === 271 /* ExportDeclaration */ && externalImport.exportClause) {
+ if (externalImport.kind === 272 /* SyntaxKind.ExportDeclaration */ && externalImport.exportClause) {
hasExportDeclarationWithExportClause = true;
break;
}
@@ -104407,7 +106082,7 @@ var ts;
factory.createForInStatement(factory.createVariableDeclarationList([
factory.createVariableDeclaration(n)
]), m, factory.createBlock([
- ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* SingleLine */)
+ ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* EmitFlags.SingleLine */)
])),
factory.createExpressionStatement(factory.createCallExpression(exportFunction,
/*typeArguments*/ undefined, [exports]))
@@ -104431,19 +106106,19 @@ var ts;
var entry = _b[_a];
var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); // TODO: GH#18217
switch (entry.kind) {
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
if (!entry.importClause) {
// 'import "..."' case
// module is imported only for side-effects, no emit required
break;
}
// falls through
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
ts.Debug.assert(importVariableName !== undefined);
// save import into the local
statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName)));
break;
- case 271 /* ExportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
ts.Debug.assert(importVariableName !== undefined);
if (entry.exportClause) {
if (ts.isNamedExports(entry.exportClause)) {
@@ -104502,13 +106177,13 @@ var ts;
*/
function topLevelVisitor(node) {
switch (node.kind) {
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
return visitImportDeclaration(node);
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return visitImportEqualsDeclaration(node);
- case 271 /* ExportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
return visitExportDeclaration(node);
- case 270 /* ExportAssignment */:
+ case 271 /* SyntaxKind.ExportAssignment */:
return visitExportAssignment(node);
default:
return topLevelNestedVisitor(node);
@@ -104584,7 +106259,7 @@ var ts;
* @param node The node to visit.
*/
function visitFunctionDeclaration(node) {
- if (ts.hasSyntacticModifier(node, 1 /* Export */)) {
+ if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) {
hoistedStatements = ts.append(hoistedStatements, factory.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true),
/*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration),
/*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock)));
@@ -104637,7 +106312,7 @@ var ts;
return ts.visitNode(node, visitor, ts.isStatement);
}
var expressions;
- var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* Export */);
+ var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */);
var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node);
for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
var variable = _a[_i];
@@ -104687,9 +106362,9 @@ var ts;
*/
function shouldHoistVariableDeclarationList(node) {
// hoist only non-block scoped declarations or block scoped declarations parented by source file
- return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0
- && (enclosingBlockScopedContainer.kind === 303 /* SourceFile */
- || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0);
+ return (ts.getEmitFlags(node) & 2097152 /* EmitFlags.NoHoisting */) === 0
+ && (enclosingBlockScopedContainer.kind === 305 /* SyntaxKind.SourceFile */
+ || (ts.getOriginalNode(node).flags & 3 /* NodeFlags.BlockScoped */) === 0);
}
/**
* Transform an initialized variable declaration into an expression.
@@ -104700,7 +106375,7 @@ var ts;
function transformInitializedVariable(node, isExportedDeclaration) {
var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment;
return ts.isBindingPattern(node.name)
- ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */,
+ ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */,
/*needsValue*/ false, createAssignment)
: node.initializer ? createAssignment(node.name, ts.visitNode(node.initializer, visitor, ts.isExpression)) : node.name;
}
@@ -104752,9 +106427,9 @@ var ts;
//
// To balance the declaration, we defer the exports of the elided variable
// statement until we visit this declaration's `EndOfDeclarationMarker`.
- if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 236 /* VariableStatement */) {
+ if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) {
var id = ts.getOriginalNodeId(node);
- var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* Export */);
+ var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* ModifierFlags.Export */);
deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration);
}
return node;
@@ -104765,7 +106440,7 @@ var ts;
* @param node The node to test.
*/
function hasAssociatedEndOfDeclarationMarker(node) {
- return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0;
+ return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0;
}
/**
* Visits a DeclarationMarker used as a placeholder for the end of a transformed
@@ -104814,10 +106489,10 @@ var ts;
var namedBindings = importClause.namedBindings;
if (namedBindings) {
switch (namedBindings.kind) {
- case 267 /* NamespaceImport */:
+ case 268 /* SyntaxKind.NamespaceImport */:
statements = appendExportsOfDeclaration(statements, namedBindings);
break;
- case 268 /* NamedImports */:
+ case 269 /* SyntaxKind.NamedImports */:
for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) {
var importBinding = _a[_i];
statements = appendExportsOfDeclaration(statements, importBinding);
@@ -104911,8 +106586,8 @@ var ts;
return statements;
}
var excludeName;
- if (ts.hasSyntacticModifier(decl, 1 /* Export */)) {
- var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createStringLiteral("default") : decl.name;
+ if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) {
+ var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createStringLiteral("default") : decl.name;
statements = appendExportStatement(statements, exportName, factory.getLocalName(decl));
excludeName = ts.getTextOfIdentifierOrLiteral(exportName);
}
@@ -104972,7 +106647,7 @@ var ts;
var statement = factory.createExpressionStatement(createExportExpression(name, value));
ts.startOnNewLine(statement);
if (!allowComments) {
- ts.setEmitFlags(statement, 1536 /* NoComments */);
+ ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */);
}
return statement;
}
@@ -104984,7 +106659,7 @@ var ts;
*/
function createExportExpression(name, value) {
var exportName = ts.isIdentifier(name) ? factory.createStringLiteralFromNode(name) : name;
- ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* NoComments */);
+ ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* EmitFlags.NoComments */);
return ts.setCommentRange(factory.createCallExpression(exportFunction, /*typeArguments*/ undefined, [exportName, value]), value);
}
//
@@ -104997,43 +106672,43 @@ var ts;
*/
function topLevelNestedVisitor(node) {
switch (node.kind) {
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
return visitVariableStatement(node);
- case 255 /* FunctionDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
return visitFunctionDeclaration(node);
- case 256 /* ClassDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
return visitClassDeclaration(node);
- case 241 /* ForStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
return visitForStatement(node, /*isTopLevel*/ true);
- case 242 /* ForInStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
return visitForInStatement(node);
- case 243 /* ForOfStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
return visitForOfStatement(node);
- case 239 /* DoStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
return visitDoStatement(node);
- case 240 /* WhileStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
return visitWhileStatement(node);
- case 249 /* LabeledStatement */:
+ case 250 /* SyntaxKind.LabeledStatement */:
return visitLabeledStatement(node);
- case 247 /* WithStatement */:
+ case 248 /* SyntaxKind.WithStatement */:
return visitWithStatement(node);
- case 248 /* SwitchStatement */:
+ case 249 /* SyntaxKind.SwitchStatement */:
return visitSwitchStatement(node);
- case 262 /* CaseBlock */:
+ case 263 /* SyntaxKind.CaseBlock */:
return visitCaseBlock(node);
- case 288 /* CaseClause */:
+ case 289 /* SyntaxKind.CaseClause */:
return visitCaseClause(node);
- case 289 /* DefaultClause */:
+ case 290 /* SyntaxKind.DefaultClause */:
return visitDefaultClause(node);
- case 251 /* TryStatement */:
+ case 252 /* SyntaxKind.TryStatement */:
return visitTryStatement(node);
- case 291 /* CatchClause */:
+ case 292 /* SyntaxKind.CatchClause */:
return visitCatchClause(node);
- case 234 /* Block */:
+ case 235 /* SyntaxKind.Block */:
return visitBlock(node);
- case 350 /* MergeDeclarationMarker */:
+ case 352 /* SyntaxKind.MergeDeclarationMarker */:
return visitMergeDeclarationMarker(node);
- case 351 /* EndOfDeclarationMarker */:
+ case 353 /* SyntaxKind.EndOfDeclarationMarker */:
return visitEndOfDeclarationMarker(node);
default:
return visitor(node);
@@ -105215,30 +106890,30 @@ var ts;
* @param node The node to visit.
*/
function visitorWorker(node, valueIsDiscarded) {
- if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 4194304 /* ContainsDynamicImport */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) {
+ if (!(node.transformFlags & (4096 /* TransformFlags.ContainsDestructuringAssignment */ | 4194304 /* TransformFlags.ContainsDynamicImport */ | 67108864 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) {
return node;
}
switch (node.kind) {
- case 241 /* ForStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
return visitForStatement(node, /*isTopLevel*/ false);
- case 237 /* ExpressionStatement */:
+ case 238 /* SyntaxKind.ExpressionStatement */:
return visitExpressionStatement(node);
- case 211 /* ParenthesizedExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
return visitParenthesizedExpression(node, valueIsDiscarded);
- case 348 /* PartiallyEmittedExpression */:
+ case 350 /* SyntaxKind.PartiallyEmittedExpression */:
return visitPartiallyEmittedExpression(node, valueIsDiscarded);
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
if (ts.isDestructuringAssignment(node)) {
return visitDestructuringAssignment(node, valueIsDiscarded);
}
break;
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
if (ts.isImportCall(node)) {
return visitImportCallExpression(node);
}
break;
- case 218 /* PrefixUnaryExpression */:
- case 219 /* PostfixUnaryExpression */:
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
+ case 220 /* SyntaxKind.PostfixUnaryExpression */:
return visitPrefixOrPostfixUnaryExpression(node, valueIsDiscarded);
}
return ts.visitEachChild(node, visitor, context);
@@ -105288,7 +106963,7 @@ var ts;
*/
function visitDestructuringAssignment(node, valueIsDiscarded) {
if (hasExportedReferenceInDestructuringTarget(node.left)) {
- return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded);
+ return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded);
}
return ts.visitEachChild(node, visitor, context);
}
@@ -105318,7 +106993,7 @@ var ts;
}
else if (ts.isIdentifier(node)) {
var container = resolver.getReferencedExportContainer(node);
- return container !== undefined && container.kind === 303 /* SourceFile */;
+ return container !== undefined && container.kind === 305 /* SyntaxKind.SourceFile */;
}
else {
return false;
@@ -105334,7 +107009,7 @@ var ts;
// - We do not transform identifiers that were originally the name of an enum or
// namespace due to how they are transformed in TypeScript.
// - We only transform identifiers that are exported at the top level.
- if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */)
+ if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */)
&& ts.isIdentifier(node.operand)
&& !ts.isGeneratedIdentifier(node.operand)
&& !ts.isLocalName(node.operand)
@@ -105379,8 +107054,8 @@ var ts;
*/
function modifierVisitor(node) {
switch (node.kind) {
- case 93 /* ExportKeyword */:
- case 88 /* DefaultKeyword */:
+ case 93 /* SyntaxKind.ExportKeyword */:
+ case 88 /* SyntaxKind.DefaultKeyword */:
return undefined;
}
return node;
@@ -105396,7 +107071,7 @@ var ts;
* @param emitCallback A callback used to emit the node in the printer.
*/
function onEmitNode(hint, node, emitCallback) {
- if (node.kind === 303 /* SourceFile */) {
+ if (node.kind === 305 /* SyntaxKind.SourceFile */) {
var id = ts.getOriginalNodeId(node);
currentSourceFile = node;
moduleInfo = moduleInfoMap[id];
@@ -105431,10 +107106,10 @@ var ts;
if (isSubstitutionPrevented(node)) {
return node;
}
- if (hint === 1 /* Expression */) {
+ if (hint === 1 /* EmitHint.Expression */) {
return substituteExpression(node);
}
- else if (hint === 4 /* Unspecified */) {
+ else if (hint === 4 /* EmitHint.Unspecified */) {
return substituteUnspecified(node);
}
return node;
@@ -105446,7 +107121,7 @@ var ts;
*/
function substituteUnspecified(node) {
switch (node.kind) {
- case 295 /* ShorthandPropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
return substituteShorthandPropertyAssignment(node);
}
return node;
@@ -105481,11 +107156,11 @@ var ts;
*/
function substituteExpression(node) {
switch (node.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return substituteExpressionIdentifier(node);
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return substituteBinaryExpression(node);
- case 230 /* MetaProperty */:
+ case 231 /* SyntaxKind.MetaProperty */:
return substituteMetaProperty(node);
}
return node;
@@ -105497,7 +107172,7 @@ var ts;
*/
function substituteExpressionIdentifier(node) {
var _a, _b;
- if (ts.getEmitFlags(node) & 4096 /* HelperName */) {
+ if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) {
var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile);
if (externalHelpersModuleName) {
return factory.createPropertyAccessExpression(externalHelpersModuleName, node);
@@ -105575,7 +107250,7 @@ var ts;
|| resolver.getReferencedValueDeclaration(name);
if (valueDeclaration) {
var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false);
- if (exportContainer && exportContainer.kind === 303 /* SourceFile */) {
+ if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) {
exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration));
}
exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]);
@@ -105618,8 +107293,8 @@ var ts;
var previousOnSubstituteNode = context.onSubstituteNode;
context.onEmitNode = onEmitNode;
context.onSubstituteNode = onSubstituteNode;
- context.enableEmitNotification(303 /* SourceFile */);
- context.enableSubstitution(79 /* Identifier */);
+ context.enableEmitNotification(305 /* SyntaxKind.SourceFile */);
+ context.enableSubstitution(79 /* SyntaxKind.Identifier */);
var helperNameSubstitutions;
var currentSourceFile;
var importRequireStatements;
@@ -105658,14 +107333,14 @@ var ts;
}
function visitor(node) {
switch (node.kind) {
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
// Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call
// To give easy access to a synchronous `require` in node-flavor esm. We do the transform even in scenarios where we error, but `import.meta.url`
// is available, just because the output is reasonable for a node-like runtime.
return ts.getEmitScriptTarget(compilerOptions) >= ts.ModuleKind.ES2020 ? visitImportEqualsDeclaration(node) : undefined;
- case 270 /* ExportAssignment */:
+ case 271 /* SyntaxKind.ExportAssignment */:
return visitExportAssignment(node);
- case 271 /* ExportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
var exportDecl = node;
return visitExportDeclaration(exportDecl);
}
@@ -105683,7 +107358,7 @@ var ts;
args.push(moduleName);
}
if (!importRequireStatements) {
- var createRequireName = factory.createUniqueName("_createRequire", 16 /* Optimistic */ | 32 /* FileLevel */);
+ var createRequireName = factory.createUniqueName("_createRequire", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */);
var importStatement = factory.createImportDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined, factory.createImportClause(
@@ -105691,16 +107366,16 @@ var ts;
/*name*/ undefined, factory.createNamedImports([
factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier("createRequire"), createRequireName)
])), factory.createStringLiteral("module"));
- var requireHelperName = factory.createUniqueName("__require", 16 /* Optimistic */ | 32 /* FileLevel */);
+ var requireHelperName = factory.createUniqueName("__require", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */);
var requireStatement = factory.createVariableStatement(
/*modifiers*/ undefined, factory.createVariableDeclarationList([
factory.createVariableDeclaration(requireHelperName,
/*exclamationToken*/ undefined,
/*type*/ undefined, factory.createCallExpression(factory.cloneNode(createRequireName), /*typeArguments*/ undefined, [
- factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url"))
+ factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url"))
]))
],
- /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */));
+ /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */));
importRequireStatements = [importStatement, requireStatement];
}
var name = importRequireStatements[1].declarationList.declarations[0].name;
@@ -105721,12 +107396,12 @@ var ts;
/*exclamationToken*/ undefined,
/*type*/ undefined, createRequireCall(node))
],
- /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node));
+ /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node));
statements = appendExportsOfImportEqualsDeclaration(statements, node);
return ts.singleOrMany(statements);
}
function appendExportsOfImportEqualsDeclaration(statements, node) {
- if (ts.hasSyntacticModifier(node, 1 /* Export */)) {
+ if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) {
statements = ts.append(statements, factory.createExportDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.idText(node.name))])));
@@ -105794,7 +107469,7 @@ var ts;
*/
function onSubstituteNode(hint, node) {
node = previousOnSubstituteNode(hint, node);
- if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* HelperName */) {
+ if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) {
return substituteHelperName(node);
}
return node;
@@ -105803,7 +107478,7 @@ var ts;
var name = ts.idText(node);
var substitution = helperNameSubstitutions.get(name);
if (!substitution) {
- helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* Optimistic */ | 32 /* FileLevel */));
+ helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */));
}
return substitution;
}
@@ -105826,8 +107501,8 @@ var ts;
var cjsOnEmitNode = context.onEmitNode;
context.onSubstituteNode = onSubstituteNode;
context.onEmitNode = onEmitNode;
- context.enableSubstitution(303 /* SourceFile */);
- context.enableEmitNotification(303 /* SourceFile */);
+ context.enableSubstitution(305 /* SyntaxKind.SourceFile */);
+ context.enableEmitNotification(305 /* SyntaxKind.SourceFile */);
var currentSourceFile;
return transformSourceFileOrBundle;
function onSubstituteNode(hint, node) {
@@ -105874,7 +107549,7 @@ var ts;
return result;
}
function transformSourceFileOrBundle(node) {
- return node.kind === 303 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node);
+ return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node);
}
function transformBundle(node) {
return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends);
@@ -105929,14 +107604,14 @@ var ts;
function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult) {
if (ts.isStatic(node)) {
return symbolAccessibilityResult.errorModuleName ?
- symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ?
+ symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ?
ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
}
- else if (node.parent.kind === 256 /* ClassDeclaration */) {
+ else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) {
return symbolAccessibilityResult.errorModuleName ?
- symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ?
+ symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ?
ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
@@ -105958,14 +107633,14 @@ var ts;
function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult) {
if (ts.isStatic(node)) {
return symbolAccessibilityResult.errorModuleName ?
- symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ?
+ symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ?
ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1;
}
- else if (node.parent.kind === 256 /* ClassDeclaration */) {
+ else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) {
return symbolAccessibilityResult.errorModuleName ?
- symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ?
+ symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ?
ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1;
@@ -105989,7 +107664,7 @@ var ts;
return getReturnTypeVisibilityError;
}
else if (ts.isParameter(node)) {
- if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* Private */)) {
+ if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */)) {
return getVariableDeclarationTypeVisibilityError;
}
return getParameterDeclarationTypeVisibilityError;
@@ -106010,28 +107685,28 @@ var ts;
return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: ".concat(ts.SyntaxKind[node.kind]));
}
function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
- if (node.kind === 253 /* VariableDeclaration */ || node.kind === 202 /* BindingElement */) {
+ if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) {
return symbolAccessibilityResult.errorModuleName ?
- symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ?
+ symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ?
ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1;
}
// This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit
// The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all.
- else if (node.kind === 166 /* PropertyDeclaration */ || node.kind === 205 /* PropertyAccessExpression */ || node.kind === 165 /* PropertySignature */ ||
- (node.kind === 163 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) {
+ else if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 166 /* SyntaxKind.PropertySignature */ ||
+ (node.kind === 164 /* SyntaxKind.Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */))) {
// TODO(jfreeman): Deal with computed properties in error reporting.
if (ts.isStatic(node)) {
return symbolAccessibilityResult.errorModuleName ?
- symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ?
+ symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ?
ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
}
- else if (node.parent.kind === 256 /* ClassDeclaration */ || node.kind === 163 /* Parameter */) {
+ else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 164 /* SyntaxKind.Parameter */) {
return symbolAccessibilityResult.errorModuleName ?
- symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ?
+ symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ?
ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
@@ -106054,7 +107729,7 @@ var ts;
}
function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) {
var diagnosticMessage;
- if (node.kind === 172 /* SetAccessor */) {
+ if (node.kind === 173 /* SyntaxKind.SetAccessor */) {
// Getters can infer the return type from the returned expression, but setters cannot, so the
// "_from_external_module_1_but_cannot_be_named" case cannot occur.
if (ts.isStatic(node)) {
@@ -106071,14 +107746,14 @@ var ts;
else {
if (ts.isStatic(node)) {
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
- symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ?
+ symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ?
ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1;
}
else {
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
- symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ?
+ symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ?
ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1;
@@ -106093,36 +107768,36 @@ var ts;
function getReturnTypeVisibilityError(symbolAccessibilityResult) {
var diagnosticMessage;
switch (node.kind) {
- case 174 /* ConstructSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
// Interfaces cannot have return types that cannot be named
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0;
break;
- case 173 /* CallSignature */:
+ case 174 /* SyntaxKind.CallSignature */:
// Interfaces cannot have return types that cannot be named
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0;
break;
- case 175 /* IndexSignature */:
+ case 176 /* SyntaxKind.IndexSignature */:
// Interfaces cannot have return types that cannot be named
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0;
break;
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
if (ts.isStatic(node)) {
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
- symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ?
+ symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ?
ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0;
}
- else if (node.parent.kind === 256 /* ClassDeclaration */) {
+ else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) {
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
- symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ?
+ symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ?
ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0;
@@ -106134,9 +107809,9 @@ var ts;
ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0;
}
break;
- case 255 /* FunctionDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
- symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ?
+ symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ?
ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 :
ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0;
@@ -106159,40 +107834,40 @@ var ts;
}
function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
switch (node.parent.kind) {
- case 170 /* Constructor */:
+ case 171 /* SyntaxKind.Constructor */:
return symbolAccessibilityResult.errorModuleName ?
- symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ?
+ symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ?
ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1;
- case 174 /* ConstructSignature */:
- case 179 /* ConstructorType */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 180 /* SyntaxKind.ConstructorType */:
// Interfaces cannot have parameter types that cannot be named
return symbolAccessibilityResult.errorModuleName ?
ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
- case 173 /* CallSignature */:
+ case 174 /* SyntaxKind.CallSignature */:
// Interfaces cannot have parameter types that cannot be named
return symbolAccessibilityResult.errorModuleName ?
ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
- case 175 /* IndexSignature */:
+ case 176 /* SyntaxKind.IndexSignature */:
// Interfaces cannot have parameter types that cannot be named
return symbolAccessibilityResult.errorModuleName ?
ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1;
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
if (ts.isStatic(node.parent)) {
return symbolAccessibilityResult.errorModuleName ?
- symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ?
+ symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ?
ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
}
- else if (node.parent.parent.kind === 256 /* ClassDeclaration */) {
+ else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) {
return symbolAccessibilityResult.errorModuleName ?
- symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ?
+ symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ?
ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
@@ -106203,17 +107878,17 @@ var ts;
ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
}
- case 255 /* FunctionDeclaration */:
- case 178 /* FunctionType */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 179 /* SyntaxKind.FunctionType */:
return symbolAccessibilityResult.errorModuleName ?
- symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ?
+ symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ?
ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 :
ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1;
- case 172 /* SetAccessor */:
- case 171 /* GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 172 /* SyntaxKind.GetAccessor */:
return symbolAccessibilityResult.errorModuleName ?
- symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ?
+ symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ?
ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
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;
@@ -106225,39 +107900,39 @@ var ts;
// Type parameter constraints are named by user so we should always be able to name it
var diagnosticMessage;
switch (node.parent.kind) {
- case 256 /* ClassDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1;
break;
- case 257 /* InterfaceDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1;
break;
- case 194 /* MappedType */:
+ case 195 /* SyntaxKind.MappedType */:
diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1;
break;
- case 179 /* ConstructorType */:
- case 174 /* ConstructSignature */:
+ case 180 /* SyntaxKind.ConstructorType */:
+ case 175 /* SyntaxKind.ConstructSignature */:
diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
break;
- case 173 /* CallSignature */:
+ case 174 /* SyntaxKind.CallSignature */:
diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
break;
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
if (ts.isStatic(node.parent)) {
diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
}
- else if (node.parent.parent.kind === 256 /* ClassDeclaration */) {
+ else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) {
diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
}
else {
diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
}
break;
- case 178 /* FunctionType */:
- case 255 /* FunctionDeclaration */:
+ case 179 /* SyntaxKind.FunctionType */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
break;
- case 258 /* TypeAliasDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1;
break;
default:
@@ -106274,7 +107949,7 @@ var ts;
// Heritage clause is written by user so it can always be named
if (ts.isClassDeclaration(node.parent.parent)) {
// Class or Interface implemented/extended is inaccessible
- diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* ImplementsKeyword */ ?
+ diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ ?
ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 :
node.parent.parent.name ? ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1 :
ts.Diagnostics.extends_clause_of_exported_class_has_or_is_using_private_name_0;
@@ -106323,7 +107998,7 @@ var ts;
}
function isInternalDeclaration(node, currentSourceFile) {
var parseTreeNode = ts.getParseTreeNode(node);
- if (parseTreeNode && parseTreeNode.kind === 163 /* Parameter */) {
+ if (parseTreeNode && parseTreeNode.kind === 164 /* SyntaxKind.Parameter */) {
var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode);
var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined;
var text = currentSourceFile.text;
@@ -106342,13 +108017,13 @@ var ts;
});
}
ts.isInternalDeclaration = isInternalDeclaration;
- var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ |
- 2048 /* WriteClassExpressionAsTypeLiteral */ |
- 4096 /* UseTypeOfFunction */ |
- 8 /* UseStructuralFallback */ |
- 524288 /* AllowEmptyTuple */ |
- 4 /* GenerateNamesForShadowedTypeParams */ |
- 1 /* NoTruncation */;
+ var declarationEmitNodeBuilderFlags = 1024 /* NodeBuilderFlags.MultilineObjectLiterals */ |
+ 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ |
+ 4096 /* NodeBuilderFlags.UseTypeOfFunction */ |
+ 8 /* NodeBuilderFlags.UseStructuralFallback */ |
+ 524288 /* NodeBuilderFlags.AllowEmptyTuple */ |
+ 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ |
+ 1 /* NodeBuilderFlags.NoTruncation */;
/**
* Transforms a ts file into a .d.ts file
* This process requires type information, which is retrieved through the emit resolver. Because of this,
@@ -106407,7 +108082,7 @@ var ts;
}
function trackReferencedAmbientModule(node, symbol) {
// If it is visible via `// <reference types="..."/>`, then we should just use that
- var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* All */);
+ var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* SymbolFlags.All */);
if (ts.length(directives)) {
return recordTypeReferenceDirectivesIfNecessary(directives);
}
@@ -106416,7 +108091,7 @@ var ts;
refs.set(ts.getOriginalNodeId(container), container);
}
function handleSymbolAccessibilityError(symbolAccessibilityResult) {
- if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) {
+ if (symbolAccessibilityResult.accessibility === 0 /* SymbolAccessibility.Accessible */) {
// Add aliases back onto the possible imports list if they're not there so we can try them again with updated visibility info
if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) {
if (!lateMarkedStatements) {
@@ -106452,7 +108127,7 @@ var ts;
}
}
function trackSymbol(symbol, enclosingDeclaration, meaning) {
- if (symbol.flags & 262144 /* TypeParameter */)
+ if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */)
return false;
var issuedDiagnostic = handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true));
recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning));
@@ -106523,10 +108198,10 @@ var ts;
return result;
}
function transformRoot(node) {
- if (node.kind === 303 /* SourceFile */ && node.isDeclarationFile) {
+ if (node.kind === 305 /* SyntaxKind.SourceFile */ && node.isDeclarationFile) {
return node;
}
- if (node.kind === 304 /* Bundle */) {
+ if (node.kind === 306 /* SyntaxKind.Bundle */) {
isBundledEmit = true;
refs = new ts.Map();
libs = new ts.Map();
@@ -106549,18 +108224,18 @@ var ts;
resultHasExternalModuleIndicator = false; // unused in external module bundle emit (all external modules are within module blocks, therefore are known to be modules)
needsDeclare = false;
var statements = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements);
- var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([], [factory.createModifier(135 /* DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []);
+ var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([], [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []);
return newFile;
}
needsDeclare = true;
var updated = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements);
return factory.updateSourceFile(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []);
}), ts.mapDefined(node.prepends, function (prepend) {
- if (prepend.kind === 306 /* InputFiles */) {
+ if (prepend.kind === 308 /* SyntaxKind.InputFiles */) {
var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal);
hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib;
collectReferences(sourceFile, refs);
- recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives);
+ recordTypeReferenceDirectivesIfNecessary(ts.map(sourceFile.typeReferenceDirectives, function (ref) { return [ref.fileName, ref.resolutionMode]; }));
collectLibs(sourceFile, libs);
return sourceFile;
}
@@ -106615,9 +108290,10 @@ var ts;
return ts.map(ts.arrayFrom(libs.keys()), function (lib) { return ({ fileName: lib, pos: -1, end: -1 }); });
}
function getFileReferencesForUsedTypeReferences() {
- return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForTypeName) : [];
+ return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForSpecifierModeTuple) : [];
}
- function getFileReferenceForTypeName(typeName) {
+ function getFileReferenceForSpecifierModeTuple(_a) {
+ var typeName = _a[0], mode = _a[1];
// Elide type references for which we have imports
if (emittedImports) {
for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
@@ -106633,7 +108309,7 @@ var ts;
}
}
}
- return { fileName: typeName, pos: -1, end: -1 };
+ return __assign({ fileName: typeName, pos: -1, end: -1 }, (mode ? { resolutionMode: mode } : undefined));
}
function mapReferencesIntoArray(references, outputFilePath) {
return function (file) {
@@ -106653,7 +108329,7 @@ var ts;
// If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration
// via a non-relative name, emit a type reference directive to that non-relative name, rather than
// a relative path to the declaration file
- recordTypeReferenceDirectivesIfNecessary([specifier]);
+ recordTypeReferenceDirectivesIfNecessary([[specifier, /*mode*/ undefined]]);
return;
}
var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName,
@@ -106692,11 +108368,11 @@ var ts;
return ret;
}
function filterBindingPatternInitializers(name) {
- if (name.kind === 79 /* Identifier */) {
+ if (name.kind === 79 /* SyntaxKind.Identifier */) {
return name;
}
else {
- if (name.kind === 201 /* ArrayBindingPattern */) {
+ if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) {
return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement));
}
else {
@@ -106704,7 +108380,7 @@ var ts;
}
}
function visitBindingElement(elem) {
- if (elem.kind === 226 /* OmittedExpression */) {
+ if (elem.kind === 227 /* SyntaxKind.OmittedExpression */) {
return elem;
}
return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
@@ -106717,7 +108393,7 @@ var ts;
getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p);
}
var newParam = factory.updateParameterDeclaration(p,
- /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param
+ /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* SyntaxKind.QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param
ensureNoInitializer(p));
if (!suppressNewDiagnosticContexts) {
getSymbolAccessibilityDiagnostic = oldDiag;
@@ -106734,7 +108410,7 @@ var ts;
return undefined;
}
function ensureType(node, type, ignorePrivate) {
- if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* Private */)) {
+ if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) {
// Private nodes emit no types (except private parameter properties, whose parameter types are actually visible)
return;
}
@@ -106742,19 +108418,19 @@ var ts;
// Literal const declarations will have an initializer ensured rather than a type
return;
}
- var shouldUseResolverType = node.kind === 163 /* Parameter */ &&
+ var shouldUseResolverType = node.kind === 164 /* SyntaxKind.Parameter */ &&
(resolver.isRequiredInitializedParameter(node) ||
resolver.isOptionalUninitializedParameterProperty(node));
if (type && !shouldUseResolverType) {
return ts.visitNode(type, visitDeclarationSubtree);
}
if (!ts.getParseTreeNode(node)) {
- return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* AnyKeyword */);
+ return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */);
}
- if (node.kind === 172 /* SetAccessor */) {
+ if (node.kind === 173 /* SyntaxKind.SetAccessor */) {
// Set accessors with no associated type node (from it's param or get accessor return) are `any` since they are never contextually typed right now
// (The inferred type here will be void, but the old declaration emitter printed `any`, so this replicates that)
- return factory.createKeywordTypeNode(130 /* AnyKeyword */);
+ return factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */);
}
errorNameNode = node.name;
var oldDiag;
@@ -106762,12 +108438,12 @@ var ts;
oldDiag = getSymbolAccessibilityDiagnostic;
getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node);
}
- if (node.kind === 253 /* VariableDeclaration */ || node.kind === 202 /* BindingElement */) {
+ if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) {
return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
}
- if (node.kind === 163 /* Parameter */
- || node.kind === 166 /* PropertyDeclaration */
- || node.kind === 165 /* PropertySignature */) {
+ if (node.kind === 164 /* SyntaxKind.Parameter */
+ || node.kind === 167 /* SyntaxKind.PropertyDeclaration */
+ || node.kind === 166 /* SyntaxKind.PropertySignature */) {
if (!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));
@@ -106778,28 +108454,28 @@ var ts;
if (!suppressNewDiagnosticContexts) {
getSymbolAccessibilityDiagnostic = oldDiag;
}
- return returnValue || factory.createKeywordTypeNode(130 /* AnyKeyword */);
+ return returnValue || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */);
}
}
function isDeclarationAndNotVisible(node) {
node = ts.getParseTreeNode(node);
switch (node.kind) {
- case 255 /* FunctionDeclaration */:
- case 260 /* ModuleDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 256 /* ClassDeclaration */:
- case 258 /* TypeAliasDeclaration */:
- case 259 /* EnumDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
return !resolver.isDeclarationVisible(node);
// The following should be doing their own visibility checks based on filtering their members
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return !getBindingNameVisible(node);
- case 264 /* ImportEqualsDeclaration */:
- case 265 /* ImportDeclaration */:
- case 271 /* ExportDeclaration */:
- case 270 /* ExportAssignment */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
+ case 271 /* SyntaxKind.ExportAssignment */:
return false;
- case 169 /* ClassStaticBlockDeclaration */:
+ case 170 /* SyntaxKind.ClassStaticBlockDeclaration */:
return true;
}
return false;
@@ -106826,7 +108502,7 @@ var ts;
}
}
function updateParamsList(node, params, modifierMask) {
- if (ts.hasEffectiveModifier(node, 8 /* Private */)) {
+ if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) {
return undefined; // TODO: GH#18217
}
var newParams = ts.map(params, function (p) { return ensureParameter(p, modifierMask); });
@@ -106863,7 +108539,7 @@ var ts;
return factory.createNodeArray(newParams || ts.emptyArray);
}
function ensureTypeParams(node, params) {
- return ts.hasEffectiveModifier(node, 8 /* Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree);
+ return ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree);
}
function isEnclosingDeclaration(node) {
return ts.isSourceFile(node)
@@ -106889,7 +108565,7 @@ var ts;
function rewriteModuleSpecifier(parent, input) {
if (!input)
return undefined; // TODO: GH#18217
- resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 260 /* ModuleDeclaration */ && parent.kind !== 199 /* ImportType */);
+ resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && parent.kind !== 200 /* SyntaxKind.ImportType */);
if (ts.isStringLiteralLike(input)) {
if (isBundledEmit) {
var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent);
@@ -106909,7 +108585,7 @@ var ts;
function transformImportEqualsDeclaration(decl) {
if (!resolver.isDeclarationVisible(decl))
return;
- if (decl.moduleReference.kind === 276 /* ExternalModuleReference */) {
+ if (decl.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) {
// Rewrite external module names if necessary
var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl);
return factory.updateImportEqualsDeclaration(decl,
@@ -106927,37 +108603,44 @@ var ts;
if (!decl.importClause) {
// import "mod" - possibly needed for side effects? (global interface patches, module augmentations, etc)
return factory.updateImportDeclaration(decl,
- /*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier),
- /*assertClause*/ undefined);
+ /*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
}
// The `importClause` visibility corresponds to the default's visibility.
var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined;
if (!decl.importClause.namedBindings) {
// No named bindings (either namespace or list), meaning the import is just default or should be elided
return visibleDefaultBinding && factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding,
- /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), /*assertClause*/ undefined);
+ /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
}
- if (decl.importClause.namedBindings.kind === 267 /* NamespaceImport */) {
+ if (decl.importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) {
// Namespace import (optionally with visible default)
var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined;
- return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), /*assertClause*/ undefined) : undefined;
+ return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)) : undefined;
}
// Named imports (optionally with visible default)
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,
- /*decorators*/ 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),
- /*assertClause*/ undefined);
+ /*decorators*/ 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));
}
// Augmentation of export depends on import
if (resolver.isImportRequiredByAugmentation(decl)) {
return factory.updateImportDeclaration(decl,
/*decorators*/ undefined, decl.modifiers,
- /*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier),
- /*assertClause*/ undefined);
+ /*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
}
// Nothing visible
}
+ function getResolutionModeOverrideForClauseInNightly(assertClause) {
+ var mode = ts.getResolutionModeOverrideForClause(assertClause);
+ if (mode !== undefined) {
+ if (!ts.isNightly()) {
+ context.addDiagnostic(ts.createDiagnosticForNode(assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next));
+ }
+ return assertClause;
+ }
+ return undefined;
+ }
function transformAndReplaceLatePaintedStatements(statements) {
// This is a `while` loop because `handleSymbolAccessibilityError` can see additional import aliases marked as visible during
// error handling which must now be included in the output and themselves checked for errors.
@@ -107034,10 +108717,10 @@ var ts;
// We'd see a TDZ violation at runtime
var canProduceDiagnostic = ts.canProduceDiagnostics(input);
var oldWithinObjectLiteralType = suppressNewDiagnosticContexts;
- var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 181 /* TypeLiteral */ || input.kind === 194 /* MappedType */) && input.parent.kind !== 258 /* TypeAliasDeclaration */);
+ var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 182 /* SyntaxKind.TypeLiteral */ || input.kind === 195 /* SyntaxKind.MappedType */) && input.parent.kind !== 259 /* SyntaxKind.TypeAliasDeclaration */);
// Emit methods which are private as properties with no type information
if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) {
- if (ts.hasEffectiveModifier(input, 8 /* Private */)) {
+ if (ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)) {
if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input)
return; // Elide all but the first overload
return cleanup(factory.createPropertyDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined));
@@ -107055,29 +108738,29 @@ var ts;
}
if (isProcessedComponent(input)) {
switch (input.kind) {
- case 227 /* ExpressionWithTypeArguments */: {
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */: {
if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) {
checkEntityNameVisibility(input.expression, enclosingDeclaration);
}
var node = ts.visitEachChild(input, visitDeclarationSubtree, context);
return cleanup(factory.updateExpressionWithTypeArguments(node, node.expression, node.typeArguments));
}
- case 177 /* TypeReference */: {
+ case 178 /* SyntaxKind.TypeReference */: {
checkEntityNameVisibility(input.typeName, enclosingDeclaration);
var node = ts.visitEachChild(input, visitDeclarationSubtree, context);
return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments));
}
- case 174 /* ConstructSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)));
- case 170 /* Constructor */: {
+ case 171 /* SyntaxKind.Constructor */: {
// A constructor declaration may not have a type annotation
var ctor = factory.createConstructorDeclaration(
/*decorators*/ undefined,
- /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* None */),
+ /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* ModifierFlags.None */),
/*body*/ undefined);
return cleanup(ctor);
}
- case 168 /* MethodDeclaration */: {
+ case 169 /* SyntaxKind.MethodDeclaration */: {
if (ts.isPrivateIdentifier(input.name)) {
return cleanup(/*returnValue*/ undefined);
}
@@ -107087,48 +108770,48 @@ var ts;
/*body*/ undefined);
return cleanup(sig);
}
- case 171 /* GetAccessor */: {
+ case 172 /* SyntaxKind.GetAccessor */: {
if (ts.isPrivateIdentifier(input.name)) {
return cleanup(/*returnValue*/ undefined);
}
var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input));
return cleanup(factory.updateGetAccessorDeclaration(input,
- /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), ensureType(input, accessorType),
+ /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)), ensureType(input, accessorType),
/*body*/ undefined));
}
- case 172 /* SetAccessor */: {
+ case 173 /* SyntaxKind.SetAccessor */: {
if (ts.isPrivateIdentifier(input.name)) {
return cleanup(/*returnValue*/ undefined);
}
return cleanup(factory.updateSetAccessorDeclaration(input,
- /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)),
+ /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)),
/*body*/ undefined));
}
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
if (ts.isPrivateIdentifier(input.name)) {
return cleanup(/*returnValue*/ undefined);
}
return cleanup(factory.updatePropertyDeclaration(input,
/*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input)));
- case 165 /* PropertySignature */:
+ case 166 /* SyntaxKind.PropertySignature */:
if (ts.isPrivateIdentifier(input.name)) {
return cleanup(/*returnValue*/ undefined);
}
return cleanup(factory.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type)));
- case 167 /* MethodSignature */: {
+ case 168 /* SyntaxKind.MethodSignature */: {
if (ts.isPrivateIdentifier(input.name)) {
return cleanup(/*returnValue*/ undefined);
}
return cleanup(factory.updateMethodSignature(input, ensureModifiers(input), input.name, input.questionToken, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)));
}
- case 173 /* CallSignature */: {
+ case 174 /* SyntaxKind.CallSignature */: {
return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)));
}
- case 175 /* IndexSignature */: {
+ case 176 /* SyntaxKind.IndexSignature */: {
return cleanup(factory.updateIndexSignature(input,
- /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* AnyKeyword */)));
+ /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)));
}
- case 253 /* VariableDeclaration */: {
+ case 254 /* SyntaxKind.VariableDeclaration */: {
if (ts.isBindingPattern(input.name)) {
return recreateBindingPattern(input.name);
}
@@ -107136,13 +108819,13 @@ var ts;
suppressNewDiagnosticContexts = true; // Variable declaration types also suppress new diagnostic contexts, provided the contexts wouldn't be made for binding pattern types
return cleanup(factory.updateVariableDeclaration(input, input.name, /*exclamationToken*/ undefined, ensureType(input, input.type), ensureNoInitializer(input)));
}
- case 162 /* TypeParameter */: {
+ case 163 /* SyntaxKind.TypeParameter */: {
if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) {
- return cleanup(factory.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined));
+ return cleanup(factory.updateTypeParameterDeclaration(input, input.modifiers, input.name, /*constraint*/ undefined, /*defaultType*/ undefined));
}
return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context));
}
- case 188 /* ConditionalType */: {
+ case 189 /* SyntaxKind.ConditionalType */: {
// We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration
// just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type.
var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree);
@@ -107154,22 +108837,22 @@ var ts;
var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree);
return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType));
}
- case 178 /* FunctionType */: {
+ case 179 /* SyntaxKind.FunctionType */: {
return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree)));
}
- case 179 /* ConstructorType */: {
+ case 180 /* SyntaxKind.ConstructorType */: {
return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree)));
}
- case 199 /* ImportType */: {
+ case 200 /* SyntaxKind.ImportType */: {
if (!ts.isLiteralImportTypeNode(input))
return cleanup(input);
- return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf));
+ 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]));
}
}
if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) {
- ts.setEmitFlags(input, 1 /* SingleLine */);
+ ts.setEmitFlags(input, 1 /* EmitFlags.SingleLine */);
}
return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context));
function cleanup(returnValue) {
@@ -107192,7 +108875,7 @@ var ts;
}
}
function isPrivateMethodTypeParameter(node) {
- return node.parent.kind === 168 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */);
+ return node.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* ModifierFlags.Private */);
}
function visitDeclarationStatements(input) {
if (!isPreservedDeclarationStatement(input)) {
@@ -107202,7 +108885,7 @@ var ts;
if (shouldStripInternal(input))
return;
switch (input.kind) {
- case 271 /* ExportDeclaration */: {
+ case 272 /* SyntaxKind.ExportDeclaration */: {
if (ts.isSourceFile(input.parent)) {
resultHasExternalModuleIndicator = true;
}
@@ -107210,20 +108893,19 @@ var ts;
// Always visible if the parent node isn't dropped for being not visible
// Rewrite external module names if necessary
return factory.updateExportDeclaration(input,
- /*decorators*/ undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier),
- /*assertClause*/ undefined);
+ /*decorators*/ undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier), ts.getResolutionModeOverrideForClause(input.assertClause) ? input.assertClause : undefined);
}
- case 270 /* ExportAssignment */: {
+ case 271 /* SyntaxKind.ExportAssignment */: {
// Always visible if the parent node isn't dropped for being not visible
if (ts.isSourceFile(input.parent)) {
resultHasExternalModuleIndicator = true;
}
resultHasScopeMarker = true;
- if (input.expression.kind === 79 /* Identifier */) {
+ if (input.expression.kind === 79 /* SyntaxKind.Identifier */) {
return input;
}
else {
- var newId = factory.createUniqueName("_default", 16 /* Optimistic */);
+ var newId = factory.createUniqueName("_default", 16 /* GeneratedIdentifierFlags.Optimistic */);
getSymbolAccessibilityDiagnostic = function () { return ({
diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0,
errorNode: input
@@ -107231,7 +108913,9 @@ var ts;
errorFallbackNode = input;
var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined);
errorFallbackNode = undefined;
- var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */));
+ var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */));
+ preserveJsDoc(statement, input);
+ ts.removeAllComments(input);
return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)];
}
}
@@ -107242,22 +108926,26 @@ var ts;
return input;
}
function stripExportModifiers(statement) {
- if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* Default */) || !ts.canHaveModifiers(statement)) {
+ if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* ModifierFlags.Default */) || !ts.canHaveModifiers(statement)) {
// `export import` statements should remain as-is, as imports are _not_ implicitly exported in an ambient namespace
// Likewise, `export default` classes and the like and just be `default`, so we preserve their `export` modifiers, too
return statement;
}
- var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (27647 /* All */ ^ 1 /* Export */));
+ var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (125951 /* ModifierFlags.All */ ^ 1 /* ModifierFlags.Export */));
return factory.updateModifiers(statement, modifiers);
}
function transformTopLevelDeclaration(input) {
+ if (lateMarkedStatements) {
+ while (ts.orderedRemoveItem(lateMarkedStatements, input))
+ ;
+ }
if (shouldStripInternal(input))
return;
switch (input.kind) {
- case 264 /* ImportEqualsDeclaration */: {
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */: {
return transformImportEqualsDeclaration(input);
}
- case 265 /* ImportDeclaration */: {
+ case 266 /* SyntaxKind.ImportDeclaration */: {
return transformImportDeclaration(input);
}
}
@@ -107278,14 +108966,14 @@ var ts;
}
var previousNeedsDeclare = needsDeclare;
switch (input.kind) {
- case 258 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all
+ case 259 /* SyntaxKind.TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all
return cleanup(factory.updateTypeAliasDeclaration(input,
/*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
- case 257 /* InterfaceDeclaration */: {
+ case 258 /* SyntaxKind.InterfaceDeclaration */: {
return cleanup(factory.updateInterfaceDeclaration(input,
/*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree)));
}
- case 255 /* FunctionDeclaration */: {
+ case 256 /* SyntaxKind.FunctionDeclaration */: {
// Generators lose their generator-ness, excepting their return type
var clean = cleanup(factory.updateFunctionDeclaration(input,
/*decorators*/ undefined, ensureModifiers(input),
@@ -107294,7 +108982,7 @@ var ts;
if (clean && resolver.isExpandoFunctionDeclaration(input) && shouldEmitFunctionProperties(input)) {
var props = resolver.getPropertiesOfContainerFunction(input);
// Use parseNodeFactory so it is usable as an enclosing declaration
- var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* Namespace */);
+ var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */);
ts.setParent(fakespace_1, enclosingDeclaration);
fakespace_1.locals = ts.createSymbolTable(props);
fakespace_1.symbol = props[0].parent;
@@ -107313,10 +109001,10 @@ var ts;
exportMappings_1.push([name, nameStr]);
}
var varDecl = factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, /*initializer*/ undefined);
- return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl]));
+ return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* SyntaxKind.ExportKeyword */)], factory.createVariableDeclarationList([varDecl]));
});
if (!exportMappings_1.length) {
- declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* None */); });
+ declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* ModifierFlags.None */); });
}
else {
declarations.push(factory.createExportDeclaration(
@@ -107327,11 +109015,11 @@ var ts;
return factory.createExportSpecifier(/*isTypeOnly*/ false, gen, exp);
}))));
}
- var namespaceDecl = factory.createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* Namespace */);
- if (!ts.hasEffectiveModifier(clean, 512 /* Default */)) {
+ var namespaceDecl = factory.createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* NodeFlags.Namespace */);
+ if (!ts.hasEffectiveModifier(clean, 512 /* ModifierFlags.Default */)) {
return [clean, namespaceDecl];
}
- var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ExportDefault */) | 2 /* Ambient */);
+ var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ModifierFlags.ExportDefault */) | 2 /* ModifierFlags.Ambient */);
var cleanDeclaration = factory.updateFunctionDeclaration(clean,
/*decorators*/ undefined, modifiers,
/*asteriskToken*/ undefined, clean.name, clean.typeParameters, clean.parameters, clean.type,
@@ -107352,17 +109040,17 @@ var ts;
return clean;
}
}
- case 260 /* ModuleDeclaration */: {
+ case 261 /* SyntaxKind.ModuleDeclaration */: {
needsDeclare = false;
var inner = input.body;
- if (inner && inner.kind === 261 /* ModuleBlock */) {
+ if (inner && inner.kind === 262 /* SyntaxKind.ModuleBlock */) {
var oldNeedsScopeFix = needsScopeFixMarker;
var oldHasScopeFix = resultHasScopeMarker;
resultHasScopeMarker = false;
needsScopeFixMarker = false;
var statements = ts.visitNodes(inner.statements, visitDeclarationStatements);
var lateStatements = transformAndReplaceLatePaintedStatements(statements);
- if (input.flags & 8388608 /* Ambient */) {
+ if (input.flags & 16777216 /* NodeFlags.Ambient */) {
needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates"
}
// With the final list of statements, there are 3 possibilities:
@@ -107398,7 +109086,7 @@ var ts;
/*decorators*/ undefined, mods, input.name, body));
}
}
- case 256 /* ClassDeclaration */: {
+ case 257 /* SyntaxKind.ClassDeclaration */: {
errorNameNode = input.name;
errorFallbackNode = input;
var modifiers = factory.createNodeArray(ensureModifiers(input));
@@ -107408,10 +109096,10 @@ var ts;
if (ctor) {
var oldDiag_1 = getSymbolAccessibilityDiagnostic;
parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) {
- if (!ts.hasSyntacticModifier(param, 16476 /* ParameterPropertyModifier */) || shouldStripInternal(param))
+ if (!ts.hasSyntacticModifier(param, 16476 /* ModifierFlags.ParameterPropertyModifier */) || shouldStripInternal(param))
return;
getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param);
- if (param.name.kind === 79 /* Identifier */) {
+ if (param.name.kind === 79 /* SyntaxKind.Identifier */) {
return preserveJsDoc(factory.createPropertyDeclaration(
/*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param);
}
@@ -107453,26 +109141,26 @@ var ts;
var memberNodes = ts.concatenate(ts.concatenate(privateIdentifier, parameterProperties), ts.visitNodes(input.members, visitDeclarationSubtree));
var members = factory.createNodeArray(memberNodes);
var extendsClause_1 = ts.getEffectiveBaseTypeNode(input);
- if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* NullKeyword */) {
+ if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* SyntaxKind.NullKeyword */) {
// We must add a temporary declaration for the extends clause expression
var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default";
- var newId_1 = factory.createUniqueName("".concat(oldId, "_base"), 16 /* Optimistic */);
+ var newId_1 = factory.createUniqueName("".concat(oldId, "_base"), 16 /* GeneratedIdentifierFlags.Optimistic */);
getSymbolAccessibilityDiagnostic = function () { return ({
diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1,
errorNode: extendsClause_1,
typeName: input.name
}); };
var varDecl = factory.createVariableDeclaration(newId_1, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined);
- var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */));
+ var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */));
var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) {
- if (clause.token === 94 /* ExtendsKeyword */) {
+ if (clause.token === 94 /* SyntaxKind.ExtendsKeyword */) {
var oldDiag_2 = getSymbolAccessibilityDiagnostic;
getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]);
var newClause = factory.updateHeritageClause(clause, ts.map(clause.types, function (t) { return factory.updateExpressionWithTypeArguments(t, newId_1, ts.visitNodes(t.typeArguments, visitDeclarationSubtree)); }));
getSymbolAccessibilityDiagnostic = oldDiag_2;
return newClause;
}
- return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* NullKeyword */; })), visitDeclarationSubtree));
+ return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* SyntaxKind.NullKeyword */; })), visitDeclarationSubtree));
}));
return [statement, cleanup(factory.updateClassDeclaration(input,
/*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217
@@ -107483,10 +109171,10 @@ var ts;
/*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members));
}
}
- case 236 /* VariableStatement */: {
+ case 237 /* SyntaxKind.VariableStatement */: {
return cleanup(transformVariableStatement(input));
}
- case 259 /* EnumDeclaration */: {
+ case 260 /* SyntaxKind.EnumDeclaration */: {
return cleanup(factory.updateEnumDeclaration(input, /*decorators*/ undefined, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) {
if (shouldStripInternal(m))
return;
@@ -107505,7 +109193,7 @@ var ts;
if (canProdiceDiagnostic) {
getSymbolAccessibilityDiagnostic = oldDiag;
}
- if (input.kind === 260 /* ModuleDeclaration */) {
+ if (input.kind === 261 /* SyntaxKind.ModuleDeclaration */) {
needsDeclare = previousNeedsDeclare;
}
if (node === input) {
@@ -107528,7 +109216,7 @@ var ts;
return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); }));
}
function recreateBindingElement(e) {
- if (e.kind === 226 /* OmittedExpression */) {
+ if (e.kind === 227 /* SyntaxKind.OmittedExpression */) {
return;
}
if (e.name) {
@@ -107576,12 +109264,12 @@ var ts;
return factory.createModifiersFromModifierFlags(newFlags);
}
function ensureModifierFlags(node) {
- var mask = 27647 /* All */ ^ (4 /* Public */ | 256 /* Async */ | 16384 /* Override */); // No async and override modifiers in declaration files
- var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */;
- var parentIsFile = node.parent.kind === 303 /* SourceFile */;
+ var mask = 125951 /* ModifierFlags.All */ ^ (4 /* ModifierFlags.Public */ | 256 /* ModifierFlags.Async */ | 16384 /* ModifierFlags.Override */); // No async and override modifiers in declaration files
+ var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* ModifierFlags.Ambient */ : 0 /* ModifierFlags.None */;
+ var parentIsFile = node.parent.kind === 305 /* SyntaxKind.SourceFile */;
if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) {
- mask ^= 2 /* Ambient */;
- additions = 0 /* None */;
+ mask ^= 2 /* ModifierFlags.Ambient */;
+ additions = 0 /* ModifierFlags.None */;
}
return maskModifierFlags(node, mask, additions);
}
@@ -107601,13 +109289,13 @@ var ts;
}
function transformHeritageClauses(nodes) {
return factory.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) {
- return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* ExtendsKeyword */ && t.expression.kind === 104 /* NullKeyword */);
+ return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* SyntaxKind.ExtendsKeyword */ && t.expression.kind === 104 /* SyntaxKind.NullKeyword */);
})), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; }));
}
}
ts.transformDeclarations = transformDeclarations;
function isAlwaysType(node) {
- if (node.kind === 257 /* InterfaceDeclaration */) {
+ if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) {
return true;
}
return false;
@@ -107617,22 +109305,22 @@ var ts;
return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions));
}
function maskModifierFlags(node, modifierMask, modifierAdditions) {
- if (modifierMask === void 0) { modifierMask = 27647 /* All */ ^ 4 /* Public */; }
- if (modifierAdditions === void 0) { modifierAdditions = 0 /* None */; }
+ if (modifierMask === void 0) { modifierMask = 125951 /* ModifierFlags.All */ ^ 4 /* ModifierFlags.Public */; }
+ if (modifierAdditions === void 0) { modifierAdditions = 0 /* ModifierFlags.None */; }
var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions;
- if (flags & 512 /* Default */ && !(flags & 1 /* Export */)) {
+ if (flags & 512 /* ModifierFlags.Default */ && !(flags & 1 /* ModifierFlags.Export */)) {
// A non-exported default is a nonsequitor - we usually try to remove all export modifiers
// from statements in ambient declarations; but a default export must retain its export modifier to be syntactically valid
- flags ^= 1 /* Export */;
+ flags ^= 1 /* ModifierFlags.Export */;
}
- if (flags & 512 /* Default */ && flags & 2 /* Ambient */) {
- flags ^= 2 /* Ambient */; // `declare` is never required alongside `default` (and would be an error if printed)
+ if (flags & 512 /* ModifierFlags.Default */ && flags & 2 /* ModifierFlags.Ambient */) {
+ flags ^= 2 /* ModifierFlags.Ambient */; // `declare` is never required alongside `default` (and would be an error if printed)
}
return flags;
}
function getTypeAnnotationFromAccessor(accessor) {
if (accessor) {
- return accessor.kind === 171 /* GetAccessor */
+ return accessor.kind === 172 /* SyntaxKind.GetAccessor */
? accessor.type // Getter - return type
: accessor.parameters.length > 0
? accessor.parameters[0].type // Setter parameter type
@@ -107641,52 +109329,52 @@ var ts;
}
function canHaveLiteralInitializer(node) {
switch (node.kind) {
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
- return !ts.hasEffectiveModifier(node, 8 /* Private */);
- case 163 /* Parameter */:
- case 253 /* VariableDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ return !ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */);
+ case 164 /* SyntaxKind.Parameter */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return true;
}
return false;
}
function isPreservedDeclarationStatement(node) {
switch (node.kind) {
- case 255 /* FunctionDeclaration */:
- case 260 /* ModuleDeclaration */:
- case 264 /* ImportEqualsDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 256 /* ClassDeclaration */:
- case 258 /* TypeAliasDeclaration */:
- case 259 /* EnumDeclaration */:
- case 236 /* VariableStatement */:
- case 265 /* ImportDeclaration */:
- case 271 /* ExportDeclaration */:
- case 270 /* ExportAssignment */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 237 /* SyntaxKind.VariableStatement */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
+ case 271 /* SyntaxKind.ExportAssignment */:
return true;
}
return false;
}
function isProcessedComponent(node) {
switch (node.kind) {
- case 174 /* ConstructSignature */:
- case 170 /* Constructor */:
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
- case 167 /* MethodSignature */:
- case 173 /* CallSignature */:
- case 175 /* IndexSignature */:
- case 253 /* VariableDeclaration */:
- case 162 /* TypeParameter */:
- case 227 /* ExpressionWithTypeArguments */:
- case 177 /* TypeReference */:
- case 188 /* ConditionalType */:
- case 178 /* FunctionType */:
- case 179 /* ConstructorType */:
- case 199 /* ImportType */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 176 /* SyntaxKind.IndexSignature */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
+ case 163 /* SyntaxKind.TypeParameter */:
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
+ case 178 /* SyntaxKind.TypeReference */:
+ case 189 /* SyntaxKind.ConditionalType */:
+ case 179 /* SyntaxKind.FunctionType */:
+ case 180 /* SyntaxKind.ConstructorType */:
+ case 200 /* SyntaxKind.ImportType */:
return true;
}
return false;
@@ -107704,7 +109392,7 @@ var ts;
return ts.transformECMAScriptModule;
case ts.ModuleKind.System:
return ts.transformSystemModule;
- case ts.ModuleKind.Node12:
+ case ts.ModuleKind.Node16:
case ts.ModuleKind.NodeNext:
return ts.transformNodeModule;
default:
@@ -107743,35 +109431,35 @@ var ts;
if (ts.getJSXTransformEnabled(compilerOptions)) {
transformers.push(ts.transformJsx);
}
- if (languageVersion < 99 /* ESNext */) {
+ if (languageVersion < 99 /* ScriptTarget.ESNext */) {
transformers.push(ts.transformESNext);
}
- if (languageVersion < 8 /* ES2021 */) {
+ if (languageVersion < 8 /* ScriptTarget.ES2021 */) {
transformers.push(ts.transformES2021);
}
- if (languageVersion < 7 /* ES2020 */) {
+ if (languageVersion < 7 /* ScriptTarget.ES2020 */) {
transformers.push(ts.transformES2020);
}
- if (languageVersion < 6 /* ES2019 */) {
+ if (languageVersion < 6 /* ScriptTarget.ES2019 */) {
transformers.push(ts.transformES2019);
}
- if (languageVersion < 5 /* ES2018 */) {
+ if (languageVersion < 5 /* ScriptTarget.ES2018 */) {
transformers.push(ts.transformES2018);
}
- if (languageVersion < 4 /* ES2017 */) {
+ if (languageVersion < 4 /* ScriptTarget.ES2017 */) {
transformers.push(ts.transformES2017);
}
- if (languageVersion < 3 /* ES2016 */) {
+ if (languageVersion < 3 /* ScriptTarget.ES2016 */) {
transformers.push(ts.transformES2016);
}
- if (languageVersion < 2 /* ES2015 */) {
+ if (languageVersion < 2 /* ScriptTarget.ES2015 */) {
transformers.push(ts.transformES2015);
transformers.push(ts.transformGenerators);
}
transformers.push(getModuleTransformer(moduleKind));
// The ES5 transformer is last so that it can substitute expressions like `exports.default`
// for ES3.
- if (languageVersion < 1 /* ES5 */) {
+ if (languageVersion < 1 /* ScriptTarget.ES5 */) {
transformers.push(ts.transformES5);
}
ts.addRange(transformers, customTransformers && ts.map(customTransformers.after, wrapScriptTransformerFactory));
@@ -107825,11 +109513,11 @@ var ts;
* @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files.
*/
function transformNodes(resolver, host, factory, options, nodes, transformers, allowDtsFiles) {
- var enabledSyntaxKindFeatures = new Array(353 /* Count */);
+ var enabledSyntaxKindFeatures = new Array(355 /* SyntaxKind.Count */);
var lexicalEnvironmentVariableDeclarations;
var lexicalEnvironmentFunctionDeclarations;
var lexicalEnvironmentStatements;
- var lexicalEnvironmentFlags = 0 /* None */;
+ var lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */;
var lexicalEnvironmentVariableDeclarationsStack = [];
var lexicalEnvironmentFunctionDeclarationsStack = [];
var lexicalEnvironmentStatementsStack = [];
@@ -107842,7 +109530,7 @@ var ts;
var emitHelpers;
var onSubstituteNode = noEmitSubstitution;
var onEmitNode = noEmitNotification;
- var state = 0 /* Uninitialized */;
+ var state = 0 /* TransformationState.Uninitialized */;
var diagnostics = [];
// The transformation context is provided to each transformer as part of transformer
// initialization.
@@ -107872,13 +109560,13 @@ var ts;
isEmitNotificationEnabled: isEmitNotificationEnabled,
get onSubstituteNode() { return onSubstituteNode; },
set onSubstituteNode(value) {
- ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed.");
+ ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed.");
ts.Debug.assert(value !== undefined, "Value must not be 'undefined'");
onSubstituteNode = value;
},
get onEmitNode() { return onEmitNode; },
set onEmitNode(value) {
- ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed.");
+ ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed.");
ts.Debug.assert(value !== undefined, "Value must not be 'undefined'");
onEmitNode = value;
},
@@ -107902,17 +109590,17 @@ var ts;
return node;
};
// prevent modification of transformation hooks.
- state = 1 /* Initialized */;
+ state = 1 /* TransformationState.Initialized */;
// Transform each node.
var transformed = [];
for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) {
var node = nodes_3[_a];
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 303 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end });
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "transformNodes", node.kind === 305 /* SyntaxKind.SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end });
transformed.push((allowDtsFiles ? transformation : transformRoot)(node));
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
}
// prevent modification of the lexical environment.
- state = 2 /* Completed */;
+ state = 2 /* TransformationState.Completed */;
ts.performance.mark("afterTransform");
ts.performance.measure("transformTime", "beforeTransform", "afterTransform");
return {
@@ -107930,15 +109618,15 @@ var ts;
* Enables expression substitutions in the pretty printer for the provided SyntaxKind.
*/
function enableSubstitution(kind) {
- ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed.");
- enabledSyntaxKindFeatures[kind] |= 1 /* Substitution */;
+ ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed.");
+ enabledSyntaxKindFeatures[kind] |= 1 /* SyntaxKindFeatureFlags.Substitution */;
}
/**
* Determines whether expression substitutions are enabled for the provided node.
*/
function isSubstitutionEnabled(node) {
- return (enabledSyntaxKindFeatures[node.kind] & 1 /* Substitution */) !== 0
- && (ts.getEmitFlags(node) & 4 /* NoSubstitution */) === 0;
+ return (enabledSyntaxKindFeatures[node.kind] & 1 /* SyntaxKindFeatureFlags.Substitution */) !== 0
+ && (ts.getEmitFlags(node) & 4 /* EmitFlags.NoSubstitution */) === 0;
}
/**
* Emits a node with possible substitution.
@@ -107948,23 +109636,23 @@ var ts;
* @param emitCallback The callback used to emit the node or its substitute.
*/
function substituteNode(hint, node) {
- ts.Debug.assert(state < 3 /* Disposed */, "Cannot substitute a node after the result is disposed.");
+ ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot substitute a node after the result is disposed.");
return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node;
}
/**
* Enables before/after emit notifications in the pretty printer for the provided SyntaxKind.
*/
function enableEmitNotification(kind) {
- ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed.");
- enabledSyntaxKindFeatures[kind] |= 2 /* EmitNotifications */;
+ ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed.");
+ enabledSyntaxKindFeatures[kind] |= 2 /* SyntaxKindFeatureFlags.EmitNotifications */;
}
/**
* Determines whether before/after emit notifications should be raised in the pretty
* printer when it emits a node.
*/
function isEmitNotificationEnabled(node) {
- return (enabledSyntaxKindFeatures[node.kind] & 2 /* EmitNotifications */) !== 0
- || (ts.getEmitFlags(node) & 2 /* AdviseOnEmitNode */) !== 0;
+ return (enabledSyntaxKindFeatures[node.kind] & 2 /* SyntaxKindFeatureFlags.EmitNotifications */) !== 0
+ || (ts.getEmitFlags(node) & 2 /* EmitFlags.AdviseOnEmitNode */) !== 0;
}
/**
* Emits a node with possible emit notification.
@@ -107974,7 +109662,7 @@ var ts;
* @param emitCallback The callback used to emit the node.
*/
function emitNodeWithNotification(hint, node, emitCallback) {
- ts.Debug.assert(state < 3 /* Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed.");
+ ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed.");
if (node) {
// TODO: Remove check and unconditionally use onEmitNode when API is breakingly changed
// (see https://github.com/microsoft/TypeScript/pull/36248/files/5062623f39120171b98870c71344b3242eb03d23#r369766739)
@@ -107990,26 +109678,26 @@ var ts;
* Records a hoisted variable declaration for the provided name within a lexical environment.
*/
function hoistVariableDeclaration(name) {
- ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization.");
- ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed.");
- var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* NoNestedSourceMaps */);
+ ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization.");
+ ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed.");
+ var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* EmitFlags.NoNestedSourceMaps */);
if (!lexicalEnvironmentVariableDeclarations) {
lexicalEnvironmentVariableDeclarations = [decl];
}
else {
lexicalEnvironmentVariableDeclarations.push(decl);
}
- if (lexicalEnvironmentFlags & 1 /* InParameters */) {
- lexicalEnvironmentFlags |= 2 /* VariablesHoistedInParameters */;
+ if (lexicalEnvironmentFlags & 1 /* LexicalEnvironmentFlags.InParameters */) {
+ lexicalEnvironmentFlags |= 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */;
}
}
/**
* Records a hoisted function declaration within a lexical environment.
*/
function hoistFunctionDeclaration(func) {
- ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization.");
- ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed.");
- ts.setEmitFlags(func, 1048576 /* CustomPrologue */);
+ ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization.");
+ ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed.");
+ ts.setEmitFlags(func, 1048576 /* EmitFlags.CustomPrologue */);
if (!lexicalEnvironmentFunctionDeclarations) {
lexicalEnvironmentFunctionDeclarations = [func];
}
@@ -108021,9 +109709,9 @@ var ts;
* Adds an initialization statement to the top of the lexical environment.
*/
function addInitializationStatement(node) {
- ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization.");
- ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed.");
- ts.setEmitFlags(node, 1048576 /* CustomPrologue */);
+ ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization.");
+ ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed.");
+ ts.setEmitFlags(node, 1048576 /* EmitFlags.CustomPrologue */);
if (!lexicalEnvironmentStatements) {
lexicalEnvironmentStatements = [node];
}
@@ -108036,8 +109724,8 @@ var ts;
* are pushed onto a stack, and the related storage variables are reset.
*/
function startLexicalEnvironment() {
- ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization.");
- ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed.");
+ ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization.");
+ ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed.");
ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended.");
// Save the current lexical environment. Rather than resizing the array we adjust the
// stack size variable. This allows us to reuse existing array slots we've
@@ -108051,19 +109739,19 @@ var ts;
lexicalEnvironmentVariableDeclarations = undefined;
lexicalEnvironmentFunctionDeclarations = undefined;
lexicalEnvironmentStatements = undefined;
- lexicalEnvironmentFlags = 0 /* None */;
+ lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */;
}
/** Suspends the current lexical environment, usually after visiting a parameter list. */
function suspendLexicalEnvironment() {
- ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization.");
- ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed.");
+ ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization.");
+ ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed.");
ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended.");
lexicalEnvironmentSuspended = true;
}
/** Resumes a suspended lexical environment, usually before visiting a function body. */
function resumeLexicalEnvironment() {
- ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization.");
- ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed.");
+ ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization.");
+ ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed.");
ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended.");
lexicalEnvironmentSuspended = false;
}
@@ -108072,8 +109760,8 @@ var ts;
* any hoisted declarations added in this environment are returned.
*/
function endLexicalEnvironment() {
- ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization.");
- ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed.");
+ ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization.");
+ ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed.");
ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended.");
var statements;
if (lexicalEnvironmentVariableDeclarations ||
@@ -108085,7 +109773,7 @@ var ts;
if (lexicalEnvironmentVariableDeclarations) {
var statement = factory.createVariableStatement(
/*modifiers*/ undefined, factory.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations));
- ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
+ ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */);
if (!statements) {
statements = [statement];
}
@@ -108128,8 +109816,8 @@ var ts;
* Starts a block scope. Any existing block hoisted variables are pushed onto the stack and the related storage variables are reset.
*/
function startBlockScope() {
- ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot start a block scope during initialization.");
- ts.Debug.assert(state < 2 /* Completed */, "Cannot start a block scope after transformation has completed.");
+ ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot start a block scope during initialization.");
+ ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot start a block scope after transformation has completed.");
blockScopedVariableDeclarationsStack[blockScopeStackOffset] = blockScopedVariableDeclarations;
blockScopeStackOffset++;
blockScopedVariableDeclarations = undefined;
@@ -108138,12 +109826,12 @@ var ts;
* Ends a block scope. The previous set of block hoisted variables are restored. Any hoisted declarations are returned.
*/
function endBlockScope() {
- ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot end a block scope during initialization.");
- ts.Debug.assert(state < 2 /* Completed */, "Cannot end a block scope after transformation has completed.");
+ ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot end a block scope during initialization.");
+ ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot end a block scope after transformation has completed.");
var statements = ts.some(blockScopedVariableDeclarations) ?
[
factory.createVariableStatement(
- /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* Let */))
+ /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* NodeFlags.Let */))
] : undefined;
blockScopeStackOffset--;
blockScopedVariableDeclarations = blockScopedVariableDeclarationsStack[blockScopeStackOffset];
@@ -108157,8 +109845,8 @@ var ts;
(blockScopedVariableDeclarations || (blockScopedVariableDeclarations = [])).push(name);
}
function requestEmitHelper(helper) {
- ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization.");
- ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed.");
+ ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization.");
+ ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed.");
ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper.");
if (helper.dependencies) {
for (var _i = 0, _a = helper.dependencies; _i < _a.length; _i++) {
@@ -108169,14 +109857,14 @@ var ts;
emitHelpers = ts.append(emitHelpers, helper);
}
function readEmitHelpers() {
- ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization.");
- ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed.");
+ ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization.");
+ ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed.");
var helpers = emitHelpers;
emitHelpers = undefined;
return helpers;
}
function dispose() {
- if (state < 3 /* Disposed */) {
+ if (state < 3 /* TransformationState.Disposed */) {
// Clean up emit nodes on parse tree
for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) {
var node = nodes_4[_i];
@@ -108191,7 +109879,7 @@ var ts;
onEmitNode = undefined;
emitHelpers = undefined;
// Prevent further use of the transformation result.
- state = 3 /* Disposed */;
+ state = 3 /* TransformationState.Disposed */;
}
}
}
@@ -108230,7 +109918,7 @@ var ts;
var brackets = createBracketsMap();
/*@internal*/
function isBuildInfoFile(file) {
- return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */);
+ return ts.fileExtensionIs(file, ".tsbuildinfo" /* Extension.TsBuildInfo */);
}
ts.isBuildInfoFile = isBuildInfoFile;
/*@internal*/
@@ -108296,7 +109984,7 @@ var ts;
ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) :
configFileExtensionLess;
}
- return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */;
+ return buildInfoExtensionLess + ".tsbuildinfo" /* Extension.TsBuildInfo */;
}
ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath;
/*@internal*/
@@ -108304,7 +109992,7 @@ var ts;
var outPath = ts.outFile(options);
var jsFilePath = options.emitDeclarationOnly ? undefined : outPath;
var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options);
- var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined;
+ var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */ : undefined;
var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined;
var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath };
@@ -108313,7 +110001,7 @@ var ts;
/*@internal*/
function getOutputPathsFor(sourceFile, host, forceDtsPaths) {
var options = host.getCompilerOptions();
- if (sourceFile.kind === 304 /* Bundle */) {
+ if (sourceFile.kind === 306 /* SyntaxKind.Bundle */) {
return getOutputPathsForBundle(options, forceDtsPaths);
}
else {
@@ -108321,7 +110009,7 @@ var ts;
var isJsonFile = ts.isJsonSourceFile(sourceFile);
// If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it
var isJsonEmittedToSameLocation = isJsonFile &&
- ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */;
+ ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */;
var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath;
var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options);
var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined;
@@ -108335,11 +110023,11 @@ var ts;
}
/* @internal */
function getOutputExtension(fileName, options) {
- return ts.fileExtensionIs(fileName, ".json" /* Json */) ? ".json" /* Json */ :
- options.jsx === 1 /* Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Jsx */, ".tsx" /* Tsx */]) ? ".jsx" /* Jsx */ :
- ts.fileExtensionIsOneOf(fileName, [".mts" /* Mts */, ".mjs" /* Mjs */]) ? ".mjs" /* Mjs */ :
- ts.fileExtensionIsOneOf(fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]) ? ".cjs" /* Cjs */ :
- ".js" /* Js */;
+ return ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) ? ".json" /* Extension.Json */ :
+ options.jsx === 1 /* JsxEmit.Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Extension.Jsx */, ".tsx" /* Extension.Tsx */]) ? ".jsx" /* Extension.Jsx */ :
+ ts.fileExtensionIsOneOf(fileName, [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ".mjs" /* Extension.Mjs */ :
+ ts.fileExtensionIsOneOf(fileName, [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ".cjs" /* Extension.Cjs */ :
+ ".js" /* Extension.Js */;
}
ts.getOutputExtension = getOutputExtension;
function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir, getCommonSourceDirectory) {
@@ -108355,9 +110043,9 @@ var ts;
function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) {
if (configFile.options.emitDeclarationOnly)
return undefined;
- var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */);
+ var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */);
var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), getOutputExtension(inputFileName, configFile.options));
- return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ?
+ return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* Comparison.EqualTo */ ?
outputFileName :
undefined;
}
@@ -108382,11 +110070,11 @@ var ts;
addOutput(buildInfoPath);
}
function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory) {
- if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */))
+ if (ts.isDeclarationFileName(inputFileName))
return;
var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
addOutput(js);
- if (ts.fileExtensionIs(inputFileName, ".json" /* Json */))
+ if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */))
return;
if (js && configFile.options.sourceMap) {
addOutput("".concat(js, ".map"));
@@ -108427,7 +110115,7 @@ var ts;
/*@internal*/
function getCommonSourceDirectoryOfConfig(_a, ignoreCase) {
var options = _a.options, fileNames = _a.fileNames;
- return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.fileExtensionIs(file, ".d.ts" /* Dts */); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase));
+ return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.isDeclarationFileName(file); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase));
}
ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig;
/*@internal*/
@@ -108469,12 +110157,12 @@ var ts;
var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); });
for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) {
var inputFileName = _b[_a];
- if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */))
+ if (ts.isDeclarationFileName(inputFileName))
continue;
var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
if (jsFilePath)
return jsFilePath;
- if (ts.fileExtensionIs(inputFileName, ".json" /* Json */))
+ if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */))
continue;
if (ts.getEmitDeclarations(configFile.options)) {
return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
@@ -108521,13 +110209,13 @@ var ts;
sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); })
};
}
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath });
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath });
emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo);
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath });
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath });
emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo);
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath });
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath });
emitBuildInfo(bundleBuildInfo, buildInfoPath);
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
if (!emitSkipped && emittedFilesList) {
@@ -108662,7 +110350,7 @@ var ts;
extendedDiagnostics: compilerOptions.extendedDiagnostics,
// Explicitly do not passthru either `inline` option
});
- if (forceDtsEmit && declarationTransform.transformed[0].kind === 303 /* SourceFile */) {
+ if (forceDtsEmit && declarationTransform.transformed[0].kind === 305 /* SyntaxKind.SourceFile */) {
var sourceFile = declarationTransform.transformed[0];
exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit;
}
@@ -108673,7 +110361,7 @@ var ts;
}
function collectLinkedAliases(node) {
if (ts.isExportAssignment(node)) {
- if (node.expression.kind === 79 /* Identifier */) {
+ if (node.expression.kind === 79 /* SyntaxKind.Identifier */) {
resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true);
}
return;
@@ -108685,8 +110373,8 @@ var ts;
ts.forEachChild(node, collectLinkedAliases);
}
function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) {
- var bundle = sourceFileOrBundle.kind === 304 /* Bundle */ ? sourceFileOrBundle : undefined;
- var sourceFile = sourceFileOrBundle.kind === 303 /* SourceFile */ ? sourceFileOrBundle : undefined;
+ var bundle = sourceFileOrBundle.kind === 306 /* SyntaxKind.Bundle */ ? sourceFileOrBundle : undefined;
+ var sourceFile = sourceFileOrBundle.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileOrBundle : undefined;
var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile];
var sourceMapGenerator;
if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) {
@@ -108698,6 +110386,7 @@ var ts;
else {
printer.writeFile(sourceFile, writer, sourceMapGenerator);
}
+ var sourceMapUrlPos;
if (sourceMapGenerator) {
if (sourceMapDataList) {
sourceMapDataList.push({
@@ -108709,6 +110398,7 @@ var ts;
if (sourceMappingURL) {
if (!writer.isAtStartOfLine())
writer.rawWrite(newLine);
+ sourceMapUrlPos = writer.getTextPos();
writer.writeComment("//# ".concat("sourceMappingURL", "=").concat(sourceMappingURL)); // Tools can sometimes see this line as a source mapping url comment
}
// Write the source map
@@ -108721,13 +110411,13 @@ var ts;
writer.writeLine();
}
// Write the output file
- ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles);
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
// Reset state
writer.clear();
}
function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) {
return (mapOptions.sourceMap || mapOptions.inlineSourceMap)
- && (sourceFileOrBundle.kind !== 303 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */));
+ && (sourceFileOrBundle.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Extension.Json */));
}
function getSourceRoot(mapOptions) {
// Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the
@@ -108851,8 +110541,8 @@ var ts;
ts.setParent(literal, statement);
return statement;
});
- var eofToken = ts.factory.createToken(1 /* EndOfFileToken */);
- var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* None */);
+ var eofToken = ts.factory.createToken(1 /* SyntaxKind.EndOfFileToken */);
+ var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* NodeFlags.None */);
sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames());
sourceFile.text = (_a = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text) !== null && _a !== void 0 ? _a : "";
ts.setTextRangePosWidth(sourceFile, 0, (_b = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text.length) !== null && _b !== void 0 ? _b : 0);
@@ -108990,7 +110680,7 @@ var ts;
var relativeToBuildInfo = bundleFileInfo ? ts.Debug.checkDefined(printerOptions.relativeToBuildInfo) : undefined;
var recordInternalSection = printerOptions.recordInternalSection;
var sourceFileTextPos = 0;
- var sourceFileTextKind = "text" /* Text */;
+ var sourceFileTextKind = "text" /* BundleFileSectionKind.Text */;
// Source Maps
var sourceMapsDisabled = true;
var sourceMapGenerator;
@@ -109010,6 +110700,9 @@ var ts;
var currentParenthesizerRule;
var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit;
var parenthesizer = ts.factory.parenthesizer;
+ var typeArgumentParenthesizerRuleSelector = {
+ select: function (index) { return index === 0 ? parenthesizer.parenthesizeLeadingTypeArgument : undefined; }
+ };
var emitBinaryExpression = createEmitBinaryExpression();
reset();
return {
@@ -109027,20 +110720,20 @@ var ts;
};
function printNode(hint, node, sourceFile) {
switch (hint) {
- case 0 /* SourceFile */:
+ case 0 /* EmitHint.SourceFile */:
ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node.");
break;
- case 2 /* IdentifierName */:
+ case 2 /* EmitHint.IdentifierName */:
ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node.");
break;
- case 1 /* Expression */:
+ case 1 /* EmitHint.Expression */:
ts.Debug.assert(ts.isExpression(node), "Expected an Expression node.");
break;
}
switch (node.kind) {
- case 303 /* SourceFile */: return printFile(node);
- case 304 /* Bundle */: return printBundle(node);
- case 305 /* UnparsedSource */: return printUnparsedSource(node);
+ case 305 /* SyntaxKind.SourceFile */: return printFile(node);
+ case 306 /* SyntaxKind.Bundle */: return printBundle(node);
+ case 307 /* SyntaxKind.UnparsedSource */: return printUnparsedSource(node);
}
writeNode(hint, node, sourceFile, beginPrint());
return endPrint();
@@ -109096,11 +110789,11 @@ var ts;
currentSourceFile &&
(ts.isDeclaration(node) || ts.isVariableStatement(node)) &&
ts.isInternalDeclaration(node, currentSourceFile) &&
- sourceFileTextKind !== "internal" /* Internal */) {
+ sourceFileTextKind !== "internal" /* BundleFileSectionKind.Internal */) {
var prevSourceFileTextKind = sourceFileTextKind;
recordBundleFileTextLikeSection(writer.getTextPos());
sourceFileTextPos = getTextPosWithWriteLine();
- sourceFileTextKind = "internal" /* Internal */;
+ sourceFileTextKind = "internal" /* BundleFileSectionKind.Internal */;
return prevSourceFileTextKind;
}
return undefined;
@@ -109135,7 +110828,7 @@ var ts;
var savedSections = bundleFileInfo && bundleFileInfo.sections;
if (savedSections)
bundleFileInfo.sections = [];
- print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined);
+ print(4 /* EmitHint.Unspecified */, prepend, /*sourceFile*/ undefined);
if (bundleFileInfo) {
var newSections = bundleFileInfo.sections;
bundleFileInfo.sections = savedSections;
@@ -109146,7 +110839,7 @@ var ts;
bundleFileInfo.sections.push({
pos: pos,
end: writer.getTextPos(),
- kind: "prepend" /* Prepend */,
+ kind: "prepend" /* BundleFileSectionKind.Prepend */,
data: relativeToBuildInfo(prepend.fileName),
texts: newSections
});
@@ -109156,7 +110849,7 @@ var ts;
sourceFileTextPos = getTextPosWithWriteLine();
for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) {
var sourceFile = _e[_d];
- print(0 /* SourceFile */, sourceFile, sourceFile);
+ print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile);
}
if (bundleFileInfo && bundle.sourceFiles.length) {
var end = writer.getTextPos();
@@ -109183,7 +110876,7 @@ var ts;
function writeUnparsedSource(unparsed, output) {
var previousWriter = writer;
setWriter(output, /*_sourceMapGenerator*/ undefined);
- print(4 /* Unspecified */, unparsed, /*sourceFile*/ undefined);
+ print(4 /* EmitHint.Unspecified */, unparsed, /*sourceFile*/ undefined);
reset();
writer = previousWriter;
}
@@ -109193,7 +110886,7 @@ var ts;
setWriter(output, sourceMapGenerator);
emitShebangIfNeeded(sourceFile);
emitPrologueDirectivesIfNeeded(sourceFile);
- print(0 /* SourceFile */, sourceFile, sourceFile);
+ print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile);
reset();
writer = previousWriter;
}
@@ -109232,7 +110925,7 @@ var ts;
autoGeneratedIdToGeneratedName = [];
generatedNames = new ts.Set();
tempFlagsStack = [];
- tempFlags = 0 /* Auto */;
+ tempFlags = 0 /* TempFlags.Auto */;
reservedNamesStack = [];
currentSourceFile = undefined;
currentLineMap = undefined;
@@ -109240,30 +110933,30 @@ var ts;
setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined);
}
function getCurrentLineMap() {
- return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile));
+ return currentLineMap || (currentLineMap = ts.getLineStarts(ts.Debug.checkDefined(currentSourceFile)));
}
function emit(node, parenthesizerRule) {
if (node === undefined)
return;
var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node);
- pipelineEmit(4 /* Unspecified */, node, parenthesizerRule);
+ pipelineEmit(4 /* EmitHint.Unspecified */, node, parenthesizerRule);
recordBundleFileInternalSectionEnd(prevSourceFileTextKind);
}
function emitIdentifierName(node) {
if (node === undefined)
return;
- pipelineEmit(2 /* IdentifierName */, node, /*parenthesizerRule*/ undefined);
+ pipelineEmit(2 /* EmitHint.IdentifierName */, node, /*parenthesizerRule*/ undefined);
}
function emitExpression(node, parenthesizerRule) {
if (node === undefined)
return;
- pipelineEmit(1 /* Expression */, node, parenthesizerRule);
+ pipelineEmit(1 /* EmitHint.Expression */, node, parenthesizerRule);
}
function emitJsxAttributeValue(node) {
- pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node);
+ pipelineEmit(ts.isStringLiteral(node) ? 6 /* EmitHint.JsxAttributeValue */ : 4 /* EmitHint.Unspecified */, node);
}
function beforeEmitNode(node) {
- if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) {
+ if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* EmitFlags.IgnoreSourceNewlines */)) {
preserveSourceNewlines = false;
}
}
@@ -109272,7 +110965,7 @@ var ts;
}
function pipelineEmit(emitHint, node, parenthesizerRule) {
currentParenthesizerRule = parenthesizerRule;
- var pipelinePhase = getPipelinePhase(0 /* Notification */, emitHint, node);
+ var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, emitHint, node);
pipelinePhase(emitHint, node);
currentParenthesizerRule = undefined;
}
@@ -109288,12 +110981,12 @@ var ts;
}
function getPipelinePhase(phase, emitHint, node) {
switch (phase) {
- case 0 /* Notification */:
+ case 0 /* PipelinePhase.Notification */:
if (onEmitNode !== ts.noEmitNotification && (!isEmitNotificationEnabled || isEmitNotificationEnabled(node))) {
return pipelineEmitWithNotification;
}
// falls through
- case 1 /* Substitution */:
+ case 1 /* PipelinePhase.Substitution */:
if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node) || node) !== node) {
if (currentParenthesizerRule) {
lastSubstitution = currentParenthesizerRule(lastSubstitution);
@@ -109301,17 +110994,17 @@ var ts;
return pipelineEmitWithSubstitution;
}
// falls through
- case 2 /* Comments */:
+ case 2 /* PipelinePhase.Comments */:
if (shouldEmitComments(node)) {
return pipelineEmitWithComments;
}
// falls through
- case 3 /* SourceMaps */:
+ case 3 /* PipelinePhase.SourceMaps */:
if (shouldEmitSourceMaps(node)) {
return pipelineEmitWithSourceMaps;
}
// falls through
- case 4 /* Emit */:
+ case 4 /* PipelinePhase.Emit */:
return pipelineEmitWithHint;
default:
return ts.Debug.assertNever(phase);
@@ -109321,7 +111014,7 @@ var ts;
return getPipelinePhase(currentPhase + 1, emitHint, node);
}
function pipelineEmitWithNotification(hint, node) {
- var pipelinePhase = getNextPipelinePhase(0 /* Notification */, hint, node);
+ var pipelinePhase = getNextPipelinePhase(0 /* PipelinePhase.Notification */, hint, node);
onEmitNode(hint, node, pipelinePhase);
}
function pipelineEmitWithHint(hint, node) {
@@ -109347,346 +111040,346 @@ var ts;
return emitSnippetNode(hint, node, snippet);
}
}
- if (hint === 0 /* SourceFile */)
+ if (hint === 0 /* EmitHint.SourceFile */)
return emitSourceFile(ts.cast(node, ts.isSourceFile));
- if (hint === 2 /* IdentifierName */)
+ if (hint === 2 /* EmitHint.IdentifierName */)
return emitIdentifier(ts.cast(node, ts.isIdentifier));
- if (hint === 6 /* JsxAttributeValue */)
+ if (hint === 6 /* EmitHint.JsxAttributeValue */)
return emitLiteral(ts.cast(node, ts.isStringLiteral), /*jsxAttributeEscape*/ true);
- if (hint === 3 /* MappedTypeParameter */)
+ if (hint === 3 /* EmitHint.MappedTypeParameter */)
return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration));
- if (hint === 5 /* EmbeddedStatement */) {
+ if (hint === 5 /* EmitHint.EmbeddedStatement */) {
ts.Debug.assertNode(node, ts.isEmptyStatement);
return emitEmptyStatement(/*isEmbeddedStatement*/ true);
}
- if (hint === 4 /* Unspecified */) {
+ if (hint === 4 /* EmitHint.Unspecified */) {
switch (node.kind) {
// Pseudo-literals
- case 15 /* TemplateHead */:
- case 16 /* TemplateMiddle */:
- case 17 /* TemplateTail */:
+ case 15 /* SyntaxKind.TemplateHead */:
+ case 16 /* SyntaxKind.TemplateMiddle */:
+ case 17 /* SyntaxKind.TemplateTail */:
return emitLiteral(node, /*jsxAttributeEscape*/ false);
// Identifiers
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return emitIdentifier(node);
// PrivateIdentifiers
- case 80 /* PrivateIdentifier */:
+ case 80 /* SyntaxKind.PrivateIdentifier */:
return emitPrivateIdentifier(node);
// Parse tree nodes
// Names
- case 160 /* QualifiedName */:
+ case 161 /* SyntaxKind.QualifiedName */:
return emitQualifiedName(node);
- case 161 /* ComputedPropertyName */:
+ case 162 /* SyntaxKind.ComputedPropertyName */:
return emitComputedPropertyName(node);
// Signature elements
- case 162 /* TypeParameter */:
+ case 163 /* SyntaxKind.TypeParameter */:
return emitTypeParameter(node);
- case 163 /* Parameter */:
+ case 164 /* SyntaxKind.Parameter */:
return emitParameter(node);
- case 164 /* Decorator */:
+ case 165 /* SyntaxKind.Decorator */:
return emitDecorator(node);
// Type members
- case 165 /* PropertySignature */:
+ case 166 /* SyntaxKind.PropertySignature */:
return emitPropertySignature(node);
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
return emitPropertyDeclaration(node);
- case 167 /* MethodSignature */:
+ case 168 /* SyntaxKind.MethodSignature */:
return emitMethodSignature(node);
- case 168 /* MethodDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
return emitMethodDeclaration(node);
- case 169 /* ClassStaticBlockDeclaration */:
+ case 170 /* SyntaxKind.ClassStaticBlockDeclaration */:
return emitClassStaticBlockDeclaration(node);
- case 170 /* Constructor */:
+ case 171 /* SyntaxKind.Constructor */:
return emitConstructor(node);
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
return emitAccessorDeclaration(node);
- case 173 /* CallSignature */:
+ case 174 /* SyntaxKind.CallSignature */:
return emitCallSignature(node);
- case 174 /* ConstructSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
return emitConstructSignature(node);
- case 175 /* IndexSignature */:
+ case 176 /* SyntaxKind.IndexSignature */:
return emitIndexSignature(node);
// Types
- case 176 /* TypePredicate */:
+ case 177 /* SyntaxKind.TypePredicate */:
return emitTypePredicate(node);
- case 177 /* TypeReference */:
+ case 178 /* SyntaxKind.TypeReference */:
return emitTypeReference(node);
- case 178 /* FunctionType */:
+ case 179 /* SyntaxKind.FunctionType */:
return emitFunctionType(node);
- case 179 /* ConstructorType */:
+ case 180 /* SyntaxKind.ConstructorType */:
return emitConstructorType(node);
- case 180 /* TypeQuery */:
+ case 181 /* SyntaxKind.TypeQuery */:
return emitTypeQuery(node);
- case 181 /* TypeLiteral */:
+ case 182 /* SyntaxKind.TypeLiteral */:
return emitTypeLiteral(node);
- case 182 /* ArrayType */:
+ case 183 /* SyntaxKind.ArrayType */:
return emitArrayType(node);
- case 183 /* TupleType */:
+ case 184 /* SyntaxKind.TupleType */:
return emitTupleType(node);
- case 184 /* OptionalType */:
+ case 185 /* SyntaxKind.OptionalType */:
return emitOptionalType(node);
// SyntaxKind.RestType is handled below
- case 186 /* UnionType */:
+ case 187 /* SyntaxKind.UnionType */:
return emitUnionType(node);
- case 187 /* IntersectionType */:
+ case 188 /* SyntaxKind.IntersectionType */:
return emitIntersectionType(node);
- case 188 /* ConditionalType */:
+ case 189 /* SyntaxKind.ConditionalType */:
return emitConditionalType(node);
- case 189 /* InferType */:
+ case 190 /* SyntaxKind.InferType */:
return emitInferType(node);
- case 190 /* ParenthesizedType */:
+ case 191 /* SyntaxKind.ParenthesizedType */:
return emitParenthesizedType(node);
- case 227 /* ExpressionWithTypeArguments */:
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
return emitExpressionWithTypeArguments(node);
- case 191 /* ThisType */:
+ case 192 /* SyntaxKind.ThisType */:
return emitThisType();
- case 192 /* TypeOperator */:
+ case 193 /* SyntaxKind.TypeOperator */:
return emitTypeOperator(node);
- case 193 /* IndexedAccessType */:
+ case 194 /* SyntaxKind.IndexedAccessType */:
return emitIndexedAccessType(node);
- case 194 /* MappedType */:
+ case 195 /* SyntaxKind.MappedType */:
return emitMappedType(node);
- case 195 /* LiteralType */:
+ case 196 /* SyntaxKind.LiteralType */:
return emitLiteralType(node);
- case 196 /* NamedTupleMember */:
+ case 197 /* SyntaxKind.NamedTupleMember */:
return emitNamedTupleMember(node);
- case 197 /* TemplateLiteralType */:
+ case 198 /* SyntaxKind.TemplateLiteralType */:
return emitTemplateType(node);
- case 198 /* TemplateLiteralTypeSpan */:
+ case 199 /* SyntaxKind.TemplateLiteralTypeSpan */:
return emitTemplateTypeSpan(node);
- case 199 /* ImportType */:
+ case 200 /* SyntaxKind.ImportType */:
return emitImportTypeNode(node);
// Binding patterns
- case 200 /* ObjectBindingPattern */:
+ case 201 /* SyntaxKind.ObjectBindingPattern */:
return emitObjectBindingPattern(node);
- case 201 /* ArrayBindingPattern */:
+ case 202 /* SyntaxKind.ArrayBindingPattern */:
return emitArrayBindingPattern(node);
- case 202 /* BindingElement */:
+ case 203 /* SyntaxKind.BindingElement */:
return emitBindingElement(node);
// Misc
- case 232 /* TemplateSpan */:
+ case 233 /* SyntaxKind.TemplateSpan */:
return emitTemplateSpan(node);
- case 233 /* SemicolonClassElement */:
+ case 234 /* SyntaxKind.SemicolonClassElement */:
return emitSemicolonClassElement();
// Statements
- case 234 /* Block */:
+ case 235 /* SyntaxKind.Block */:
return emitBlock(node);
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
return emitVariableStatement(node);
- case 235 /* EmptyStatement */:
+ case 236 /* SyntaxKind.EmptyStatement */:
return emitEmptyStatement(/*isEmbeddedStatement*/ false);
- case 237 /* ExpressionStatement */:
+ case 238 /* SyntaxKind.ExpressionStatement */:
return emitExpressionStatement(node);
- case 238 /* IfStatement */:
+ case 239 /* SyntaxKind.IfStatement */:
return emitIfStatement(node);
- case 239 /* DoStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
return emitDoStatement(node);
- case 240 /* WhileStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
return emitWhileStatement(node);
- case 241 /* ForStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
return emitForStatement(node);
- case 242 /* ForInStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
return emitForInStatement(node);
- case 243 /* ForOfStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
return emitForOfStatement(node);
- case 244 /* ContinueStatement */:
+ case 245 /* SyntaxKind.ContinueStatement */:
return emitContinueStatement(node);
- case 245 /* BreakStatement */:
+ case 246 /* SyntaxKind.BreakStatement */:
return emitBreakStatement(node);
- case 246 /* ReturnStatement */:
+ case 247 /* SyntaxKind.ReturnStatement */:
return emitReturnStatement(node);
- case 247 /* WithStatement */:
+ case 248 /* SyntaxKind.WithStatement */:
return emitWithStatement(node);
- case 248 /* SwitchStatement */:
+ case 249 /* SyntaxKind.SwitchStatement */:
return emitSwitchStatement(node);
- case 249 /* LabeledStatement */:
+ case 250 /* SyntaxKind.LabeledStatement */:
return emitLabeledStatement(node);
- case 250 /* ThrowStatement */:
+ case 251 /* SyntaxKind.ThrowStatement */:
return emitThrowStatement(node);
- case 251 /* TryStatement */:
+ case 252 /* SyntaxKind.TryStatement */:
return emitTryStatement(node);
- case 252 /* DebuggerStatement */:
+ case 253 /* SyntaxKind.DebuggerStatement */:
return emitDebuggerStatement(node);
// Declarations
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return emitVariableDeclaration(node);
- case 254 /* VariableDeclarationList */:
+ case 255 /* SyntaxKind.VariableDeclarationList */:
return emitVariableDeclarationList(node);
- case 255 /* FunctionDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
return emitFunctionDeclaration(node);
- case 256 /* ClassDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
return emitClassDeclaration(node);
- case 257 /* InterfaceDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
return emitInterfaceDeclaration(node);
- case 258 /* TypeAliasDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
return emitTypeAliasDeclaration(node);
- case 259 /* EnumDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
return emitEnumDeclaration(node);
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
return emitModuleDeclaration(node);
- case 261 /* ModuleBlock */:
+ case 262 /* SyntaxKind.ModuleBlock */:
return emitModuleBlock(node);
- case 262 /* CaseBlock */:
+ case 263 /* SyntaxKind.CaseBlock */:
return emitCaseBlock(node);
- case 263 /* NamespaceExportDeclaration */:
+ case 264 /* SyntaxKind.NamespaceExportDeclaration */:
return emitNamespaceExportDeclaration(node);
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return emitImportEqualsDeclaration(node);
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
return emitImportDeclaration(node);
- case 266 /* ImportClause */:
+ case 267 /* SyntaxKind.ImportClause */:
return emitImportClause(node);
- case 267 /* NamespaceImport */:
+ case 268 /* SyntaxKind.NamespaceImport */:
return emitNamespaceImport(node);
- case 273 /* NamespaceExport */:
+ case 274 /* SyntaxKind.NamespaceExport */:
return emitNamespaceExport(node);
- case 268 /* NamedImports */:
+ case 269 /* SyntaxKind.NamedImports */:
return emitNamedImports(node);
- case 269 /* ImportSpecifier */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
return emitImportSpecifier(node);
- case 270 /* ExportAssignment */:
+ case 271 /* SyntaxKind.ExportAssignment */:
return emitExportAssignment(node);
- case 271 /* ExportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
return emitExportDeclaration(node);
- case 272 /* NamedExports */:
+ case 273 /* SyntaxKind.NamedExports */:
return emitNamedExports(node);
- case 274 /* ExportSpecifier */:
+ case 275 /* SyntaxKind.ExportSpecifier */:
return emitExportSpecifier(node);
- case 292 /* AssertClause */:
+ case 293 /* SyntaxKind.AssertClause */:
return emitAssertClause(node);
- case 293 /* AssertEntry */:
+ case 294 /* SyntaxKind.AssertEntry */:
return emitAssertEntry(node);
- case 275 /* MissingDeclaration */:
+ case 276 /* SyntaxKind.MissingDeclaration */:
return;
// Module references
- case 276 /* ExternalModuleReference */:
+ case 277 /* SyntaxKind.ExternalModuleReference */:
return emitExternalModuleReference(node);
// JSX (non-expression)
- case 11 /* JsxText */:
+ case 11 /* SyntaxKind.JsxText */:
return emitJsxText(node);
- case 279 /* JsxOpeningElement */:
- case 282 /* JsxOpeningFragment */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
+ case 283 /* SyntaxKind.JsxOpeningFragment */:
return emitJsxOpeningElementOrFragment(node);
- case 280 /* JsxClosingElement */:
- case 283 /* JsxClosingFragment */:
+ case 281 /* SyntaxKind.JsxClosingElement */:
+ case 284 /* SyntaxKind.JsxClosingFragment */:
return emitJsxClosingElementOrFragment(node);
- case 284 /* JsxAttribute */:
+ case 285 /* SyntaxKind.JsxAttribute */:
return emitJsxAttribute(node);
- case 285 /* JsxAttributes */:
+ case 286 /* SyntaxKind.JsxAttributes */:
return emitJsxAttributes(node);
- case 286 /* JsxSpreadAttribute */:
+ case 287 /* SyntaxKind.JsxSpreadAttribute */:
return emitJsxSpreadAttribute(node);
- case 287 /* JsxExpression */:
+ case 288 /* SyntaxKind.JsxExpression */:
return emitJsxExpression(node);
// Clauses
- case 288 /* CaseClause */:
+ case 289 /* SyntaxKind.CaseClause */:
return emitCaseClause(node);
- case 289 /* DefaultClause */:
+ case 290 /* SyntaxKind.DefaultClause */:
return emitDefaultClause(node);
- case 290 /* HeritageClause */:
+ case 291 /* SyntaxKind.HeritageClause */:
return emitHeritageClause(node);
- case 291 /* CatchClause */:
+ case 292 /* SyntaxKind.CatchClause */:
return emitCatchClause(node);
// Property assignments
- case 294 /* PropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
return emitPropertyAssignment(node);
- case 295 /* ShorthandPropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
return emitShorthandPropertyAssignment(node);
- case 296 /* SpreadAssignment */:
+ case 298 /* SyntaxKind.SpreadAssignment */:
return emitSpreadAssignment(node);
// Enum
- case 297 /* EnumMember */:
+ case 299 /* SyntaxKind.EnumMember */:
return emitEnumMember(node);
// Unparsed
- case 298 /* UnparsedPrologue */:
+ case 300 /* SyntaxKind.UnparsedPrologue */:
return writeUnparsedNode(node);
- case 305 /* UnparsedSource */:
- case 299 /* UnparsedPrepend */:
+ case 307 /* SyntaxKind.UnparsedSource */:
+ case 301 /* SyntaxKind.UnparsedPrepend */:
return emitUnparsedSourceOrPrepend(node);
- case 300 /* UnparsedText */:
- case 301 /* UnparsedInternalText */:
+ case 302 /* SyntaxKind.UnparsedText */:
+ case 303 /* SyntaxKind.UnparsedInternalText */:
return emitUnparsedTextLike(node);
- case 302 /* UnparsedSyntheticReference */:
+ case 304 /* SyntaxKind.UnparsedSyntheticReference */:
return emitUnparsedSyntheticReference(node);
// Top-level nodes
- case 303 /* SourceFile */:
+ case 305 /* SyntaxKind.SourceFile */:
return emitSourceFile(node);
- case 304 /* Bundle */:
+ case 306 /* SyntaxKind.Bundle */:
return ts.Debug.fail("Bundles should be printed using printBundle");
// SyntaxKind.UnparsedSource (handled above)
- case 306 /* InputFiles */:
+ case 308 /* SyntaxKind.InputFiles */:
return ts.Debug.fail("InputFiles should not be printed");
// JSDoc nodes (only used in codefixes currently)
- case 307 /* JSDocTypeExpression */:
+ case 309 /* SyntaxKind.JSDocTypeExpression */:
return emitJSDocTypeExpression(node);
- case 308 /* JSDocNameReference */:
+ case 310 /* SyntaxKind.JSDocNameReference */:
return emitJSDocNameReference(node);
- case 310 /* JSDocAllType */:
+ case 312 /* SyntaxKind.JSDocAllType */:
return writePunctuation("*");
- case 311 /* JSDocUnknownType */:
+ case 313 /* SyntaxKind.JSDocUnknownType */:
return writePunctuation("?");
- case 312 /* JSDocNullableType */:
+ case 314 /* SyntaxKind.JSDocNullableType */:
return emitJSDocNullableType(node);
- case 313 /* JSDocNonNullableType */:
+ case 315 /* SyntaxKind.JSDocNonNullableType */:
return emitJSDocNonNullableType(node);
- case 314 /* JSDocOptionalType */:
+ case 316 /* SyntaxKind.JSDocOptionalType */:
return emitJSDocOptionalType(node);
- case 315 /* JSDocFunctionType */:
+ case 317 /* SyntaxKind.JSDocFunctionType */:
return emitJSDocFunctionType(node);
- case 185 /* RestType */:
- case 316 /* JSDocVariadicType */:
+ case 186 /* SyntaxKind.RestType */:
+ case 318 /* SyntaxKind.JSDocVariadicType */:
return emitRestOrJSDocVariadicType(node);
- case 317 /* JSDocNamepathType */:
+ case 319 /* SyntaxKind.JSDocNamepathType */:
return;
- case 318 /* JSDocComment */:
+ case 320 /* SyntaxKind.JSDoc */:
return emitJSDoc(node);
- case 320 /* JSDocTypeLiteral */:
+ case 322 /* SyntaxKind.JSDocTypeLiteral */:
return emitJSDocTypeLiteral(node);
- case 321 /* JSDocSignature */:
+ case 323 /* SyntaxKind.JSDocSignature */:
return emitJSDocSignature(node);
- case 325 /* JSDocTag */:
- case 330 /* JSDocClassTag */:
- case 335 /* JSDocOverrideTag */:
+ case 327 /* SyntaxKind.JSDocTag */:
+ case 332 /* SyntaxKind.JSDocClassTag */:
+ case 337 /* SyntaxKind.JSDocOverrideTag */:
return emitJSDocSimpleTag(node);
- case 326 /* JSDocAugmentsTag */:
- case 327 /* JSDocImplementsTag */:
+ case 328 /* SyntaxKind.JSDocAugmentsTag */:
+ case 329 /* SyntaxKind.JSDocImplementsTag */:
return emitJSDocHeritageTag(node);
- case 328 /* JSDocAuthorTag */:
- case 329 /* JSDocDeprecatedTag */:
+ case 330 /* SyntaxKind.JSDocAuthorTag */:
+ case 331 /* SyntaxKind.JSDocDeprecatedTag */:
return;
// SyntaxKind.JSDocClassTag (see JSDocTag, above)
- case 331 /* JSDocPublicTag */:
- case 332 /* JSDocPrivateTag */:
- case 333 /* JSDocProtectedTag */:
- case 334 /* JSDocReadonlyTag */:
+ case 333 /* SyntaxKind.JSDocPublicTag */:
+ case 334 /* SyntaxKind.JSDocPrivateTag */:
+ case 335 /* SyntaxKind.JSDocProtectedTag */:
+ case 336 /* SyntaxKind.JSDocReadonlyTag */:
return;
- case 336 /* JSDocCallbackTag */:
+ case 338 /* SyntaxKind.JSDocCallbackTag */:
return emitJSDocCallbackTag(node);
// SyntaxKind.JSDocEnumTag (see below)
- case 338 /* JSDocParameterTag */:
- case 345 /* JSDocPropertyTag */:
+ case 340 /* SyntaxKind.JSDocParameterTag */:
+ case 347 /* SyntaxKind.JSDocPropertyTag */:
return emitJSDocPropertyLikeTag(node);
- case 337 /* JSDocEnumTag */:
- case 339 /* JSDocReturnTag */:
- case 340 /* JSDocThisTag */:
- case 341 /* JSDocTypeTag */:
+ case 339 /* SyntaxKind.JSDocEnumTag */:
+ case 341 /* SyntaxKind.JSDocReturnTag */:
+ case 342 /* SyntaxKind.JSDocThisTag */:
+ case 343 /* SyntaxKind.JSDocTypeTag */:
return emitJSDocSimpleTypedTag(node);
- case 342 /* JSDocTemplateTag */:
+ case 344 /* SyntaxKind.JSDocTemplateTag */:
return emitJSDocTemplateTag(node);
- case 343 /* JSDocTypedefTag */:
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
return emitJSDocTypedefTag(node);
- case 344 /* JSDocSeeTag */:
+ case 346 /* SyntaxKind.JSDocSeeTag */:
return emitJSDocSeeTag(node);
// SyntaxKind.JSDocPropertyTag (see JSDocParameterTag, above)
// Transformation nodes
- case 347 /* NotEmittedStatement */:
- case 351 /* EndOfDeclarationMarker */:
- case 350 /* MergeDeclarationMarker */:
+ case 349 /* SyntaxKind.NotEmittedStatement */:
+ case 353 /* SyntaxKind.EndOfDeclarationMarker */:
+ case 352 /* SyntaxKind.MergeDeclarationMarker */:
return;
}
if (ts.isExpression(node)) {
- hint = 1 /* Expression */;
+ hint = 1 /* EmitHint.Expression */;
if (substituteNode !== ts.noEmitSubstitution) {
var substitute = substituteNode(hint, node) || node;
if (substitute !== node) {
@@ -109698,99 +111391,101 @@ var ts;
}
}
}
- if (hint === 1 /* Expression */) {
+ if (hint === 1 /* EmitHint.Expression */) {
switch (node.kind) {
// Literals
- case 8 /* NumericLiteral */:
- case 9 /* BigIntLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
+ case 9 /* SyntaxKind.BigIntLiteral */:
return emitNumericOrBigIntLiteral(node);
- case 10 /* StringLiteral */:
- case 13 /* RegularExpressionLiteral */:
- case 14 /* NoSubstitutionTemplateLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 13 /* SyntaxKind.RegularExpressionLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
return emitLiteral(node, /*jsxAttributeEscape*/ false);
// Identifiers
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return emitIdentifier(node);
- case 80 /* PrivateIdentifier */:
+ case 80 /* SyntaxKind.PrivateIdentifier */:
return emitPrivateIdentifier(node);
// Expressions
- case 203 /* ArrayLiteralExpression */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
return emitArrayLiteralExpression(node);
- case 204 /* ObjectLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
return emitObjectLiteralExpression(node);
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
return emitPropertyAccessExpression(node);
- case 206 /* ElementAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
return emitElementAccessExpression(node);
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
return emitCallExpression(node);
- case 208 /* NewExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
return emitNewExpression(node);
- case 209 /* TaggedTemplateExpression */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
return emitTaggedTemplateExpression(node);
- case 210 /* TypeAssertionExpression */:
+ case 211 /* SyntaxKind.TypeAssertionExpression */:
return emitTypeAssertionExpression(node);
- case 211 /* ParenthesizedExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
return emitParenthesizedExpression(node);
- case 212 /* FunctionExpression */:
+ case 213 /* SyntaxKind.FunctionExpression */:
return emitFunctionExpression(node);
- case 213 /* ArrowFunction */:
+ case 214 /* SyntaxKind.ArrowFunction */:
return emitArrowFunction(node);
- case 214 /* DeleteExpression */:
+ case 215 /* SyntaxKind.DeleteExpression */:
return emitDeleteExpression(node);
- case 215 /* TypeOfExpression */:
+ case 216 /* SyntaxKind.TypeOfExpression */:
return emitTypeOfExpression(node);
- case 216 /* VoidExpression */:
+ case 217 /* SyntaxKind.VoidExpression */:
return emitVoidExpression(node);
- case 217 /* AwaitExpression */:
+ case 218 /* SyntaxKind.AwaitExpression */:
return emitAwaitExpression(node);
- case 218 /* PrefixUnaryExpression */:
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
return emitPrefixUnaryExpression(node);
- case 219 /* PostfixUnaryExpression */:
+ case 220 /* SyntaxKind.PostfixUnaryExpression */:
return emitPostfixUnaryExpression(node);
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return emitBinaryExpression(node);
- case 221 /* ConditionalExpression */:
+ case 222 /* SyntaxKind.ConditionalExpression */:
return emitConditionalExpression(node);
- case 222 /* TemplateExpression */:
+ case 223 /* SyntaxKind.TemplateExpression */:
return emitTemplateExpression(node);
- case 223 /* YieldExpression */:
+ case 224 /* SyntaxKind.YieldExpression */:
return emitYieldExpression(node);
- case 224 /* SpreadElement */:
+ case 225 /* SyntaxKind.SpreadElement */:
return emitSpreadElement(node);
- case 225 /* ClassExpression */:
+ case 226 /* SyntaxKind.ClassExpression */:
return emitClassExpression(node);
- case 226 /* OmittedExpression */:
+ case 227 /* SyntaxKind.OmittedExpression */:
return;
- case 228 /* AsExpression */:
+ case 229 /* SyntaxKind.AsExpression */:
return emitAsExpression(node);
- case 229 /* NonNullExpression */:
+ case 230 /* SyntaxKind.NonNullExpression */:
return emitNonNullExpression(node);
- case 230 /* MetaProperty */:
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
+ return emitExpressionWithTypeArguments(node);
+ case 231 /* SyntaxKind.MetaProperty */:
return emitMetaProperty(node);
- case 231 /* SyntheticExpression */:
+ case 232 /* SyntaxKind.SyntheticExpression */:
return ts.Debug.fail("SyntheticExpression should never be printed.");
// JSX
- case 277 /* JsxElement */:
+ case 278 /* SyntaxKind.JsxElement */:
return emitJsxElement(node);
- case 278 /* JsxSelfClosingElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
return emitJsxSelfClosingElement(node);
- case 281 /* JsxFragment */:
+ case 282 /* SyntaxKind.JsxFragment */:
return emitJsxFragment(node);
// Synthesized list
- case 346 /* SyntaxList */:
+ case 348 /* SyntaxKind.SyntaxList */:
return ts.Debug.fail("SyntaxList should not be printed");
// Transformation nodes
- case 347 /* NotEmittedStatement */:
+ case 349 /* SyntaxKind.NotEmittedStatement */:
return;
- case 348 /* PartiallyEmittedExpression */:
+ case 350 /* SyntaxKind.PartiallyEmittedExpression */:
return emitPartiallyEmittedExpression(node);
- case 349 /* CommaListExpression */:
+ case 351 /* SyntaxKind.CommaListExpression */:
return emitCommaList(node);
- case 350 /* MergeDeclarationMarker */:
- case 351 /* EndOfDeclarationMarker */:
+ case 352 /* SyntaxKind.MergeDeclarationMarker */:
+ case 353 /* SyntaxKind.EndOfDeclarationMarker */:
return;
- case 352 /* SyntheticReferenceExpression */:
+ case 354 /* SyntaxKind.SyntheticReferenceExpression */:
return ts.Debug.fail("SyntheticReferenceExpression should not be printed");
}
}
@@ -109808,7 +111503,7 @@ var ts;
emit(node.constraint);
}
function pipelineEmitWithSubstitution(hint, node) {
- var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, hint, node);
+ var pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, hint, node);
ts.Debug.assertIsDefined(lastSubstitution);
node = lastSubstitution;
lastSubstitution = undefined;
@@ -109838,7 +111533,7 @@ var ts;
}
function emitHelpers(node) {
var helpersEmitted = false;
- var bundle = node.kind === 304 /* Bundle */ ? node : undefined;
+ var bundle = node.kind === 306 /* SyntaxKind.Bundle */ ? node : undefined;
if (bundle && moduleKind === ts.ModuleKind.None) {
return;
}
@@ -109880,7 +111575,7 @@ var ts;
writeLines(helper.text(makeFileLevelOptimisticUniqueName));
}
if (bundleFileInfo)
- bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* EmitHelpers */, data: helper.name });
+ bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* BundleFileSectionKind.EmitHelpers */, data: helper.name });
helpersEmitted = true;
}
}
@@ -109908,7 +111603,7 @@ var ts;
function emitLiteral(node, jsxAttributeEscape) {
var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape, jsxAttributeEscape);
if ((printerOptions.sourceMap || printerOptions.inlineSourceMap)
- && (node.kind === 10 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) {
+ && (node.kind === 10 /* SyntaxKind.StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) {
writeLiteral(text);
}
else {
@@ -109938,9 +111633,9 @@ var ts;
var pos = getTextPosWithWriteLine();
writeUnparsedNode(unparsed);
if (bundleFileInfo) {
- updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 300 /* UnparsedText */ ?
- "text" /* Text */ :
- "internal" /* Internal */);
+ updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 302 /* SyntaxKind.UnparsedText */ ?
+ "text" /* BundleFileSectionKind.Text */ :
+ "internal" /* BundleFileSectionKind.Internal */);
}
}
// SyntaxKind.UnparsedSyntheticReference
@@ -109959,10 +111654,10 @@ var ts;
//
function emitSnippetNode(hint, node, snippet) {
switch (snippet.kind) {
- case 1 /* Placeholder */:
+ case 1 /* SnippetKind.Placeholder */:
emitPlaceholder(hint, node, snippet);
break;
- case 0 /* TabStop */:
+ case 0 /* SnippetKind.TabStop */:
emitTabStop(hint, node, snippet);
break;
}
@@ -109975,8 +111670,8 @@ var ts;
}
function emitTabStop(hint, node, snippet) {
// A tab stop should only be attached to an empty node, i.e. a node that doesn't emit any text.
- ts.Debug.assert(node.kind === 235 /* EmptyStatement */, "A tab stop cannot be attached to a node of kind ".concat(ts.Debug.formatSyntaxKind(node.kind), "."));
- ts.Debug.assert(hint !== 5 /* EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement.");
+ ts.Debug.assert(node.kind === 236 /* SyntaxKind.EmptyStatement */, "A tab stop cannot be attached to a node of kind ".concat(ts.Debug.formatSyntaxKind(node.kind), "."));
+ ts.Debug.assert(hint !== 5 /* EmitHint.EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement.");
nonEscapingWrite("$".concat(snippet.order));
}
//
@@ -109985,7 +111680,7 @@ var ts;
function emitIdentifier(node) {
var writeText = node.symbol ? writeSymbol : write;
writeText(getTextOfNode(node, /*includeTrivia*/ false), node.symbol);
- emitList(node, node.typeArguments, 53776 /* TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments
+ emitList(node, node.typeArguments, 53776 /* ListFormat.TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments
}
//
// Names
@@ -110000,7 +111695,7 @@ var ts;
emit(node.right);
}
function emitEntityName(node) {
- if (node.kind === 79 /* Identifier */) {
+ if (node.kind === 79 /* SyntaxKind.Identifier */) {
emitExpression(node);
}
else {
@@ -110016,6 +111711,7 @@ var ts;
// Signature elements
//
function emitTypeParameter(node) {
+ emitModifiers(node, node.modifiers);
emit(node.name);
if (node.constraint) {
writeSpace();
@@ -110036,7 +111732,7 @@ var ts;
emit(node.dotDotDotToken);
emitNodeWithWriter(node.name, writeParameter);
emit(node.questionToken);
- if (node.parent && node.parent.kind === 315 /* JSDocFunctionType */ && !node.name) {
+ if (node.parent && node.parent.kind === 317 /* SyntaxKind.JSDocFunctionType */ && !node.name) {
emit(node.type);
}
else {
@@ -110104,7 +111800,7 @@ var ts;
function emitAccessorDeclaration(node) {
emitDecorators(node, node.decorators);
emitModifiers(node, node.modifiers);
- writeKeyword(node.kind === 171 /* GetAccessor */ ? "get" : "set");
+ writeKeyword(node.kind === 172 /* SyntaxKind.GetAccessor */ ? "get" : "set");
writeSpace();
emit(node.name);
emitSignatureAndBody(node, emitSignatureHead);
@@ -110210,15 +111906,16 @@ var ts;
writeKeyword("typeof");
writeSpace();
emit(node.exprName);
+ emitTypeArguments(node, node.typeArguments);
}
function emitTypeLiteral(node) {
writePunctuation("{");
- var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineTypeLiteralMembers */ : 32897 /* MultiLineTypeLiteralMembers */;
- emitList(node, node.members, flags | 524288 /* NoSpaceIfEmpty */);
+ var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineTypeLiteralMembers */ : 32897 /* ListFormat.MultiLineTypeLiteralMembers */;
+ emitList(node, node.members, flags | 524288 /* ListFormat.NoSpaceIfEmpty */);
writePunctuation("}");
}
function emitArrayType(node) {
- emit(node.elementType, parenthesizer.parenthesizeElementTypeOfArrayType);
+ emit(node.elementType, parenthesizer.parenthesizeNonArrayTypeOfPostfixType);
writePunctuation("[");
writePunctuation("]");
}
@@ -110227,35 +111924,35 @@ var ts;
emit(node.type);
}
function emitTupleType(node) {
- emitTokenWithComment(22 /* OpenBracketToken */, node.pos, writePunctuation, node);
- var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 528 /* SingleLineTupleTypeElements */ : 657 /* MultiLineTupleTypeElements */;
- emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */);
- emitTokenWithComment(23 /* CloseBracketToken */, node.elements.end, writePunctuation, node);
+ emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.pos, writePunctuation, node);
+ var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 528 /* ListFormat.SingleLineTupleTypeElements */ : 657 /* ListFormat.MultiLineTupleTypeElements */;
+ emitList(node, node.elements, flags | 524288 /* ListFormat.NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType);
+ emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.elements.end, writePunctuation, node);
}
function emitNamedTupleMember(node) {
emit(node.dotDotDotToken);
emit(node.name);
emit(node.questionToken);
- emitTokenWithComment(58 /* ColonToken */, node.name.end, writePunctuation, node);
+ emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.name.end, writePunctuation, node);
writeSpace();
emit(node.type);
}
function emitOptionalType(node) {
- emit(node.type, parenthesizer.parenthesizeElementTypeOfArrayType);
+ emit(node.type, parenthesizer.parenthesizeTypeOfOptionalType);
writePunctuation("?");
}
function emitUnionType(node) {
- emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType);
+ emitList(node, node.types, 516 /* ListFormat.UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType);
}
function emitIntersectionType(node) {
- emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType);
+ emitList(node, node.types, 520 /* ListFormat.IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType);
}
function emitConditionalType(node) {
- emit(node.checkType, parenthesizer.parenthesizeMemberOfConditionalType);
+ emit(node.checkType, parenthesizer.parenthesizeCheckTypeOfConditionalType);
writeSpace();
writeKeyword("extends");
writeSpace();
- emit(node.extendsType, parenthesizer.parenthesizeMemberOfConditionalType);
+ emit(node.extendsType, parenthesizer.parenthesizeExtendsTypeOfConditionalType);
writeSpace();
writePunctuation("?");
writeSpace();
@@ -110281,10 +111978,13 @@ var ts;
function emitTypeOperator(node) {
writeTokenText(node.operator, writeKeyword);
writeSpace();
- emit(node.type, parenthesizer.parenthesizeMemberOfElementType);
+ var parenthesizerRule = node.operator === 145 /* SyntaxKind.ReadonlyKeyword */ ?
+ parenthesizer.parenthesizeOperandOfReadonlyTypeOperator :
+ parenthesizer.parenthesizeOperandOfTypeOperator;
+ emit(node.type, parenthesizerRule);
}
function emitIndexedAccessType(node) {
- emit(node.objectType, parenthesizer.parenthesizeMemberOfElementType);
+ emit(node.objectType, parenthesizer.parenthesizeNonArrayTypeOfPostfixType);
writePunctuation("[");
emit(node.indexType);
writePunctuation("]");
@@ -110292,7 +111992,7 @@ var ts;
function emitMappedType(node) {
var emitFlags = ts.getEmitFlags(node);
writePunctuation("{");
- if (emitFlags & 1 /* SingleLine */) {
+ if (emitFlags & 1 /* EmitFlags.SingleLine */) {
writeSpace();
}
else {
@@ -110301,13 +112001,13 @@ var ts;
}
if (node.readonlyToken) {
emit(node.readonlyToken);
- if (node.readonlyToken.kind !== 144 /* ReadonlyKeyword */) {
+ if (node.readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) {
writeKeyword("readonly");
}
writeSpace();
}
writePunctuation("[");
- pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter);
+ pipelineEmit(3 /* EmitHint.MappedTypeParameter */, node.typeParameter);
if (node.nameType) {
writeSpace();
writeKeyword("as");
@@ -110317,7 +112017,7 @@ var ts;
writePunctuation("]");
if (node.questionToken) {
emit(node.questionToken);
- if (node.questionToken.kind !== 57 /* QuestionToken */) {
+ if (node.questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) {
writePunctuation("?");
}
}
@@ -110325,13 +112025,14 @@ var ts;
writeSpace();
emit(node.type);
writeTrailingSemicolon();
- if (emitFlags & 1 /* SingleLine */) {
+ if (emitFlags & 1 /* EmitFlags.SingleLine */) {
writeSpace();
}
else {
writeLine();
decreaseIndent();
}
+ emitList(node, node.members, 2 /* ListFormat.PreserveLines */);
writePunctuation("}");
}
function emitLiteralType(node) {
@@ -110339,7 +112040,7 @@ var ts;
}
function emitTemplateType(node) {
emit(node.head);
- emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */);
+ emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */);
}
function emitImportTypeNode(node) {
if (node.isTypeOf) {
@@ -110349,6 +112050,19 @@ var ts;
writeKeyword("import");
writePunctuation("(");
emit(node.argument);
+ if (node.assertions) {
+ writePunctuation(",");
+ writeSpace();
+ writePunctuation("{");
+ writeSpace();
+ writeKeyword("assert");
+ writePunctuation(":");
+ writeSpace();
+ var elements = node.assertions.assertClause.elements;
+ emitList(node.assertions.assertClause, elements, 526226 /* ListFormat.ImportClauseEntries */);
+ writeSpace();
+ writePunctuation("}");
+ }
writePunctuation(")");
if (node.qualifier) {
writePunctuation(".");
@@ -110361,12 +112075,12 @@ var ts;
//
function emitObjectBindingPattern(node) {
writePunctuation("{");
- emitList(node, node.elements, 525136 /* ObjectBindingPatternElements */);
+ emitList(node, node.elements, 525136 /* ListFormat.ObjectBindingPatternElements */);
writePunctuation("}");
}
function emitArrayBindingPattern(node) {
writePunctuation("[");
- emitList(node, node.elements, 524880 /* ArrayBindingPatternElements */);
+ emitList(node, node.elements, 524880 /* ListFormat.ArrayBindingPatternElements */);
writePunctuation("]");
}
function emitBindingElement(node) {
@@ -110384,29 +112098,29 @@ var ts;
//
function emitArrayLiteralExpression(node) {
var elements = node.elements;
- var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */;
- emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma);
+ var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */;
+ emitExpressionList(node, elements, 8914 /* ListFormat.ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma);
}
function emitObjectLiteralExpression(node) {
ts.forEach(node.properties, generateMemberNames);
- var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */;
+ var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */;
if (indentedFlag) {
increaseIndent();
}
- var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */;
- var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* AllowTrailingComma */ : 0 /* None */;
- emitList(node, node.properties, 526226 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine);
+ var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */;
+ var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 /* ScriptTarget.ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* ListFormat.AllowTrailingComma */ : 0 /* ListFormat.None */;
+ emitList(node, node.properties, 526226 /* ListFormat.ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine);
if (indentedFlag) {
decreaseIndent();
}
}
function emitPropertyAccessExpression(node) {
emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess);
- var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* DotToken */), node.expression.end, node.name.pos);
+ var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* SyntaxKind.DotToken */), node.expression.end, node.name.pos);
var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token);
var linesAfterDot = getLinesBetweenNodes(node, token, node.name);
writeLinesAndIndent(linesBeforeDot, /*writeSpaceIfNotIndenting*/ false);
- var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ &&
+ var shouldEmitDotDot = token.kind !== 28 /* SyntaxKind.QuestionDotToken */ &&
mayNeedDotDotForPropertyAccess(node.expression) &&
!writer.hasTrailingComment() &&
!writer.hasTrailingWhitespace();
@@ -110432,7 +112146,7 @@ var ts;
var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true, /*jsxAttributeEscape*/ false);
// If he number will be printed verbatim and it doesn't already contain a dot, add one
// if the expression doesn't have any comments that will be emitted.
- return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */));
+ return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* SyntaxKind.DotToken */));
}
else if (ts.isAccessExpression(expression)) {
// check if constant enum value is integer
@@ -110445,12 +112159,12 @@ var ts;
function emitElementAccessExpression(node) {
emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess);
emit(node.questionDotToken);
- emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node);
+ emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.expression.end, writePunctuation, node);
emitExpression(node.argumentExpression);
- emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node);
+ emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.argumentExpression.end, writePunctuation, node);
}
function emitCallExpression(node) {
- var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */;
+ var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */;
if (indirectCall) {
writePunctuation("(");
writeLiteral("0");
@@ -110463,17 +112177,17 @@ var ts;
}
emit(node.questionDotToken);
emitTypeArguments(node, node.typeArguments);
- emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma);
+ emitExpressionList(node, node.arguments, 2576 /* ListFormat.CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma);
}
function emitNewExpression(node) {
- emitTokenWithComment(103 /* NewKeyword */, node.pos, writeKeyword, node);
+ emitTokenWithComment(103 /* SyntaxKind.NewKeyword */, node.pos, writeKeyword, node);
writeSpace();
emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfNew);
emitTypeArguments(node, node.typeArguments);
- emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma);
+ emitExpressionList(node, node.arguments, 18960 /* ListFormat.NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma);
}
function emitTaggedTemplateExpression(node) {
- var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */;
+ var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */;
if (indirectCall) {
writePunctuation("(");
writeLiteral("0");
@@ -110495,12 +112209,12 @@ var ts;
emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary);
}
function emitParenthesizedExpression(node) {
- var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node);
+ var openParenPos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, node.pos, writePunctuation, node);
var indented = writeLineSeparatorsAndIndentBefore(node.expression, node);
emitExpression(node.expression, /*parenthesizerRules*/ undefined);
writeLineSeparatorsAfter(node.expression, node);
decreaseIndentIf(indented);
- emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node);
+ emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node);
}
function emitFunctionExpression(node) {
generateNameIfNeeded(node.name);
@@ -110519,22 +112233,22 @@ var ts;
emit(node.equalsGreaterThanToken);
}
function emitDeleteExpression(node) {
- emitTokenWithComment(89 /* DeleteKeyword */, node.pos, writeKeyword, node);
+ emitTokenWithComment(89 /* SyntaxKind.DeleteKeyword */, node.pos, writeKeyword, node);
writeSpace();
emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary);
}
function emitTypeOfExpression(node) {
- emitTokenWithComment(112 /* TypeOfKeyword */, node.pos, writeKeyword, node);
+ emitTokenWithComment(112 /* SyntaxKind.TypeOfKeyword */, node.pos, writeKeyword, node);
writeSpace();
emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary);
}
function emitVoidExpression(node) {
- emitTokenWithComment(114 /* VoidKeyword */, node.pos, writeKeyword, node);
+ emitTokenWithComment(114 /* SyntaxKind.VoidKeyword */, node.pos, writeKeyword, node);
writeSpace();
emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary);
}
function emitAwaitExpression(node) {
- emitTokenWithComment(132 /* AwaitKeyword */, node.pos, writeKeyword, node);
+ emitTokenWithComment(132 /* SyntaxKind.AwaitKeyword */, node.pos, writeKeyword, node);
writeSpace();
emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary);
}
@@ -110559,9 +112273,9 @@ var ts;
// expression a prefix increment whose operand is a plus expression - (++(+x))
// The same is true of minus of course.
var operand = node.operand;
- return operand.kind === 218 /* PrefixUnaryExpression */
- && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */))
- || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */)));
+ return operand.kind === 219 /* SyntaxKind.PrefixUnaryExpression */
+ && ((node.operator === 39 /* SyntaxKind.PlusToken */ && (operand.operator === 39 /* SyntaxKind.PlusToken */ || operand.operator === 45 /* SyntaxKind.PlusPlusToken */))
+ || (node.operator === 40 /* SyntaxKind.MinusToken */ && (operand.operator === 40 /* SyntaxKind.MinusToken */ || operand.operator === 46 /* SyntaxKind.MinusMinusToken */)));
}
function emitPostfixUnaryExpression(node) {
emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPostfixUnary);
@@ -110602,12 +112316,12 @@ var ts;
return maybeEmitExpression(next, parent, "left");
}
function onOperator(operatorToken, _state, node) {
- var isCommaOperator = operatorToken.kind !== 27 /* CommaToken */;
+ var isCommaOperator = operatorToken.kind !== 27 /* SyntaxKind.CommaToken */;
var linesBeforeOperator = getLinesBetweenNodes(node, node.left, operatorToken);
var linesAfterOperator = getLinesBetweenNodes(node, operatorToken, node.right);
writeLinesAndIndent(linesBeforeOperator, isCommaOperator);
emitLeadingCommentsOfPosition(operatorToken.pos);
- writeTokenNode(operatorToken, operatorToken.kind === 101 /* InKeyword */ ? writeKeyword : writeOperator);
+ writeTokenNode(operatorToken, operatorToken.kind === 101 /* SyntaxKind.InKeyword */ ? writeKeyword : writeOperator);
emitTrailingCommentsOfPosition(operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts
writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true);
}
@@ -110638,11 +112352,11 @@ var ts;
var parenthesizerRule = side === "left" ?
parenthesizer.getParenthesizeLeftSideOfBinaryForOperator(parent.operatorToken.kind) :
parenthesizer.getParenthesizeRightSideOfBinaryForOperator(parent.operatorToken.kind);
- var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */, next);
+ var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, 1 /* EmitHint.Expression */, next);
if (pipelinePhase === pipelineEmitWithSubstitution) {
ts.Debug.assertIsDefined(lastSubstitution);
next = parenthesizerRule(ts.cast(lastSubstitution, ts.isExpression));
- pipelinePhase = getNextPipelinePhase(1 /* Substitution */, 1 /* Expression */, next);
+ pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, 1 /* EmitHint.Expression */, next);
lastSubstitution = undefined;
}
if (pipelinePhase === pipelineEmitWithComments ||
@@ -110653,7 +112367,7 @@ var ts;
}
}
currentParenthesizerRule = parenthesizerRule;
- pipelinePhase(1 /* Expression */, next);
+ pipelinePhase(1 /* EmitHint.Expression */, next);
}
}
function emitConditionalExpression(node) {
@@ -110675,15 +112389,15 @@ var ts;
}
function emitTemplateExpression(node) {
emit(node.head);
- emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */);
+ emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */);
}
function emitYieldExpression(node) {
- emitTokenWithComment(125 /* YieldKeyword */, node.pos, writeKeyword, node);
+ emitTokenWithComment(125 /* SyntaxKind.YieldKeyword */, node.pos, writeKeyword, node);
emit(node.asteriskToken);
emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsiAndDisallowedComma);
}
function emitSpreadElement(node) {
- emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node);
+ emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node);
emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma);
}
function emitClassExpression(node) {
@@ -110726,10 +112440,10 @@ var ts;
emitBlockStatements(node, /*forceSingleLine*/ !node.multiLine && isEmptyBlock(node));
}
function emitBlockStatements(node, forceSingleLine) {
- emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node);
- var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineBlockStatements */ : 129 /* MultiLineBlockStatements */;
+ emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node);
+ var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineBlockStatements */ : 129 /* ListFormat.MultiLineBlockStatements */;
emitList(node, node.statements, format);
- emitTokenWithComment(19 /* CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* MultiLine */));
+ emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* ListFormat.MultiLine */));
}
function emitVariableStatement(node) {
emitModifiers(node, node.modifiers);
@@ -110750,21 +112464,21 @@ var ts;
emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement);
// Emit semicolon in non json files
// or if json file that created synthesized expression(eg.define expression statement when --out and amd code generation)
- if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
+ if (!currentSourceFile || !ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
writeTrailingSemicolon();
}
}
function emitIfStatement(node) {
- var openParenPos = emitTokenWithComment(99 /* IfKeyword */, node.pos, writeKeyword, node);
+ var openParenPos = emitTokenWithComment(99 /* SyntaxKind.IfKeyword */, node.pos, writeKeyword, node);
writeSpace();
- emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node);
+ emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node);
emitExpression(node.expression);
- emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node);
+ emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node);
emitEmbeddedStatement(node, node.thenStatement);
if (node.elseStatement) {
writeLineOrSpace(node, node.thenStatement, node.elseStatement);
- emitTokenWithComment(91 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node);
- if (node.elseStatement.kind === 238 /* IfStatement */) {
+ emitTokenWithComment(91 /* SyntaxKind.ElseKeyword */, node.thenStatement.end, writeKeyword, node);
+ if (node.elseStatement.kind === 239 /* SyntaxKind.IfStatement */) {
writeSpace();
emit(node.elseStatement);
}
@@ -110774,14 +112488,14 @@ var ts;
}
}
function emitWhileClause(node, startPos) {
- var openParenPos = emitTokenWithComment(115 /* WhileKeyword */, startPos, writeKeyword, node);
+ var openParenPos = emitTokenWithComment(115 /* SyntaxKind.WhileKeyword */, startPos, writeKeyword, node);
writeSpace();
- emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node);
+ emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node);
emitExpression(node.expression);
- emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node);
+ emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node);
}
function emitDoStatement(node) {
- emitTokenWithComment(90 /* DoKeyword */, node.pos, writeKeyword, node);
+ emitTokenWithComment(90 /* SyntaxKind.DoKeyword */, node.pos, writeKeyword, node);
emitEmbeddedStatement(node, node.statement);
if (ts.isBlock(node.statement) && !preserveSourceNewlines) {
writeSpace();
@@ -110797,45 +112511,45 @@ var ts;
emitEmbeddedStatement(node, node.statement);
}
function emitForStatement(node) {
- var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node);
+ var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node);
writeSpace();
- var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node);
+ var pos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node);
emitForBinding(node.initializer);
- pos = emitTokenWithComment(26 /* SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node);
+ pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node);
emitExpressionWithLeadingSpace(node.condition);
- pos = emitTokenWithComment(26 /* SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node);
+ pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node);
emitExpressionWithLeadingSpace(node.incrementor);
- emitTokenWithComment(21 /* CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node);
+ emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node);
emitEmbeddedStatement(node, node.statement);
}
function emitForInStatement(node) {
- var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node);
+ var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node);
writeSpace();
- emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node);
+ emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node);
emitForBinding(node.initializer);
writeSpace();
- emitTokenWithComment(101 /* InKeyword */, node.initializer.end, writeKeyword, node);
+ emitTokenWithComment(101 /* SyntaxKind.InKeyword */, node.initializer.end, writeKeyword, node);
writeSpace();
emitExpression(node.expression);
- emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node);
+ emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node);
emitEmbeddedStatement(node, node.statement);
}
function emitForOfStatement(node) {
- var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node);
+ var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node);
writeSpace();
emitWithTrailingSpace(node.awaitModifier);
- emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node);
+ emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node);
emitForBinding(node.initializer);
writeSpace();
- emitTokenWithComment(159 /* OfKeyword */, node.initializer.end, writeKeyword, node);
+ emitTokenWithComment(160 /* SyntaxKind.OfKeyword */, node.initializer.end, writeKeyword, node);
writeSpace();
emitExpression(node.expression);
- emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node);
+ emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node);
emitEmbeddedStatement(node, node.statement);
}
function emitForBinding(node) {
if (node !== undefined) {
- if (node.kind === 254 /* VariableDeclarationList */) {
+ if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) {
emit(node);
}
else {
@@ -110844,12 +112558,12 @@ var ts;
}
}
function emitContinueStatement(node) {
- emitTokenWithComment(86 /* ContinueKeyword */, node.pos, writeKeyword, node);
+ emitTokenWithComment(86 /* SyntaxKind.ContinueKeyword */, node.pos, writeKeyword, node);
emitWithLeadingSpace(node.label);
writeTrailingSemicolon();
}
function emitBreakStatement(node) {
- emitTokenWithComment(81 /* BreakKeyword */, node.pos, writeKeyword, node);
+ emitTokenWithComment(81 /* SyntaxKind.BreakKeyword */, node.pos, writeKeyword, node);
emitWithLeadingSpace(node.label);
writeTrailingSemicolon();
}
@@ -110872,13 +112586,13 @@ var ts;
}
pos = writeTokenText(token, writer, pos);
if (isSimilarNode && contextNode.end !== pos) {
- var isJsxExprContext = contextNode.kind === 287 /* JsxExpression */;
+ var isJsxExprContext = contextNode.kind === 288 /* SyntaxKind.JsxExpression */;
emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext);
}
return pos;
}
function commentWillEmitNewLine(node) {
- return node.kind === 2 /* SingleLineCommentTrivia */ || !!node.hasTrailingNewLine;
+ return node.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || !!node.hasTrailingNewLine;
}
function willEmitLeadingNewLine(node) {
if (!currentSourceFile)
@@ -110918,40 +112632,40 @@ var ts;
return parenthesizeExpressionForNoAsi(parenthesizer.parenthesizeExpressionForDisallowedComma(node));
}
function emitReturnStatement(node) {
- emitTokenWithComment(105 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node);
+ emitTokenWithComment(105 /* SyntaxKind.ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node);
emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi);
writeTrailingSemicolon();
}
function emitWithStatement(node) {
- var openParenPos = emitTokenWithComment(116 /* WithKeyword */, node.pos, writeKeyword, node);
+ var openParenPos = emitTokenWithComment(116 /* SyntaxKind.WithKeyword */, node.pos, writeKeyword, node);
writeSpace();
- emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node);
+ emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node);
emitExpression(node.expression);
- emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node);
+ emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node);
emitEmbeddedStatement(node, node.statement);
}
function emitSwitchStatement(node) {
- var openParenPos = emitTokenWithComment(107 /* SwitchKeyword */, node.pos, writeKeyword, node);
+ var openParenPos = emitTokenWithComment(107 /* SyntaxKind.SwitchKeyword */, node.pos, writeKeyword, node);
writeSpace();
- emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node);
+ emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node);
emitExpression(node.expression);
- emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node);
+ emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node);
writeSpace();
emit(node.caseBlock);
}
function emitLabeledStatement(node) {
emit(node.label);
- emitTokenWithComment(58 /* ColonToken */, node.label.end, writePunctuation, node);
+ emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.label.end, writePunctuation, node);
writeSpace();
emit(node.statement);
}
function emitThrowStatement(node) {
- emitTokenWithComment(109 /* ThrowKeyword */, node.pos, writeKeyword, node);
+ emitTokenWithComment(109 /* SyntaxKind.ThrowKeyword */, node.pos, writeKeyword, node);
emitExpressionWithLeadingSpace(parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi);
writeTrailingSemicolon();
}
function emitTryStatement(node) {
- emitTokenWithComment(111 /* TryKeyword */, node.pos, writeKeyword, node);
+ emitTokenWithComment(111 /* SyntaxKind.TryKeyword */, node.pos, writeKeyword, node);
writeSpace();
emit(node.tryBlock);
if (node.catchClause) {
@@ -110960,28 +112674,29 @@ var ts;
}
if (node.finallyBlock) {
writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock);
- emitTokenWithComment(96 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node);
+ emitTokenWithComment(96 /* SyntaxKind.FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node);
writeSpace();
emit(node.finallyBlock);
}
}
function emitDebuggerStatement(node) {
- writeToken(87 /* DebuggerKeyword */, node.pos, writeKeyword);
+ writeToken(87 /* SyntaxKind.DebuggerKeyword */, node.pos, writeKeyword);
writeTrailingSemicolon();
}
//
// Declarations
//
function emitVariableDeclaration(node) {
+ var _a, _b, _c, _d, _e;
emit(node.name);
emit(node.exclamationToken);
emitTypeAnnotation(node.type);
- emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma);
+ emitInitializer(node.initializer, (_e = (_b = (_a = node.type) === null || _a === void 0 ? void 0 : _a.end) !== null && _b !== void 0 ? _b : (_d = (_c = node.name.emitNode) === null || _c === void 0 ? void 0 : _c.typeNode) === null || _d === void 0 ? void 0 : _d.end) !== null && _e !== void 0 ? _e : node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma);
}
function emitVariableDeclarationList(node) {
writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var");
writeSpace();
- emitList(node, node.declarations, 528 /* VariableDeclarationList */);
+ emitList(node, node.declarations, 528 /* ListFormat.VariableDeclarationList */);
}
function emitFunctionDeclaration(node) {
emitFunctionDeclarationOrExpression(node);
@@ -110999,7 +112714,7 @@ var ts;
var body = node.body;
if (body) {
if (ts.isBlock(body)) {
- var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */;
+ var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */;
if (indentedFlag) {
increaseIndent();
}
@@ -111036,23 +112751,23 @@ var ts;
// * The body is explicitly marked as multi-line.
// * A non-synthesized body's start and end position are on different lines.
// * Any statement in the body starts on a new line.
- if (ts.getEmitFlags(body) & 1 /* SingleLine */) {
+ if (ts.getEmitFlags(body) & 1 /* EmitFlags.SingleLine */) {
return true;
}
if (body.multiLine) {
return false;
}
- if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
+ if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
return false;
}
- if (getLeadingLineTerminatorCount(body, body.statements, 2 /* PreserveLines */)
- || getClosingLineTerminatorCount(body, body.statements, 2 /* PreserveLines */)) {
+ if (getLeadingLineTerminatorCount(body, body.statements, 2 /* ListFormat.PreserveLines */)
+ || getClosingLineTerminatorCount(body, body.statements, 2 /* ListFormat.PreserveLines */)) {
return false;
}
var previousStatement;
for (var _a = 0, _b = body.statements; _a < _b.length; _a++) {
var statement = _b[_a];
- if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* PreserveLines */) > 0) {
+ if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* ListFormat.PreserveLines */) > 0) {
return false;
}
previousStatement = statement;
@@ -111067,14 +112782,9 @@ var ts;
var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body)
? emitBlockFunctionBodyOnSingleLine
: emitBlockFunctionBodyWorker;
- if (emitBodyWithDetachedComments) {
- emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
- }
- else {
- emitBlockFunctionBody(body);
- }
+ emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
decreaseIndent();
- writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body);
+ writeToken(19 /* SyntaxKind.CloseBraceToken */, body.statements.end, writePunctuation, body);
onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body);
}
function emitBlockFunctionBodyOnSingleLine(body) {
@@ -111087,11 +112797,11 @@ var ts;
emitHelpers(body);
if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) {
decreaseIndent();
- emitList(body, body.statements, 768 /* SingleLineFunctionBodyStatements */);
+ emitList(body, body.statements, 768 /* ListFormat.SingleLineFunctionBodyStatements */);
increaseIndent();
}
else {
- emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset);
+ emitList(body, body.statements, 1 /* ListFormat.MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset);
}
}
function emitClassDeclaration(node) {
@@ -111106,15 +112816,15 @@ var ts;
writeSpace();
emitIdentifierName(node.name);
}
- var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */;
+ var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */;
if (indentedFlag) {
increaseIndent();
}
emitTypeParameters(node, node.typeParameters);
- emitList(node, node.heritageClauses, 0 /* ClassHeritageClauses */);
+ emitList(node, node.heritageClauses, 0 /* ListFormat.ClassHeritageClauses */);
writeSpace();
writePunctuation("{");
- emitList(node, node.members, 129 /* ClassMembers */);
+ emitList(node, node.members, 129 /* ListFormat.ClassMembers */);
writePunctuation("}");
if (indentedFlag) {
decreaseIndent();
@@ -111127,10 +112837,10 @@ var ts;
writeSpace();
emit(node.name);
emitTypeParameters(node, node.typeParameters);
- emitList(node, node.heritageClauses, 512 /* HeritageClauses */);
+ emitList(node, node.heritageClauses, 512 /* ListFormat.HeritageClauses */);
writeSpace();
writePunctuation("{");
- emitList(node, node.members, 129 /* InterfaceMembers */);
+ emitList(node, node.members, 129 /* ListFormat.InterfaceMembers */);
writePunctuation("}");
}
function emitTypeAliasDeclaration(node) {
@@ -111153,13 +112863,13 @@ var ts;
emit(node.name);
writeSpace();
writePunctuation("{");
- emitList(node, node.members, 145 /* EnumMembers */);
+ emitList(node, node.members, 145 /* ListFormat.EnumMembers */);
writePunctuation("}");
}
function emitModuleDeclaration(node) {
emitModifiers(node, node.modifiers);
- if (~node.flags & 1024 /* GlobalAugmentation */) {
- writeKeyword(node.flags & 16 /* Namespace */ ? "namespace" : "module");
+ if (~node.flags & 1024 /* NodeFlags.GlobalAugmentation */) {
+ writeKeyword(node.flags & 16 /* NodeFlags.Namespace */ ? "namespace" : "module");
writeSpace();
}
emit(node.name);
@@ -111181,27 +112891,27 @@ var ts;
popNameGenerationScope(node);
}
function emitCaseBlock(node) {
- emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node);
- emitList(node, node.clauses, 129 /* CaseBlockClauses */);
- emitTokenWithComment(19 /* CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true);
+ emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node);
+ emitList(node, node.clauses, 129 /* ListFormat.CaseBlockClauses */);
+ emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true);
}
function emitImportEqualsDeclaration(node) {
emitModifiers(node, node.modifiers);
- emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node);
+ emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node);
writeSpace();
if (node.isTypeOnly) {
- emitTokenWithComment(151 /* TypeKeyword */, node.pos, writeKeyword, node);
+ emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node);
writeSpace();
}
emit(node.name);
writeSpace();
- emitTokenWithComment(63 /* EqualsToken */, node.name.end, writePunctuation, node);
+ emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, node.name.end, writePunctuation, node);
writeSpace();
emitModuleReference(node.moduleReference);
writeTrailingSemicolon();
}
function emitModuleReference(node) {
- if (node.kind === 79 /* Identifier */) {
+ if (node.kind === 79 /* SyntaxKind.Identifier */) {
emitExpression(node);
}
else {
@@ -111210,12 +112920,12 @@ var ts;
}
function emitImportDeclaration(node) {
emitModifiers(node, node.modifiers);
- emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node);
+ emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node);
writeSpace();
if (node.importClause) {
emit(node.importClause);
writeSpace();
- emitTokenWithComment(155 /* FromKeyword */, node.importClause.end, writeKeyword, node);
+ emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, node.importClause.end, writeKeyword, node);
writeSpace();
}
emitExpression(node.moduleSpecifier);
@@ -111226,20 +112936,20 @@ var ts;
}
function emitImportClause(node) {
if (node.isTypeOnly) {
- emitTokenWithComment(151 /* TypeKeyword */, node.pos, writeKeyword, node);
+ emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node);
writeSpace();
}
emit(node.name);
if (node.name && node.namedBindings) {
- emitTokenWithComment(27 /* CommaToken */, node.name.end, writePunctuation, node);
+ emitTokenWithComment(27 /* SyntaxKind.CommaToken */, node.name.end, writePunctuation, node);
writeSpace();
}
emit(node.namedBindings);
}
function emitNamespaceImport(node) {
- var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node);
+ var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node);
writeSpace();
- emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node);
+ emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node);
writeSpace();
emit(node.name);
}
@@ -111250,37 +112960,37 @@ var ts;
emitImportOrExportSpecifier(node);
}
function emitExportAssignment(node) {
- var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node);
+ var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node);
writeSpace();
if (node.isExportEquals) {
- emitTokenWithComment(63 /* EqualsToken */, nextPos, writeOperator, node);
+ emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, nextPos, writeOperator, node);
}
else {
- emitTokenWithComment(88 /* DefaultKeyword */, nextPos, writeKeyword, node);
+ emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, nextPos, writeKeyword, node);
}
writeSpace();
emitExpression(node.expression, node.isExportEquals ?
- parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* EqualsToken */) :
+ parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* SyntaxKind.EqualsToken */) :
parenthesizer.parenthesizeExpressionOfExportDefault);
writeTrailingSemicolon();
}
function emitExportDeclaration(node) {
- var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node);
+ var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node);
writeSpace();
if (node.isTypeOnly) {
- nextPos = emitTokenWithComment(151 /* TypeKeyword */, nextPos, writeKeyword, node);
+ nextPos = emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, nextPos, writeKeyword, node);
writeSpace();
}
if (node.exportClause) {
emit(node.exportClause);
}
else {
- nextPos = emitTokenWithComment(41 /* AsteriskToken */, nextPos, writePunctuation, node);
+ nextPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, nextPos, writePunctuation, node);
}
if (node.moduleSpecifier) {
writeSpace();
var fromPos = node.exportClause ? node.exportClause.end : nextPos;
- emitTokenWithComment(155 /* FromKeyword */, fromPos, writeKeyword, node);
+ emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, fromPos, writeKeyword, node);
writeSpace();
emitExpression(node.moduleSpecifier);
}
@@ -111290,10 +113000,10 @@ var ts;
writeTrailingSemicolon();
}
function emitAssertClause(node) {
- emitTokenWithComment(129 /* AssertKeyword */, node.pos, writeKeyword, node);
+ emitTokenWithComment(129 /* SyntaxKind.AssertKeyword */, node.pos, writeKeyword, node);
writeSpace();
var elements = node.elements;
- emitList(node, elements, 526226 /* ImportClauseEntries */);
+ emitList(node, elements, 526226 /* ListFormat.ImportClauseEntries */);
}
function emitAssertEntry(node) {
emit(node.name);
@@ -111301,26 +113011,26 @@ var ts;
writeSpace();
var value = node.value;
/** @see {emitPropertyAssignment} */
- if ((ts.getEmitFlags(value) & 512 /* NoLeadingComments */) === 0) {
+ if ((ts.getEmitFlags(value) & 512 /* EmitFlags.NoLeadingComments */) === 0) {
var commentRange = ts.getCommentRange(value);
emitTrailingCommentsOfPosition(commentRange.pos);
}
emit(value);
}
function emitNamespaceExportDeclaration(node) {
- var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node);
+ var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node);
writeSpace();
- nextPos = emitTokenWithComment(127 /* AsKeyword */, nextPos, writeKeyword, node);
+ nextPos = emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, nextPos, writeKeyword, node);
writeSpace();
- nextPos = emitTokenWithComment(142 /* NamespaceKeyword */, nextPos, writeKeyword, node);
+ nextPos = emitTokenWithComment(142 /* SyntaxKind.NamespaceKeyword */, nextPos, writeKeyword, node);
writeSpace();
emit(node.name);
writeTrailingSemicolon();
}
function emitNamespaceExport(node) {
- var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node);
+ var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node);
writeSpace();
- emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node);
+ emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node);
writeSpace();
emit(node.name);
}
@@ -111332,7 +113042,7 @@ var ts;
}
function emitNamedImportsOrExports(node) {
writePunctuation("{");
- emitList(node, node.elements, 525136 /* NamedImportsOrExportsElements */);
+ emitList(node, node.elements, 525136 /* ListFormat.NamedImportsOrExportsElements */);
writePunctuation("}");
}
function emitImportOrExportSpecifier(node) {
@@ -111343,7 +113053,7 @@ var ts;
if (node.propertyName) {
emit(node.propertyName);
writeSpace();
- emitTokenWithComment(127 /* AsKeyword */, node.propertyName.end, writeKeyword, node);
+ emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, node.propertyName.end, writeKeyword, node);
writeSpace();
}
emit(node.name);
@@ -111362,7 +113072,7 @@ var ts;
//
function emitJsxElement(node) {
emit(node.openingElement);
- emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */);
+ emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */);
emit(node.closingElement);
}
function emitJsxSelfClosingElement(node) {
@@ -111375,7 +113085,7 @@ var ts;
}
function emitJsxFragment(node) {
emit(node.openingFragment);
- emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */);
+ emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */);
emit(node.closingFragment);
}
function emitJsxOpeningElementOrFragment(node) {
@@ -111404,7 +113114,7 @@ var ts;
writePunctuation(">");
}
function emitJsxAttributes(node) {
- emitList(node, node.properties, 262656 /* JsxElementAttributes */);
+ emitList(node, node.properties, 262656 /* ListFormat.JsxElementAttributes */);
}
function emitJsxAttribute(node) {
emit(node.name);
@@ -111435,17 +113145,17 @@ var ts;
if (isMultiline) {
writer.increaseIndent();
}
- var end = emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node);
+ var end = emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node);
emit(node.dotDotDotToken);
emitExpression(node.expression);
- emitTokenWithComment(19 /* CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node);
+ emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node);
if (isMultiline) {
writer.decreaseIndent();
}
}
}
function emitJsxTagName(node) {
- if (node.kind === 79 /* Identifier */) {
+ if (node.kind === 79 /* SyntaxKind.Identifier */) {
emitExpression(node);
}
else {
@@ -111456,30 +113166,31 @@ var ts;
// Clauses
//
function emitCaseClause(node) {
- emitTokenWithComment(82 /* CaseKeyword */, node.pos, writeKeyword, node);
+ emitTokenWithComment(82 /* SyntaxKind.CaseKeyword */, node.pos, writeKeyword, node);
writeSpace();
emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma);
emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end);
}
function emitDefaultClause(node) {
- var pos = emitTokenWithComment(88 /* DefaultKeyword */, node.pos, writeKeyword, node);
+ var pos = emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, node.pos, writeKeyword, node);
emitCaseOrDefaultClauseRest(node, node.statements, pos);
}
function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) {
var emitAsSingleStatement = statements.length === 1 &&
(
// treat synthesized nodes as located on the same line for emit purposes
- ts.nodeIsSynthesized(parentNode) ||
+ !currentSourceFile ||
+ ts.nodeIsSynthesized(parentNode) ||
ts.nodeIsSynthesized(statements[0]) ||
ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile));
- var format = 163969 /* CaseOrDefaultClauseStatements */;
+ var format = 163969 /* ListFormat.CaseOrDefaultClauseStatements */;
if (emitAsSingleStatement) {
- writeToken(58 /* ColonToken */, colonPos, writePunctuation, parentNode);
+ writeToken(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode);
writeSpace();
- format &= ~(1 /* MultiLine */ | 128 /* Indented */);
+ format &= ~(1 /* ListFormat.MultiLine */ | 128 /* ListFormat.Indented */);
}
else {
- emitTokenWithComment(58 /* ColonToken */, colonPos, writePunctuation, parentNode);
+ emitTokenWithComment(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode);
}
emitList(parentNode, statements, format);
}
@@ -111487,15 +113198,15 @@ var ts;
writeSpace();
writeTokenText(node.token, writeKeyword);
writeSpace();
- emitList(node, node.types, 528 /* HeritageClauseTypes */);
+ emitList(node, node.types, 528 /* ListFormat.HeritageClauseTypes */);
}
function emitCatchClause(node) {
- var openParenPos = emitTokenWithComment(83 /* CatchKeyword */, node.pos, writeKeyword, node);
+ var openParenPos = emitTokenWithComment(83 /* SyntaxKind.CatchKeyword */, node.pos, writeKeyword, node);
writeSpace();
if (node.variableDeclaration) {
- emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node);
+ emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node);
emit(node.variableDeclaration);
- emitTokenWithComment(21 /* CloseParenToken */, node.variableDeclaration.end, writePunctuation, node);
+ emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.variableDeclaration.end, writePunctuation, node);
writeSpace();
}
emit(node.block);
@@ -111515,7 +113226,7 @@ var ts;
// "comment1" is not considered to be leading comment for node.initializer
// but rather a trailing comment on the previous node.
var initializer = node.initializer;
- if ((ts.getEmitFlags(initializer) & 512 /* NoLeadingComments */) === 0) {
+ if ((ts.getEmitFlags(initializer) & 512 /* EmitFlags.NoLeadingComments */) === 0) {
var commentRange = ts.getCommentRange(initializer);
emitTrailingCommentsOfPosition(commentRange.pos);
}
@@ -111532,7 +113243,7 @@ var ts;
}
function emitSpreadAssignment(node) {
if (node.expression) {
- emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node);
+ emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node);
emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma);
}
}
@@ -111563,12 +113274,12 @@ var ts;
}
}
if (node.tags) {
- if (node.tags.length === 1 && node.tags[0].kind === 341 /* JSDocTypeTag */ && !node.comment) {
+ if (node.tags.length === 1 && node.tags[0].kind === 343 /* SyntaxKind.JSDocTypeTag */ && !node.comment) {
writeSpace();
emit(node.tags[0]);
}
else {
- emitList(node, node.tags, 33 /* JSDocComment */);
+ emitList(node, node.tags, 33 /* ListFormat.JSDocComment */);
}
}
writeSpace();
@@ -111602,13 +113313,13 @@ var ts;
emitJSDocTagName(tag.tagName);
emitJSDocTypeExpression(tag.constraint);
writeSpace();
- emitList(tag, tag.typeParameters, 528 /* CommaListElements */);
+ emitList(tag, tag.typeParameters, 528 /* ListFormat.CommaListElements */);
emitJSDocComment(tag.comment);
}
function emitJSDocTypedefTag(tag) {
emitJSDocTagName(tag.tagName);
if (tag.typeExpression) {
- if (tag.typeExpression.kind === 307 /* JSDocTypeExpression */) {
+ if (tag.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */) {
emitJSDocTypeExpression(tag.typeExpression);
}
else {
@@ -111627,7 +113338,7 @@ var ts;
emit(tag.fullName);
}
emitJSDocComment(tag.comment);
- if (tag.typeExpression && tag.typeExpression.kind === 320 /* JSDocTypeLiteral */) {
+ if (tag.typeExpression && tag.typeExpression.kind === 322 /* SyntaxKind.JSDocTypeLiteral */) {
emitJSDocTypeLiteral(tag.typeExpression);
}
}
@@ -111645,14 +113356,14 @@ var ts;
emitJSDocComment(tag.comment);
}
function emitJSDocTypeLiteral(lit) {
- emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* JSDocComment */);
+ emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* ListFormat.JSDocComment */);
}
function emitJSDocSignature(sig) {
if (sig.typeParameters) {
- emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* JSDocComment */);
+ emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* ListFormat.JSDocComment */);
}
if (sig.parameters) {
- emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* JSDocComment */);
+ emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* ListFormat.JSDocComment */);
}
if (sig.type) {
writeLine();
@@ -111700,16 +113411,14 @@ var ts;
function emitSourceFile(node) {
writeLine();
var statements = node.statements;
- if (emitBodyWithDetachedComments) {
- // Emit detached comment if there are no prologue directives or if the first node is synthesized.
- // The synthesized node will have no leading comment so some comments may be missed.
- var shouldEmitDetachedComment = statements.length === 0 ||
- !ts.isPrologueDirective(statements[0]) ||
- ts.nodeIsSynthesized(statements[0]);
- if (shouldEmitDetachedComment) {
- emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
- return;
- }
+ // Emit detached comment if there are no prologue directives or if the first node is synthesized.
+ // The synthesized node will have no leading comment so some comments may be missed.
+ var shouldEmitDetachedComment = statements.length === 0 ||
+ !ts.isPrologueDirective(statements[0]) ||
+ ts.nodeIsSynthesized(statements[0]);
+ if (shouldEmitDetachedComment) {
+ emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
+ return;
}
emitSourceFileWorker(node);
}
@@ -111735,7 +113444,7 @@ var ts;
var pos = writer.getTextPos();
writeComment("/// <reference no-default-lib=\"true\"/>");
if (bundleFileInfo)
- bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* NoDefaultLib */ });
+ bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */ });
writeLine();
}
if (currentSourceFile && currentSourceFile.moduleName) {
@@ -111759,15 +113468,18 @@ var ts;
var pos = writer.getTextPos();
writeComment("/// <reference path=\"".concat(directive.fileName, "\" />"));
if (bundleFileInfo)
- bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName });
+ bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* BundleFileSectionKind.Reference */, data: directive.fileName });
writeLine();
}
for (var _d = 0, types_24 = types; _d < types_24.length; _d++) {
var directive = types_24[_d];
var pos = writer.getTextPos();
- writeComment("/// <reference types=\"".concat(directive.fileName, "\" />"));
+ 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", "\"")
+ : "";
+ writeComment("/// <reference types=\"".concat(directive.fileName, "\" ").concat(resolutionMode, "/>"));
if (bundleFileInfo)
- bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type" /* Type */, data: directive.fileName });
+ bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* BundleFileSectionKind.Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */ : "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */, data: directive.fileName });
writeLine();
}
for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) {
@@ -111775,7 +113487,7 @@ var ts;
var pos = writer.getTextPos();
writeComment("/// <reference lib=\"".concat(directive.fileName, "\" />"));
if (bundleFileInfo)
- bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* Lib */, data: directive.fileName });
+ bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* BundleFileSectionKind.Lib */, data: directive.fileName });
writeLine();
}
}
@@ -111786,22 +113498,22 @@ var ts;
emitHelpers(node);
var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); });
emitTripleSlashDirectivesIfNeeded(node);
- emitList(node, statements, 1 /* MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index);
+ emitList(node, statements, 1 /* ListFormat.MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index);
popNameGenerationScope(node);
}
// Transformation nodes
function emitPartiallyEmittedExpression(node) {
var emitFlags = ts.getEmitFlags(node);
- if (!(emitFlags & 512 /* NoLeadingComments */) && node.pos !== node.expression.pos) {
+ if (!(emitFlags & 512 /* EmitFlags.NoLeadingComments */) && node.pos !== node.expression.pos) {
emitTrailingCommentsOfPosition(node.expression.pos);
}
emitExpression(node.expression);
- if (!(emitFlags & 1024 /* NoTrailingComments */) && node.end !== node.expression.end) {
+ if (!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */) && node.end !== node.expression.end) {
emitLeadingCommentsOfPosition(node.expression.end);
}
}
function emitCommaList(node) {
- emitExpressionList(node, node.elements, 528 /* CommaListElements */, /*parenthesizerRule*/ undefined);
+ emitExpressionList(node, node.elements, 528 /* ListFormat.CommaListElements */, /*parenthesizerRule*/ undefined);
}
/**
* Emits any prologue directives at the start of a Statement list, returning the
@@ -111822,7 +113534,7 @@ var ts;
var pos = writer.getTextPos();
emit(statement);
if (recordBundleFileSection && bundleFileInfo)
- bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: statement.expression.text });
+ bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: statement.expression.text });
if (seenPrologueDirectives) {
seenPrologueDirectives.add(statement.expression.text);
}
@@ -111843,7 +113555,7 @@ var ts;
var pos = writer.getTextPos();
emit(prologue);
if (bundleFileInfo)
- bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: prologue.data });
+ bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: prologue.data });
if (seenPrologueDirectives) {
seenPrologueDirectives.add(prologue.data);
}
@@ -111936,7 +113648,7 @@ var ts;
}
function emitModifiers(node, modifiers) {
if (modifiers && modifiers.length) {
- emitList(node, modifiers, 262656 /* Modifiers */);
+ emitList(node, modifiers, 262656 /* ListFormat.Modifiers */);
writeSpace();
}
}
@@ -111950,7 +113662,7 @@ var ts;
function emitInitializer(node, equalCommentStartPos, container, parenthesizerRule) {
if (node) {
writeSpace();
- emitTokenWithComment(63 /* EqualsToken */, equalCommentStartPos, writeOperator, container);
+ emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, equalCommentStartPos, writeOperator, container);
writeSpace();
emitExpression(node, parenthesizerRule);
}
@@ -111980,7 +113692,7 @@ var ts;
}
}
function emitEmbeddedStatement(parent, node) {
- if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* SingleLine */) {
+ if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* EmitFlags.SingleLine */) {
writeSpace();
emit(node);
}
@@ -111988,7 +113700,7 @@ var ts;
writeLine();
increaseIndent();
if (ts.isEmptyStatement(node)) {
- pipelineEmit(5 /* EmbeddedStatement */, node);
+ pipelineEmit(5 /* EmitHint.EmbeddedStatement */, node);
}
else {
emit(node);
@@ -111997,19 +113709,19 @@ var ts;
}
}
function emitDecorators(parentNode, decorators) {
- emitList(parentNode, decorators, 2146305 /* Decorators */);
+ emitList(parentNode, decorators, 2146305 /* ListFormat.Decorators */);
}
function emitTypeArguments(parentNode, typeArguments) {
- emitList(parentNode, typeArguments, 53776 /* TypeArguments */, parenthesizer.parenthesizeMemberOfElementType);
+ emitList(parentNode, typeArguments, 53776 /* ListFormat.TypeArguments */, typeArgumentParenthesizerRuleSelector);
}
function emitTypeParameters(parentNode, typeParameters) {
if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures
return emitTypeArguments(parentNode, parentNode.typeArguments);
}
- emitList(parentNode, typeParameters, 53776 /* TypeParameters */);
+ emitList(parentNode, typeParameters, 53776 /* ListFormat.TypeParameters */);
}
function emitParameters(parentNode, parameters) {
- emitList(parentNode, parameters, 2576 /* Parameters */);
+ emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */);
}
function canEmitSimpleArrowHead(parentNode, parameters) {
var parameter = ts.singleOrUndefined(parameters);
@@ -112030,32 +113742,32 @@ var ts;
}
function emitParametersForArrow(parentNode, parameters) {
if (canEmitSimpleArrowHead(parentNode, parameters)) {
- emitList(parentNode, parameters, 2576 /* Parameters */ & ~2048 /* Parenthesis */);
+ emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */ & ~2048 /* ListFormat.Parenthesis */);
}
else {
emitParameters(parentNode, parameters);
}
}
function emitParametersForIndexSignature(parentNode, parameters) {
- emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */);
+ emitList(parentNode, parameters, 8848 /* ListFormat.IndexSignatureParameters */);
}
function writeDelimiter(format) {
- switch (format & 60 /* DelimitersMask */) {
- case 0 /* None */:
+ switch (format & 60 /* ListFormat.DelimitersMask */) {
+ case 0 /* ListFormat.None */:
break;
- case 16 /* CommaDelimited */:
+ case 16 /* ListFormat.CommaDelimited */:
writePunctuation(",");
break;
- case 4 /* BarDelimited */:
+ case 4 /* ListFormat.BarDelimited */:
writeSpace();
writePunctuation("|");
break;
- case 32 /* AsteriskDelimited */:
+ case 32 /* ListFormat.AsteriskDelimited */:
writeSpace();
writePunctuation("*");
writeSpace();
break;
- case 8 /* AmpersandDelimited */:
+ case 8 /* ListFormat.AmpersandDelimited */:
writeSpace();
writePunctuation("&");
break;
@@ -112071,11 +113783,11 @@ var ts;
if (start === void 0) { start = 0; }
if (count === void 0) { count = children ? children.length - start : 0; }
var isUndefined = children === undefined;
- if (isUndefined && format & 16384 /* OptionalIfUndefined */) {
+ if (isUndefined && format & 16384 /* ListFormat.OptionalIfUndefined */) {
return;
}
var isEmpty = children === undefined || start >= children.length || count === 0;
- if (isEmpty && format & 32768 /* OptionalIfEmpty */) {
+ if (isEmpty && format & 32768 /* ListFormat.OptionalIfEmpty */) {
if (onBeforeEmitNodeArray) {
onBeforeEmitNodeArray(children);
}
@@ -112084,7 +113796,7 @@ var ts;
}
return;
}
- if (format & 15360 /* BracketsMask */) {
+ if (format & 15360 /* ListFormat.BracketsMask */) {
writePunctuation(getOpeningBracket(format));
if (isEmpty && children) {
emitTrailingCommentsOfPosition(children.pos, /*prefixSpace*/ true); // Emit comments within empty bracketed lists
@@ -112095,30 +113807,31 @@ var ts;
}
if (isEmpty) {
// Write a line terminator if the parent node was multi-line
- if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) {
+ if (format & 1 /* ListFormat.MultiLine */ && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) {
writeLine();
}
- else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) {
+ else if (format & 256 /* ListFormat.SpaceBetweenBraces */ && !(format & 524288 /* ListFormat.NoSpaceIfEmpty */)) {
writeSpace();
}
}
else {
ts.Debug.type(children);
// Write the opening line terminator or leading whitespace.
- var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0;
+ var mayEmitInterveningComments = (format & 262144 /* ListFormat.NoInterveningComments */) === 0;
var shouldEmitInterveningComments = mayEmitInterveningComments;
var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children, format); // TODO: GH#18217
if (leadingLineTerminatorCount) {
writeLine(leadingLineTerminatorCount);
shouldEmitInterveningComments = false;
}
- else if (format & 256 /* SpaceBetweenBraces */) {
+ else if (format & 256 /* ListFormat.SpaceBetweenBraces */) {
writeSpace();
}
// Increase the indent, if requested.
- if (format & 128 /* Indented */) {
+ if (format & 128 /* ListFormat.Indented */) {
increaseIndent();
}
+ var emitListItem = getEmitListItem(emit, parenthesizerRule);
// Emit each child.
var previousSibling = void 0;
var previousSourceFileTextKind = void 0;
@@ -112126,7 +113839,7 @@ var ts;
for (var i = 0; i < count; i++) {
var child = children[start + i];
// Write the delimiter if this is not the first node.
- if (format & 32 /* AsteriskDelimited */) {
+ if (format & 32 /* ListFormat.AsteriskDelimited */) {
// always write JSDoc in the format "\n *"
writeLine();
writeDelimiter(format);
@@ -112138,7 +113851,7 @@ var ts;
// a
// /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline
// ,
- if (format & 60 /* DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) {
+ if (format & 60 /* ListFormat.DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) {
emitLeadingCommentsOfPosition(previousSibling.end);
}
writeDelimiter(format);
@@ -112148,14 +113861,14 @@ var ts;
if (separatingLineTerminatorCount > 0) {
// If a synthesized node in a single-line list starts on a new
// line, we should increase the indent.
- if ((format & (3 /* LinesMask */ | 128 /* Indented */)) === 0 /* SingleLine */) {
+ if ((format & (3 /* ListFormat.LinesMask */ | 128 /* ListFormat.Indented */)) === 0 /* ListFormat.SingleLine */) {
increaseIndent();
shouldDecreaseIndentAfterEmit = true;
}
writeLine(separatingLineTerminatorCount);
shouldEmitInterveningComments = false;
}
- else if (previousSibling && format & 512 /* SpaceBetweenSiblings */) {
+ else if (previousSibling && format & 512 /* ListFormat.SpaceBetweenSiblings */) {
writeSpace();
}
}
@@ -112169,12 +113882,7 @@ var ts;
shouldEmitInterveningComments = mayEmitInterveningComments;
}
nextListElementPos = child.pos;
- if (emit.length === 1) {
- emit(child);
- }
- else {
- emit(child, parenthesizerRule);
- }
+ emitListItem(child, emit, parenthesizerRule, i);
if (shouldDecreaseIndentAfterEmit) {
decreaseIndent();
shouldDecreaseIndentAfterEmit = false;
@@ -112183,11 +113891,11 @@ var ts;
}
// Write a trailing comma, if requested.
var emitFlags = previousSibling ? ts.getEmitFlags(previousSibling) : 0;
- var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* NoTrailingComments */);
- var hasTrailingComma = (children === null || children === void 0 ? void 0 : children.hasTrailingComma) && (format & 64 /* AllowTrailingComma */) && (format & 16 /* CommaDelimited */);
+ var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */);
+ var hasTrailingComma = (children === null || children === void 0 ? void 0 : children.hasTrailingComma) && (format & 64 /* ListFormat.AllowTrailingComma */) && (format & 16 /* ListFormat.CommaDelimited */);
if (hasTrailingComma) {
if (previousSibling && !skipTrailingComments) {
- emitTokenWithComment(27 /* CommaToken */, previousSibling.end, writePunctuation, previousSibling);
+ emitTokenWithComment(27 /* SyntaxKind.CommaToken */, previousSibling.end, writePunctuation, previousSibling);
}
else {
writePunctuation(",");
@@ -112199,11 +113907,11 @@ var ts;
// 2
// /* end of element 2 */
// ];
- if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) {
+ if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* ListFormat.DelimitersMask */) && !skipTrailingComments) {
emitLeadingCommentsOfPosition(hasTrailingComma && (children === null || children === void 0 ? void 0 : children.end) ? children.end : previousSibling.end);
}
// Decrease the indent, if requested.
- if (format & 128 /* Indented */) {
+ if (format & 128 /* ListFormat.Indented */) {
decreaseIndent();
}
recordBundleFileInternalSectionEnd(previousSourceFileTextKind);
@@ -112212,14 +113920,14 @@ var ts;
if (closingLineTerminatorCount) {
writeLine(closingLineTerminatorCount);
}
- else if (format & (2097152 /* SpaceAfterList */ | 256 /* SpaceBetweenBraces */)) {
+ else if (format & (2097152 /* ListFormat.SpaceAfterList */ | 256 /* ListFormat.SpaceBetweenBraces */)) {
writeSpace();
}
}
if (onAfterEmitNodeArray) {
onAfterEmitNodeArray(children);
}
- if (format & 15360 /* BracketsMask */) {
+ if (format & 15360 /* ListFormat.BracketsMask */) {
if (isEmpty && children) {
emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists
}
@@ -112304,7 +114012,7 @@ var ts;
return pos < 0 ? pos : pos + tokenString.length;
}
function writeLineOrSpace(parentNode, prevChildNode, nextChildNode) {
- if (ts.getEmitFlags(parentNode) & 1 /* SingleLine */) {
+ if (ts.getEmitFlags(parentNode) & 1 /* EmitFlags.SingleLine */) {
writeSpace();
}
else if (preserveSourceNewlines) {
@@ -112354,13 +114062,13 @@ var ts;
}
}
function getLeadingLineTerminatorCount(parentNode, children, format) {
- if (format & 2 /* PreserveLines */ || preserveSourceNewlines) {
- if (format & 65536 /* PreferNewLine */) {
+ if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) {
+ if (format & 65536 /* ListFormat.PreferNewLine */) {
return 1;
}
var firstChild_1 = children[0];
if (firstChild_1 === undefined) {
- return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
+ return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
}
if (firstChild_1.pos === nextListElementPos) {
// If this child starts at the beginning of a list item in a parent list, its leading
@@ -112380,11 +114088,11 @@ var ts;
// leading newline to start the modifiers.
return 0;
}
- if (firstChild_1.kind === 11 /* JsxText */) {
+ if (firstChild_1.kind === 11 /* SyntaxKind.JsxText */) {
// JsxText will be written with its leading whitespace, so don't add more manually.
return 0;
}
- if (parentNode &&
+ if (currentSourceFile && parentNode &&
!ts.positionIsSynthesized(parentNode.pos) &&
!ts.nodeIsSynthesized(firstChild_1) &&
(!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) {
@@ -112397,18 +114105,18 @@ var ts;
return 1;
}
}
- return format & 1 /* MultiLine */ ? 1 : 0;
+ return format & 1 /* ListFormat.MultiLine */ ? 1 : 0;
}
function getSeparatingLineTerminatorCount(previousNode, nextNode, format) {
- if (format & 2 /* PreserveLines */ || preserveSourceNewlines) {
+ if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) {
if (previousNode === undefined || nextNode === undefined) {
return 0;
}
- if (nextNode.kind === 11 /* JsxText */) {
+ if (nextNode.kind === 11 /* SyntaxKind.JsxText */) {
// JsxText will be written with its leading whitespace, so don't add more manually.
return 0;
}
- else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) {
+ else if (currentSourceFile && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) {
if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) {
return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); });
}
@@ -112422,7 +114130,7 @@ var ts;
}
// If the two nodes are not comparable, add a line terminator based on the format that can indicate
// whether new lines are preferred or not.
- return format & 65536 /* PreferNewLine */ ? 1 : 0;
+ return format & 65536 /* ListFormat.PreferNewLine */ ? 1 : 0;
}
else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) {
return 1;
@@ -112431,18 +114139,18 @@ var ts;
else if (ts.getStartsOnNewLine(nextNode)) {
return 1;
}
- return format & 1 /* MultiLine */ ? 1 : 0;
+ return format & 1 /* ListFormat.MultiLine */ ? 1 : 0;
}
function getClosingLineTerminatorCount(parentNode, children, format) {
- if (format & 2 /* PreserveLines */ || preserveSourceNewlines) {
- if (format & 65536 /* PreferNewLine */) {
+ if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) {
+ if (format & 65536 /* ListFormat.PreferNewLine */) {
return 1;
}
var lastChild = ts.lastOrUndefined(children);
if (lastChild === undefined) {
- return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
+ return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
}
- if (parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) {
+ 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;
return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); });
@@ -112453,7 +114161,7 @@ var ts;
return 1;
}
}
- if (format & 1 /* MultiLine */ && !(format & 131072 /* NoTrailingNewLine */)) {
+ if (format & 1 /* ListFormat.MultiLine */ && !(format & 131072 /* ListFormat.NoTrailingNewLine */)) {
return 1;
}
return 0;
@@ -112482,14 +114190,14 @@ var ts;
return lines;
}
function writeLineSeparatorsAndIndentBefore(node, parent) {
- var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0 /* None */);
+ var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0 /* ListFormat.None */);
if (leadingNewlines) {
writeLinesAndIndent(leadingNewlines, /*writeSpaceIfNotIndenting*/ false);
}
return !!leadingNewlines;
}
function writeLineSeparatorsAfter(node, parent) {
- var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0 /* None */);
+ var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0 /* ListFormat.None */);
if (trailingNewlines) {
writeLine(trailingNewlines);
}
@@ -112498,14 +114206,14 @@ var ts;
if (ts.nodeIsSynthesized(node)) {
var startsOnNewLine = ts.getStartsOnNewLine(node);
if (startsOnNewLine === undefined) {
- return (format & 65536 /* PreferNewLine */) !== 0;
+ return (format & 65536 /* ListFormat.PreferNewLine */) !== 0;
}
return startsOnNewLine;
}
- return (format & 65536 /* PreferNewLine */) !== 0;
+ return (format & 65536 /* ListFormat.PreferNewLine */) !== 0;
}
function getLinesBetweenNodes(parent, node1, node2) {
- if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) {
+ if (ts.getEmitFlags(parent) & 131072 /* EmitFlags.NoIndentation */) {
return 0;
}
parent = skipSynthesizedParentheses(parent);
@@ -112515,7 +114223,7 @@ var ts;
if (ts.getStartsOnNewLine(node2)) {
return 1;
}
- if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
+ if (currentSourceFile && !ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
if (preserveSourceNewlines) {
return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); });
}
@@ -112525,10 +114233,10 @@ var ts;
}
function isEmptyBlock(block) {
return block.statements.length === 0
- && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile);
+ && (!currentSourceFile || ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile));
}
function skipSynthesizedParentheses(node) {
- while (node.kind === 211 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) {
+ while (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) {
node = node.expression;
}
return node;
@@ -112537,41 +114245,48 @@ var ts;
if (ts.isGeneratedIdentifier(node)) {
return generateName(node);
}
- else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) {
- return ts.idText(node);
- }
- else if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) {
+ if (ts.isStringLiteral(node) && node.textSourceNode) {
return getTextOfNode(node.textSourceNode, includeTrivia);
}
- else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) {
- return node.text;
+ var sourceFile = currentSourceFile; // const needed for control flow
+ var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node);
+ if (ts.isMemberName(node)) {
+ if (!canUseSourceFile || ts.getSourceFileOfNode(node) !== ts.getOriginalNode(sourceFile)) {
+ return ts.idText(node);
+ }
+ }
+ else {
+ ts.Debug.assertNode(node, ts.isLiteralExpression); // not strictly necessary
+ if (!canUseSourceFile) {
+ return node.text;
+ }
}
- return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia);
+ return ts.getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia);
}
function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) {
- if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) {
+ if (node.kind === 10 /* SyntaxKind.StringLiteral */ && node.textSourceNode) {
var textSourceNode = node.textSourceNode;
if (ts.isIdentifier(textSourceNode) || ts.isNumericLiteral(textSourceNode)) {
var text = ts.isNumericLiteral(textSourceNode) ? textSourceNode.text : getTextOfNode(textSourceNode);
return jsxAttributeEscape ? "\"".concat(ts.escapeJsxAttributeString(text), "\"") :
- neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? "\"".concat(ts.escapeString(text), "\"") :
+ neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? "\"".concat(ts.escapeString(text), "\"") :
"\"".concat(ts.escapeNonAsciiString(text), "\"");
}
else {
return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape);
}
}
- var flags = (neverAsciiEscape ? 1 /* NeverAsciiEscape */ : 0)
- | (jsxAttributeEscape ? 2 /* JsxAttributeEscape */ : 0)
- | (printerOptions.terminateUnterminatedLiterals ? 4 /* TerminateUnterminatedLiterals */ : 0)
- | (printerOptions.target && printerOptions.target === 99 /* ESNext */ ? 8 /* AllowNumericSeparator */ : 0);
+ var flags = (neverAsciiEscape ? 1 /* GetLiteralTextFlags.NeverAsciiEscape */ : 0)
+ | (jsxAttributeEscape ? 2 /* GetLiteralTextFlags.JsxAttributeEscape */ : 0)
+ | (printerOptions.terminateUnterminatedLiterals ? 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ : 0)
+ | (printerOptions.target && printerOptions.target === 99 /* ScriptTarget.ESNext */ ? 8 /* GetLiteralTextFlags.AllowNumericSeparator */ : 0);
return ts.getLiteralText(node, currentSourceFile, flags);
}
/**
* Push a new name generation scope.
*/
function pushNameGenerationScope(node) {
- if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) {
+ if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) {
return;
}
tempFlagsStack.push(tempFlags);
@@ -112582,7 +114297,7 @@ var ts;
* Pop the current name generation scope.
*/
function popNameGenerationScope(node) {
- if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) {
+ if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) {
return;
}
tempFlags = tempFlagsStack.pop();
@@ -112598,84 +114313,84 @@ var ts;
if (!node)
return;
switch (node.kind) {
- case 234 /* Block */:
+ case 235 /* SyntaxKind.Block */:
ts.forEach(node.statements, generateNames);
break;
- case 249 /* LabeledStatement */:
- case 247 /* WithStatement */:
- case 239 /* DoStatement */:
- case 240 /* WhileStatement */:
+ case 250 /* SyntaxKind.LabeledStatement */:
+ case 248 /* SyntaxKind.WithStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
generateNames(node.statement);
break;
- case 238 /* IfStatement */:
+ case 239 /* SyntaxKind.IfStatement */:
generateNames(node.thenStatement);
generateNames(node.elseStatement);
break;
- case 241 /* ForStatement */:
- case 243 /* ForOfStatement */:
- case 242 /* ForInStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
generateNames(node.initializer);
generateNames(node.statement);
break;
- case 248 /* SwitchStatement */:
+ case 249 /* SyntaxKind.SwitchStatement */:
generateNames(node.caseBlock);
break;
- case 262 /* CaseBlock */:
+ case 263 /* SyntaxKind.CaseBlock */:
ts.forEach(node.clauses, generateNames);
break;
- case 288 /* CaseClause */:
- case 289 /* DefaultClause */:
+ case 289 /* SyntaxKind.CaseClause */:
+ case 290 /* SyntaxKind.DefaultClause */:
ts.forEach(node.statements, generateNames);
break;
- case 251 /* TryStatement */:
+ case 252 /* SyntaxKind.TryStatement */:
generateNames(node.tryBlock);
generateNames(node.catchClause);
generateNames(node.finallyBlock);
break;
- case 291 /* CatchClause */:
+ case 292 /* SyntaxKind.CatchClause */:
generateNames(node.variableDeclaration);
generateNames(node.block);
break;
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
generateNames(node.declarationList);
break;
- case 254 /* VariableDeclarationList */:
+ case 255 /* SyntaxKind.VariableDeclarationList */:
ts.forEach(node.declarations, generateNames);
break;
- case 253 /* VariableDeclaration */:
- case 163 /* Parameter */:
- case 202 /* BindingElement */:
- case 256 /* ClassDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
+ case 164 /* SyntaxKind.Parameter */:
+ case 203 /* SyntaxKind.BindingElement */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
generateNameIfNeeded(node.name);
break;
- case 255 /* FunctionDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
generateNameIfNeeded(node.name);
- if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) {
+ if (ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) {
ts.forEach(node.parameters, generateNames);
generateNames(node.body);
}
break;
- case 200 /* ObjectBindingPattern */:
- case 201 /* ArrayBindingPattern */:
+ case 201 /* SyntaxKind.ObjectBindingPattern */:
+ case 202 /* SyntaxKind.ArrayBindingPattern */:
ts.forEach(node.elements, generateNames);
break;
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
generateNames(node.importClause);
break;
- case 266 /* ImportClause */:
+ case 267 /* SyntaxKind.ImportClause */:
generateNameIfNeeded(node.name);
generateNames(node.namedBindings);
break;
- case 267 /* NamespaceImport */:
+ case 268 /* SyntaxKind.NamespaceImport */:
generateNameIfNeeded(node.name);
break;
- case 273 /* NamespaceExport */:
+ case 274 /* SyntaxKind.NamespaceExport */:
generateNameIfNeeded(node.name);
break;
- case 268 /* NamedImports */:
+ case 269 /* SyntaxKind.NamedImports */:
ts.forEach(node.elements, generateNames);
break;
- case 269 /* ImportSpecifier */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
generateNameIfNeeded(node.propertyName || node.name);
break;
}
@@ -112684,12 +114399,12 @@ var ts;
if (!node)
return;
switch (node.kind) {
- case 294 /* PropertyAssignment */:
- case 295 /* ShorthandPropertyAssignment */:
- case 166 /* PropertyDeclaration */:
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
generateNameIfNeeded(node.name);
break;
}
@@ -112708,7 +114423,7 @@ var ts;
* Generate the text for a generated identifier.
*/
function generateName(name) {
- if ((name.autoGenerateFlags & 7 /* KindMask */) === 4 /* Node */) {
+ if ((name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) === 4 /* GeneratedIdentifierFlags.Node */) {
// Node names generate unique names based on their original node
// and are cached based on that node's id.
return generateNameCached(getNodeForGeneratedName(name), name.autoGenerateFlags);
@@ -112747,7 +114462,7 @@ var ts;
if (node.locals) {
var local = node.locals.get(ts.escapeLeadingUnderscores(name));
// We conservatively include alias symbols to cover cases where they're emitted as locals
- if (local && local.flags & (111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) {
+ if (local && local.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */)) {
return false;
}
}
@@ -112761,7 +114476,7 @@ var ts;
*/
function makeTempVariableName(flags, reservedInNestedScopes) {
if (flags && !(tempFlags & flags)) {
- var name = flags === 268435456 /* _i */ ? "_i" : "_n";
+ var name = flags === 268435456 /* TempFlags._i */ ? "_i" : "_n";
if (isUniqueName(name)) {
tempFlags |= flags;
if (reservedInNestedScopes) {
@@ -112771,12 +114486,12 @@ var ts;
}
}
while (true) {
- var count = tempFlags & 268435455 /* CountMask */;
+ var count = tempFlags & 268435455 /* TempFlags.CountMask */;
tempFlags++;
// Skip over 'i' and 'n'
if (count !== 8 && count !== 13) {
var name = count < 26
- ? "_" + String.fromCharCode(97 /* a */ + count)
+ ? "_" + String.fromCharCode(97 /* CharacterCodes.a */ + count)
: "_" + (count - 26);
if (isUniqueName(name)) {
if (reservedInNestedScopes) {
@@ -112808,7 +114523,7 @@ var ts;
}
}
// Find the first unique 'name_n', where n is a positive number
- if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) {
+ if (baseName.charCodeAt(baseName.length - 1) !== 95 /* CharacterCodes._ */) {
baseName += "_";
}
var i = 1;
@@ -112862,48 +114577,48 @@ var ts;
if (ts.isIdentifier(node.name)) {
return generateNameCached(node.name);
}
- return makeTempVariableName(0 /* Auto */);
+ return makeTempVariableName(0 /* TempFlags.Auto */);
}
/**
* Generates a unique name from a node.
*/
function generateNameForNode(node, flags) {
switch (node.kind) {
- case 79 /* Identifier */:
- return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */));
- case 260 /* ModuleDeclaration */:
- case 259 /* EnumDeclaration */:
+ case 79 /* SyntaxKind.Identifier */:
+ return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(flags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */));
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
return generateNameForModuleOrEnum(node);
- case 265 /* ImportDeclaration */:
- case 271 /* ExportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
return generateNameForImportOrExportDeclaration(node);
- case 255 /* FunctionDeclaration */:
- case 256 /* ClassDeclaration */:
- case 270 /* ExportAssignment */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 271 /* SyntaxKind.ExportAssignment */:
return generateNameForExportDefault();
- case 225 /* ClassExpression */:
+ case 226 /* SyntaxKind.ClassExpression */:
return generateNameForClassExpression();
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
return generateNameForMethodOrAccessor(node);
- case 161 /* ComputedPropertyName */:
- return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true);
+ case 162 /* SyntaxKind.ComputedPropertyName */:
+ return makeTempVariableName(0 /* TempFlags.Auto */, /*reserveInNestedScopes*/ true);
default:
- return makeTempVariableName(0 /* Auto */);
+ return makeTempVariableName(0 /* TempFlags.Auto */);
}
}
/**
* Generates a unique identifier for a node.
*/
function makeName(name) {
- switch (name.autoGenerateFlags & 7 /* KindMask */) {
- case 1 /* Auto */:
- return makeTempVariableName(0 /* Auto */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */));
- case 2 /* Loop */:
- return makeTempVariableName(268435456 /* _i */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */));
- case 3 /* Unique */:
- return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* Optimistic */), !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */));
+ switch (name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) {
+ case 1 /* GeneratedIdentifierFlags.Auto */:
+ return makeTempVariableName(0 /* TempFlags.Auto */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */));
+ case 2 /* GeneratedIdentifierFlags.Loop */:
+ return makeTempVariableName(268435456 /* TempFlags._i */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */));
+ case 3 /* GeneratedIdentifierFlags.Unique */:
+ return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* GeneratedIdentifierFlags.FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */));
}
return ts.Debug.fail("Unsupported GeneratedIdentifierKind.");
}
@@ -112919,7 +114634,7 @@ var ts;
// if "node" is a different generated name (having a different
// "autoGenerateId"), use it and stop traversing.
if (ts.isIdentifier(node)
- && !!(node.autoGenerateFlags & 4 /* Node */)
+ && !!(node.autoGenerateFlags & 4 /* GeneratedIdentifierFlags.Node */)
&& node.autoGenerateId !== autoGenerateId) {
break;
}
@@ -112930,7 +114645,7 @@ var ts;
}
// Comments
function pipelineEmitWithComments(hint, node) {
- var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node);
+ var pipelinePhase = getNextPipelinePhase(2 /* PipelinePhase.Comments */, hint, node);
var savedContainerPos = containerPos;
var savedContainerEnd = containerEnd;
var savedDeclarationListContainerEnd = declarationListContainerEnd;
@@ -112943,7 +114658,7 @@ var ts;
var commentRange = ts.getCommentRange(node);
// Emit leading comments
emitLeadingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end);
- if (emitFlags & 2048 /* NoNestedComments */) {
+ if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) {
commentsDisabled = true;
}
}
@@ -112951,35 +114666,39 @@ var ts;
var emitFlags = ts.getEmitFlags(node);
var commentRange = ts.getCommentRange(node);
// Emit trailing comments
- if (emitFlags & 2048 /* NoNestedComments */) {
+ if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) {
commentsDisabled = false;
}
emitTrailingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd);
+ var typeNode = ts.getTypeNode(node);
+ if (typeNode) {
+ emitTrailingCommentsOfNode(node, emitFlags, typeNode.pos, typeNode.end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd);
+ }
}
function emitLeadingCommentsOfNode(node, emitFlags, pos, end) {
enterComment();
hasWrittenComment = false;
// We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation.
// It is expensive to walk entire tree just to set one kind of node to have no comments.
- var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */;
- var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */;
+ var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */;
+ var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */;
// Save current container state on the stack.
if ((pos > 0 || end > 0) && pos !== end) {
// Emit leading comments if the position is not synthesized and the node
// has not opted out from emitting leading comments.
if (!skipLeadingComments) {
- emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 347 /* NotEmittedStatement */);
+ emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* SyntaxKind.NotEmittedStatement */);
}
- if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) {
+ if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0)) {
// Advance the container position if comments get emitted or if they've been disabled explicitly using NoLeadingComments.
containerPos = pos;
}
- if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* NoTrailingComments */) !== 0)) {
+ if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0)) {
// As above.
containerEnd = end;
// To avoid invalid comment emit in a down-level binding pattern, we
// keep track of the last declaration list container's end
- if (node.kind === 254 /* VariableDeclarationList */) {
+ if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) {
declarationListContainerEnd = end;
}
}
@@ -112989,7 +114708,7 @@ var ts;
}
function emitTrailingCommentsOfNode(node, emitFlags, pos, end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) {
enterComment();
- var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */;
+ var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */;
ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment);
if ((pos > 0 || end > 0) && pos !== end) {
// Restore previous container state.
@@ -112998,18 +114717,18 @@ var ts;
declarationListContainerEnd = savedDeclarationListContainerEnd;
// Emit trailing comments if the position is not synthesized and the node
// has not opted out from emitting leading comments and is an emitted node.
- if (!skipTrailingComments && node.kind !== 347 /* NotEmittedStatement */) {
+ if (!skipTrailingComments && node.kind !== 349 /* SyntaxKind.NotEmittedStatement */) {
emitTrailingComments(end);
}
}
exitComment();
}
function emitLeadingSynthesizedComment(comment) {
- if (comment.hasLeadingNewline || comment.kind === 2 /* SingleLineCommentTrivia */) {
+ if (comment.hasLeadingNewline || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) {
writer.writeLine();
}
writeSynthesizedComment(comment);
- if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) {
+ if (comment.hasTrailingNewLine || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) {
writer.writeLine();
}
else {
@@ -113027,11 +114746,11 @@ var ts;
}
function writeSynthesizedComment(comment) {
var text = formatSynthesizedComment(comment);
- var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined;
+ var lineMap = comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined;
ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine);
}
function formatSynthesizedComment(comment) {
- return comment.kind === 3 /* MultiLineCommentTrivia */
+ return comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */
? "/*".concat(comment.text, "*/")
: "//".concat(comment.text);
}
@@ -113039,13 +114758,13 @@ var ts;
enterComment();
var pos = detachedRange.pos, end = detachedRange.end;
var emitFlags = ts.getEmitFlags(node);
- var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0;
- var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0;
+ var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0;
+ var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0;
if (!skipLeadingComments) {
emitDetachedCommentsAndUpdateCommentsInfo(detachedRange);
}
exitComment();
- if (emitFlags & 2048 /* NoNestedComments */ && !commentsDisabled) {
+ if (emitFlags & 2048 /* EmitFlags.NoNestedComments */ && !commentsDisabled) {
commentsDisabled = true;
emitCallback(node);
commentsDisabled = false;
@@ -113121,7 +114840,7 @@ var ts;
return true;
}
function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
return;
if (!hasWrittenComment) {
ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos);
@@ -113134,7 +114853,7 @@ var ts;
if (hasTrailingNewLine) {
writer.writeLine();
}
- else if (kind === 3 /* MultiLineCommentTrivia */) {
+ else if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) {
writer.writeSpace(" ");
}
}
@@ -113148,7 +114867,7 @@ var ts;
forEachTrailingCommentToEmit(pos, emitTrailingComment);
}
function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) {
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
return;
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/
if (!writer.isAtStartOfLine()) {
@@ -113170,15 +114889,19 @@ var ts;
exitComment();
}
function emitTrailingCommentOfPositionNoNewline(commentPos, commentEnd, kind) {
+ if (!currentSourceFile)
+ return;
// trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space
emitPos(commentPos);
ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
emitPos(commentEnd);
- if (kind === 2 /* SingleLineCommentTrivia */) {
+ if (kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) {
writer.writeLine(); // still write a newline for single-line comments, so closing tokens aren't written on the same line
}
}
function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) {
+ if (!currentSourceFile)
+ return;
// trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space
emitPos(commentPos);
ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
@@ -113211,6 +114934,8 @@ var ts;
return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos;
}
function forEachLeadingCommentWithoutDetachedComments(cb) {
+ if (!currentSourceFile)
+ return;
// get the leading comments from detachedPos
var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos;
if (detachedCommentsInfo.length - 1) {
@@ -113222,7 +114947,7 @@ var ts;
ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos);
}
function emitDetachedCommentsAndUpdateCommentsInfo(range) {
- var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
+ var currentDetachedCommentInfo = currentSourceFile && ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
if (currentDetachedCommentInfo) {
if (detachedCommentsInfo) {
detachedCommentsInfo.push(currentDetachedCommentInfo);
@@ -113233,7 +114958,7 @@ var ts;
}
}
function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) {
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
return;
emitPos(commentPos);
ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine);
@@ -113245,7 +114970,7 @@ var ts;
* @return true if the comment is a triple-slash comment else false
*/
function isTripleSlashComment(commentPos, commentEnd) {
- return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
+ return !!currentSourceFile && ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
}
// Source Maps
function getParsedSourceMap(node) {
@@ -113255,7 +114980,7 @@ var ts;
return node.parsedSourceMap || undefined;
}
function pipelineEmitWithSourceMaps(hint, node) {
- var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, hint, node);
+ var pipelinePhase = getNextPipelinePhase(3 /* PipelinePhase.SourceMaps */, hint, node);
emitSourceMapsBeforeNode(node);
pipelinePhase(hint, node);
emitSourceMapsAfterNode(node);
@@ -113273,12 +114998,12 @@ var ts;
}
else {
var source = sourceMapRange.source || sourceMapSource;
- if (node.kind !== 347 /* NotEmittedStatement */
- && (emitFlags & 16 /* NoLeadingSourceMap */) === 0
+ if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */
+ && (emitFlags & 16 /* EmitFlags.NoLeadingSourceMap */) === 0
&& sourceMapRange.pos >= 0) {
emitSourcePos(sourceMapRange.source || sourceMapSource, skipSourceTrivia(source, sourceMapRange.pos));
}
- if (emitFlags & 64 /* NoNestedSourceMaps */) {
+ if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) {
sourceMapsDisabled = true;
}
}
@@ -113288,11 +115013,11 @@ var ts;
var sourceMapRange = ts.getSourceMapRange(node);
// Emit trailing sourcemap
if (!ts.isUnparsedNode(node)) {
- if (emitFlags & 64 /* NoNestedSourceMaps */) {
+ if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) {
sourceMapsDisabled = false;
}
- if (node.kind !== 347 /* NotEmittedStatement */
- && (emitFlags & 32 /* NoTrailingSourceMap */) === 0
+ if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */
+ && (emitFlags & 32 /* EmitFlags.NoTrailingSourceMap */) === 0
&& sourceMapRange.end >= 0) {
emitSourcePos(sourceMapRange.source || sourceMapSource, sourceMapRange.end);
}
@@ -113345,17 +115070,17 @@ var ts;
return emitCallback(token, writer, tokenPos);
}
var emitNode = node && node.emitNode;
- var emitFlags = emitNode && emitNode.flags || 0 /* None */;
+ var emitFlags = emitNode && emitNode.flags || 0 /* EmitFlags.None */;
var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token];
var source = range && range.source || sourceMapSource;
tokenPos = skipSourceTrivia(source, range ? range.pos : tokenPos);
- if ((emitFlags & 128 /* NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) {
+ if ((emitFlags & 128 /* EmitFlags.NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) {
emitSourcePos(source, tokenPos);
}
tokenPos = emitCallback(token, writer, tokenPos);
if (range)
tokenPos = range.end;
- if ((emitFlags & 256 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) {
+ if ((emitFlags & 256 /* EmitFlags.NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) {
emitSourcePos(source, tokenPos);
}
return tokenPos;
@@ -113386,23 +115111,23 @@ var ts;
sourceMapSourceIndex = sourceIndex;
}
function isJsonSourceMapSource(sourceFile) {
- return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */);
+ return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Extension.Json */);
}
}
ts.createPrinter = createPrinter;
function createBracketsMap() {
var brackets = [];
- brackets[1024 /* Braces */] = ["{", "}"];
- brackets[2048 /* Parenthesis */] = ["(", ")"];
- brackets[4096 /* AngleBrackets */] = ["<", ">"];
- brackets[8192 /* SquareBrackets */] = ["[", "]"];
+ brackets[1024 /* ListFormat.Braces */] = ["{", "}"];
+ brackets[2048 /* ListFormat.Parenthesis */] = ["(", ")"];
+ brackets[4096 /* ListFormat.AngleBrackets */] = ["<", ">"];
+ brackets[8192 /* ListFormat.SquareBrackets */] = ["[", "]"];
return brackets;
}
function getOpeningBracket(format) {
- return brackets[format & 15360 /* BracketsMask */][0];
+ return brackets[format & 15360 /* ListFormat.BracketsMask */][0];
}
function getClosingBracket(format) {
- return brackets[format & 15360 /* BracketsMask */][1];
+ return brackets[format & 15360 /* ListFormat.BracketsMask */][1];
}
// Flags enum to track count of temp variables and a few dedicated names
var TempFlags;
@@ -113411,6 +115136,20 @@ var ts;
TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask";
TempFlags[TempFlags["_i"] = 268435456] = "_i";
})(TempFlags || (TempFlags = {}));
+ function emitListItemNoParenthesizer(node, emit, _parenthesizerRule, _index) {
+ emit(node);
+ }
+ function emitListItemWithParenthesizerRuleSelector(node, emit, parenthesizerRuleSelector, index) {
+ emit(node, parenthesizerRuleSelector.select(index));
+ }
+ function emitListItemWithParenthesizerRule(node, emit, parenthesizerRule, _index) {
+ emit(node, parenthesizerRule);
+ }
+ function getEmitListItem(emit, parenthesizerRule) {
+ return emit.length === 1 ? emitListItemNoParenthesizer :
+ typeof parenthesizerRule === "object" ? emitListItemWithParenthesizerRuleSelector :
+ emitListItemWithParenthesizerRule;
+ }
})(ts || (ts = {}));
/* @internal */
var ts;
@@ -113777,7 +115516,7 @@ var ts;
if (ts.outFile(options) || options.outDir)
return false;
// File if emitted next to input needs to be ignored
- if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts" /* Dts */)) {
+ if (ts.isDeclarationFileName(fileOrDirectoryPath)) {
// If its declaration directory: its not ignored if not excluded by config
if (options.declarationDir)
return false;
@@ -113789,8 +115528,8 @@ var ts;
var filePathWithoutExtension = ts.removeFileExtension(fileOrDirectoryPath);
var realProgram = ts.isArray(program) ? undefined : isBuilderProgram(program) ? program.getProgramOrUndefined() : program;
var builderProgram = !realProgram && !ts.isArray(program) ? program : undefined;
- if (hasSourceFile((filePathWithoutExtension + ".ts" /* Ts */)) ||
- hasSourceFile((filePathWithoutExtension + ".tsx" /* Tsx */))) {
+ if (hasSourceFile((filePathWithoutExtension + ".ts" /* Extension.Ts */)) ||
+ hasSourceFile((filePathWithoutExtension + ".tsx" /* Extension.Tsx */))) {
writeLog("Project: ".concat(configFileName, " Detected output file: ").concat(fileOrDirectory));
return true;
}
@@ -113824,7 +115563,7 @@ var ts;
ts.setSysLog(watchLogLevel === WatchLogLevel.Verbose ? log : ts.noop);
var plainInvokeFactory = {
watchFile: function (file, callback, pollingInterval, options) { return host.watchFile(file, callback, pollingInterval, options); },
- watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* Recursive */) !== 0, options); },
+ watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* WatchDirectoryFlags.Recursive */) !== 0, options); },
};
var triggerInvokingFactory = watchLogLevel !== WatchLogLevel.None ?
{
@@ -113991,7 +115730,7 @@ var ts;
var existingDirectories = new ts.Map();
var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
var computeHash = ts.maybeBind(system, system.createHash) || ts.generateDjb2Hash;
- function getSourceFile(fileName, languageVersion, onError) {
+ function getSourceFile(fileName, languageVersionOrOptions, onError) {
var text;
try {
ts.performance.mark("beforeIORead");
@@ -114005,7 +115744,7 @@ var ts;
}
text = "";
}
- return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined;
+ return text !== undefined ? ts.createSourceFile(fileName, text, languageVersionOrOptions, setParentNodes) : undefined;
}
function directoryExists(directoryPath) {
if (existingDirectories.has(directoryPath)) {
@@ -114119,7 +115858,7 @@ var ts;
if (value !== undefined)
return value !== false ? value : undefined; // could be .d.ts from output
// Cache json or buildInfo
- if (!ts.fileExtensionIs(fileName, ".json" /* Json */) && !ts.isBuildInfoFile(fileName)) {
+ if (!ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) && !ts.isBuildInfoFile(fileName)) {
return originalReadFile.call(host, fileName);
}
return setReadFileCache(key, fileName);
@@ -114130,7 +115869,7 @@ var ts;
if (value)
return value;
var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile);
- if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */))) {
+ if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */))) {
sourceFileCache.set(key, sourceFile);
}
return sourceFile;
@@ -114146,7 +115885,11 @@ var ts;
return newValue;
};
if (originalWriteFile) {
- host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) {
+ host.writeFile = function (fileName, data) {
+ var rest = [];
+ for (var _i = 2; _i < arguments.length; _i++) {
+ rest[_i - 2] = arguments[_i];
+ }
var key = toPath(fileName);
fileExistsCache.delete(key);
var value = readFileCache.get(key);
@@ -114160,7 +115903,7 @@ var ts;
sourceFileCache.delete(key);
}
}
- originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles);
+ originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false));
};
}
// directoryExists
@@ -114374,7 +116117,7 @@ var ts;
}
ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText;
/* @internal */
- function loadWithLocalCache(names, containingFile, redirectedReference, loader) {
+ function loadWithTypeDirectiveCache(names, containingFile, redirectedReference, containingFileMode, loader) {
if (names.length === 0) {
return [];
}
@@ -114383,19 +116126,28 @@ var ts;
for (var _i = 0, names_2 = names; _i < names_2.length; _i++) {
var name = names_2[_i];
var result = void 0;
- if (cache.has(name)) {
- result = cache.get(name);
+ var mode = getModeForFileReference(name, containingFileMode);
+ // We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
+ var strName = ts.isString(name) ? name : name.fileName.toLowerCase();
+ var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(strName) : strName;
+ if (cache.has(cacheKey)) {
+ result = cache.get(cacheKey);
}
else {
- cache.set(name, result = loader(name, containingFile, redirectedReference));
+ cache.set(cacheKey, result = loader(strName, containingFile, redirectedReference, mode));
}
resolutions.push(result);
}
return resolutions;
}
- ts.loadWithLocalCache = loadWithLocalCache;
+ ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
;
/* @internal */
+ function getModeForFileReference(ref, containingFileMode) {
+ return (ts.isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
+ }
+ ts.getModeForFileReference = getModeForFileReference;
+ /* @internal */
function getModeForResolutionAtIndex(file, index) {
if (file.impliedNodeFormat === undefined)
return undefined;
@@ -114405,21 +116157,72 @@ var ts;
}
ts.getModeForResolutionAtIndex = getModeForResolutionAtIndex;
/* @internal */
- function getModeForUsageLocation(file, usage) {
+ function isExclusivelyTypeOnlyImportOrExport(decl) {
var _a;
+ if (ts.isExportDeclaration(decl)) {
+ return decl.isTypeOnly;
+ }
+ if ((_a = decl.importClause) === null || _a === void 0 ? void 0 : _a.isTypeOnly) {
+ return true;
+ }
+ return false;
+ }
+ ts.isExclusivelyTypeOnlyImportOrExport = isExclusivelyTypeOnlyImportOrExport;
+ /* @internal */
+ function getModeForUsageLocation(file, usage) {
+ var _a, _b;
if (file.impliedNodeFormat === undefined)
return undefined;
+ if ((ts.isImportDeclaration(usage.parent) || ts.isExportDeclaration(usage.parent))) {
+ var isTypeOnly = isExclusivelyTypeOnlyImportOrExport(usage.parent);
+ if (isTypeOnly) {
+ var override = getResolutionModeOverrideForClause(usage.parent.assertClause);
+ if (override) {
+ return override;
+ }
+ }
+ }
+ if (usage.parent.parent && ts.isImportTypeNode(usage.parent.parent)) {
+ var override = getResolutionModeOverrideForClause((_a = usage.parent.parent.assertions) === null || _a === void 0 ? void 0 : _a.assertClause);
+ if (override) {
+ return override;
+ }
+ }
if (file.impliedNodeFormat !== ts.ModuleKind.ESNext) {
// in cjs files, import call expressions are esm format, otherwise everything is cjs
return ts.isImportCall(ts.walkUpParenthesizedExpressions(usage.parent)) ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
}
// in esm files, import=require statements are cjs format, otherwise everything is esm
// imports are only parent'd up to their containing declaration/expression, so access farther parents with care
- var exprParentParent = (_a = ts.walkUpParenthesizedExpressions(usage.parent)) === null || _a === void 0 ? void 0 : _a.parent;
+ var exprParentParent = (_b = ts.walkUpParenthesizedExpressions(usage.parent)) === null || _b === void 0 ? void 0 : _b.parent;
return exprParentParent && ts.isImportEqualsDeclaration(exprParentParent) ? ts.ModuleKind.CommonJS : ts.ModuleKind.ESNext;
}
ts.getModeForUsageLocation = getModeForUsageLocation;
/* @internal */
+ function getResolutionModeOverrideForClause(clause, grammarErrorOnNode) {
+ if (!clause)
+ return undefined;
+ if (ts.length(clause.elements) !== 1) {
+ grammarErrorOnNode === null || grammarErrorOnNode === void 0 ? void 0 : grammarErrorOnNode(clause, ts.Diagnostics.Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require);
+ return undefined;
+ }
+ var elem = clause.elements[0];
+ if (!ts.isStringLiteralLike(elem.name))
+ return undefined;
+ if (elem.name.text !== "resolution-mode") {
+ grammarErrorOnNode === null || grammarErrorOnNode === void 0 ? void 0 : grammarErrorOnNode(elem.name, ts.Diagnostics.resolution_mode_is_the_only_valid_key_for_type_import_assertions);
+ return undefined;
+ }
+ if (!ts.isStringLiteralLike(elem.value))
+ return undefined;
+ if (elem.value.text !== "import" && elem.value.text !== "require") {
+ grammarErrorOnNode === null || grammarErrorOnNode === void 0 ? void 0 : grammarErrorOnNode(elem.value, ts.Diagnostics.resolution_mode_should_be_either_require_or_import);
+ return undefined;
+ }
+ return elem.value.text === "import" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
+ }
+ ts.getResolutionModeOverrideForClause = getResolutionModeOverrideForClause;
+ /* @internal */
function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, loader) {
if (names.length === 0) {
return [];
@@ -114498,7 +116301,7 @@ var ts;
var _d, _e, _f, _g;
var file = ts.Debug.checkDefined(getSourceFileByPath(ref.file));
var kind = ref.kind, index = ref.index;
- var pos, end, packageId;
+ var pos, end, packageId, resolutionMode;
switch (kind) {
case ts.FileIncludeKind.Import:
var importLiteral = getModuleNameStringLiteralAt(file, index);
@@ -114512,8 +116315,8 @@ var ts;
(_a = file.referencedFiles[index], pos = _a.pos, end = _a.end);
break;
case ts.FileIncludeKind.TypeReferenceDirective:
- (_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
- packageId = (_g = (_f = file.resolvedTypeReferenceDirectiveNames) === null || _f === void 0 ? void 0 : _f.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), file.impliedNodeFormat)) === null || _g === void 0 ? void 0 : _g.packageId;
+ (_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end, resolutionMode = _b.resolutionMode);
+ packageId = (_g = (_f = file.resolvedTypeReferenceDirectiveNames) === null || _f === void 0 ? void 0 : _f.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), resolutionMode || file.impliedNodeFormat)) === null || _g === void 0 ? void 0 : _g.packageId;
break;
case ts.FileIncludeKind.LibReferenceDirective:
(_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
@@ -114612,11 +116415,11 @@ var ts;
*/
function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) {
switch (ts.getEmitModuleResolutionKind(options)) {
- case ts.ModuleResolutionKind.Node12:
+ case ts.ModuleResolutionKind.Node16:
case ts.ModuleResolutionKind.NodeNext:
- return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? ts.ModuleKind.ESNext :
- ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? ts.ModuleKind.CommonJS :
- ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() :
+ return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ts.ModuleKind.ESNext :
+ ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ts.ModuleKind.CommonJS :
+ ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Extension.Dts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */]) ? lookupFromPackageJson() :
undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline
default:
return undefined;
@@ -114666,7 +116469,6 @@ var ts;
ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer.code,
ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list.code,
ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma.code,
- ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body.code,
ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code,
ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code,
ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code,
@@ -114750,14 +116552,13 @@ var ts;
var files;
var symlinks;
var commonSourceDirectory;
- var diagnosticsProducingTypeChecker;
- var noDiagnosticsTypeChecker;
+ var typeChecker;
var classifiableNames;
var ambientModuleNameToUnmodifiedFileName = new ts.Map();
var fileReasons = ts.createMultiMap();
var cachedBindAndCheckDiagnosticsForFile = {};
var cachedDeclarationDiagnosticsForFile = {};
- var resolvedTypeReferenceDirectives = new ts.Map();
+ var resolvedTypeReferenceDirectives = ts.createModeAwareCache();
var fileProcessingDiagnostics;
// The below settings are to track if a .js file should be add to the program if loaded via searching under node_modules.
// This works as imported modules are discovered recursively in a depth first manner, specifically:
@@ -114773,7 +116574,7 @@ var ts;
var modulesWithElidedImports = new ts.Map();
// Track source files that are source files found by searching under node_modules, as these shouldn't be compiled.
var sourceFilesFoundSearchingNodeModules = new ts.Map();
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true);
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true);
ts.performance.mark("beforeProgram");
var host = createProgramOptions.host || createCompilerHost(options);
var configParsingHost = parseConfigHostFromCompilerHostLike(host);
@@ -114810,12 +116611,12 @@ var ts;
}
var actualResolveTypeReferenceDirectiveNamesWorker;
if (host.resolveTypeReferenceDirectives) {
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); };
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options, containingFileMode); };
}
else {
typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
- var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; // TODO: GH#18217
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); };
+ var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode).resolvedTypeReferenceDirective; }; // TODO: GH#18217
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) { return loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_2); };
}
// Map from a stringified PackageId to the source file with that id.
// Only one source file may have a given packageId. Others become redirects (see createRedirectSourceFile).
@@ -114854,16 +116655,16 @@ var ts;
forEachResolvedProjectReference: forEachResolvedProjectReference
}), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists;
var readFile = host.readFile.bind(host);
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
// We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks
// `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`.
var structureIsReused;
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {});
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "tryReuseStructureFromOldProgram", {});
structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
- if (structureIsReused !== 2 /* Completely */) {
+ if (structureIsReused !== 2 /* StructureIsReused.Completely */) {
processingDefaultLibFiles = [];
processingOtherFiles = [];
if (projectReferences) {
@@ -114891,7 +116692,7 @@ var ts;
var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); });
for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) {
var fileName = _c[_b];
- if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
+ if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) {
processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index });
}
}
@@ -114900,19 +116701,20 @@ var ts;
});
}
}
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processRootFiles", { count: rootNames.length });
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processRootFiles", { count: rootNames.length });
ts.forEach(rootNames, function (name, index) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.RootFile, index: index }); });
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
// load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders
var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray;
if (typeReferences.length) {
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length });
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferences", { count: typeReferences.length });
// This containingFilename needs to match with the one used in managed-side
var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
for (var i = 0; i < typeReferences.length; i++) {
- processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId });
+ // under node16/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode
+ processTypeReferenceDirective(typeReferences[i], /*mode*/ undefined, resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId });
}
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
}
@@ -114996,21 +116798,19 @@ var ts;
getProgramDiagnostics: getProgramDiagnostics,
getTypeChecker: getTypeChecker,
getClassifiableNames: getClassifiableNames,
- getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
getCommonSourceDirectory: getCommonSourceDirectory,
emit: emit,
getCurrentDirectory: function () { return currentDirectory; },
- getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); },
- getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); },
- getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); },
- getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); },
- getInstantiationCount: function () { return getDiagnosticsProducingTypeChecker().getInstantiationCount(); },
- getRelationCacheSizes: function () { return getDiagnosticsProducingTypeChecker().getRelationCacheSizes(); },
+ getNodeCount: function () { return getTypeChecker().getNodeCount(); },
+ getIdentifierCount: function () { return getTypeChecker().getIdentifierCount(); },
+ getSymbolCount: function () { return getTypeChecker().getSymbolCount(); },
+ getTypeCount: function () { return getTypeChecker().getTypeCount(); },
+ getInstantiationCount: function () { return getTypeChecker().getInstantiationCount(); },
+ getRelationCacheSizes: function () { return getTypeChecker().getRelationCacheSizes(); },
getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
- dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker,
getSourceFileFromReference: getSourceFileFromReference,
getLibFileFromReference: getLibFileFromReference,
sourceFileToPackageName: sourceFileToPackageName,
@@ -115035,14 +116835,15 @@ var ts;
useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
getFileIncludeReasons: function () { return fileReasons; },
structureIsReused: structureIsReused,
+ writeFile: writeFile,
};
onProgramCreateComplete();
// Add file processingDiagnostics
fileProcessingDiagnostics === null || fileProcessingDiagnostics === void 0 ? void 0 : fileProcessingDiagnostics.forEach(function (diagnostic) {
switch (diagnostic.kind) {
- case 1 /* FilePreprocessingFileExplainingDiagnostic */:
+ case 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */:
return programDiagnostics.add(createDiagnosticExplainingFile(diagnostic.file && getSourceFileByPath(diagnostic.file), diagnostic.fileProcessingReason, diagnostic.diagnostic, diagnostic.args || ts.emptyArray));
- case 0 /* FilePreprocessingReferencedDiagnostic */:
+ case 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */:
var _a = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason), file = _a.file, pos = _a.pos, end = _a.end;
return programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArray([file, ts.Debug.checkDefined(pos), ts.Debug.checkDefined(end) - pos, diagnostic.diagnostic], diagnostic.args || ts.emptyArray, false)));
default:
@@ -115054,17 +116855,52 @@ var ts;
ts.performance.measure("Program", "beforeProgram", "afterProgram");
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
return program;
+ function addResolutionDiagnostics(list) {
+ if (!list)
+ return;
+ for (var _i = 0, list_3 = list; _i < list_3.length; _i++) {
+ var elem = list_3[_i];
+ programDiagnostics.add(elem);
+ }
+ }
+ function pullDiagnosticsFromCache(names, containingFile) {
+ var _a;
+ if (!moduleResolutionCache)
+ return;
+ var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
+ var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
+ var containingDir = ts.getDirectoryPath(containingFileName);
+ var redirectedReference = getRedirectReferenceForResolution(containingFile);
+ var i = 0;
+ for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
+ var n = names_4[_i];
+ // mimics logic done in the resolution cache, should be resilient to upgrading it to use `FileReference`s for non-type-reference modal lookups to make it rely on the index in the list less
+ var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode);
+ var name = typeof n === "string" ? n : n.fileName;
+ i++;
+ // only nonrelative names hit the cache, and, at least as of right now, only nonrelative names can issue diagnostics
+ // (Since diagnostics are only issued via import or export map lookup)
+ // This may totally change if/when the issue of output paths not mapping to input files is fixed in a broader context
+ // When it is, how we extract diagnostics from the module name resolver will have the be refined - the current cache
+ // APIs wrapping the underlying resolver make it almost impossible to smuggle the diagnostics out in a generalized way
+ if (ts.isExternalModuleNameRelative(name))
+ continue;
+ var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics;
+ addResolutionDiagnostics(diags);
+ }
+ }
function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
if (!moduleNames.length)
return ts.emptyArray;
var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
var redirectedReference = getRedirectReferenceForResolution(containingFile);
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName });
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName });
ts.performance.mark("beforeResolveModule");
var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference);
ts.performance.mark("afterResolveModule");
ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
+ pullDiagnosticsFromCache(moduleNames, containingFile);
return result;
}
function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) {
@@ -115072,9 +116908,10 @@ var ts;
return [];
var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
+ var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
ts.performance.mark("beforeResolveTypeReference");
- var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference);
+ var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode);
ts.performance.mark("afterResolveTypeReference");
ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
@@ -115082,7 +116919,7 @@ var ts;
}
function getRedirectReferenceForResolution(file) {
var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName);
- if (redirect || !ts.fileExtensionIsOneOf(file.originalFileName, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */]))
+ if (redirect || !ts.isDeclarationFileName(file.originalFileName))
return redirect;
// The originalFileName could not be actual source file name if file found was d.ts from referecned project
// So in this case try to look up if this is output from referenced project, if it is use the redirected project in that case
@@ -115154,7 +116991,7 @@ var ts;
return classifiableNames;
}
function resolveModuleNamesReusingOldState(moduleNames, file) {
- if (structureIsReused === 0 /* Not */ && !file.ambientModuleNames.length) {
+ if (structureIsReused === 0 /* StructureIsReused.Not */ && !file.ambientModuleNames.length) {
// If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules,
// the best we can do is fallback to the default logic.
return resolveModuleNamesWorker(moduleNames, file, /*reusedNames*/ undefined);
@@ -115169,15 +117006,15 @@ var ts;
// which per above occurred during the current program creation.
// Since we assume the filesystem does not change during program creation,
// it is safe to reuse resolutions from the earlier call.
- var result_13 = [];
+ var result_14 = [];
var i = 0;
for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
var moduleName = moduleNames_1[_i];
var resolvedModule = file.resolvedModules.get(moduleName, getModeForResolutionAtIndex(file, i));
i++;
- result_13.push(resolvedModule);
+ result_14.push(resolvedModule);
}
- return result_13;
+ return result_14;
}
// At this point, we know at least one of the following hold:
// - file has local declarations for ambient modules
@@ -115309,22 +117146,22 @@ var ts;
function tryReuseStructureFromOldProgram() {
var _a;
if (!oldProgram) {
- return 0 /* Not */;
+ return 0 /* StructureIsReused.Not */;
}
// check properties that can affect structure of the program or module resolution strategy
// if any of these properties has changed - structure cannot be reused
var oldOptions = oldProgram.getCompilerOptions();
if (ts.changesAffectModuleResolution(oldOptions, options)) {
- return 0 /* Not */;
+ return 0 /* StructureIsReused.Not */;
}
// there is an old program, check if we can reuse its structure
var oldRootNames = oldProgram.getRootFileNames();
if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) {
- return 0 /* Not */;
+ return 0 /* StructureIsReused.Not */;
}
// Check if any referenced project tsconfig files are different
if (!canReuseProjectReferences()) {
- return 0 /* Not */;
+ return 0 /* StructureIsReused.Not */;
}
if (projectReferences) {
resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile);
@@ -115332,12 +117169,12 @@ var ts;
// check if program source files has changed in the way that can affect structure of the program
var newSourceFiles = [];
var modifiedSourceFiles = [];
- structureIsReused = 2 /* Completely */;
+ structureIsReused = 2 /* StructureIsReused.Completely */;
// If the missing file paths are now present, it can change the progam structure,
// and hence cant reuse the structure.
// This is same as how we dont reuse the structure if one of the file from old program is now missing
if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) {
- return 0 /* Not */;
+ return 0 /* StructureIsReused.Not */;
}
var oldSourceFiles = oldProgram.getSourceFiles();
var SeenPackageName;
@@ -115349,10 +117186,10 @@ var ts;
for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
var oldSourceFile = oldSourceFiles_2[_i];
var newSourceFile = host.getSourceFileByPath
- ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, ts.getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile)
- : host.getSourceFile(oldSourceFile.fileName, ts.getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217
+ ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile)
+ : host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217
if (!newSourceFile) {
- return 0 /* Not */;
+ return 0 /* StructureIsReused.Not */;
}
ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`");
var fileChanged = void 0;
@@ -115361,7 +117198,7 @@ var ts;
// This lets us know if the unredirected file has changed. If it has we should break the redirect.
if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) {
// Underlying file has changed. Might not redirect anymore. Must rebuild program.
- return 0 /* Not */;
+ return 0 /* StructureIsReused.Not */;
}
fileChanged = false;
newSourceFile = oldSourceFile; // Use the redirect.
@@ -115369,7 +117206,7 @@ var ts;
else if (oldProgram.redirectTargetsMap.has(oldSourceFile.path)) {
// If a redirected-to source file changes, the redirect may be broken.
if (newSourceFile !== oldSourceFile) {
- return 0 /* Not */;
+ return 0 /* StructureIsReused.Not */;
}
fileChanged = false;
}
@@ -115381,15 +117218,14 @@ var ts;
newSourceFile.originalFileName = oldSourceFile.originalFileName;
newSourceFile.resolvedPath = oldSourceFile.resolvedPath;
newSourceFile.fileName = oldSourceFile.fileName;
- newSourceFile.impliedNodeFormat = oldSourceFile.impliedNodeFormat;
var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path);
if (packageName !== undefined) {
// If there are 2 different source files for the same package name and at least one of them changes,
// they might become redirects. So we must rebuild the program.
var prevKind = seenPackageNames.get(packageName);
- var newKind = fileChanged ? 1 /* Modified */ : 0 /* Exists */;
- if ((prevKind !== undefined && newKind === 1 /* Modified */) || prevKind === 1 /* Modified */) {
- return 0 /* Not */;
+ var newKind = fileChanged ? 1 /* SeenPackageName.Modified */ : 0 /* SeenPackageName.Exists */;
+ if ((prevKind !== undefined && newKind === 1 /* SeenPackageName.Modified */) || prevKind === 1 /* SeenPackageName.Modified */) {
+ return 0 /* StructureIsReused.Not */;
}
seenPackageNames.set(packageName, newKind);
}
@@ -115397,49 +117233,49 @@ var ts;
// The `newSourceFile` object was created for the new program.
if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
// 'lib' references has changed. Matches behavior in changesAffectModuleResolution
- structureIsReused = 1 /* SafeModules */;
+ structureIsReused = 1 /* StructureIsReused.SafeModules */;
}
if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
// value of no-default-lib has changed
// this will affect if default library is injected into the list of files
- structureIsReused = 1 /* SafeModules */;
+ structureIsReused = 1 /* StructureIsReused.SafeModules */;
}
// check tripleslash references
if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
// tripleslash references has changed
- structureIsReused = 1 /* SafeModules */;
+ structureIsReused = 1 /* StructureIsReused.SafeModules */;
}
// check imports and module augmentations
collectExternalModuleReferences(newSourceFile);
if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
// imports has changed
- structureIsReused = 1 /* SafeModules */;
+ structureIsReused = 1 /* StructureIsReused.SafeModules */;
}
if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
// moduleAugmentations has changed
- structureIsReused = 1 /* SafeModules */;
+ structureIsReused = 1 /* StructureIsReused.SafeModules */;
}
- if ((oldSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */)) {
+ if ((oldSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */)) {
// dynamicImport has changed
- structureIsReused = 1 /* SafeModules */;
+ structureIsReused = 1 /* StructureIsReused.SafeModules */;
}
if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
// 'types' references has changed
- structureIsReused = 1 /* SafeModules */;
+ structureIsReused = 1 /* StructureIsReused.SafeModules */;
}
// tentatively approve the file
modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
}
else if (hasInvalidatedResolution(oldSourceFile.path)) {
// 'module/types' references could have changed
- structureIsReused = 1 /* SafeModules */;
+ structureIsReused = 1 /* StructureIsReused.SafeModules */;
// add file to the modified list so that we will resolve it later
modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
}
// if file has passed all checks it should be safe to reuse it
newSourceFiles.push(newSourceFile);
}
- if (structureIsReused !== 2 /* Completely */) {
+ if (structureIsReused !== 2 /* StructureIsReused.Completely */) {
return structureIsReused;
}
var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
@@ -115460,30 +117296,29 @@ var ts;
// ensure that module resolution results are still correct
var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo);
if (resolutionsChanged) {
- structureIsReused = 1 /* SafeModules */;
+ structureIsReused = 1 /* StructureIsReused.SafeModules */;
newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions);
}
else {
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
}
- // We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
- var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
+ var typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
// ensure that types resolutions are still correct
var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
if (typeReferenceResolutionsChanged) {
- structureIsReused = 1 /* SafeModules */;
+ structureIsReused = 1 /* StructureIsReused.SafeModules */;
newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions);
}
else {
newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
}
}
- if (structureIsReused !== 2 /* Completely */) {
+ if (structureIsReused !== 2 /* StructureIsReused.Completely */) {
return structureIsReused;
}
if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) {
- return 1 /* SafeModules */;
+ return 1 /* StructureIsReused.SafeModules */;
}
missingFilePaths = oldProgram.getMissingFilePaths();
// update fileName -> file mapping
@@ -115514,7 +117349,7 @@ var ts;
sourceFileToPackageName = oldProgram.sourceFileToPackageName;
redirectTargetsMap = oldProgram.redirectTargetsMap;
usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules;
- return 2 /* Completely */;
+ return 2 /* StructureIsReused.Completely */;
}
function getEmitHost(writeFileCallback) {
return {
@@ -115533,7 +117368,7 @@ var ts;
getProjectReferenceRedirect: getProjectReferenceRedirect,
isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
getSymlinkCache: getSymlinkCache,
- writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }),
+ writeFile: writeFileCallback || writeFile,
isEmitBlocked: isEmitBlocked,
readFile: function (f) { return host.readFile(f); },
fileExists: function (f) {
@@ -115553,9 +117388,12 @@ var ts;
getFileIncludeReasons: program.getFileIncludeReasons,
};
}
+ function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
+ host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
+ }
function emitBuildInfo(writeFileCallback) {
ts.Debug.assert(!ts.outFile(options));
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true);
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true);
ts.performance.mark("beforeEmit");
var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback),
/*targetSourceFile*/ undefined,
@@ -115584,6 +117422,9 @@ var ts;
return !!sourceFilesFoundSearchingNodeModules.get(file.path);
}
function isSourceFileDefaultLibrary(file) {
+ if (!file.isDeclarationFile) {
+ return false;
+ }
if (file.hasNoDefaultLib) {
return true;
}
@@ -115600,17 +117441,11 @@ var ts;
return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, pathForLibFile(libFileName)); });
}
}
- function getDiagnosticsProducingTypeChecker() {
- return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true));
- }
- function dropDiagnosticsProducingTypeChecker() {
- diagnosticsProducingTypeChecker = undefined;
- }
function getTypeChecker() {
- return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false));
+ return typeChecker || (typeChecker = ts.createTypeChecker(program));
}
function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) {
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true);
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true);
var result = runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); });
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
return result;
@@ -115632,7 +117467,7 @@ var ts;
// This is because in the -out scenario all files need to be emitted, and therefore all
// files need to be type checked. And the way to specify that all files need to be type
// checked is to not pass the file to getEmitResolver.
- var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(ts.outFile(options) ? undefined : sourceFile, cancellationToken);
+ var emitResolver = getTypeChecker().getEmitResolver(ts.outFile(options) ? undefined : sourceFile, cancellationToken);
ts.performance.mark("beforeEmit");
var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles,
/*onlyBuildInfo*/ false, forceDtsEmit);
@@ -115712,15 +117547,7 @@ var ts;
if (e instanceof ts.OperationCanceledException) {
// We were canceled while performing the operation. Because our type checker
// might be a bad state, we need to throw it away.
- //
- // Note: we are overly aggressive here. We do not actually *have* to throw away
- // the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep
- // the lifetimes of these two TypeCheckers the same. Also, we generally only
- // cancel when the user has made a change anyways. And, in that case, we (the
- // program instance) will get thrown away anyways. So trying to keep one of
- // these type checkers alive doesn't serve much purpose.
- noDiagnosticsTypeChecker = undefined;
- diagnosticsProducingTypeChecker = undefined;
+ typeChecker = undefined;
}
throw e;
}
@@ -115736,9 +117563,9 @@ var ts;
if (ts.skipTypeChecking(sourceFile, options, program)) {
return ts.emptyArray;
}
- var typeChecker = getDiagnosticsProducingTypeChecker();
+ var typeChecker = getTypeChecker();
ts.Debug.assert(!!sourceFile.bindDiagnostics);
- var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */;
+ var isJs = sourceFile.scriptKind === 1 /* ScriptKind.JS */ || sourceFile.scriptKind === 2 /* ScriptKind.JSX */;
var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options);
var isPlainJs = ts.isPlainJsFile(sourceFile, options.checkJs);
var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
@@ -115746,8 +117573,8 @@ var ts;
// - plain JS: .js files with no // ts-check and checkJs: undefined
// - check JS: .js files with either // ts-check or checkJs: true
// - external: files that are added by plugins
- var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */
- || sourceFile.scriptKind === 5 /* External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */);
+ var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* ScriptKind.TS */ || sourceFile.scriptKind === 4 /* ScriptKind.TSX */
+ || sourceFile.scriptKind === 5 /* ScriptKind.External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* ScriptKind.Deferred */);
var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray;
var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray;
if (isPlainJs) {
@@ -115788,7 +117615,7 @@ var ts;
}
function getSuggestionDiagnostics(sourceFile, cancellationToken) {
return runWithCancellationToken(function () {
- return getDiagnosticsProducingTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken);
+ return getTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken);
});
}
/**
@@ -115826,22 +117653,22 @@ var ts;
// Return directly from the case if the given node doesnt want to visit each child
// Otherwise break to visit each child
switch (parent.kind) {
- case 163 /* Parameter */:
- case 166 /* PropertyDeclaration */:
- case 168 /* MethodDeclaration */:
+ case 164 /* SyntaxKind.Parameter */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
if (parent.questionToken === node) {
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?"));
return "skip";
}
// falls through
- case 167 /* MethodSignature */:
- case 170 /* Constructor */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 212 /* FunctionExpression */:
- case 255 /* FunctionDeclaration */:
- case 213 /* ArrowFunction */:
- case 253 /* VariableDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
// type annotation
if (parent.type === node) {
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files));
@@ -115849,58 +117676,65 @@ var ts;
}
}
switch (node.kind) {
- case 266 /* ImportClause */:
+ case 267 /* SyntaxKind.ImportClause */:
if (node.isTypeOnly) {
diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type"));
return "skip";
}
break;
- case 271 /* ExportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
if (node.isTypeOnly) {
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type"));
return "skip";
}
break;
- case 264 /* ImportEqualsDeclaration */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
+ case 275 /* SyntaxKind.ExportSpecifier */:
+ if (node.isTypeOnly) {
+ diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, ts.isImportSpecifier(node) ? "import...type" : "export...type"));
+ return "skip";
+ }
+ break;
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files));
return "skip";
- case 270 /* ExportAssignment */:
+ case 271 /* SyntaxKind.ExportAssignment */:
if (node.isExportEquals) {
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files));
return "skip";
}
break;
- case 290 /* HeritageClause */:
+ case 291 /* SyntaxKind.HeritageClause */:
var heritageClause = node;
- if (heritageClause.token === 117 /* ImplementsKeyword */) {
+ if (heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */) {
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files));
return "skip";
}
break;
- case 257 /* InterfaceDeclaration */:
- var interfaceKeyword = ts.tokenToString(118 /* InterfaceKeyword */);
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ var interfaceKeyword = ts.tokenToString(118 /* SyntaxKind.InterfaceKeyword */);
ts.Debug.assertIsDefined(interfaceKeyword);
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword));
return "skip";
- case 260 /* ModuleDeclaration */:
- var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(142 /* NamespaceKeyword */) : ts.tokenToString(141 /* ModuleKeyword */);
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ var moduleKeyword = node.flags & 16 /* NodeFlags.Namespace */ ? ts.tokenToString(142 /* SyntaxKind.NamespaceKeyword */) : ts.tokenToString(141 /* SyntaxKind.ModuleKeyword */);
ts.Debug.assertIsDefined(moduleKeyword);
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword));
return "skip";
- case 258 /* TypeAliasDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files));
return "skip";
- case 259 /* EnumDeclaration */:
- var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* EnumKeyword */));
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* SyntaxKind.EnumKeyword */));
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword));
return "skip";
- case 229 /* NonNullExpression */:
+ case 230 /* SyntaxKind.NonNullExpression */:
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files));
return "skip";
- case 228 /* AsExpression */:
+ case 229 /* SyntaxKind.AsExpression */:
diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files));
return "skip";
- case 210 /* TypeAssertionExpression */:
+ case 211 /* SyntaxKind.TypeAssertionExpression */:
ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX.
}
}
@@ -115909,53 +117743,53 @@ var ts;
diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning));
}
switch (parent.kind) {
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- case 168 /* MethodDeclaration */:
- case 170 /* Constructor */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 212 /* FunctionExpression */:
- case 255 /* FunctionDeclaration */:
- case 213 /* ArrowFunction */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 214 /* SyntaxKind.ArrowFunction */:
// Check type parameters
if (nodes === parent.typeParameters) {
diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files));
return "skip";
}
// falls through
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
// Check modifiers
if (nodes === parent.modifiers) {
- checkModifiers(parent.modifiers, parent.kind === 236 /* VariableStatement */);
+ checkModifiers(parent.modifiers, parent.kind === 237 /* SyntaxKind.VariableStatement */);
return "skip";
}
break;
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
// Check modifiers of property declaration
if (nodes === parent.modifiers) {
for (var _i = 0, _a = nodes; _i < _a.length; _i++) {
var modifier = _a[_i];
- if (modifier.kind !== 124 /* StaticKeyword */) {
+ if (modifier.kind !== 124 /* SyntaxKind.StaticKeyword */) {
diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind)));
}
}
return "skip";
}
break;
- case 163 /* Parameter */:
+ case 164 /* SyntaxKind.Parameter */:
// Check modifiers of parameter declaration
if (nodes === parent.modifiers) {
diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files));
return "skip";
}
break;
- case 207 /* CallExpression */:
- case 208 /* NewExpression */:
- case 227 /* ExpressionWithTypeArguments */:
- case 278 /* JsxSelfClosingElement */:
- case 279 /* JsxOpeningElement */:
- case 209 /* TaggedTemplateExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
// Check type arguments
if (nodes === parent.typeArguments) {
diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files));
@@ -115968,25 +117802,27 @@ var ts;
for (var _i = 0, modifiers_2 = modifiers; _i < modifiers_2.length; _i++) {
var modifier = modifiers_2[_i];
switch (modifier.kind) {
- case 85 /* ConstKeyword */:
+ case 85 /* SyntaxKind.ConstKeyword */:
if (isConstValid) {
continue;
}
// to report error,
// falls through
- case 123 /* PublicKeyword */:
- case 121 /* PrivateKeyword */:
- case 122 /* ProtectedKeyword */:
- case 144 /* ReadonlyKeyword */:
- case 135 /* DeclareKeyword */:
- case 126 /* AbstractKeyword */:
- case 158 /* OverrideKeyword */:
+ case 123 /* SyntaxKind.PublicKeyword */:
+ case 121 /* SyntaxKind.PrivateKeyword */:
+ case 122 /* SyntaxKind.ProtectedKeyword */:
+ case 145 /* SyntaxKind.ReadonlyKeyword */:
+ case 135 /* SyntaxKind.DeclareKeyword */:
+ case 126 /* SyntaxKind.AbstractKeyword */:
+ case 159 /* SyntaxKind.OverrideKeyword */:
+ case 101 /* SyntaxKind.InKeyword */:
+ case 144 /* SyntaxKind.OutKeyword */:
diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind)));
break;
// These are all legal modifiers.
- case 124 /* StaticKeyword */:
- case 93 /* ExportKeyword */:
- case 88 /* DefaultKeyword */:
+ case 124 /* SyntaxKind.StaticKeyword */:
+ case 93 /* SyntaxKind.ExportKeyword */:
+ case 88 /* SyntaxKind.DefaultKeyword */:
}
}
}
@@ -116006,7 +117842,7 @@ var ts;
}
function getDeclarationDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
return runWithCancellationToken(function () {
- var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
+ var resolver = getTypeChecker().getEmitResolver(sourceFile, cancellationToken);
// Don't actually write any files since we're just getting diagnostics.
return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile) || ts.emptyArray;
});
@@ -116044,7 +117880,7 @@ var ts;
return diagnostics;
}
function getGlobalDiagnostics() {
- return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray;
+ return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray;
}
function getConfigFileParsingDiagnostics() {
return configFileParsingDiagnostics || ts.emptyArray;
@@ -116056,20 +117892,20 @@ var ts;
return a.fileName === b.fileName;
}
function moduleNameIsEqualTo(a, b) {
- return a.kind === 79 /* Identifier */
- ? b.kind === 79 /* Identifier */ && a.escapedText === b.escapedText
- : b.kind === 10 /* StringLiteral */ && a.text === b.text;
+ return a.kind === 79 /* SyntaxKind.Identifier */
+ ? b.kind === 79 /* SyntaxKind.Identifier */ && a.escapedText === b.escapedText
+ : b.kind === 10 /* SyntaxKind.StringLiteral */ && a.text === b.text;
}
function createSyntheticImport(text, file) {
var externalHelpersModuleReference = ts.factory.createStringLiteral(text);
var importDecl = ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference, /*assertClause*/ undefined);
- ts.addEmitFlags(importDecl, 67108864 /* NeverApplyImportHelper */);
+ ts.addEmitFlags(importDecl, 67108864 /* EmitFlags.NeverApplyImportHelper */);
ts.setParent(externalHelpersModuleReference, importDecl);
ts.setParent(importDecl, file);
// explicitly unset the synthesized flag on these declarations so the checker API will answer questions about them
// (which is required to build the dependency graph for incremental emit)
- externalHelpersModuleReference.flags &= ~8 /* Synthesized */;
- importDecl.flags &= ~8 /* Synthesized */;
+ externalHelpersModuleReference.flags &= ~8 /* NodeFlags.Synthesized */;
+ importDecl.flags &= ~8 /* NodeFlags.Synthesized */;
return externalHelpersModuleReference;
}
function collectExternalModuleReferences(file) {
@@ -116100,7 +117936,7 @@ var ts;
var node = _a[_i];
collectModuleReferences(node, /*inAmbientModule*/ false);
}
- if ((file.flags & 1048576 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) {
+ if ((file.flags & 2097152 /* NodeFlags.PossiblyContainsDynamicImport */) || isJavaScriptFile) {
collectDynamicImportOrRequireCalls(file);
}
file.imports = imports || ts.emptyArray;
@@ -116122,7 +117958,7 @@ var ts;
}
}
else if (ts.isModuleDeclaration(node)) {
- if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* Ambient */) || file.isDeclarationFile)) {
+ if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */) || file.isDeclarationFile)) {
node.name.parent = node;
var nameText = ts.getTextOfIdentifierOrLiteral(node.name);
// Ambient module declarations can be interpreted as augmentations for some existing external modules.
@@ -116177,7 +118013,7 @@ var ts;
function getNodeAtPosition(sourceFile, position) {
var current = sourceFile;
var getContainingChild = function (child) {
- if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* EndOfFileToken */)))) {
+ if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* SyntaxKind.EndOfFileToken */)))) {
return child;
}
};
@@ -116292,7 +118128,7 @@ var ts;
}
// Get source file from normalized fileName
function findSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "findSourceFile", {
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "findSourceFile", {
fileName: fileName,
isDefaultLib: isDefaultLib || undefined,
fileIncludeKind: ts.FileIncludeKind[reason.kind],
@@ -116301,6 +118137,17 @@ var ts;
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
return result;
}
+ function getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options) {
+ // It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache
+ // and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way
+ // to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront.
+ 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)
+ };
+ }
function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
var path = toPath(fileName);
if (useSourceOfProjectReferenceRedirect) {
@@ -116388,7 +118235,7 @@ var ts;
}
}
// We haven't looked for this file, do so now and cache result
- var file = host.getSourceFile(fileName, ts.getEmitScriptTarget(options), function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile);
+ var file = host.getSourceFile(fileName, getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options), function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile);
if (packageId) {
var packageIdKey = ts.packageIdToString(packageId);
var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
@@ -116416,10 +118263,6 @@ var ts;
file.path = path;
file.resolvedPath = toPath(fileName);
file.originalFileName = originalFileName;
- // It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache
- // and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way
- // to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront.
- file.impliedNodeFormat = getImpliedNodeFormatForFile(file.resolvedPath, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
addFileIncludeReason(file, reason);
if (host.useCaseSensitiveFileNames()) {
var pathLowerCase = ts.toFileNameLowerCase(path);
@@ -116470,7 +118313,7 @@ var ts;
}
function getProjectReferenceRedirectProject(fileName) {
// Ignore dts or any json files
- if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || ts.fileExtensionIs(fileName, ".json" /* Json */)) {
+ if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) {
return undefined;
}
// If this file is produced by a referenced project, we need to rewrite it to
@@ -116480,7 +118323,7 @@ var ts;
function getProjectReferenceOutputName(referencedProject, fileName) {
var out = ts.outFile(referencedProject.commandLine.options);
return out ?
- ts.changeExtension(out, ".d.ts" /* Dts */) :
+ ts.changeExtension(out, ".d.ts" /* Extension.Dts */) :
ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine, !host.useCaseSensitiveFileNames());
}
/**
@@ -116513,13 +118356,13 @@ var ts;
var out = ts.outFile(resolvedRef.commandLine.options);
if (out) {
// Dont know which source file it means so return true?
- var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */);
+ var outputDts = ts.changeExtension(out, ".d.ts" /* Extension.Dts */);
mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true);
}
else {
var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); });
ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) {
- if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
+ if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) {
var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3);
mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName);
}
@@ -116546,8 +118389,7 @@ var ts;
});
}
function processTypeReferenceDirectives(file) {
- // We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
- var typeDirectives = ts.map(file.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
+ var typeDirectives = file.typeReferenceDirectives;
if (!typeDirectives) {
return;
}
@@ -116558,17 +118400,21 @@ var ts;
// store resolved type directive on the file
var fileName = ts.toFileNameLowerCase(ref.fileName);
ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
- processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
+ var mode = ref.resolutionMode || file.impliedNodeFormat;
+ if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
+ programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
+ }
+ processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
}
}
- function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
- processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason);
+ function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, 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();
}
- function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
+ function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
// If we already found this library as a primary reference - nothing to do
- var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective);
+ var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode);
if (previousResolution && previousResolution.primary) {
return;
}
@@ -116607,7 +118453,7 @@ var ts;
addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
}
if (saveResolution) {
- resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective);
+ resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolvedTypeReferenceDirective);
}
}
function pathForLibFile(libFileName) {
@@ -116641,7 +118487,7 @@ var ts;
var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity);
var diagnostic = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0;
(fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
- kind: 0 /* FilePreprocessingReferencedDiagnostic */,
+ kind: 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */,
reason: { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, },
diagnostic: diagnostic,
args: [libName, suggestion]
@@ -116688,7 +118534,7 @@ var ts;
&& index < file.imports.length
&& !elideImport
&& !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile))
- && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 4194304 /* JSDoc */));
+ && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* NodeFlags.JSDoc */));
if (elideImport) {
modulesWithElidedImports.set(file.path, true);
}
@@ -116749,7 +118595,7 @@ var ts;
else {
// An absolute path pointing to the containing directory of the config file
var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory());
- sourceFile = host.getSourceFile(refPath, 100 /* JSON */);
+ sourceFile = host.getSourceFile(refPath, 100 /* ScriptTarget.JSON */);
addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined);
if (sourceFile === undefined) {
projectReferenceRedirects.set(sourceFilePath, false);
@@ -116769,21 +118615,6 @@ var ts;
return resolvedRef;
}
function verifyCompilerOptions() {
- var isNightly = ts.stringContains(ts.version, "-dev") || ts.stringContains(ts.version, "-insiders");
- if (!isNightly) {
- if (ts.getEmitModuleKind(options) === ts.ModuleKind.Node12) {
- createOptionValueDiagnostic("module", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "module", "node12");
- }
- else if (ts.getEmitModuleKind(options) === ts.ModuleKind.NodeNext) {
- createOptionValueDiagnostic("module", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "module", "nodenext");
- }
- else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12) {
- createOptionValueDiagnostic("moduleResolution", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "moduleResolution", "node12");
- }
- else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
- createOptionValueDiagnostic("moduleResolution", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "moduleResolution", "nodenext");
- }
- }
if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) {
createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks");
}
@@ -116904,21 +118735,21 @@ var ts;
var languageVersion = ts.getEmitScriptTarget(options);
var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; });
if (options.isolatedModules) {
- if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) {
+ if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ScriptTarget.ES2015 */) {
createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target");
}
if (options.preserveConstEnums === false) {
createDiagnosticForOptionName(ts.Diagnostics.Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled, "preserveConstEnums", "isolatedModules");
}
- var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; });
+ var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* ScriptKind.JSON */; });
if (firstNonExternalModuleSourceFile) {
var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics._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, ts.getBaseFileName(firstNonExternalModuleSourceFile.fileName)));
}
}
- else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) {
+ else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ScriptTarget.ES2015 */ && options.module === ts.ModuleKind.None) {
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
- var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
+ var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
}
// Cannot specify module gen that isn't amd or system with --out
@@ -116927,13 +118758,13 @@ var ts;
createDiagnosticForOptionName(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile", "module");
}
else if (options.module === undefined && firstNonAmbientExternalModuleSourceFile) {
- var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
+ var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, options.out ? "out" : "outFile"));
}
}
if (options.resolveJsonModule) {
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs &&
- ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 &&
+ ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 &&
ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule");
}
@@ -116955,7 +118786,7 @@ var ts;
createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir");
}
}
- if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) {
+ if (options.useDefineForClassFields && languageVersion === 0 /* ScriptTarget.ES3 */) {
createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields");
}
if (options.checkJs && !ts.getAllowJSCompilerOption(options)) {
@@ -116977,7 +118808,7 @@ var ts;
if (options.reactNamespace) {
createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory");
}
- if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) {
+ if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) {
createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFactory", ts.inverseJsxOptionMap.get("" + options.jsx));
}
if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) {
@@ -116991,7 +118822,7 @@ var ts;
if (!options.jsxFactory) {
createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "jsxFragmentFactory", "jsxFactory");
}
- if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) {
+ if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) {
createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFragmentFactory", ts.inverseJsxOptionMap.get("" + options.jsx));
}
if (!ts.parseIsolatedEntityName(options.jsxFragmentFactory, languageVersion)) {
@@ -116999,12 +118830,12 @@ var ts;
}
}
if (options.reactNamespace) {
- if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) {
+ if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) {
createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "reactNamespace", ts.inverseJsxOptionMap.get("" + options.jsx));
}
}
if (options.jsxImportSource) {
- if (options.jsx === 2 /* React */) {
+ if (options.jsx === 2 /* JsxEmit.React */) {
createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxImportSource", ts.inverseJsxOptionMap.get("" + options.jsx));
}
}
@@ -117083,7 +118914,7 @@ var ts;
}
function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) {
(fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
- kind: 1 /* FilePreprocessingFileExplainingDiagnostic */,
+ kind: 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */,
file: file && file.path,
fileProcessingReason: fileProcessingReason,
diagnostic: diagnostic,
@@ -117322,7 +119153,7 @@ var ts;
// If options have --outFile or --out just check that
var out = ts.outFile(options);
if (out) {
- return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Dts */);
+ return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Extension.Dts */);
}
// If declarationDir is specified, return if its a file in that directory
if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) {
@@ -117332,16 +119163,16 @@ var ts;
if (options.outDir) {
return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
}
- if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.fileExtensionIs(filePath, ".d.ts" /* Dts */)) {
+ if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) {
// Otherwise just check if sourceFile with the name exists
var filePathWithoutExtension = ts.removeFileExtension(filePath);
- return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) ||
- !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Tsx */));
+ return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Extension.Ts */)) ||
+ !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Extension.Tsx */));
}
return false;
}
function isSameFile(file1, file2) {
- return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */;
+ return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */;
}
function getSymlinkCache() {
if (host.getSymlinkCache) {
@@ -117596,17 +119427,17 @@ var ts;
function getResolutionDiagnostic(options, _a) {
var extension = _a.extension;
switch (extension) {
- case ".ts" /* Ts */:
- case ".d.ts" /* Dts */:
+ case ".ts" /* Extension.Ts */:
+ case ".d.ts" /* Extension.Dts */:
// These are always allowed.
return undefined;
- case ".tsx" /* Tsx */:
+ case ".tsx" /* Extension.Tsx */:
return needJsx();
- case ".jsx" /* Jsx */:
+ case ".jsx" /* Extension.Jsx */:
return needJsx() || needAllowJs();
- case ".js" /* Js */:
+ case ".js" /* Extension.Js */:
return needAllowJs();
- case ".json" /* Json */:
+ case ".json" /* Extension.Json */:
return needResolveJsonModule();
}
function needJsx() {
@@ -117625,7 +119456,7 @@ var ts;
var res = imports.map(function (i) { return i.text; });
for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) {
var aug = moduleAugmentations_1[_i];
- if (aug.kind === 10 /* StringLiteral */) {
+ if (aug.kind === 10 /* SyntaxKind.StringLiteral */) {
res.push(aug.text);
}
// Do nothing if it's an Identifier; we don't need to do module resolution for `declare global`.
@@ -117640,7 +119471,7 @@ var ts;
var augIndex = imports.length;
for (var _i = 0, moduleAugmentations_2 = moduleAugmentations; _i < moduleAugmentations_2.length; _i++) {
var aug = moduleAugmentations_2[_i];
- if (aug.kind === 10 /* StringLiteral */) {
+ if (aug.kind === 10 /* SyntaxKind.StringLiteral */) {
if (index === augIndex)
return aug;
augIndex++;
@@ -117665,13 +119496,9 @@ var ts;
ts.getFileEmitOutput = getFileEmitOutput;
var BuilderState;
(function (BuilderState) {
- var manyToManyPathMapCount = 0;
function createManyToManyPathMap() {
function create(forward, reverse, deleted) {
- var version = 0;
var map = {
- id: manyToManyPathMapCount++,
- version: function () { return version; },
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); },
@@ -117687,30 +119514,29 @@ var ts;
}
set.forEach(function (v) { return deleteFromMultimap(reverse, v, k); });
forward.delete(k);
- version++;
return true;
},
set: function (k, vSet) {
- var changed = !!(deleted === null || deleted === void 0 ? void 0 : deleted.delete(k));
+ deleted === null || deleted === void 0 ? void 0 : deleted.delete(k);
var existingVSet = forward.get(k);
forward.set(k, vSet);
existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.forEach(function (v) {
if (!vSet.has(v)) {
- changed = true;
deleteFromMultimap(reverse, v, k);
}
});
vSet.forEach(function (v) {
if (!(existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.has(v))) {
- changed = true;
addToMultimap(reverse, v, k);
}
});
- if (changed) {
- version++;
- }
return map;
},
+ clear: function () {
+ forward.clear();
+ reverse.clear();
+ deleted === null || deleted === void 0 ? void 0 : deleted.clear();
+ }
};
return map;
}
@@ -117725,11 +119551,10 @@ var ts;
}
set.add(v);
}
- function deleteFromMultimap(map, k, v, removeEmpty) {
- if (removeEmpty === void 0) { removeEmpty = true; }
+ function deleteFromMultimap(map, k, v) {
var set = map.get(k);
if (set === null || set === void 0 ? void 0 : set.delete(v)) {
- if (removeEmpty && !set.size) {
+ if (!set.size) {
map.delete(k);
}
return true;
@@ -117958,7 +119783,7 @@ var ts;
/*forceDtsEmit*/ true);
var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
if (firstDts_1) {
- ts.Debug.assert(ts.fileExtensionIsOneOf(firstDts_1.name, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]), "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; }))); });
+ 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);
@@ -118008,6 +119833,7 @@ var ts;
}
}
}
+ BuilderState.updateExportedModules = updateExportedModules;
/**
* Updates the exported modules from cache into state's exported modules map
* This should be called whenever it is safe to commit the state of the builder
@@ -118016,20 +119842,6 @@ var ts;
var _a;
if (exportedModulesMapCache) {
ts.Debug.assert(!!state.exportedModulesMap);
- var cacheId = exportedModulesMapCache.id;
- var cacheVersion = exportedModulesMapCache.version();
- if (state.previousCache) {
- if (state.previousCache.id === cacheId && state.previousCache.version === cacheVersion) {
- // If this is the same cache at the same version as last time this BuilderState
- // was updated, there's no need to update again
- return;
- }
- state.previousCache.id = cacheId;
- state.previousCache.version = cacheVersion;
- }
- else {
- state.previousCache = { id: cacheId, version: cacheVersion };
- }
(_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); });
}
@@ -118278,7 +120090,7 @@ var ts;
}
else if (oldCompilerOptions && !ts.outFile(compilerOptions) && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
// Add all files to affectedFilesPendingEmit since emit changed
- newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); });
+ newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* BuilderFileEmit.Full */); });
ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
}
@@ -118363,7 +120175,8 @@ var ts;
* This is to allow the callers to be able to actually remove affected file only when the operation is complete
* eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
*/
- function getNextAffectedFile(state, cancellationToken, computeHash) {
+ function getNextAffectedFile(state, cancellationToken, computeHash, host) {
+ var _a;
while (true) {
var affectedFiles = state.affectedFiles;
if (affectedFiles) {
@@ -118374,7 +120187,7 @@ var ts;
if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
// Set the next affected file as seen and remove the cached semantic diagnostics
state.affectedFilesIndex = affectedFilesIndex;
- handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash);
+ handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
return affectedFile;
}
affectedFilesIndex++;
@@ -118386,6 +120199,7 @@ var ts;
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();
state.affectedFiles = undefined;
}
// Get next changed file
@@ -118415,6 +120229,11 @@ var ts;
state.seenAffectedFiles = new ts.Set();
}
}
+ function clearAffectedFilesPendingEmit(state) {
+ state.affectedFilesPendingEmit = undefined;
+ state.affectedFilesPendingEmitKind = undefined;
+ state.affectedFilesPendingEmitIndex = undefined;
+ }
/**
* Returns next file to be emitted from files that retrieved semantic diagnostics but did not emit yet
*/
@@ -118434,49 +120253,48 @@ var ts;
}
}
}
- state.affectedFilesPendingEmit = undefined;
- state.affectedFilesPendingEmitKind = undefined;
- state.affectedFilesPendingEmitIndex = undefined;
+ clearAffectedFilesPendingEmit(state);
}
return undefined;
}
+ function removeDiagnosticsOfLibraryFiles(state) {
+ if (!state.cleanedDiagnosticsOfLibFiles) {
+ state.cleanedDiagnosticsOfLibFiles = true;
+ var program_1 = ts.Debug.checkDefined(state.program);
+ var options_2 = program_1.getCompilerOptions();
+ ts.forEach(program_1.getSourceFiles(), function (f) {
+ return program_1.isSourceFileDefaultLibrary(f) &&
+ !ts.skipTypeChecking(f, options_2, program_1) &&
+ removeSemanticDiagnosticsOf(state, f.resolvedPath);
+ });
+ }
+ }
/**
* Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
* This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
*/
- function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) {
+ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
var _a;
removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
// If affected files is everything except default library, then nothing more to do
if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
- if (!state.cleanedDiagnosticsOfLibFiles) {
- state.cleanedDiagnosticsOfLibFiles = true;
- var program_1 = ts.Debug.checkDefined(state.program);
- var options_2 = program_1.getCompilerOptions();
- ts.forEach(program_1.getSourceFiles(), function (f) {
- return program_1.isSourceFileDefaultLibrary(f) &&
- !ts.skipTypeChecking(f, options_2, program_1) &&
- removeSemanticDiagnosticsOf(state, f.resolvedPath);
- });
- }
+ removeDiagnosticsOfLibraryFiles(state);
// When a change affects the global scope, all files are considered to be affected without updating their signature
// That means when affected file is handled, its signature can be out of date
// To avoid this, ensure that we update the signature for any affected file in this scenario.
ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
return;
}
- else {
- 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) {
- forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); });
- }
+ 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);
}
/**
* Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
* Also we need to make sure signature is updated for these files
*/
- function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) {
+ function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) {
removeSemanticDiagnosticsOf(state, path);
if (!state.changedFilesSet.has(path)) {
var program = ts.Debug.checkDefined(state.program);
@@ -118487,11 +120305,10 @@ var ts;
// This ensures that we dont later during incremental builds considering wrong signature.
// Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
// But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap,
- /* useFileVersionAsSignature */ true);
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature);
// If not dts emit, nothing more to do
if (ts.getEmitDeclarations(state.compilerOptions)) {
- addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
+ addToAffectedFilesPendingEmit(state, path, 0 /* BuilderFileEmit.DtsOnly */);
}
}
}
@@ -118513,16 +120330,41 @@ var ts;
var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
return newSignature !== oldSignature;
}
+ function forEachKeyOfExportedModulesMap(state, filePath, fn) {
+ // Go through exported modules from cache first
+ var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
+ var result = keys && ts.forEachKey(keys, fn);
+ if (result)
+ return result;
+ // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
+ keys = state.exportedModulesMap.getKeys(filePath);
+ return keys && ts.forEachKey(keys, function (exportedFromPath) {
+ var _a;
+ // If the cache had an updated value, skip
+ 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) {
+ var _a;
+ if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
+ return false;
+ // Every file needs to be handled
+ ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined)
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); });
+ removeDiagnosticsOfLibraryFiles(state);
+ return true;
+ }
/**
- * Iterate on referencing modules that export entities from affected file
+ * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
*/
- function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) {
- var _a, _b;
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
// If there was change in signature (dts output) for the changed file,
// then only we need to handle pending file emit
- if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) {
+ if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
return;
- }
if (!isChangedSignature(state, affectedFile.resolvedPath))
return;
// Since isolated modules dont change js files, files affected by change in signature is itself
@@ -118535,7 +120377,9 @@ var ts;
var currentPath = queue.pop();
if (!seenFileNamesMap.has(currentPath)) {
seenFileNamesMap.set(currentPath, true);
- fn(state, currentPath);
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host))
+ return;
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host);
if (isChangedSignature(state, currentPath)) {
var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -118547,56 +120391,38 @@ var ts;
var seenFileAndExportsOfFile = new ts.Set();
// Go through exported modules from cache first
// If exported modules has path, all files referencing file exported from are affected
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
- return forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
- });
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
- (_b = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
- var _a;
- // If the cache had an updated value, skip
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
- forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
+ forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
+ return true;
+ var references = state.referencedMap.getKeys(exportedFromPath);
+ return references && ts.forEachKey(references, function (filePath) {
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
+ });
});
}
/**
- * Iterate on files referencing referencedPath
+ * handle dts and semantic diagnostics on file and iterate on anything that exports this file
+ * return true when all work is done and we can exit handling dts emit and semantic diagnostics
*/
- function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) {
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
var _a;
- (_a = state.referencedMap.getKeys(referencedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (filePath) {
- return forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn);
- });
- }
- /**
- * fn on file and iterate on anything that exports this file
- */
- function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) {
- var _a, _b, _c;
- if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) {
- return;
- }
- fn(state, filePath);
+ if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
+ return undefined;
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
+ return true;
+ handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
- // Go through exported modules from cache first
// If exported modules has path, all files referencing file exported from are affected
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
- return forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
- });
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
- (_b = state.exportedModulesMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
- var _a;
- // If the cache had an updated value, skip
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
- forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
+ forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
});
// Remove diagnostics of files that import this file (without going to exports of referencing files)
- (_c = state.referencedMap.getKeys(filePath)) === null || _c === void 0 ? void 0 : _c.forEach(function (referencingFilePath) {
+ (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
- fn(state, referencingFilePath);
- } // Dont add to seen since this is not yet done with the export removal
- );
+ handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
+ state, referencingFilePath, cancellationToken, computeHash, host);
+ });
+ return undefined;
}
/**
* This is called after completing operation on the next affected file.
@@ -118685,13 +120511,18 @@ var ts;
var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
return value.version === actualSignature ?
- value.affectsGlobalScope ?
- { version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } :
+ value.affectsGlobalScope || value.impliedFormat ?
+ // If file version is same as signature, dont serialize signature
+ { version: value.version, signature: undefined, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
+ // If file info only contains version and signature and both are same we can just write string
value.version :
- actualSignature !== undefined ?
+ actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
signature === undefined ?
+ // If we havent computed signature, use fileInfo as is
value :
+ // Serialize fileInfo with new updated signature
{ version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
+ // Signature of the FileInfo is undefined, serialize it as false
{ version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
});
var referencedMap;
@@ -118936,8 +120767,8 @@ var ts;
* in that order would be used to write the files
*/
function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
- var affected = getNextAffectedFile(state, cancellationToken, computeHash);
- var emitKind = 1 /* Full */;
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
+ var emitKind = 1 /* BuilderFileEmit.Full */;
var isPendingEmitFile = false;
if (!affected) {
if (!ts.outFile(state.compilerOptions)) {
@@ -118950,7 +120781,7 @@ var ts;
return toAffectedFileEmitResult(state,
// When whole program is affected, do emit only once (eg when --out or --outFile is specified)
// Otherwise just affected file
- affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */,
+ affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* BuilderFileEmit.Full */,
/*isPendingEmitFile*/ false,
/*isBuildInfoEmit*/ true);
}
@@ -118967,7 +120798,43 @@ var ts;
return toAffectedFileEmitResult(state,
// When whole program is affected, do emit only once (eg when --out or --outFile is specified)
// Otherwise just affected file
- ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
+ ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
+ getWriteFileUpdatingSignatureCallback(writeFile) :
+ writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* BuilderFileEmit.DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
+ }
+ function getWriteFileUpdatingSignatureCallback(writeFile) {
+ return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
+ var _a;
+ 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) { // Update it
+ 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 (writeFile)
+ writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
+ else if (host.writeFile)
+ host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
+ else
+ state.program.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
+ };
}
/**
* Emits the JavaScript and declaration files.
@@ -118981,56 +120848,52 @@ var ts;
* in that order would be used to write the files
*/
function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
- var restorePendingEmitOnHandlingNoEmitSuccess = false;
- var savedAffectedFilesPendingEmit;
- var savedAffectedFilesPendingEmitKind;
- var savedAffectedFilesPendingEmitIndex;
- // Backup and restore affected pendings emit state for non emit Builder if noEmitOnError is enabled and emitBuildInfo could be written in case there are errors
- // This ensures pending files to emit is updated in tsbuildinfo
- // Note that when there are no errors, emit proceeds as if everything is emitted as it is callers reponsibility to write the files to disk if at all (because its builder that doesnt track files to emit)
- if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram &&
- !targetSourceFile &&
- !ts.outFile(state.compilerOptions) &&
- !state.compilerOptions.noEmit &&
- state.compilerOptions.noEmitOnError) {
- restorePendingEmitOnHandlingNoEmitSuccess = true;
- savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
- savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
- savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
- }
+ var _a;
if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
}
var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken);
if (result)
return result;
- if (restorePendingEmitOnHandlingNoEmitSuccess) {
- state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit;
- state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind;
- state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex;
- }
// Emit only affected files if using builder for emit
- if (!targetSourceFile && kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
- // Emit and report any errors we ran into.
- var sourceMaps = [];
- var emitSkipped = false;
- var diagnostics = void 0;
- var emittedFiles = [];
- var affectedEmitResult = void 0;
- while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
- emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
- diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
- emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
- sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
+ if (!targetSourceFile) {
+ if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
+ // Emit and report any errors we ran into.
+ var sourceMaps = [];
+ var emitSkipped = false;
+ var diagnostics = void 0;
+ var emittedFiles = [];
+ var affectedEmitResult = void 0;
+ while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
+ emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
+ diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
+ emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
+ sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
+ }
+ return {
+ emitSkipped: emitSkipped,
+ diagnostics: diagnostics || ts.emptyArray,
+ emittedFiles: emittedFiles,
+ sourceMaps: sourceMaps
+ };
+ }
+ // In non Emit builder, clear affected files pending emit
+ else if ((_a = state.affectedFilesPendingEmitKind) === null || _a === void 0 ? void 0 : _a.size) {
+ ts.Debug.assert(kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram);
+ // State can clear affected files pending emit if
+ if (!emitOnlyDtsFiles // If we are doing complete emit, affected files pending emit can be cleared
+ // If every file pending emit is pending on only dts emit
+ || ts.every(state.affectedFilesPendingEmit, function (path, index) {
+ return index < state.affectedFilesPendingEmitIndex ||
+ state.affectedFilesPendingEmitKind.get(path) === 0 /* BuilderFileEmit.DtsOnly */;
+ })) {
+ clearAffectedFilesPendingEmit(state);
+ }
}
- return {
- emitSkipped: emitSkipped,
- diagnostics: diagnostics || ts.emptyArray,
- emittedFiles: emittedFiles,
- sourceMaps: sourceMaps
- };
}
- return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
+ return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
+ getWriteFileUpdatingSignatureCallback(writeFile) :
+ writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
}
/**
* Return the semantic diagnostics for the next affected file or undefined if iteration is complete
@@ -119038,7 +120901,7 @@ var ts;
*/
function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
while (true) {
- var affected = getNextAffectedFile(state, cancellationToken, computeHash);
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
if (!affected) {
// Done
return undefined;
@@ -119050,7 +120913,7 @@ var ts;
// Add file to affected file pending emit to handle for later emit time
// Apart for emit builder do this for tsbuildinfo, do this for non emit builder when noEmit is set as tsbuildinfo is written and reused between emitters
if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram || state.compilerOptions.noEmit || state.compilerOptions.noEmitOnError) {
- addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* Full */);
+ addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* BuilderFileEmit.Full */);
}
// Get diagnostics for the affected file if its not ignored
if (ignoreSourceFile && ignoreSourceFile(affected)) {
@@ -119262,7 +121125,7 @@ var ts;
return false;
}
var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1);
- var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */;
+ var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* CharacterCodes.slash */;
if (isNonDirectorySeparatorRoot &&
dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths
pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart
@@ -119319,7 +121182,7 @@ var ts;
* This helps in not having to comb through all resolutions when files are added/removed
* Note that .d.ts file also has .d.ts extension hence will be part of default extensions
*/
- var failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */];
+ var failedLookupDefaultExtensions = [".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */];
var customFailedLookupPaths = new ts.Map();
var directoryWatchesOfFailedLookups = new ts.Map();
var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
@@ -119425,9 +121288,9 @@ var ts;
});
hasChangedAutomaticTypeDirectiveNames = false;
}
- function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) {
+ function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
var _a;
- var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference);
+ var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
// return result immediately only if global cache support is not enabled or if it is .ts, .tsx or .d.ts
if (!resolutionHost.getGlobalCache) {
return primaryResult;
@@ -119448,12 +121311,12 @@ var ts;
// Default return the result from the first pass
return primaryResult;
}
- function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) {
- return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache);
+ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, _containingSourceFile, resolutionMode) {
+ return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
}
function resolveNamesWithLocalCache(_a) {
var _b, _c, _d;
- var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges, containingSourceFile = _a.containingSourceFile;
+ var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges, containingSourceFile = _a.containingSourceFile, containingSourceFileMode = _a.containingSourceFileMode;
var path = resolutionHost.toPath(containingFile);
var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
var dirPath = ts.getDirectoryPath(path);
@@ -119474,9 +121337,16 @@ var ts;
!!redirectedReference;
var seenNamesInFile = ts.createModeAwareCache();
var i = 0;
- for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
- var name = names_4[_i];
- var mode = containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
+ for (var _i = 0, names_5 = names; _i < names_5.length; _i++) {
+ var entry = names_5[_i];
+ var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
+ // Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant
+ // they require calculating the mode for a given import from it's position in the resolution table, since a given
+ // import's syntax may override the file's default mode.
+ // Type references instead supply a `containingSourceFileMode` and a non-string entry which contains
+ // a default file mode override if applicable.
+ var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, containingSourceFileMode) :
+ containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
i++;
var resolution = resolutionsInFile.get(name, mode);
// Resolution is valid if it is present and not invalidated
@@ -119505,7 +121375,7 @@ var ts;
}
}
else {
- resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile);
+ resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
perDirectoryResolution.set(name, mode, resolution);
if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
resolutionHost.onDiscoveredSymlink();
@@ -119569,7 +121439,7 @@ var ts;
return oldResult.resolvedFileName === newResult.resolvedFileName;
}
}
- function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) {
+ function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode) {
return resolveNamesWithLocalCache({
names: typeDirectiveNames,
containingFile: containingFile,
@@ -119579,6 +121449,7 @@ var ts;
loader: resolveTypeReferenceDirective,
getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
+ containingSourceFileMode: containingFileMode
});
}
function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) {
@@ -119788,7 +121659,7 @@ var ts;
cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
}
scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
- }, nonRecursive ? 0 /* None */ : 1 /* Recursive */);
+ }, nonRecursive ? 0 /* WatchDirectoryFlags.None */ : 1 /* WatchDirectoryFlags.Recursive */);
}
function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) {
// Deleted file, stop watching failed lookups for all the resolutions in the file
@@ -119799,7 +121670,7 @@ var ts;
}
}
function removeResolutionsFromProjectReferenceRedirects(filePath) {
- if (!ts.fileExtensionIs(filePath, ".json" /* Json */))
+ if (!ts.fileExtensionIs(filePath, ".json" /* Extension.Json */))
return;
var program = resolutionHost.getCurrentProgram();
if (!program)
@@ -119939,7 +121810,7 @@ var ts;
if (dirPath) {
scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
}
- }, 1 /* Recursive */);
+ }, 1 /* WatchDirectoryFlags.Recursive */);
}
/**
* Watches the types that would get added as part of getAutomaticTypeDirectiveNames
@@ -120007,33 +121878,33 @@ var ts;
function getPreferences(host, _a, compilerOptions, importingSourceFile) {
var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding;
return {
- relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* Relative */ :
- importModuleSpecifierPreference === "non-relative" ? 1 /* NonRelative */ :
- importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ :
- 2 /* Shortest */,
+ relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* RelativePreference.Relative */ :
+ importModuleSpecifierPreference === "non-relative" ? 1 /* RelativePreference.NonRelative */ :
+ importModuleSpecifierPreference === "project-relative" ? 3 /* RelativePreference.ExternalNonRelative */ :
+ 2 /* RelativePreference.Shortest */,
ending: getEnding(),
};
function getEnding() {
switch (importModuleSpecifierEnding) {
- case "minimal": return 0 /* Minimal */;
- case "index": return 1 /* Index */;
- case "js": return 2 /* JsExtension */;
- default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* JsExtension */
- : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */;
+ case "minimal": return 0 /* Ending.Minimal */;
+ case "index": return 1 /* Ending.Index */;
+ case "js": return 2 /* Ending.JsExtension */;
+ default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* Ending.JsExtension */
+ : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */;
}
}
}
function getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host) {
return {
- relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */,
+ relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* RelativePreference.Relative */ : 1 /* RelativePreference.NonRelative */,
ending: ts.hasJSFileExtension(oldImportSpecifier) || isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) ?
- 2 /* JsExtension */ :
- ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */,
+ 2 /* Ending.JsExtension */ :
+ ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */,
};
}
function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) {
var _a;
- if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12
+ if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16
&& ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
return false;
}
@@ -120054,8 +121925,9 @@ var ts;
// Because when this is called by the file renamer, `importingSourceFile` is the file being renamed,
// while `importingSourceFileName` its *new* name. We need a source file just to get its
// `impliedNodeFormat` and to detect certain preferences from existing import module specifiers.
- function updateModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, oldImportSpecifier) {
- var res = getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host), {});
+ function updateModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, oldImportSpecifier, options) {
+ if (options === void 0) { options = {}; }
+ var res = getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host), {}, options);
if (res === oldImportSpecifier)
return undefined;
return res;
@@ -120067,68 +121939,80 @@ var ts;
// one currently being produced; the latter to the one being imported). We need an implementation file
// just to get its `impliedNodeFormat` and to detect certain preferences from existing import module
// specifiers.
- function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host) {
- return getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile), {});
+ function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, options) {
+ if (options === void 0) { options = {}; }
+ return getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile), {}, options);
}
moduleSpecifiers_1.getModuleSpecifier = getModuleSpecifier;
- function getNodeModulesPackageName(compilerOptions, importingSourceFile, nodeModulesFileName, host, preferences) {
+ function getNodeModulesPackageName(compilerOptions, importingSourceFile, nodeModulesFileName, host, preferences, options) {
+ if (options === void 0) { options = {}; }
var info = getInfo(importingSourceFile.path, host);
- var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences);
- return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true); });
+ var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences, options);
+ return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, preferences, /*packageNameOnly*/ true, options.overrideImportMode); });
}
moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName;
- function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences) {
+ function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences, options) {
+ if (options === void 0) { options = {}; }
var info = getInfo(importingSourceFileName, host);
- var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences);
- return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions); }) ||
+ var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
+ return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
}
- function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences) {
- return tryGetModuleSpecifiersFromCacheWorker(moduleSymbol, importingSourceFile, host, userPreferences)[0];
+ function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
+ if (options === void 0) { options = {}; }
+ return tryGetModuleSpecifiersFromCacheWorker(moduleSymbol, importingSourceFile, host, userPreferences, options)[0];
}
moduleSpecifiers_1.tryGetModuleSpecifiersFromCache = tryGetModuleSpecifiersFromCache;
- function tryGetModuleSpecifiersFromCacheWorker(moduleSymbol, importingSourceFile, host, userPreferences) {
+ function tryGetModuleSpecifiersFromCacheWorker(moduleSymbol, importingSourceFile, host, userPreferences, options) {
var _a;
+ if (options === void 0) { options = {}; }
var moduleSourceFile = ts.getSourceFileOfModule(moduleSymbol);
if (!moduleSourceFile) {
return ts.emptyArray;
}
var cache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host);
- var cached = cache === null || cache === void 0 ? void 0 : cache.get(importingSourceFile.path, moduleSourceFile.path, userPreferences);
+ var cached = cache === null || cache === void 0 ? void 0 : cache.get(importingSourceFile.path, moduleSourceFile.path, userPreferences, options);
return [cached === null || cached === void 0 ? void 0 : cached.moduleSpecifiers, moduleSourceFile, cached === null || cached === void 0 ? void 0 : cached.modulePaths, cache];
}
/** Returns an import for each symlink and for the realpath. */
- function getModuleSpecifiers(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences) {
- return getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences).moduleSpecifiers;
+ function getModuleSpecifiers(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences, options) {
+ if (options === void 0) { options = {}; }
+ return getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences, options).moduleSpecifiers;
}
moduleSpecifiers_1.getModuleSpecifiers = getModuleSpecifiers;
- function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences) {
+ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences, options) {
+ if (options === void 0) { options = {}; }
var computedWithoutCache = false;
var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol, checker);
if (ambient)
return { moduleSpecifiers: [ambient], computedWithoutCache: computedWithoutCache };
// eslint-disable-next-line prefer-const
- var _a = tryGetModuleSpecifiersFromCacheWorker(moduleSymbol, importingSourceFile, host, userPreferences), specifiers = _a[0], moduleSourceFile = _a[1], modulePaths = _a[2], cache = _a[3];
+ var _a = tryGetModuleSpecifiersFromCacheWorker(moduleSymbol, importingSourceFile, host, userPreferences, options), specifiers = _a[0], moduleSourceFile = _a[1], modulePaths = _a[2], cache = _a[3];
if (specifiers)
return { moduleSpecifiers: specifiers, computedWithoutCache: computedWithoutCache };
if (!moduleSourceFile)
return { moduleSpecifiers: ts.emptyArray, computedWithoutCache: computedWithoutCache };
computedWithoutCache = true;
modulePaths || (modulePaths = getAllModulePathsWorker(importingSourceFile.path, moduleSourceFile.originalFileName, host));
- var result = computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences);
- cache === null || cache === void 0 ? void 0 : cache.set(importingSourceFile.path, moduleSourceFile.path, userPreferences, modulePaths, result);
+ var result = computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options);
+ cache === null || cache === void 0 ? void 0 : cache.set(importingSourceFile.path, moduleSourceFile.path, userPreferences, options, modulePaths, result);
return { moduleSpecifiers: result, computedWithoutCache: computedWithoutCache };
}
moduleSpecifiers_1.getModuleSpecifiersWithCacheInfo = getModuleSpecifiersWithCacheInfo;
- function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences) {
+ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options) {
+ if (options === void 0) { options = {}; }
var info = getInfo(importingSourceFile.path, host);
var preferences = getPreferences(host, userPreferences, compilerOptions, importingSourceFile);
var existingSpecifier = ts.forEach(modulePaths, function (modulePath) { return ts.forEach(host.getFileIncludeReasons().get(ts.toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)), function (reason) {
if (reason.kind !== ts.FileIncludeKind.Import || reason.file !== importingSourceFile.path)
return undefined;
+ // If the candidate import mode doesn't match the mode we're generating for, don't consider it
+ // TODO: maybe useful to keep around as an alternative option for certain contexts where the mode is overridable
+ if (importingSourceFile.impliedNodeFormat && importingSourceFile.impliedNodeFormat !== ts.getModeForResolutionAtIndex(importingSourceFile, reason.index))
+ return undefined;
var specifier = ts.getModuleNameStringLiteralAt(importingSourceFile, reason.index).text;
// If the preference is for non relative and the module specifier is relative, ignore it
- return preferences.relativePreference !== 1 /* NonRelative */ || !ts.pathIsRelative(specifier) ?
+ return preferences.relativePreference !== 1 /* RelativePreference.NonRelative */ || !ts.pathIsRelative(specifier) ?
specifier :
undefined;
}); });
@@ -120147,7 +122031,7 @@ var ts;
var relativeSpecifiers;
for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
var modulePath = modulePaths_1[_i];
- var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions);
+ var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode);
nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
if (specifier && modulePath.isRedirect) {
// If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar",
@@ -120189,7 +122073,7 @@ var ts;
var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName;
var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) ||
removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions);
- if (!baseUrl && !paths || relativePreference === 0 /* Relative */) {
+ if (!baseUrl && !paths || relativePreference === 0 /* RelativePreference.Relative */) {
return relativePath;
}
var baseDirectory = ts.getNormalizedAbsolutePath(ts.getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory());
@@ -120203,10 +122087,10 @@ var ts;
if (!nonRelative) {
return relativePath;
}
- if (relativePreference === 1 /* NonRelative */) {
+ if (relativePreference === 1 /* RelativePreference.NonRelative */) {
return nonRelative;
}
- if (relativePreference === 3 /* ExternalNonRelative */) {
+ if (relativePreference === 3 /* RelativePreference.ExternalNonRelative */) {
var projectDirectory = compilerOptions.configFilePath ?
ts.toPath(ts.getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) :
info.getCanonicalFileName(host.getCurrentDirectory());
@@ -120240,7 +122124,7 @@ var ts;
}
return relativePath;
}
- if (relativePreference !== 2 /* Shortest */)
+ if (relativePreference !== 2 /* RelativePreference.Shortest */)
ts.Debug.assertNever(relativePreference);
// Prefer a relative import over a baseUrl import if it has fewer components.
return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative;
@@ -120248,7 +122132,7 @@ var ts;
function countPathComponents(path) {
var count = 0;
for (var i = ts.startsWith(path, "./") ? 2 : 0; i < path.length; i++) {
- if (path.charCodeAt(i) === 47 /* slash */)
+ if (path.charCodeAt(i) === 47 /* CharacterCodes.slash */)
count++;
}
return count;
@@ -120285,9 +122169,9 @@ var ts;
if (!preferSymlinks) {
// Symlinks inside ignored paths are already filtered out of the symlink cache,
// so we only need to remove them from the realpath filenames.
- var result_14 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
- if (result_14)
- return result_14;
+ var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
+ if (result_15)
+ return result_15;
}
var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -120307,10 +122191,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_15 = cb(option, target === referenceRedirect);
+ var result_16 = cb(option, target === referenceRedirect);
shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
- if (result_15)
- return result_15;
+ if (result_16)
+ return result_16;
}
});
});
@@ -120323,18 +122207,19 @@ var ts;
* Looks for existing imports that use symlinks to this module.
* Symlinks will be returned first so they are preferred over the real path.
*/
- function getAllModulePaths(importingFilePath, importedFileName, host, preferences, importedFilePath) {
+ function getAllModulePaths(importingFilePath, importedFileName, host, preferences, options) {
var _a;
- if (importedFilePath === void 0) { importedFilePath = ts.toPath(importedFileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }
+ if (options === void 0) { options = {}; }
+ var importedFilePath = ts.toPath(importedFileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host));
var cache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host);
if (cache) {
- var cached = cache.get(importingFilePath, importedFilePath, preferences);
+ var cached = cache.get(importingFilePath, importedFilePath, preferences, options);
if (cached === null || cached === void 0 ? void 0 : cached.modulePaths)
return cached.modulePaths;
}
var modulePaths = getAllModulePathsWorker(importingFilePath, importedFileName, host);
if (cache) {
- cache.setModulePaths(importingFilePath, importedFilePath, preferences, modulePaths);
+ cache.setModulePaths(importingFilePath, importedFilePath, preferences, options, modulePaths);
}
return modulePaths;
}
@@ -120351,7 +122236,7 @@ var ts;
});
// Sort by paths closest to importing file Name directory
var sortedPaths = [];
- var _loop_31 = function (directory) {
+ var _loop_32 = function (directory) {
var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
var pathsInDirectory;
allFileNames.forEach(function (_a, fileName) {
@@ -120375,9 +122260,9 @@ var ts;
};
var out_directory_1;
for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
- var state_9 = _loop_31(directory);
+ var state_10 = _loop_32(directory);
directory = out_directory_1;
- if (state_9 === "break")
+ if (state_10 === "break")
break;
}
if (allFileNames.size) {
@@ -120418,11 +122303,11 @@ var ts;
var exportSymbol = checker.getSymbolAtLocation(exportAssignment);
if (!exportSymbol)
return;
- var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol;
+ var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol;
if (originalExportSymbol === d.symbol)
return topNamespace.parent.parent;
function getTopNamespace(namespaceDeclaration) {
- while (namespaceDeclaration.flags & 4 /* NestedNamespace */) {
+ while (namespaceDeclaration.flags & 4 /* NodeFlags.NestedNamespace */) {
namespaceDeclaration = namespaceDeclaration.parent;
}
return namespaceDeclaration;
@@ -120463,23 +122348,23 @@ var ts;
MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern";
})(MatchingMode || (MatchingMode = {}));
function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) {
- if (mode === void 0) { mode = 0 /* Exact */; }
+ if (mode === void 0) { mode = 0 /* MatchingMode.Exact */; }
if (typeof exports === "string") {
var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined);
var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined;
switch (mode) {
- case 0 /* Exact */:
- if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) {
+ case 0 /* MatchingMode.Exact */:
+ if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* Comparison.EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* Comparison.EqualTo */)) {
return { moduleFileToTry: packageName };
}
break;
- case 1 /* Directory */:
+ case 1 /* MatchingMode.Directory */:
if (ts.containsPath(pathOrPattern, targetFilePath)) {
var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false);
return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) };
}
break;
- case 2 /* Pattern */:
+ case 2 /* MatchingMode.Pattern */:
var starPos = pathOrPattern.indexOf("*");
var leadingSlice = pathOrPattern.slice(0, starPos);
var trailingSlice = pathOrPattern.slice(starPos + 1);
@@ -120506,9 +122391,9 @@ var ts;
// * exact mappings (no *, does not end with /)
return ts.forEach(ts.getOwnKeys(exports), function (k) {
var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined);
- var mode = ts.endsWith(k, "/") ? 1 /* Directory */
- : ts.stringContains(k, "*") ? 2 /* Pattern */
- : 0 /* Exact */;
+ var mode = ts.endsWith(k, "/") ? 1 /* MatchingMode.Directory */
+ : ts.stringContains(k, "*") ? 2 /* MatchingMode.Pattern */
+ : 0 /* MatchingMode.Exact */;
return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode);
});
}
@@ -120539,7 +122424,7 @@ var ts;
? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
: ts.removeFileExtension(relativePath);
}
- function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly) {
+ function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
var path = _a.path, isRedirect = _a.isRedirect;
var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
if (!host.fileExists || !host.readFile) {
@@ -120553,8 +122438,9 @@ var ts;
var moduleSpecifier = path;
var isPackageRootPath = false;
if (!packageNameOnly) {
+ var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
var packageRootIndex = parts.packageRootIndex;
- var moduleFileNameForExtensionless = void 0;
+ var moduleFileName = void 0;
while (true) {
// If the module could be imported by a directory name, use that directory's name
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
@@ -120571,12 +122457,12 @@ var ts;
isPackageRootPath = true;
break;
}
- if (!moduleFileNameForExtensionless)
- moduleFileNameForExtensionless = moduleFileToTry;
+ if (!moduleFileName)
+ moduleFileName = moduleFileToTry;
// try with next level of directory
packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1);
if (packageRootIndex === -1) {
- moduleSpecifier = getExtensionlessFileName(moduleFileNameForExtensionless);
+ moduleSpecifier = removeExtensionAndIndexPostFix(moduleFileName, preferences.ending, options, host);
break;
}
}
@@ -120604,12 +122490,12 @@ var ts;
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));
- if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
+ if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
// `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate
// an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
// usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex`
// with, so for now we just stick with the mode of the file.
- var conditions = ["node", importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"];
+ var conditions = ["node", overrideMode || importingSourceFile.impliedNodeFormat === 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;
@@ -120628,13 +122514,13 @@ var ts;
: undefined;
if (versionPaths) {
var subModuleName = path.slice(packageRootPath.length + 1);
- var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths);
+ var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Ending.Minimal */, options), versionPaths.paths);
if (fromPaths !== undefined) {
moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths);
}
}
// If the file is the main module, it can be imported by the package name
- var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
+ var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
if (ts.isString(mainFileRelative)) {
var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
@@ -120642,24 +122528,21 @@ var ts;
}
}
}
- return { moduleFileToTry: moduleFileToTry };
- }
- function getExtensionlessFileName(path) {
- // We still have a file name - remove the extension
- var fullModulePathWithoutExtension = ts.removeFileExtension(path);
- // If the file is /index, it can be imported by its directory name
- // IFF there is not _also_ a file by the same name
- if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) {
- return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex);
+ else {
+ // No package.json exists; an index.js will still resolve as the package name
+ var fileName = getCanonicalFileName(moduleFileToTry.substring(parts.packageRootIndex + 1));
+ if (fileName === "index.d.ts" || fileName === "index.js" || fileName === "index.ts" || fileName === "index.tsx") {
+ return { moduleFileToTry: moduleFileToTry, packageRootPath: packageRootPath };
+ }
}
- return fullModulePathWithoutExtension;
+ return { moduleFileToTry: moduleFileToTry };
}
}
function tryGetAnyFileFromPath(host, path) {
if (!host.fileExists)
return;
// We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory
- var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* JSON */ }]));
+ var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* ScriptKind.JSON */ }]));
for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) {
var e = extensions_3[_i];
var fullPath = path + e;
@@ -120674,18 +122557,26 @@ var ts;
return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
});
}
- function removeExtensionAndIndexPostFix(fileName, ending, options) {
- if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]))
+ function removeExtensionAndIndexPostFix(fileName, ending, options, host) {
+ if (ts.fileExtensionIsOneOf(fileName, [".json" /* Extension.Json */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */]))
return fileName;
var noExtension = ts.removeFileExtension(fileName);
- if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */]))
+ if (fileName === noExtension)
+ return fileName;
+ if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */]))
return noExtension + getJSExtensionForFile(fileName, options);
switch (ending) {
- case 0 /* Minimal */:
- return ts.removeSuffix(noExtension, "/index");
- case 1 /* Index */:
+ case 0 /* Ending.Minimal */:
+ var withoutIndex = ts.removeSuffix(noExtension, "/index");
+ if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) {
+ // Can't remove index if there's a file by the same name as the directory.
+ // Probably more callers should pass `host` so we can determine this?
+ return noExtension;
+ }
+ return withoutIndex;
+ case 1 /* Ending.Index */:
return noExtension;
- case 2 /* JsExtension */:
+ case 2 /* Ending.JsExtension */:
return noExtension + getJSExtensionForFile(fileName, options);
default:
return ts.Debug.assertNever(ending);
@@ -120698,23 +122589,23 @@ var ts;
function tryGetJSExtensionForFile(fileName, options) {
var ext = ts.tryGetExtensionFromPath(fileName);
switch (ext) {
- case ".ts" /* Ts */:
- case ".d.ts" /* Dts */:
- return ".js" /* Js */;
- case ".tsx" /* Tsx */:
- return options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : ".js" /* Js */;
- case ".js" /* Js */:
- case ".jsx" /* Jsx */:
- case ".json" /* Json */:
+ case ".ts" /* Extension.Ts */:
+ case ".d.ts" /* Extension.Dts */:
+ return ".js" /* Extension.Js */;
+ case ".tsx" /* Extension.Tsx */:
+ return options.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" /* Extension.Jsx */ : ".js" /* Extension.Js */;
+ case ".js" /* Extension.Js */:
+ case ".jsx" /* Extension.Jsx */:
+ case ".json" /* Extension.Json */:
return ext;
- case ".d.mts" /* Dmts */:
- case ".mts" /* Mts */:
- case ".mjs" /* Mjs */:
- return ".mjs" /* Mjs */;
- case ".d.cts" /* Dcts */:
- case ".cts" /* Cts */:
- case ".cjs" /* Cjs */:
- return ".cjs" /* Cjs */;
+ case ".d.mts" /* Extension.Dmts */:
+ case ".mts" /* Extension.Mts */:
+ case ".mjs" /* Extension.Mjs */:
+ return ".mjs" /* Extension.Mjs */;
+ case ".d.cts" /* Extension.Dcts */:
+ case ".cts" /* Extension.Cts */:
+ case ".cjs" /* Extension.Cjs */:
+ return ".cjs" /* Extension.Cjs */;
default:
return undefined;
}
@@ -120960,11 +122851,11 @@ var ts;
var configFile = program.getCompilerOptions().configFile;
if (!((_a = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _a === void 0 ? void 0 : _a.validatedIncludeSpecs))
return undefined;
- var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Json */);
+ var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Extension.Json */);
var basePath = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory()));
var useCaseSensitiveFileNames = program.useCaseSensitiveFileNames();
return ts.find((_b = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _b === void 0 ? void 0 : _b.validatedIncludeSpecs, function (includeSpec) {
- if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Json */))
+ if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Extension.Json */))
return false;
var pattern = ts.getPatternFromSpec(includeSpec, basePath, "files");
return !!pattern && ts.getRegexFromPattern("(".concat(pattern, ")$"), useCaseSensitiveFileNames).test(fileName);
@@ -121167,7 +123058,7 @@ var ts;
var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); });
return {
- getSourceFile: function (fileName, languageVersion, onError) {
+ getSourceFile: function (fileName, languageVersionOrOptions, onError) {
var text;
try {
ts.performance.mark("beforeIORead");
@@ -121181,7 +123072,7 @@ var ts;
}
text = "";
}
- return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion) : undefined;
+ return text !== undefined ? ts.createSourceFile(fileName, text, languageVersionOrOptions) : undefined;
},
getDefaultLibLocation: ts.maybeBind(host, host.getDefaultLibLocation),
getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); },
@@ -121200,6 +123091,7 @@ var ts;
createHash: ts.maybeBind(host, host.createHash),
readDirectory: ts.maybeBind(host, host.readDirectory),
disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
+ storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
};
function writeFile(fileName, text, writeByteOrderMark, onError) {
try {
@@ -121259,6 +123151,7 @@ var ts;
createHash: ts.maybeBind(system, system.createHash),
createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
+ storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
};
}
ts.createProgramHost = createProgramHost;
@@ -121347,6 +123240,7 @@ var ts;
var host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, system);
host.createHash = ts.maybeBind(system, system.createHash);
host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
+ host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
ts.setGetSourceFileAsHashVersioned(host, system);
ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
return host;
@@ -121487,7 +123381,7 @@ var ts;
}
return host.resolveTypeReferenceDirectives.apply(host, args);
}) :
- (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); });
+ (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
builderProgram = readBuilderProgram(compilerOptions, compilerHost);
synchronizeProgram();
@@ -121649,7 +123543,7 @@ var ts;
}
return directoryStructureHost.fileExists(fileName);
}
- function getVersionedSourceFileByPath(fileName, path, languageVersion, onError, shouldCreateNewSourceFile) {
+ function getVersionedSourceFileByPath(fileName, path, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
var hostSourceFile = sourceFilesCache.get(path);
// No source file on the host
if (isFileMissingOnHost(hostSourceFile)) {
@@ -121657,7 +123551,7 @@ var ts;
}
// Create new source file if requested or the versions dont match
if (hostSourceFile === undefined || shouldCreateNewSourceFile || isFilePresenceUnknownOnHost(hostSourceFile)) {
- var sourceFile = getNewSourceFile(fileName, languageVersion, onError);
+ var sourceFile = getNewSourceFile(fileName, languageVersionOrOptions, onError);
if (hostSourceFile) {
if (sourceFile) {
// Set the source file and create file watcher now that file was present on the disk
@@ -122091,7 +123985,7 @@ var ts;
UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly";
})(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
function resolveConfigFileProjectName(project) {
- if (ts.fileExtensionIs(project, ".json" /* Json */)) {
+ if (ts.fileExtensionIs(project, ".json" /* Extension.Json */)) {
return project;
}
return ts.combinePaths(project, "tsconfig.json");
@@ -122136,9 +124030,6 @@ var ts;
function newer(date1, date2) {
return date2 > date1 ? date2 : date1;
}
- function isDeclarationFile(fileName) {
- return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */);
- }
/*@internal*/
function isCircularBuildOrder(buildOrder) {
return !!buildOrder && !!buildOrder.buildOrder;
@@ -122223,9 +124114,9 @@ var ts;
compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
}
if (!compilerHost.resolveTypeReferenceDirectives) {
- var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; };
- compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) {
- return ts.loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_4);
+ var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode).resolvedTypeReferenceDirective; };
+ compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
+ return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
};
}
var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
@@ -122701,7 +124592,7 @@ var ts;
outputFiles.forEach(function (_a) {
var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
var priorChangeTime;
- if (!anyDtsChanged && isDeclarationFile(name)) {
+ if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
// Check for unchanged .d.ts files
if (host.fileExists(name) && state.readFileWithCache(name) === text) {
priorChangeTime = host.getModifiedTime(name);
@@ -123042,7 +124933,7 @@ var ts;
// In addition to file timestamps, we also keep track of when a .d.ts file
// had its file touched but not had its contents changed - this allows us
// to skip a downstream typecheck
- if (isDeclarationFile(output)) {
+ if (ts.isDeclarationFileName(output)) {
var outputModifiedTime = ts.getModifiedTime(host, output);
newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
}
@@ -123196,7 +125087,7 @@ var ts;
reportVerbose = false;
reportStatus(state, verboseMessage, proj.options.configFilePath);
}
- if (isDeclarationFile(file)) {
+ if (ts.isDeclarationFileName(file)) {
priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file));
}
host.setModifiedTime(file, now);
@@ -123449,7 +125340,7 @@ var ts;
if (!state.watch || !state.lastCachedPackageJsonLookups)
return;
ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), {
- createNewValue: function (path, _input) { return state.watchFile(path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); },
+ createNewValue: function (path, _input) { return state.watchFile(path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); },
onDeleteValue: ts.closeFileWatcher,
});
}
@@ -123894,7 +125785,7 @@ var ts;
// This is #1 described above.
? manifestTypingNames.map(function (typingName) { return ts.combinePaths(packagesFolderPath, typingName, manifestName); })
// And #2. Depth = 3 because scoped packages look like `node_modules/@foo/bar/package.json`
- : host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3)
+ : host.readDirectory(packagesFolderPath, [".json" /* Extension.Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3)
.filter(function (manifestPath) {
if (ts.getBaseFileName(manifestPath) !== manifestName) {
return false;
@@ -123960,7 +125851,7 @@ var ts;
if (fromFileNames.length) {
addInferredTypings(fromFileNames, "Inferred typings from file names");
}
- var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Jsx */); });
+ var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Extension.Jsx */); });
if (hasJsxFile) {
if (log)
log("Inferred 'react' typings due to presence of '.jsx' extension");
@@ -123988,16 +125879,16 @@ var ts;
JsTyping.validatePackageName = validatePackageName;
function validatePackageNameWorker(packageName, supportScopedPackage) {
if (!packageName) {
- return 1 /* EmptyName */;
+ return 1 /* NameValidationResult.EmptyName */;
}
if (packageName.length > maxPackageNameLength) {
- return 2 /* NameTooLong */;
+ return 2 /* NameValidationResult.NameTooLong */;
}
- if (packageName.charCodeAt(0) === 46 /* dot */) {
- return 3 /* NameStartsWithDot */;
+ if (packageName.charCodeAt(0) === 46 /* CharacterCodes.dot */) {
+ return 3 /* NameValidationResult.NameStartsWithDot */;
}
- if (packageName.charCodeAt(0) === 95 /* _ */) {
- return 4 /* NameStartsWithUnderscore */;
+ if (packageName.charCodeAt(0) === 95 /* CharacterCodes._ */) {
+ return 4 /* NameValidationResult.NameStartsWithUnderscore */;
}
// check if name is scope package like: starts with @ and has one '/' in the middle
// scoped packages are not currently supported
@@ -124005,20 +125896,20 @@ var ts;
var matches = /^@([^/]+)\/([^/]+)$/.exec(packageName);
if (matches) {
var scopeResult = validatePackageNameWorker(matches[1], /*supportScopedPackage*/ false);
- if (scopeResult !== 0 /* Ok */) {
+ if (scopeResult !== 0 /* NameValidationResult.Ok */) {
return { name: matches[1], isScopeName: true, result: scopeResult };
}
var packageResult = validatePackageNameWorker(matches[2], /*supportScopedPackage*/ false);
- if (packageResult !== 0 /* Ok */) {
+ if (packageResult !== 0 /* NameValidationResult.Ok */) {
return { name: matches[2], isScopeName: false, result: packageResult };
}
- return 0 /* Ok */;
+ return 0 /* NameValidationResult.Ok */;
}
}
if (encodeURIComponent(packageName) !== packageName) {
- return 5 /* NameContainsNonURISafeCharacters */;
+ return 5 /* NameValidationResult.NameContainsNonURISafeCharacters */;
}
- return 0 /* Ok */;
+ return 0 /* NameValidationResult.Ok */;
}
function renderPackageNameValidationFailure(result, typing) {
return typeof result === "object" ?
@@ -124029,17 +125920,17 @@ var ts;
function renderPackageNameValidationFailureWorker(typing, result, name, isScopeName) {
var kind = isScopeName ? "Scope" : "Package";
switch (result) {
- case 1 /* EmptyName */:
+ case 1 /* NameValidationResult.EmptyName */:
return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot be empty");
- case 2 /* NameTooLong */:
+ case 2 /* NameValidationResult.NameTooLong */:
return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' should be less than ").concat(maxPackageNameLength, " characters");
- case 3 /* NameStartsWithDot */:
+ case 3 /* NameValidationResult.NameStartsWithDot */:
return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '.'");
- case 4 /* NameStartsWithUnderscore */:
+ case 4 /* NameValidationResult.NameStartsWithUnderscore */:
return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '_'");
- case 5 /* NameContainsNonURISafeCharacters */:
+ case 5 /* NameValidationResult.NameContainsNonURISafeCharacters */:
return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' contains non URI safe characters");
- case 0 /* Ok */:
+ case 0 /* NameValidationResult.Ok */:
return ts.Debug.fail(); // Shouldn't have called this.
default:
throw ts.Debug.assertNever(result);
@@ -124194,6 +126085,17 @@ var ts;
SymbolDisplayPartKind[SymbolDisplayPartKind["linkName"] = 23] = "linkName";
SymbolDisplayPartKind[SymbolDisplayPartKind["linkText"] = 24] = "linkText";
})(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {}));
+ // Do not change existing values, as they exist in telemetry.
+ var CompletionInfoFlags;
+ (function (CompletionInfoFlags) {
+ CompletionInfoFlags[CompletionInfoFlags["None"] = 0] = "None";
+ CompletionInfoFlags[CompletionInfoFlags["MayIncludeAutoImports"] = 1] = "MayIncludeAutoImports";
+ CompletionInfoFlags[CompletionInfoFlags["IsImportStatementCompletion"] = 2] = "IsImportStatementCompletion";
+ CompletionInfoFlags[CompletionInfoFlags["IsContinuation"] = 4] = "IsContinuation";
+ CompletionInfoFlags[CompletionInfoFlags["ResolvedModuleSpecifiers"] = 8] = "ResolvedModuleSpecifiers";
+ CompletionInfoFlags[CompletionInfoFlags["ResolvedModuleSpecifiersBeyondLimit"] = 16] = "ResolvedModuleSpecifiersBeyondLimit";
+ CompletionInfoFlags[CompletionInfoFlags["MayIncludeMethodSnippets"] = 32] = "MayIncludeMethodSnippets";
+ })(CompletionInfoFlags = ts.CompletionInfoFlags || (ts.CompletionInfoFlags = {}));
var OutliningSpanKind;
(function (OutliningSpanKind) {
/** Single or multi-line comments */
@@ -124400,7 +126302,7 @@ var ts;
(function (ts) {
// These utilities are common to multiple language service features.
//#region
- ts.scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true);
+ ts.scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true);
var SemanticMeaning;
(function (SemanticMeaning) {
SemanticMeaning[SemanticMeaning["None"] = 0] = "None";
@@ -124411,66 +126313,66 @@ var ts;
})(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {}));
function getMeaningFromDeclaration(node) {
switch (node.kind) {
- case 253 /* VariableDeclaration */:
- return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */;
- case 163 /* Parameter */:
- case 202 /* BindingElement */:
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
- case 294 /* PropertyAssignment */:
- case 295 /* ShorthandPropertyAssignment */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 170 /* Constructor */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
- case 291 /* CatchClause */:
- case 284 /* JsxAttribute */:
- return 1 /* Value */;
- case 162 /* TypeParameter */:
- case 257 /* InterfaceDeclaration */:
- case 258 /* TypeAliasDeclaration */:
- case 181 /* TypeLiteral */:
- return 2 /* Type */;
- case 343 /* JSDocTypedefTag */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
+ return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* SemanticMeaning.All */ : 1 /* SemanticMeaning.Value */;
+ case 164 /* SyntaxKind.Parameter */:
+ case 203 /* SyntaxKind.BindingElement */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 292 /* SyntaxKind.CatchClause */:
+ case 285 /* SyntaxKind.JsxAttribute */:
+ return 1 /* SemanticMeaning.Value */;
+ case 163 /* SyntaxKind.TypeParameter */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 182 /* SyntaxKind.TypeLiteral */:
+ return 2 /* SemanticMeaning.Type */;
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
// If it has no name node, it shares the name with the value declaration below it.
- return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */;
- case 297 /* EnumMember */:
- case 256 /* ClassDeclaration */:
- return 1 /* Value */ | 2 /* Type */;
- case 260 /* ModuleDeclaration */:
+ return node.name === undefined ? 1 /* SemanticMeaning.Value */ | 2 /* SemanticMeaning.Type */ : 2 /* SemanticMeaning.Type */;
+ case 299 /* SyntaxKind.EnumMember */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ return 1 /* SemanticMeaning.Value */ | 2 /* SemanticMeaning.Type */;
+ case 261 /* SyntaxKind.ModuleDeclaration */:
if (ts.isAmbientModule(node)) {
- return 4 /* Namespace */ | 1 /* Value */;
+ return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */;
}
- else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) {
- return 4 /* Namespace */ | 1 /* Value */;
+ else if (ts.getModuleInstanceState(node) === 1 /* ModuleInstanceState.Instantiated */) {
+ return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */;
}
else {
- return 4 /* Namespace */;
- }
- case 259 /* EnumDeclaration */:
- case 268 /* NamedImports */:
- case 269 /* ImportSpecifier */:
- case 264 /* ImportEqualsDeclaration */:
- case 265 /* ImportDeclaration */:
- case 270 /* ExportAssignment */:
- case 271 /* ExportDeclaration */:
- return 7 /* All */;
+ return 4 /* SemanticMeaning.Namespace */;
+ }
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 269 /* SyntaxKind.NamedImports */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
+ case 271 /* SyntaxKind.ExportAssignment */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
+ return 7 /* SemanticMeaning.All */;
// An external module can be a Value
- case 303 /* SourceFile */:
- return 4 /* Namespace */ | 1 /* Value */;
+ case 305 /* SyntaxKind.SourceFile */:
+ return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */;
}
- return 7 /* All */;
+ return 7 /* SemanticMeaning.All */;
}
ts.getMeaningFromDeclaration = getMeaningFromDeclaration;
function getMeaningFromLocation(node) {
node = getAdjustedReferenceLocation(node);
var parent = node.parent;
- if (node.kind === 303 /* SourceFile */) {
- return 1 /* Value */;
+ if (node.kind === 305 /* SyntaxKind.SourceFile */) {
+ return 1 /* SemanticMeaning.Value */;
}
else if (ts.isExportAssignment(parent)
|| ts.isExportSpecifier(parent)
@@ -124478,7 +126380,7 @@ var ts;
|| ts.isImportSpecifier(parent)
|| ts.isImportClause(parent)
|| ts.isImportEqualsDeclaration(parent) && node === parent.name) {
- return 7 /* All */;
+ return 7 /* SemanticMeaning.All */;
}
else if (isInRightSideOfInternalImportEqualsDeclaration(node)) {
return getMeaningFromRightHandSideOfImportEquals(node);
@@ -124487,24 +126389,24 @@ var ts;
return getMeaningFromDeclaration(parent);
}
else if (ts.isEntityName(node) && ts.findAncestor(node, ts.or(ts.isJSDocNameReference, ts.isJSDocLinkLike, ts.isJSDocMemberName))) {
- return 7 /* All */;
+ return 7 /* SemanticMeaning.All */;
}
else if (isTypeReference(node)) {
- return 2 /* Type */;
+ return 2 /* SemanticMeaning.Type */;
}
else if (isNamespaceReference(node)) {
- return 4 /* Namespace */;
+ return 4 /* SemanticMeaning.Namespace */;
}
else if (ts.isTypeParameterDeclaration(parent)) {
ts.Debug.assert(ts.isJSDocTemplateTag(parent.parent)); // Else would be handled by isDeclarationName
- return 2 /* Type */;
+ return 2 /* SemanticMeaning.Type */;
}
else if (ts.isLiteralTypeNode(parent)) {
// This might be T["name"], which is actually referencing a property and not a type. So allow both meanings.
- return 2 /* Type */ | 1 /* Value */;
+ return 2 /* SemanticMeaning.Type */ | 1 /* SemanticMeaning.Value */;
}
else {
- return 1 /* Value */;
+ return 1 /* SemanticMeaning.Value */;
}
}
ts.getMeaningFromLocation = getMeaningFromLocation;
@@ -124512,11 +126414,11 @@ var ts;
// import a = |b|; // Namespace
// import a = |b.c|; // Value, type, namespace
// import a = |b.c|.d; // Namespace
- var name = node.kind === 160 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined;
- return name && name.parent.kind === 264 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */;
+ var name = node.kind === 161 /* SyntaxKind.QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined;
+ return name && name.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? 7 /* SemanticMeaning.All */ : 4 /* SemanticMeaning.Namespace */;
}
function isInRightSideOfInternalImportEqualsDeclaration(node) {
- while (node.parent.kind === 160 /* QualifiedName */) {
+ while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) {
node = node.parent;
}
return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node;
@@ -124528,27 +126430,27 @@ var ts;
function isQualifiedNameNamespaceReference(node) {
var root = node;
var isLastClause = true;
- if (root.parent.kind === 160 /* QualifiedName */) {
- while (root.parent && root.parent.kind === 160 /* QualifiedName */) {
+ if (root.parent.kind === 161 /* SyntaxKind.QualifiedName */) {
+ while (root.parent && root.parent.kind === 161 /* SyntaxKind.QualifiedName */) {
root = root.parent;
}
isLastClause = root.right === node;
}
- return root.parent.kind === 177 /* TypeReference */ && !isLastClause;
+ return root.parent.kind === 178 /* SyntaxKind.TypeReference */ && !isLastClause;
}
function isPropertyAccessNamespaceReference(node) {
var root = node;
var isLastClause = true;
- if (root.parent.kind === 205 /* PropertyAccessExpression */) {
- while (root.parent && root.parent.kind === 205 /* PropertyAccessExpression */) {
+ if (root.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) {
+ while (root.parent && root.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) {
root = root.parent;
}
isLastClause = root.name === node;
}
- if (!isLastClause && root.parent.kind === 227 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 290 /* HeritageClause */) {
+ if (!isLastClause && root.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && root.parent.parent.kind === 291 /* SyntaxKind.HeritageClause */) {
var decl = root.parent.parent.parent;
- return (decl.kind === 256 /* ClassDeclaration */ && root.parent.parent.token === 117 /* ImplementsKeyword */) ||
- (decl.kind === 257 /* InterfaceDeclaration */ && root.parent.parent.token === 94 /* ExtendsKeyword */);
+ return (decl.kind === 257 /* SyntaxKind.ClassDeclaration */ && root.parent.parent.token === 117 /* SyntaxKind.ImplementsKeyword */) ||
+ (decl.kind === 258 /* SyntaxKind.InterfaceDeclaration */ && root.parent.parent.token === 94 /* SyntaxKind.ExtendsKeyword */);
}
return false;
}
@@ -124557,18 +126459,18 @@ var ts;
node = node.parent;
}
switch (node.kind) {
- case 108 /* ThisKeyword */:
+ case 108 /* SyntaxKind.ThisKeyword */:
return !ts.isExpressionNode(node);
- case 191 /* ThisType */:
+ case 192 /* SyntaxKind.ThisType */:
return true;
}
switch (node.parent.kind) {
- case 177 /* TypeReference */:
+ case 178 /* SyntaxKind.TypeReference */:
return true;
- case 199 /* ImportType */:
+ case 200 /* SyntaxKind.ImportType */:
return !node.parent.isTypeOf;
- case 227 /* ExpressionWithTypeArguments */:
- return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent);
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
+ return ts.isPartOfTypeNode(node.parent);
}
return false;
}
@@ -124634,7 +126536,7 @@ var ts;
ts.climbPastPropertyOrElementAccess = climbPastPropertyOrElementAccess;
function getTargetLabel(referenceNode, labelName) {
while (referenceNode) {
- if (referenceNode.kind === 249 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) {
+ if (referenceNode.kind === 250 /* SyntaxKind.LabeledStatement */ && referenceNode.label.escapedText === labelName) {
return referenceNode.label;
}
referenceNode = referenceNode.parent;
@@ -124695,22 +126597,22 @@ var ts;
ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration;
function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) {
switch (node.parent.kind) {
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
- case 294 /* PropertyAssignment */:
- case 297 /* EnumMember */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 260 /* ModuleDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
+ case 299 /* SyntaxKind.EnumMember */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
return ts.getNameOfDeclaration(node.parent) === node;
- case 206 /* ElementAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
return node.parent.argumentExpression === node;
- case 161 /* ComputedPropertyName */:
+ case 162 /* SyntaxKind.ComputedPropertyName */:
return true;
- case 195 /* LiteralType */:
- return node.parent.parent.kind === 193 /* IndexedAccessType */;
+ case 196 /* SyntaxKind.LiteralType */:
+ return node.parent.parent.kind === 194 /* SyntaxKind.IndexedAccessType */;
default:
return false;
}
@@ -124734,17 +126636,17 @@ var ts;
return undefined;
}
switch (node.kind) {
- case 303 /* SourceFile */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 256 /* ClassDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 259 /* EnumDeclaration */:
- case 260 /* ModuleDeclaration */:
+ case 305 /* SyntaxKind.SourceFile */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
return node;
}
}
@@ -124752,108 +126654,108 @@ var ts;
ts.getContainerNode = getContainerNode;
function getNodeKind(node) {
switch (node.kind) {
- case 303 /* SourceFile */:
- return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */;
- case 260 /* ModuleDeclaration */:
- return "module" /* moduleElement */;
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- return "class" /* classElement */;
- case 257 /* InterfaceDeclaration */: return "interface" /* interfaceElement */;
- case 258 /* TypeAliasDeclaration */:
- case 336 /* JSDocCallbackTag */:
- case 343 /* JSDocTypedefTag */:
- return "type" /* typeElement */;
- case 259 /* EnumDeclaration */: return "enum" /* enumElement */;
- case 253 /* VariableDeclaration */:
+ case 305 /* SyntaxKind.SourceFile */:
+ return ts.isExternalModule(node) ? "module" /* ScriptElementKind.moduleElement */ : "script" /* ScriptElementKind.scriptElement */;
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ return "module" /* ScriptElementKind.moduleElement */;
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ return "class" /* ScriptElementKind.classElement */;
+ case 258 /* SyntaxKind.InterfaceDeclaration */: return "interface" /* ScriptElementKind.interfaceElement */;
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 338 /* SyntaxKind.JSDocCallbackTag */:
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
+ return "type" /* ScriptElementKind.typeElement */;
+ case 260 /* SyntaxKind.EnumDeclaration */: return "enum" /* ScriptElementKind.enumElement */;
+ case 254 /* SyntaxKind.VariableDeclaration */:
return getKindOfVariableDeclaration(node);
- case 202 /* BindingElement */:
+ case 203 /* SyntaxKind.BindingElement */:
return getKindOfVariableDeclaration(ts.getRootDeclaration(node));
- case 213 /* ArrowFunction */:
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- return "function" /* functionElement */;
- case 171 /* GetAccessor */: return "getter" /* memberGetAccessorElement */;
- case 172 /* SetAccessor */: return "setter" /* memberSetAccessorElement */;
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- return "method" /* memberFunctionElement */;
- case 294 /* PropertyAssignment */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ return "function" /* ScriptElementKind.functionElement */;
+ case 172 /* SyntaxKind.GetAccessor */: return "getter" /* ScriptElementKind.memberGetAccessorElement */;
+ case 173 /* SyntaxKind.SetAccessor */: return "setter" /* ScriptElementKind.memberSetAccessorElement */;
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ return "method" /* ScriptElementKind.memberFunctionElement */;
+ case 296 /* SyntaxKind.PropertyAssignment */:
var initializer = node.initializer;
- return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */;
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
- case 295 /* ShorthandPropertyAssignment */:
- case 296 /* SpreadAssignment */:
- return "property" /* memberVariableElement */;
- case 175 /* IndexSignature */: return "index" /* indexSignatureElement */;
- case 174 /* ConstructSignature */: return "construct" /* constructSignatureElement */;
- case 173 /* CallSignature */: return "call" /* callSignatureElement */;
- case 170 /* Constructor */:
- case 169 /* ClassStaticBlockDeclaration */:
- return "constructor" /* constructorImplementationElement */;
- case 162 /* TypeParameter */: return "type parameter" /* typeParameterElement */;
- case 297 /* EnumMember */: return "enum member" /* enumMemberElement */;
- case 163 /* Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */;
- case 264 /* ImportEqualsDeclaration */:
- case 269 /* ImportSpecifier */:
- case 274 /* ExportSpecifier */:
- case 267 /* NamespaceImport */:
- case 273 /* NamespaceExport */:
- return "alias" /* alias */;
- case 220 /* BinaryExpression */:
+ return ts.isFunctionLike(initializer) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */;
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
+ case 298 /* SyntaxKind.SpreadAssignment */:
+ return "property" /* ScriptElementKind.memberVariableElement */;
+ case 176 /* SyntaxKind.IndexSignature */: return "index" /* ScriptElementKind.indexSignatureElement */;
+ case 175 /* SyntaxKind.ConstructSignature */: return "construct" /* ScriptElementKind.constructSignatureElement */;
+ case 174 /* SyntaxKind.CallSignature */: return "call" /* ScriptElementKind.callSignatureElement */;
+ case 171 /* SyntaxKind.Constructor */:
+ case 170 /* SyntaxKind.ClassStaticBlockDeclaration */:
+ return "constructor" /* ScriptElementKind.constructorImplementationElement */;
+ case 163 /* SyntaxKind.TypeParameter */: return "type parameter" /* ScriptElementKind.typeParameterElement */;
+ case 299 /* SyntaxKind.EnumMember */: return "enum member" /* ScriptElementKind.enumMemberElement */;
+ case 164 /* SyntaxKind.Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */) ? "property" /* ScriptElementKind.memberVariableElement */ : "parameter" /* ScriptElementKind.parameterElement */;
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
+ case 275 /* SyntaxKind.ExportSpecifier */:
+ case 268 /* SyntaxKind.NamespaceImport */:
+ case 274 /* SyntaxKind.NamespaceExport */:
+ return "alias" /* ScriptElementKind.alias */;
+ case 221 /* SyntaxKind.BinaryExpression */:
var kind = ts.getAssignmentDeclarationKind(node);
var right = node.right;
switch (kind) {
- case 7 /* ObjectDefinePropertyValue */:
- case 8 /* ObjectDefinePropertyExports */:
- case 9 /* ObjectDefinePrototypeProperty */:
- case 0 /* None */:
- return "" /* unknown */;
- case 1 /* ExportsProperty */:
- case 2 /* ModuleExports */:
+ case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */:
+ case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */:
+ case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */:
+ case 0 /* AssignmentDeclarationKind.None */:
+ return "" /* ScriptElementKind.unknown */;
+ case 1 /* AssignmentDeclarationKind.ExportsProperty */:
+ case 2 /* AssignmentDeclarationKind.ModuleExports */:
var rightKind = getNodeKind(right);
- return rightKind === "" /* unknown */ ? "const" /* constElement */ : rightKind;
- case 3 /* PrototypeProperty */:
- return ts.isFunctionExpression(right) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */;
- case 4 /* ThisProperty */:
- return "property" /* memberVariableElement */; // property
- case 5 /* Property */:
+ return rightKind === "" /* ScriptElementKind.unknown */ ? "const" /* ScriptElementKind.constElement */ : rightKind;
+ case 3 /* AssignmentDeclarationKind.PrototypeProperty */:
+ return ts.isFunctionExpression(right) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */;
+ case 4 /* AssignmentDeclarationKind.ThisProperty */:
+ return "property" /* ScriptElementKind.memberVariableElement */; // property
+ case 5 /* AssignmentDeclarationKind.Property */:
// static method / property
- return ts.isFunctionExpression(right) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */;
- case 6 /* Prototype */:
- return "local class" /* localClassElement */;
+ return ts.isFunctionExpression(right) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */;
+ case 6 /* AssignmentDeclarationKind.Prototype */:
+ return "local class" /* ScriptElementKind.localClassElement */;
default: {
ts.assertType(kind);
- return "" /* unknown */;
+ return "" /* ScriptElementKind.unknown */;
}
}
- case 79 /* Identifier */:
- return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */;
- case 270 /* ExportAssignment */:
+ case 79 /* SyntaxKind.Identifier */:
+ return ts.isImportClause(node.parent) ? "alias" /* ScriptElementKind.alias */ : "" /* ScriptElementKind.unknown */;
+ case 271 /* SyntaxKind.ExportAssignment */:
var scriptKind = getNodeKind(node.expression);
// If the expression didn't come back with something (like it does for an identifiers)
- return scriptKind === "" /* unknown */ ? "const" /* constElement */ : scriptKind;
+ return scriptKind === "" /* ScriptElementKind.unknown */ ? "const" /* ScriptElementKind.constElement */ : scriptKind;
default:
- return "" /* unknown */;
+ return "" /* ScriptElementKind.unknown */;
}
function getKindOfVariableDeclaration(v) {
return ts.isVarConst(v)
- ? "const" /* constElement */
+ ? "const" /* ScriptElementKind.constElement */
: ts.isLet(v)
- ? "let" /* letElement */
- : "var" /* variableElement */;
+ ? "let" /* ScriptElementKind.letElement */
+ : "var" /* ScriptElementKind.variableElement */;
}
}
ts.getNodeKind = getNodeKind;
function isThis(node) {
switch (node.kind) {
- case 108 /* ThisKeyword */:
+ case 108 /* SyntaxKind.ThisKeyword */:
// case SyntaxKind.ThisType: TODO: GH#9267
return true;
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
// 'this' as a parameter
- return ts.identifierIsThisKeyword(node) && node.parent.kind === 163 /* Parameter */;
+ return ts.identifierIsThisKeyword(node) && node.parent.kind === 164 /* SyntaxKind.Parameter */;
default:
return false;
}
@@ -124918,42 +126820,42 @@ var ts;
return false;
}
switch (n.kind) {
- case 256 /* ClassDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 259 /* EnumDeclaration */:
- case 204 /* ObjectLiteralExpression */:
- case 200 /* ObjectBindingPattern */:
- case 181 /* TypeLiteral */:
- case 234 /* Block */:
- case 261 /* ModuleBlock */:
- case 262 /* CaseBlock */:
- case 268 /* NamedImports */:
- case 272 /* NamedExports */:
- return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile);
- case 291 /* CatchClause */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
+ case 201 /* SyntaxKind.ObjectBindingPattern */:
+ case 182 /* SyntaxKind.TypeLiteral */:
+ case 235 /* SyntaxKind.Block */:
+ case 262 /* SyntaxKind.ModuleBlock */:
+ case 263 /* SyntaxKind.CaseBlock */:
+ case 269 /* SyntaxKind.NamedImports */:
+ case 273 /* SyntaxKind.NamedExports */:
+ return nodeEndsWith(n, 19 /* SyntaxKind.CloseBraceToken */, sourceFile);
+ case 292 /* SyntaxKind.CatchClause */:
return isCompletedNode(n.block, sourceFile);
- case 208 /* NewExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
if (!n.arguments) {
return true;
}
// falls through
- case 207 /* CallExpression */:
- case 211 /* ParenthesizedExpression */:
- case 190 /* ParenthesizedType */:
- return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile);
- case 178 /* FunctionType */:
- case 179 /* ConstructorType */:
+ case 208 /* SyntaxKind.CallExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
+ case 191 /* SyntaxKind.ParenthesizedType */:
+ return nodeEndsWith(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile);
+ case 179 /* SyntaxKind.FunctionType */:
+ case 180 /* SyntaxKind.ConstructorType */:
return isCompletedNode(n.type, sourceFile);
- case 170 /* Constructor */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 174 /* ConstructSignature */:
- case 173 /* CallSignature */:
- case 213 /* ArrowFunction */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 214 /* SyntaxKind.ArrowFunction */:
if (n.body) {
return isCompletedNode(n.body, sourceFile);
}
@@ -124962,66 +126864,66 @@ var ts;
}
// Even though type parameters can be unclosed, we can get away with
// having at least a closing paren.
- return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile);
- case 260 /* ModuleDeclaration */:
+ return hasChildOfKind(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile);
+ case 261 /* SyntaxKind.ModuleDeclaration */:
return !!n.body && isCompletedNode(n.body, sourceFile);
- case 238 /* IfStatement */:
+ case 239 /* SyntaxKind.IfStatement */:
if (n.elseStatement) {
return isCompletedNode(n.elseStatement, sourceFile);
}
return isCompletedNode(n.thenStatement, sourceFile);
- case 237 /* ExpressionStatement */:
+ case 238 /* SyntaxKind.ExpressionStatement */:
return isCompletedNode(n.expression, sourceFile) ||
- hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile);
- case 203 /* ArrayLiteralExpression */:
- case 201 /* ArrayBindingPattern */:
- case 206 /* ElementAccessExpression */:
- case 161 /* ComputedPropertyName */:
- case 183 /* TupleType */:
- return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile);
- case 175 /* IndexSignature */:
+ hasChildOfKind(n, 26 /* SyntaxKind.SemicolonToken */, sourceFile);
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
+ case 202 /* SyntaxKind.ArrayBindingPattern */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
+ case 162 /* SyntaxKind.ComputedPropertyName */:
+ case 184 /* SyntaxKind.TupleType */:
+ return nodeEndsWith(n, 23 /* SyntaxKind.CloseBracketToken */, sourceFile);
+ case 176 /* SyntaxKind.IndexSignature */:
if (n.type) {
return isCompletedNode(n.type, sourceFile);
}
- return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile);
- case 288 /* CaseClause */:
- case 289 /* DefaultClause */:
+ return hasChildOfKind(n, 23 /* SyntaxKind.CloseBracketToken */, sourceFile);
+ case 289 /* SyntaxKind.CaseClause */:
+ case 290 /* SyntaxKind.DefaultClause */:
// there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed
return false;
- case 241 /* ForStatement */:
- case 242 /* ForInStatement */:
- case 243 /* ForOfStatement */:
- case 240 /* WhileStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
return isCompletedNode(n.statement, sourceFile);
- case 239 /* DoStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
// rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')';
- return hasChildOfKind(n, 115 /* WhileKeyword */, sourceFile)
- ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile)
+ return hasChildOfKind(n, 115 /* SyntaxKind.WhileKeyword */, sourceFile)
+ ? nodeEndsWith(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile)
: isCompletedNode(n.statement, sourceFile);
- case 180 /* TypeQuery */:
+ case 181 /* SyntaxKind.TypeQuery */:
return isCompletedNode(n.exprName, sourceFile);
- case 215 /* TypeOfExpression */:
- case 214 /* DeleteExpression */:
- case 216 /* VoidExpression */:
- case 223 /* YieldExpression */:
- case 224 /* SpreadElement */:
+ case 216 /* SyntaxKind.TypeOfExpression */:
+ case 215 /* SyntaxKind.DeleteExpression */:
+ case 217 /* SyntaxKind.VoidExpression */:
+ case 224 /* SyntaxKind.YieldExpression */:
+ case 225 /* SyntaxKind.SpreadElement */:
var unaryWordExpression = n;
return isCompletedNode(unaryWordExpression.expression, sourceFile);
- case 209 /* TaggedTemplateExpression */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
return isCompletedNode(n.template, sourceFile);
- case 222 /* TemplateExpression */:
+ case 223 /* SyntaxKind.TemplateExpression */:
var lastSpan = ts.lastOrUndefined(n.templateSpans);
return isCompletedNode(lastSpan, sourceFile);
- case 232 /* TemplateSpan */:
+ case 233 /* SyntaxKind.TemplateSpan */:
return ts.nodeIsPresent(n.literal);
- case 271 /* ExportDeclaration */:
- case 265 /* ImportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
return ts.nodeIsPresent(n.moduleSpecifier);
- case 218 /* PrefixUnaryExpression */:
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
return isCompletedNode(n.operand, sourceFile);
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return isCompletedNode(n.right, sourceFile);
- case 221 /* ConditionalExpression */:
+ case 222 /* SyntaxKind.ConditionalExpression */:
return isCompletedNode(n.whenFalse, sourceFile);
default:
return true;
@@ -125038,7 +126940,7 @@ var ts;
if (lastChild.kind === expectedLastToken) {
return true;
}
- else if (lastChild.kind === 26 /* SemicolonToken */ && children.length !== 1) {
+ else if (lastChild.kind === 26 /* SyntaxKind.SemicolonToken */ && children.length !== 1) {
return children[children.length - 2].kind === expectedLastToken;
}
}
@@ -125081,13 +126983,13 @@ var ts;
}
ts.findContainingList = findContainingList;
function isDefaultModifier(node) {
- return node.kind === 88 /* DefaultKeyword */;
+ return node.kind === 88 /* SyntaxKind.DefaultKeyword */;
}
function isClassKeyword(node) {
- return node.kind === 84 /* ClassKeyword */;
+ return node.kind === 84 /* SyntaxKind.ClassKeyword */;
}
function isFunctionKeyword(node) {
- return node.kind === 98 /* FunctionKeyword */;
+ return node.kind === 98 /* SyntaxKind.FunctionKeyword */;
}
function getAdjustedLocationForClass(node) {
if (ts.isNamedDeclaration(node)) {
@@ -125146,11 +127048,11 @@ var ts;
function getAdjustedLocationForDeclaration(node, forRename) {
if (!forRename) {
switch (node.kind) {
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
return getAdjustedLocationForClass(node);
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
return getAdjustedLocationForFunction(node);
}
}
@@ -125240,30 +127142,30 @@ var ts;
//
// NOTE: If the node is a modifier, we don't adjust its location if it is the `default` modifier as that is handled
// specially by `getSymbolAtLocation`.
- if (ts.isModifier(node) && (forRename || node.kind !== 88 /* DefaultKeyword */) ? ts.contains(parent.modifiers, node) :
- node.kind === 84 /* ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) :
- node.kind === 98 /* FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) :
- node.kind === 118 /* InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) :
- node.kind === 92 /* EnumKeyword */ ? ts.isEnumDeclaration(parent) :
- node.kind === 151 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) :
- node.kind === 142 /* NamespaceKeyword */ || node.kind === 141 /* ModuleKeyword */ ? ts.isModuleDeclaration(parent) :
- node.kind === 100 /* ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) :
- node.kind === 136 /* GetKeyword */ ? ts.isGetAccessorDeclaration(parent) :
- node.kind === 148 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) {
+ if (ts.isModifier(node) && (forRename || node.kind !== 88 /* SyntaxKind.DefaultKeyword */) ? ts.contains(parent.modifiers, node) :
+ node.kind === 84 /* SyntaxKind.ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) :
+ node.kind === 98 /* SyntaxKind.FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) :
+ node.kind === 118 /* SyntaxKind.InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) :
+ node.kind === 92 /* SyntaxKind.EnumKeyword */ ? ts.isEnumDeclaration(parent) :
+ node.kind === 152 /* SyntaxKind.TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) :
+ node.kind === 142 /* SyntaxKind.NamespaceKeyword */ || node.kind === 141 /* SyntaxKind.ModuleKeyword */ ? ts.isModuleDeclaration(parent) :
+ node.kind === 100 /* SyntaxKind.ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) :
+ node.kind === 136 /* SyntaxKind.GetKeyword */ ? ts.isGetAccessorDeclaration(parent) :
+ node.kind === 149 /* SyntaxKind.SetKeyword */ && ts.isSetAccessorDeclaration(parent)) {
var location = getAdjustedLocationForDeclaration(parent, forRename);
if (location) {
return location;
}
}
// /**/<var|let|const> [|name|] ...
- if ((node.kind === 113 /* VarKeyword */ || node.kind === 85 /* ConstKeyword */ || node.kind === 119 /* LetKeyword */) &&
+ if ((node.kind === 113 /* SyntaxKind.VarKeyword */ || node.kind === 85 /* SyntaxKind.ConstKeyword */ || node.kind === 119 /* SyntaxKind.LetKeyword */) &&
ts.isVariableDeclarationList(parent) && parent.declarations.length === 1) {
var decl = parent.declarations[0];
if (ts.isIdentifier(decl.name)) {
return decl.name;
}
}
- if (node.kind === 151 /* TypeKeyword */) {
+ if (node.kind === 152 /* SyntaxKind.TypeKeyword */) {
// import /**/type [|name|] from ...;
// import /**/type { [|name|] } from ...;
// import /**/type { propertyName as [|name|] } from ...;
@@ -125289,7 +127191,7 @@ var ts;
// import * /**/as [|name|] ...
// export { propertyName /**/as [|name|] } ...
// export * /**/as [|name|] ...
- if (node.kind === 127 /* AsKeyword */) {
+ if (node.kind === 127 /* SyntaxKind.AsKeyword */) {
if (ts.isImportSpecifier(parent) && parent.propertyName ||
ts.isExportSpecifier(parent) && parent.propertyName ||
ts.isNamespaceImport(parent) ||
@@ -125305,13 +127207,13 @@ var ts;
// /**/import { propertyName as [|name|] } from ...;
// /**/import ... from "[|module|]";
// /**/import "[|module|]";
- if (node.kind === 100 /* ImportKeyword */ && ts.isImportDeclaration(parent)) {
+ if (node.kind === 100 /* SyntaxKind.ImportKeyword */ && ts.isImportDeclaration(parent)) {
var location = getAdjustedLocationForImportDeclaration(parent, forRename);
if (location) {
return location;
}
}
- if (node.kind === 93 /* ExportKeyword */) {
+ if (node.kind === 93 /* SyntaxKind.ExportKeyword */) {
// /**/export { [|name|] } ...;
// /**/export { propertyName as [|name|] } ...;
// /**/export * from "[|module|]";
@@ -125330,12 +127232,12 @@ var ts;
}
}
// import name = /**/require("[|module|]");
- if (node.kind === 145 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) {
+ if (node.kind === 146 /* SyntaxKind.RequireKeyword */ && ts.isExternalModuleReference(parent)) {
return parent.expression;
}
// import ... /**/from "[|module|]";
// export ... /**/from "[|module|]";
- if (node.kind === 155 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) {
+ if (node.kind === 156 /* SyntaxKind.FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) {
return parent.moduleSpecifier;
}
// class ... /**/extends [|name|] ...
@@ -125343,13 +127245,13 @@ var ts;
// class ... /**/implements name1, name2 ...
// interface ... /**/extends [|name|] ...
// interface ... /**/extends name1, name2 ...
- if ((node.kind === 94 /* ExtendsKeyword */ || node.kind === 117 /* ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) {
+ if ((node.kind === 94 /* SyntaxKind.ExtendsKeyword */ || node.kind === 117 /* SyntaxKind.ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) {
var location = getAdjustedLocationForHeritageClause(parent);
if (location) {
return location;
}
}
- if (node.kind === 94 /* ExtendsKeyword */) {
+ if (node.kind === 94 /* SyntaxKind.ExtendsKeyword */) {
// ... <T /**/extends [|U|]> ...
if (ts.isTypeParameterDeclaration(parent) && parent.constraint && ts.isTypeReferenceNode(parent.constraint)) {
return parent.constraint.typeName;
@@ -125360,20 +127262,20 @@ var ts;
}
}
// ... T extends /**/infer [|U|] ? ...
- if (node.kind === 137 /* InferKeyword */ && ts.isInferTypeNode(parent)) {
+ if (node.kind === 137 /* SyntaxKind.InferKeyword */ && ts.isInferTypeNode(parent)) {
return parent.typeParameter.name;
}
// { [ [|K|] /**/in keyof T]: ... }
- if (node.kind === 101 /* InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) {
+ if (node.kind === 101 /* SyntaxKind.InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) {
return parent.name;
}
// /**/keyof [|T|]
- if (node.kind === 140 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 140 /* KeyOfKeyword */ &&
+ if (node.kind === 140 /* SyntaxKind.KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 140 /* SyntaxKind.KeyOfKeyword */ &&
ts.isTypeReferenceNode(parent.type)) {
return parent.type.typeName;
}
// /**/readonly [|name|][]
- if (node.kind === 144 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 144 /* ReadonlyKeyword */ &&
+ if (node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 145 /* SyntaxKind.ReadonlyKeyword */ &&
ts.isArrayTypeNode(parent.type) && ts.isTypeReferenceNode(parent.type.elementType)) {
return parent.type.elementType.typeName;
}
@@ -125388,29 +127290,29 @@ var ts;
// /**/yield [|name|]
// /**/yield obj.[|name|]
// /**/delete obj.[|name|]
- if (node.kind === 103 /* NewKeyword */ && ts.isNewExpression(parent) ||
- node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(parent) ||
- node.kind === 112 /* TypeOfKeyword */ && ts.isTypeOfExpression(parent) ||
- node.kind === 132 /* AwaitKeyword */ && ts.isAwaitExpression(parent) ||
- node.kind === 125 /* YieldKeyword */ && ts.isYieldExpression(parent) ||
- node.kind === 89 /* DeleteKeyword */ && ts.isDeleteExpression(parent)) {
+ if (node.kind === 103 /* SyntaxKind.NewKeyword */ && ts.isNewExpression(parent) ||
+ node.kind === 114 /* SyntaxKind.VoidKeyword */ && ts.isVoidExpression(parent) ||
+ node.kind === 112 /* SyntaxKind.TypeOfKeyword */ && ts.isTypeOfExpression(parent) ||
+ node.kind === 132 /* SyntaxKind.AwaitKeyword */ && ts.isAwaitExpression(parent) ||
+ node.kind === 125 /* SyntaxKind.YieldKeyword */ && ts.isYieldExpression(parent) ||
+ node.kind === 89 /* SyntaxKind.DeleteKeyword */ && ts.isDeleteExpression(parent)) {
if (parent.expression) {
return ts.skipOuterExpressions(parent.expression);
}
}
// left /**/in [|name|]
// left /**/instanceof [|name|]
- if ((node.kind === 101 /* InKeyword */ || node.kind === 102 /* InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) {
+ if ((node.kind === 101 /* SyntaxKind.InKeyword */ || node.kind === 102 /* SyntaxKind.InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) {
return ts.skipOuterExpressions(parent.right);
}
// left /**/as [|name|]
- if (node.kind === 127 /* AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) {
+ if (node.kind === 127 /* SyntaxKind.AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) {
return parent.type.typeName;
}
// for (... /**/in [|name|])
// for (... /**/of [|name|])
- if (node.kind === 101 /* InKeyword */ && ts.isForInStatement(parent) ||
- node.kind === 159 /* OfKeyword */ && ts.isForOfStatement(parent)) {
+ if (node.kind === 101 /* SyntaxKind.InKeyword */ && ts.isForInStatement(parent) ||
+ node.kind === 160 /* SyntaxKind.OfKeyword */ && ts.isForOfStatement(parent)) {
return ts.skipOuterExpressions(parent.expression);
}
}
@@ -125481,23 +127383,23 @@ var ts;
// position and whose end is greater than the position.
var start = allowPositionInLeadingTrivia ? children[middle].getFullStart() : children[middle].getStart(sourceFile, /*includeJsDoc*/ true);
if (start > position) {
- return 1 /* GreaterThan */;
+ return 1 /* Comparison.GreaterThan */;
}
// first element whose start position is before the input and whose end position is after or equal to the input
if (nodeContainsPosition(children[middle])) {
if (children[middle - 1]) {
// we want the _first_ element that contains the position, so left-recur if the prior node also contains the position
if (nodeContainsPosition(children[middle - 1])) {
- return 1 /* GreaterThan */;
+ return 1 /* Comparison.GreaterThan */;
}
}
- return 0 /* EqualTo */;
+ return 0 /* Comparison.EqualTo */;
}
// this complex condition makes us left-recur around a zero-length node when includePrecedingTokenAtEndPosition is set, rather than right-recur on it
if (includePrecedingTokenAtEndPosition && start === position && children[middle - 1] && children[middle - 1].getEnd() === position && nodeContainsPosition(children[middle - 1])) {
- return 1 /* GreaterThan */;
+ return 1 /* Comparison.GreaterThan */;
}
- return -1 /* LessThan */;
+ return -1 /* Comparison.LessThan */;
});
if (foundToken) {
return { value: foundToken };
@@ -125523,7 +127425,7 @@ var ts;
return false;
}
var end = node.getEnd();
- if (position < end || (position === end && (node.kind === 1 /* EndOfFileToken */ || includeEndPosition))) {
+ if (position < end || (position === end && (node.kind === 1 /* SyntaxKind.EndOfFileToken */ || includeEndPosition))) {
return true;
}
else if (includePrecedingTokenAtEndPosition && end === position) {
@@ -125587,16 +127489,12 @@ var ts;
}
}
ts.findNextToken = findNextToken;
- /**
- * Finds the rightmost token satisfying `token.end <= position`,
- * excluding `JsxText` tokens containing only whitespace.
- */
function findPrecedingToken(position, sourceFile, startNode, excludeJsdoc) {
- var result = find(startNode || sourceFile);
+ var result = find((startNode || sourceFile));
ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result)));
return result;
function find(n) {
- if (isNonWhitespaceToken(n) && n.kind !== 1 /* EndOfFileToken */) {
+ if (isNonWhitespaceToken(n) && n.kind !== 1 /* SyntaxKind.EndOfFileToken */) {
return n;
}
var children = n.getChildren(sourceFile);
@@ -125608,11 +127506,11 @@ var ts;
if (position < children[middle].end) {
// first element whose end position is greater than the input position
if (!children[middle - 1] || position >= children[middle - 1].end) {
- return 0 /* EqualTo */;
+ return 0 /* Comparison.EqualTo */;
}
- return 1 /* GreaterThan */;
+ return 1 /* Comparison.GreaterThan */;
}
- return -1 /* LessThan */;
+ return -1 /* Comparison.LessThan */;
});
if (i >= 0 && children[i]) {
var child = children[i];
@@ -125637,7 +127535,7 @@ var ts;
}
}
}
- ts.Debug.assert(startNode !== undefined || n.kind === 303 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n));
+ ts.Debug.assert(startNode !== undefined || n.kind === 305 /* SyntaxKind.SourceFile */ || n.kind === 1 /* SyntaxKind.EndOfFileToken */ || ts.isJSDocCommentContainingNode(n));
// Here we know that none of child token nodes embrace the position,
// the only known case is when position is at the end of the file.
// Try to find the rightmost token in the file without filtering.
@@ -125668,7 +127566,7 @@ var ts;
for (var i = exclusiveStartPosition - 1; i >= 0; i--) {
var child = children[i];
if (isWhiteSpaceOnlyJsxText(child)) {
- if (i === 0 && (parentKind === 11 /* JsxText */ || parentKind === 278 /* JsxSelfClosingElement */)) {
+ if (i === 0 && (parentKind === 11 /* SyntaxKind.JsxText */ || parentKind === 279 /* SyntaxKind.JsxSelfClosingElement */)) {
ts.Debug.fail("`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`");
}
}
@@ -125704,25 +127602,25 @@ var ts;
if (!token) {
return false;
}
- if (token.kind === 11 /* JsxText */) {
+ if (token.kind === 11 /* SyntaxKind.JsxText */) {
return true;
}
// <div>Hello |</div>
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) {
+ if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 11 /* SyntaxKind.JsxText */) {
return true;
}
// <div> { | </div> or <div a={| </div>
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 287 /* JsxExpression */) {
+ if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) {
return true;
}
// <div> {
// |
// } < /div>
- if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 287 /* JsxExpression */) {
+ if (token && token.kind === 19 /* SyntaxKind.CloseBraceToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) {
return true;
}
// <div>|</div>
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 280 /* JsxClosingElement */) {
+ if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 281 /* SyntaxKind.JsxClosingElement */) {
return true;
}
return false;
@@ -125741,10 +127639,10 @@ var ts;
if (ts.isJsxText(token)) {
return true;
}
- if (token.kind === 18 /* OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) {
+ if (token.kind === 18 /* SyntaxKind.OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) {
return true;
}
- if (token.kind === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) {
+ if (token.kind === 29 /* SyntaxKind.LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) {
return true;
}
return false;
@@ -125753,17 +127651,17 @@ var ts;
function isInsideJsxElement(sourceFile, position) {
function isInsideJsxElementTraversal(node) {
while (node) {
- if (node.kind >= 278 /* JsxSelfClosingElement */ && node.kind <= 287 /* JsxExpression */
- || node.kind === 11 /* JsxText */
- || node.kind === 29 /* LessThanToken */
- || node.kind === 31 /* GreaterThanToken */
- || node.kind === 79 /* Identifier */
- || node.kind === 19 /* CloseBraceToken */
- || node.kind === 18 /* OpenBraceToken */
- || node.kind === 43 /* SlashToken */) {
+ if (node.kind >= 279 /* SyntaxKind.JsxSelfClosingElement */ && node.kind <= 288 /* SyntaxKind.JsxExpression */
+ || node.kind === 11 /* SyntaxKind.JsxText */
+ || node.kind === 29 /* SyntaxKind.LessThanToken */
+ || node.kind === 31 /* SyntaxKind.GreaterThanToken */
+ || node.kind === 79 /* SyntaxKind.Identifier */
+ || node.kind === 19 /* SyntaxKind.CloseBraceToken */
+ || node.kind === 18 /* SyntaxKind.OpenBraceToken */
+ || node.kind === 43 /* SyntaxKind.SlashToken */) {
node = node.parent;
}
- else if (node.kind === 277 /* JsxElement */) {
+ else if (node.kind === 278 /* SyntaxKind.JsxElement */) {
if (position > node.getStart(sourceFile))
return true;
node = node.parent;
@@ -125853,10 +127751,10 @@ var ts;
var nTypeArguments = 0;
while (token) {
switch (token.kind) {
- case 29 /* LessThanToken */:
+ case 29 /* SyntaxKind.LessThanToken */:
// Found the beginning of the generic argument expression
token = findPrecedingToken(token.getFullStart(), sourceFile);
- if (token && token.kind === 28 /* QuestionDotToken */) {
+ if (token && token.kind === 28 /* SyntaxKind.QuestionDotToken */) {
token = findPrecedingToken(token.getFullStart(), sourceFile);
}
if (!token || !ts.isIdentifier(token))
@@ -125866,56 +127764,56 @@ var ts;
}
remainingLessThanTokens--;
break;
- case 49 /* GreaterThanGreaterThanGreaterThanToken */:
+ case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */:
remainingLessThanTokens = +3;
break;
- case 48 /* GreaterThanGreaterThanToken */:
+ case 48 /* SyntaxKind.GreaterThanGreaterThanToken */:
remainingLessThanTokens = +2;
break;
- case 31 /* GreaterThanToken */:
+ case 31 /* SyntaxKind.GreaterThanToken */:
remainingLessThanTokens++;
break;
- case 19 /* CloseBraceToken */:
+ case 19 /* SyntaxKind.CloseBraceToken */:
// This can be object type, skip until we find the matching open brace token
// Skip until the matching open brace token
- token = findPrecedingMatchingToken(token, 18 /* OpenBraceToken */, sourceFile);
+ token = findPrecedingMatchingToken(token, 18 /* SyntaxKind.OpenBraceToken */, sourceFile);
if (!token)
return undefined;
break;
- case 21 /* CloseParenToken */:
+ case 21 /* SyntaxKind.CloseParenToken */:
// This can be object type, skip until we find the matching open brace token
// Skip until the matching open brace token
- token = findPrecedingMatchingToken(token, 20 /* OpenParenToken */, sourceFile);
+ token = findPrecedingMatchingToken(token, 20 /* SyntaxKind.OpenParenToken */, sourceFile);
if (!token)
return undefined;
break;
- case 23 /* CloseBracketToken */:
+ case 23 /* SyntaxKind.CloseBracketToken */:
// This can be object type, skip until we find the matching open brace token
// Skip until the matching open brace token
- token = findPrecedingMatchingToken(token, 22 /* OpenBracketToken */, sourceFile);
+ token = findPrecedingMatchingToken(token, 22 /* SyntaxKind.OpenBracketToken */, sourceFile);
if (!token)
return undefined;
break;
// Valid tokens in a type name. Skip.
- case 27 /* CommaToken */:
+ case 27 /* SyntaxKind.CommaToken */:
nTypeArguments++;
break;
- case 38 /* EqualsGreaterThanToken */:
+ case 38 /* SyntaxKind.EqualsGreaterThanToken */:
// falls through
- case 79 /* Identifier */:
- case 10 /* StringLiteral */:
- case 8 /* NumericLiteral */:
- case 9 /* BigIntLiteral */:
- case 110 /* TrueKeyword */:
- case 95 /* FalseKeyword */:
+ case 79 /* SyntaxKind.Identifier */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
+ case 9 /* SyntaxKind.BigIntLiteral */:
+ case 110 /* SyntaxKind.TrueKeyword */:
+ case 95 /* SyntaxKind.FalseKeyword */:
// falls through
- case 112 /* TypeOfKeyword */:
- case 94 /* ExtendsKeyword */:
- case 140 /* KeyOfKeyword */:
- case 24 /* DotToken */:
- case 51 /* BarToken */:
- case 57 /* QuestionToken */:
- case 58 /* ColonToken */:
+ case 112 /* SyntaxKind.TypeOfKeyword */:
+ case 94 /* SyntaxKind.ExtendsKeyword */:
+ case 140 /* SyntaxKind.KeyOfKeyword */:
+ case 24 /* SyntaxKind.DotToken */:
+ case 51 /* SyntaxKind.BarToken */:
+ case 57 /* SyntaxKind.QuestionToken */:
+ case 58 /* SyntaxKind.ColonToken */:
break;
default:
if (ts.isTypeNode(token)) {
@@ -125947,52 +127845,52 @@ var ts;
function nodeHasTokens(n, sourceFile) {
// If we have a token or node that has a non-zero width, it must have tokens.
// Note: getWidth() does not take trivia into account.
- return n.kind === 1 /* EndOfFileToken */ ? !!n.jsDoc : n.getWidth(sourceFile) !== 0;
+ return n.kind === 1 /* SyntaxKind.EndOfFileToken */ ? !!n.jsDoc : n.getWidth(sourceFile) !== 0;
}
function getNodeModifiers(node, excludeFlags) {
- if (excludeFlags === void 0) { excludeFlags = 0 /* None */; }
+ if (excludeFlags === void 0) { excludeFlags = 0 /* ModifierFlags.None */; }
var result = [];
var flags = ts.isDeclaration(node)
? ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(node) & ~excludeFlags
- : 0 /* None */;
- if (flags & 8 /* Private */)
- result.push("private" /* privateMemberModifier */);
- if (flags & 16 /* Protected */)
- result.push("protected" /* protectedMemberModifier */);
- if (flags & 4 /* Public */)
- result.push("public" /* publicMemberModifier */);
- if (flags & 32 /* Static */ || ts.isClassStaticBlockDeclaration(node))
- result.push("static" /* staticModifier */);
- if (flags & 128 /* Abstract */)
- result.push("abstract" /* abstractModifier */);
- if (flags & 1 /* Export */)
- result.push("export" /* exportedModifier */);
- if (flags & 8192 /* Deprecated */)
- result.push("deprecated" /* deprecatedModifier */);
- if (node.flags & 8388608 /* Ambient */)
- result.push("declare" /* ambientModifier */);
- if (node.kind === 270 /* ExportAssignment */)
- result.push("export" /* exportedModifier */);
- return result.length > 0 ? result.join(",") : "" /* none */;
+ : 0 /* ModifierFlags.None */;
+ if (flags & 8 /* ModifierFlags.Private */)
+ result.push("private" /* ScriptElementKindModifier.privateMemberModifier */);
+ if (flags & 16 /* ModifierFlags.Protected */)
+ result.push("protected" /* ScriptElementKindModifier.protectedMemberModifier */);
+ if (flags & 4 /* ModifierFlags.Public */)
+ result.push("public" /* ScriptElementKindModifier.publicMemberModifier */);
+ if (flags & 32 /* ModifierFlags.Static */ || ts.isClassStaticBlockDeclaration(node))
+ result.push("static" /* ScriptElementKindModifier.staticModifier */);
+ if (flags & 128 /* ModifierFlags.Abstract */)
+ result.push("abstract" /* ScriptElementKindModifier.abstractModifier */);
+ if (flags & 1 /* ModifierFlags.Export */)
+ result.push("export" /* ScriptElementKindModifier.exportedModifier */);
+ if (flags & 8192 /* ModifierFlags.Deprecated */)
+ result.push("deprecated" /* ScriptElementKindModifier.deprecatedModifier */);
+ if (node.flags & 16777216 /* NodeFlags.Ambient */)
+ result.push("declare" /* ScriptElementKindModifier.ambientModifier */);
+ if (node.kind === 271 /* SyntaxKind.ExportAssignment */)
+ result.push("export" /* ScriptElementKindModifier.exportedModifier */);
+ return result.length > 0 ? result.join(",") : "" /* ScriptElementKindModifier.none */;
}
ts.getNodeModifiers = getNodeModifiers;
function getTypeArgumentOrTypeParameterList(node) {
- if (node.kind === 177 /* TypeReference */ || node.kind === 207 /* CallExpression */) {
+ if (node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 208 /* SyntaxKind.CallExpression */) {
return node.typeArguments;
}
- if (ts.isFunctionLike(node) || node.kind === 256 /* ClassDeclaration */ || node.kind === 257 /* InterfaceDeclaration */) {
+ if (ts.isFunctionLike(node) || node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) {
return node.typeParameters;
}
return undefined;
}
ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList;
function isComment(kind) {
- return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */;
+ return kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || kind === 3 /* SyntaxKind.MultiLineCommentTrivia */;
}
ts.isComment = isComment;
function isStringOrRegularExpressionOrTemplateLiteral(kind) {
- if (kind === 10 /* StringLiteral */
- || kind === 13 /* RegularExpressionLiteral */
+ if (kind === 10 /* SyntaxKind.StringLiteral */
+ || kind === 13 /* SyntaxKind.RegularExpressionLiteral */
|| ts.isTemplateLiteralKind(kind)) {
return true;
}
@@ -126000,7 +127898,7 @@ var ts;
}
ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral;
function isPunctuation(kind) {
- return 18 /* FirstPunctuation */ <= kind && kind <= 78 /* LastPunctuation */;
+ return 18 /* SyntaxKind.FirstPunctuation */ <= kind && kind <= 78 /* SyntaxKind.LastPunctuation */;
}
ts.isPunctuation = isPunctuation;
function isInsideTemplateLiteral(node, position, sourceFile) {
@@ -126010,9 +127908,9 @@ var ts;
ts.isInsideTemplateLiteral = isInsideTemplateLiteral;
function isAccessibilityModifier(kind) {
switch (kind) {
- case 123 /* PublicKeyword */:
- case 121 /* PrivateKeyword */:
- case 122 /* ProtectedKeyword */:
+ case 123 /* SyntaxKind.PublicKeyword */:
+ case 121 /* SyntaxKind.PrivateKeyword */:
+ case 122 /* SyntaxKind.ProtectedKeyword */:
return true;
}
return false;
@@ -126025,18 +127923,18 @@ var ts;
}
ts.cloneCompilerOptions = cloneCompilerOptions;
function isArrayLiteralOrObjectLiteralDestructuringPattern(node) {
- if (node.kind === 203 /* ArrayLiteralExpression */ ||
- node.kind === 204 /* ObjectLiteralExpression */) {
+ if (node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ ||
+ node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) {
// [a,b,c] from:
// [a, b, c] = someExpression;
- if (node.parent.kind === 220 /* BinaryExpression */ &&
+ if (node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ &&
node.parent.left === node &&
- node.parent.operatorToken.kind === 63 /* EqualsToken */) {
+ node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) {
return true;
}
// [a, b, c] from:
// for([a, b, c] of expression)
- if (node.parent.kind === 243 /* ForOfStatement */ &&
+ if (node.parent.kind === 244 /* SyntaxKind.ForOfStatement */ &&
node.parent.initializer === node) {
return true;
}
@@ -126044,7 +127942,7 @@ var ts;
// [x, [a, b, c] ] = someExpression
// or
// {x, a: {a, b, c} } = someExpression
- if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 294 /* PropertyAssignment */ ? node.parent.parent : node.parent)) {
+ if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ? node.parent.parent : node.parent)) {
return true;
}
}
@@ -126067,8 +127965,8 @@ var ts;
if (!contextToken)
return undefined;
switch (contextToken.kind) {
- case 10 /* StringLiteral */:
- case 14 /* NoSubstitutionTemplateLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
return createTextSpanFromStringLiteralLikeContent(contextToken);
default:
return createTextSpanFromNode(contextToken);
@@ -126106,32 +128004,32 @@ var ts;
}
ts.createTextChange = createTextChange;
ts.typeKeywords = [
- 130 /* AnyKeyword */,
- 128 /* AssertsKeyword */,
- 157 /* BigIntKeyword */,
- 133 /* BooleanKeyword */,
- 95 /* FalseKeyword */,
- 137 /* InferKeyword */,
- 140 /* KeyOfKeyword */,
- 143 /* NeverKeyword */,
- 104 /* NullKeyword */,
- 146 /* NumberKeyword */,
- 147 /* ObjectKeyword */,
- 144 /* ReadonlyKeyword */,
- 149 /* StringKeyword */,
- 150 /* SymbolKeyword */,
- 110 /* TrueKeyword */,
- 114 /* VoidKeyword */,
- 152 /* UndefinedKeyword */,
- 153 /* UniqueKeyword */,
- 154 /* UnknownKeyword */,
+ 130 /* SyntaxKind.AnyKeyword */,
+ 128 /* SyntaxKind.AssertsKeyword */,
+ 158 /* SyntaxKind.BigIntKeyword */,
+ 133 /* SyntaxKind.BooleanKeyword */,
+ 95 /* SyntaxKind.FalseKeyword */,
+ 137 /* SyntaxKind.InferKeyword */,
+ 140 /* SyntaxKind.KeyOfKeyword */,
+ 143 /* SyntaxKind.NeverKeyword */,
+ 104 /* SyntaxKind.NullKeyword */,
+ 147 /* SyntaxKind.NumberKeyword */,
+ 148 /* SyntaxKind.ObjectKeyword */,
+ 145 /* SyntaxKind.ReadonlyKeyword */,
+ 150 /* SyntaxKind.StringKeyword */,
+ 151 /* SyntaxKind.SymbolKeyword */,
+ 110 /* SyntaxKind.TrueKeyword */,
+ 114 /* SyntaxKind.VoidKeyword */,
+ 153 /* SyntaxKind.UndefinedKeyword */,
+ 154 /* SyntaxKind.UniqueKeyword */,
+ 155 /* SyntaxKind.UnknownKeyword */,
];
function isTypeKeyword(kind) {
return ts.contains(ts.typeKeywords, kind);
}
ts.isTypeKeyword = isTypeKeyword;
function isTypeKeywordToken(node) {
- return node.kind === 151 /* TypeKeyword */;
+ return node.kind === 152 /* SyntaxKind.TypeKeyword */;
}
ts.isTypeKeywordToken = isTypeKeywordToken;
function isTypeKeywordTokenOrIdentifier(node) {
@@ -126140,7 +128038,7 @@ var ts;
ts.isTypeKeywordTokenOrIdentifier = isTypeKeywordTokenOrIdentifier;
/** True if the symbol is for an external module, as opposed to a namespace. */
function isExternalModuleSymbol(moduleSymbol) {
- return !!(moduleSymbol.flags & 1536 /* Module */) && moduleSymbol.name.charCodeAt(0) === 34 /* doubleQuote */;
+ return !!(moduleSymbol.flags & 1536 /* SymbolFlags.Module */) && moduleSymbol.name.charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */;
}
ts.isExternalModuleSymbol = isExternalModuleSymbol;
function nodeSeenTracker() {
@@ -126168,7 +128066,7 @@ var ts;
}
ts.skipConstraint = skipConstraint;
function getNameFromPropertyName(name) {
- return name.kind === 161 /* ComputedPropertyName */
+ return name.kind === 162 /* SyntaxKind.ComputedPropertyName */
// treat computed property names where expression is string/numeric literal as just string/numeric literal
? ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined
: ts.isPrivateIdentifier(name) ? ts.idText(name) : ts.getTextOfIdentifierOrLiteral(name);
@@ -126183,7 +128081,7 @@ var ts;
}
ts.programContainsEsModules = programContainsEsModules;
function compilerOptionsIndicateEsModules(compilerOptions) {
- return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ || !!compilerOptions.noEmit;
+ return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */ || !!compilerOptions.noEmit;
}
ts.compilerOptionsIndicateEsModules = compilerOptionsIndicateEsModules;
function createModuleSpecifierResolutionHost(program, host) {
@@ -126210,6 +128108,14 @@ var ts;
return __assign(__assign({}, createModuleSpecifierResolutionHost(program, host)), { getCommonSourceDirectory: function () { return program.getCommonSourceDirectory(); } });
}
ts.getModuleSpecifierResolverHost = getModuleSpecifierResolverHost;
+ function moduleResolutionRespectsExports(moduleResolution) {
+ return moduleResolution >= ts.ModuleResolutionKind.Node16 && moduleResolution <= ts.ModuleResolutionKind.NodeNext;
+ }
+ ts.moduleResolutionRespectsExports = moduleResolutionRespectsExports;
+ function moduleResolutionUsesNodeModules(moduleResolution) {
+ return moduleResolution === ts.ModuleResolutionKind.NodeJs || moduleResolution >= ts.ModuleResolutionKind.Node16 && moduleResolution <= ts.ModuleResolutionKind.NodeNext;
+ }
+ ts.moduleResolutionUsesNodeModules = moduleResolutionUsesNodeModules;
function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier, quotePreference) {
return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier, quotePreference) : undefined;
}
@@ -126224,7 +128130,7 @@ var ts;
}
ts.makeImport = makeImport;
function makeStringLiteral(text, quotePreference) {
- return ts.factory.createStringLiteral(text, quotePreference === 0 /* Single */);
+ return ts.factory.createStringLiteral(text, quotePreference === 0 /* QuotePreference.Single */);
}
ts.makeStringLiteral = makeStringLiteral;
var QuotePreference;
@@ -126233,25 +128139,25 @@ var ts;
QuotePreference[QuotePreference["Double"] = 1] = "Double";
})(QuotePreference = ts.QuotePreference || (ts.QuotePreference = {}));
function quotePreferenceFromString(str, sourceFile) {
- return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* Double */ : 0 /* Single */;
+ return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* QuotePreference.Double */ : 0 /* QuotePreference.Single */;
}
ts.quotePreferenceFromString = quotePreferenceFromString;
function getQuotePreference(sourceFile, preferences) {
if (preferences.quotePreference && preferences.quotePreference !== "auto") {
- return preferences.quotePreference === "single" ? 0 /* Single */ : 1 /* Double */;
+ return preferences.quotePreference === "single" ? 0 /* QuotePreference.Single */ : 1 /* QuotePreference.Double */;
}
else {
// ignore synthetic import added when importHelpers: true
var firstModuleSpecifier = sourceFile.imports &&
ts.find(sourceFile.imports, function (n) { return ts.isStringLiteral(n) && !ts.nodeIsSynthesized(n.parent); });
- return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* Double */;
+ return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* QuotePreference.Double */;
}
}
ts.getQuotePreference = getQuotePreference;
function getQuoteFromPreference(qp) {
switch (qp) {
- case 0 /* Single */: return "'";
- case 1 /* Double */: return '"';
+ case 0 /* QuotePreference.Single */: return "'";
+ case 1 /* QuotePreference.Double */: return '"';
default: return ts.Debug.assertNever(qp);
}
}
@@ -126262,12 +128168,12 @@ var ts;
}
ts.symbolNameNoDefault = symbolNameNoDefault;
function symbolEscapedNameNoDefault(symbol) {
- if (symbol.escapedName !== "default" /* Default */) {
+ if (symbol.escapedName !== "default" /* InternalSymbolName.Default */) {
return symbol.escapedName;
}
return ts.firstDefined(symbol.declarations, function (decl) {
var name = ts.getNameOfDeclaration(decl);
- return name && name.kind === 79 /* Identifier */ ? name.escapedText : undefined;
+ return name && name.kind === 79 /* SyntaxKind.Identifier */ ? name.escapedText : undefined;
});
}
ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault;
@@ -126311,7 +128217,7 @@ var ts;
ts.findModifier = findModifier;
function insertImports(changes, sourceFile, imports, blankLineBetween) {
var decl = ts.isArray(imports) ? imports[0] : imports;
- var importKindPredicate = decl.kind === 236 /* VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax;
+ var importKindPredicate = decl.kind === 237 /* SyntaxKind.VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax;
var existingImportStatements = ts.filter(sourceFile.statements, importKindPredicate);
var sortedNewImports = ts.isArray(imports) ? ts.stableSort(imports, ts.OrganizeImports.compareImportsOrRequireStatements) : [imports];
if (!existingImportStatements.length) {
@@ -126489,34 +128395,34 @@ var ts;
return displayPart(text, displayPartKind(symbol));
function displayPartKind(symbol) {
var flags = symbol.flags;
- if (flags & 3 /* Variable */) {
+ if (flags & 3 /* SymbolFlags.Variable */) {
return isFirstDeclarationOfSymbolParameter(symbol) ? ts.SymbolDisplayPartKind.parameterName : ts.SymbolDisplayPartKind.localName;
}
- if (flags & 4 /* Property */)
+ if (flags & 4 /* SymbolFlags.Property */)
return ts.SymbolDisplayPartKind.propertyName;
- if (flags & 32768 /* GetAccessor */)
+ if (flags & 32768 /* SymbolFlags.GetAccessor */)
return ts.SymbolDisplayPartKind.propertyName;
- if (flags & 65536 /* SetAccessor */)
+ if (flags & 65536 /* SymbolFlags.SetAccessor */)
return ts.SymbolDisplayPartKind.propertyName;
- if (flags & 8 /* EnumMember */)
+ if (flags & 8 /* SymbolFlags.EnumMember */)
return ts.SymbolDisplayPartKind.enumMemberName;
- if (flags & 16 /* Function */)
+ if (flags & 16 /* SymbolFlags.Function */)
return ts.SymbolDisplayPartKind.functionName;
- if (flags & 32 /* Class */)
+ if (flags & 32 /* SymbolFlags.Class */)
return ts.SymbolDisplayPartKind.className;
- if (flags & 64 /* Interface */)
+ if (flags & 64 /* SymbolFlags.Interface */)
return ts.SymbolDisplayPartKind.interfaceName;
- if (flags & 384 /* Enum */)
+ if (flags & 384 /* SymbolFlags.Enum */)
return ts.SymbolDisplayPartKind.enumName;
- if (flags & 1536 /* Module */)
+ if (flags & 1536 /* SymbolFlags.Module */)
return ts.SymbolDisplayPartKind.moduleName;
- if (flags & 8192 /* Method */)
+ if (flags & 8192 /* SymbolFlags.Method */)
return ts.SymbolDisplayPartKind.methodName;
- if (flags & 262144 /* TypeParameter */)
+ if (flags & 262144 /* SymbolFlags.TypeParameter */)
return ts.SymbolDisplayPartKind.typeParameterName;
- if (flags & 524288 /* TypeAlias */)
+ if (flags & 524288 /* SymbolFlags.TypeAlias */)
return ts.SymbolDisplayPartKind.aliasName;
- if (flags & 2097152 /* Alias */)
+ if (flags & 2097152 /* SymbolFlags.Alias */)
return ts.SymbolDisplayPartKind.aliasName;
return ts.SymbolDisplayPartKind.text;
}
@@ -126595,14 +128501,15 @@ var ts;
: "linkplain";
var parts = [linkPart("{@".concat(prefix, " "))];
if (!link.name) {
- if (link.text)
+ if (link.text) {
parts.push(linkTextPart(link.text));
+ }
}
else {
var symbol = checker === null || checker === void 0 ? void 0 : checker.getSymbolAtLocation(link.name);
var suffix = findLinkNameEnd(link.text);
var name = ts.getTextOfNode(link.name) + link.text.slice(0, suffix);
- var text = link.text.slice(suffix);
+ var text = skipSeparatorFromLinkText(link.text.slice(suffix));
var decl = (symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) || ((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]);
if (decl) {
parts.push(linkNamePart(name, decl));
@@ -126617,6 +128524,15 @@ var ts;
return parts;
}
ts.buildLinkParts = buildLinkParts;
+ function skipSeparatorFromLinkText(text) {
+ var pos = 0;
+ if (text.charCodeAt(pos++) === 124 /* CharacterCodes.bar */) {
+ while (pos < text.length && text.charCodeAt(pos) === 32 /* CharacterCodes.space */)
+ pos++;
+ return text.slice(pos);
+ }
+ return text;
+ }
function findLinkNameEnd(text) {
if (text.indexOf("()") === 0)
return 2;
@@ -126661,27 +128577,35 @@ var ts;
}
ts.mapToDisplayParts = mapToDisplayParts;
function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) {
- if (flags === void 0) { flags = 0 /* None */; }
+ if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; }
return mapToDisplayParts(function (writer) {
- typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer);
+ typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* TypeFormatFlags.MultilineObjectLiterals */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */, writer);
});
}
ts.typeToDisplayParts = typeToDisplayParts;
function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) {
- if (flags === void 0) { flags = 0 /* None */; }
+ if (flags === void 0) { flags = 0 /* SymbolFormatFlags.None */; }
return mapToDisplayParts(function (writer) {
- typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* UseAliasDefinedOutsideCurrentScope */, writer);
+ typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* SymbolFormatFlags.UseAliasDefinedOutsideCurrentScope */, writer);
});
}
ts.symbolToDisplayParts = symbolToDisplayParts;
function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) {
- if (flags === void 0) { flags = 0 /* None */; }
- flags |= 16384 /* UseAliasDefinedOutsideCurrentScope */ | 1024 /* MultilineObjectLiterals */ | 32 /* WriteTypeArgumentsOfSignature */ | 8192 /* OmitParameterModifiers */;
+ if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; }
+ flags |= 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */ | 1024 /* TypeFormatFlags.MultilineObjectLiterals */ | 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */ | 8192 /* TypeFormatFlags.OmitParameterModifiers */;
return mapToDisplayParts(function (writer) {
typechecker.writeSignature(signature, enclosingDeclaration, flags, /*signatureKind*/ undefined, writer);
});
}
ts.signatureToDisplayParts = signatureToDisplayParts;
+ function nodeToDisplayParts(node, enclosingDeclaration) {
+ var file = enclosingDeclaration.getSourceFile();
+ return mapToDisplayParts(function (writer) {
+ var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
+ printer.writeNode(4 /* EmitHint.Unspecified */, node, file, writer);
+ });
+ }
+ ts.nodeToDisplayParts = nodeToDisplayParts;
function isImportOrExportSpecifierName(location) {
return !!location.parent && ts.isImportOrExportSpecifier(location.parent) && location.parent.propertyName === location;
}
@@ -126706,10 +128630,10 @@ var ts;
}
ts.getSymbolTarget = getSymbolTarget;
function isTransientSymbol(symbol) {
- return (symbol.flags & 33554432 /* Transient */) !== 0;
+ return (symbol.flags & 33554432 /* SymbolFlags.Transient */) !== 0;
}
function isAliasSymbol(symbol) {
- return (symbol.flags & 2097152 /* Alias */) !== 0;
+ return (symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0;
}
function getUniqueSymbolId(symbol, checker) {
return ts.getSymbolId(ts.skipAlias(symbol, checker));
@@ -126798,14 +128722,14 @@ var ts;
* Sets EmitFlags to suppress leading trivia on the node.
*/
function suppressLeadingTrivia(node) {
- addEmitFlagsRecursively(node, 512 /* NoLeadingComments */, getFirstChild);
+ addEmitFlagsRecursively(node, 512 /* EmitFlags.NoLeadingComments */, getFirstChild);
}
ts.suppressLeadingTrivia = suppressLeadingTrivia;
/**
* Sets EmitFlags to suppress trailing trivia on the node.
*/
function suppressTrailingTrivia(node) {
- addEmitFlagsRecursively(node, 1024 /* NoTrailingComments */, ts.getLastChild);
+ addEmitFlagsRecursively(node, 1024 /* EmitFlags.NoTrailingComments */, ts.getLastChild);
}
ts.suppressTrailingTrivia = suppressTrailingTrivia;
function copyComments(sourceNode, targetNode) {
@@ -126824,7 +128748,7 @@ var ts;
var start = node.getFullStart();
var end = node.getStart();
for (var i = start; i < end; i++) {
- if (text.charCodeAt(i) === 10 /* lineFeed */)
+ if (text.charCodeAt(i) === 10 /* CharacterCodes.lineFeed */)
return true;
}
return false;
@@ -126898,7 +128822,7 @@ var ts;
ts.copyTrailingAsLeadingComments = copyTrailingAsLeadingComments;
function getAddCommentsFunction(targetNode, sourceFile, commentKind, hasTrailingNewLine, cb) {
return function (pos, end, kind, htnl) {
- if (kind === 3 /* MultiLineCommentTrivia */) {
+ if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) {
// Remove leading /*
pos += 2;
// Remove trailing */
@@ -126924,7 +128848,7 @@ var ts;
}
/* @internal */
function needsParentheses(expression) {
- return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */
+ return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */
|| ts.isObjectLiteralExpression(expression)
|| ts.isAsExpression(expression) && ts.isObjectLiteralExpression(expression.expression);
}
@@ -126932,15 +128856,15 @@ var ts;
function getContextualTypeFromParent(node, checker) {
var parent = node.parent;
switch (parent.kind) {
- case 208 /* NewExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
return checker.getContextualType(parent);
- case 220 /* BinaryExpression */: {
+ case 221 /* SyntaxKind.BinaryExpression */: {
var _a = parent, left = _a.left, operatorToken = _a.operatorToken, right = _a.right;
return isEqualityOperatorKind(operatorToken.kind)
? checker.getTypeAtLocation(node === right ? left : right)
: checker.getContextualType(node);
}
- case 288 /* CaseClause */:
+ case 289 /* SyntaxKind.CaseClause */:
return parent.expression === node ? getSwitchedType(parent, checker) : undefined;
default:
return checker.getContextualType(node);
@@ -126951,15 +128875,15 @@ var ts;
// Editors can pass in undefined or empty string - we want to infer the preference in those cases.
var quotePreference = getQuotePreference(sourceFile, preferences);
var quoted = JSON.stringify(text);
- return quotePreference === 0 /* Single */ ? "'".concat(ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"'), "'") : quoted;
+ return quotePreference === 0 /* QuotePreference.Single */ ? "'".concat(ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"'), "'") : quoted;
}
ts.quote = quote;
function isEqualityOperatorKind(kind) {
switch (kind) {
- case 36 /* EqualsEqualsEqualsToken */:
- case 34 /* EqualsEqualsToken */:
- case 37 /* ExclamationEqualsEqualsToken */:
- case 35 /* ExclamationEqualsToken */:
+ case 36 /* SyntaxKind.EqualsEqualsEqualsToken */:
+ case 34 /* SyntaxKind.EqualsEqualsToken */:
+ case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */:
+ case 35 /* SyntaxKind.ExclamationEqualsToken */:
return true;
default:
return false;
@@ -126968,10 +128892,10 @@ var ts;
ts.isEqualityOperatorKind = isEqualityOperatorKind;
function isStringLiteralOrTemplate(node) {
switch (node.kind) {
- case 10 /* StringLiteral */:
- case 14 /* NoSubstitutionTemplateLiteral */:
- case 222 /* TemplateExpression */:
- case 209 /* TaggedTemplateExpression */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
+ case 223 /* SyntaxKind.TemplateExpression */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
return true;
default:
return false;
@@ -126991,9 +128915,9 @@ var ts;
var checker = program.getTypeChecker();
var typeIsAccessible = true;
var notAccessible = function () { return typeIsAccessible = false; };
- var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NoTruncation */, {
+ var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NodeBuilderFlags.NoTruncation */, {
trackSymbol: function (symbol, declaration, meaning) {
- typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */;
+ typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* SymbolAccessibility.Accessible */;
return !typeIsAccessible;
},
reportInaccessibleThisError: notAccessible,
@@ -127005,48 +128929,48 @@ var ts;
}
ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible;
function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) {
- return kind === 173 /* CallSignature */
- || kind === 174 /* ConstructSignature */
- || kind === 175 /* IndexSignature */
- || kind === 165 /* PropertySignature */
- || kind === 167 /* MethodSignature */;
+ return kind === 174 /* SyntaxKind.CallSignature */
+ || kind === 175 /* SyntaxKind.ConstructSignature */
+ || kind === 176 /* SyntaxKind.IndexSignature */
+ || kind === 166 /* SyntaxKind.PropertySignature */
+ || kind === 168 /* SyntaxKind.MethodSignature */;
}
function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) {
- return kind === 255 /* FunctionDeclaration */
- || kind === 170 /* Constructor */
- || kind === 168 /* MethodDeclaration */
- || kind === 171 /* GetAccessor */
- || kind === 172 /* SetAccessor */;
+ return kind === 256 /* SyntaxKind.FunctionDeclaration */
+ || kind === 171 /* SyntaxKind.Constructor */
+ || kind === 169 /* SyntaxKind.MethodDeclaration */
+ || kind === 172 /* SyntaxKind.GetAccessor */
+ || kind === 173 /* SyntaxKind.SetAccessor */;
}
function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) {
- return kind === 260 /* ModuleDeclaration */;
+ return kind === 261 /* SyntaxKind.ModuleDeclaration */;
}
function syntaxRequiresTrailingSemicolonOrASI(kind) {
- return kind === 236 /* VariableStatement */
- || kind === 237 /* ExpressionStatement */
- || kind === 239 /* DoStatement */
- || kind === 244 /* ContinueStatement */
- || kind === 245 /* BreakStatement */
- || kind === 246 /* ReturnStatement */
- || kind === 250 /* ThrowStatement */
- || kind === 252 /* DebuggerStatement */
- || kind === 166 /* PropertyDeclaration */
- || kind === 258 /* TypeAliasDeclaration */
- || kind === 265 /* ImportDeclaration */
- || kind === 264 /* ImportEqualsDeclaration */
- || kind === 271 /* ExportDeclaration */
- || kind === 263 /* NamespaceExportDeclaration */
- || kind === 270 /* ExportAssignment */;
+ return kind === 237 /* SyntaxKind.VariableStatement */
+ || kind === 238 /* SyntaxKind.ExpressionStatement */
+ || kind === 240 /* SyntaxKind.DoStatement */
+ || kind === 245 /* SyntaxKind.ContinueStatement */
+ || kind === 246 /* SyntaxKind.BreakStatement */
+ || kind === 247 /* SyntaxKind.ReturnStatement */
+ || kind === 251 /* SyntaxKind.ThrowStatement */
+ || kind === 253 /* SyntaxKind.DebuggerStatement */
+ || kind === 167 /* SyntaxKind.PropertyDeclaration */
+ || kind === 259 /* SyntaxKind.TypeAliasDeclaration */
+ || kind === 266 /* SyntaxKind.ImportDeclaration */
+ || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */
+ || kind === 272 /* SyntaxKind.ExportDeclaration */
+ || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */
+ || kind === 271 /* SyntaxKind.ExportAssignment */;
}
ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI;
ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI);
function nodeIsASICandidate(node, sourceFile) {
var lastToken = node.getLastToken(sourceFile);
- if (lastToken && lastToken.kind === 26 /* SemicolonToken */) {
+ if (lastToken && lastToken.kind === 26 /* SyntaxKind.SemicolonToken */) {
return false;
}
if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) {
- if (lastToken && lastToken.kind === 27 /* CommaToken */) {
+ if (lastToken && lastToken.kind === 27 /* SyntaxKind.CommaToken */) {
return false;
}
}
@@ -127066,12 +128990,12 @@ var ts;
return false;
}
// See comment in parser’s `parseDoStatement`
- if (node.kind === 239 /* DoStatement */) {
+ if (node.kind === 240 /* SyntaxKind.DoStatement */) {
return true;
}
var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; });
var nextToken = findNextToken(node, topNode, sourceFile);
- if (!nextToken || nextToken.kind === 19 /* CloseBraceToken */) {
+ if (!nextToken || nextToken.kind === 19 /* SyntaxKind.CloseBraceToken */) {
return true;
}
var startLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line;
@@ -127095,7 +129019,7 @@ var ts;
ts.forEachChild(sourceFile, function visit(node) {
if (syntaxRequiresTrailingSemicolonOrASI(node.kind)) {
var lastToken = node.getLastToken(sourceFile);
- if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SemicolonToken */) {
+ if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SyntaxKind.SemicolonToken */) {
withSemicolon++;
}
else {
@@ -127104,10 +129028,10 @@ var ts;
}
else if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) {
var lastToken = node.getLastToken(sourceFile);
- if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SemicolonToken */) {
+ if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SyntaxKind.SemicolonToken */) {
withSemicolon++;
}
- else if (lastToken && lastToken.kind !== 27 /* CommaToken */) {
+ else if (lastToken && lastToken.kind !== 27 /* SyntaxKind.CommaToken */) {
var lastTokenLine = ts.getLineAndCharacterOfPosition(sourceFile, lastToken.getStart(sourceFile)).line;
var nextTokenLine = ts.getLineAndCharacterOfPosition(sourceFile, ts.getSpanOfTokenAtPosition(sourceFile, lastToken.end).start).line;
// Avoid counting missing semicolon in single-line objects:
@@ -127231,16 +129155,16 @@ var ts;
}
}
var dependencyGroups = [
- [1 /* Dependencies */, info.dependencies],
- [2 /* DevDependencies */, info.devDependencies],
- [8 /* OptionalDependencies */, info.optionalDependencies],
- [4 /* PeerDependencies */, info.peerDependencies],
+ [1 /* PackageJsonDependencyGroup.Dependencies */, info.dependencies],
+ [2 /* PackageJsonDependencyGroup.DevDependencies */, info.devDependencies],
+ [8 /* PackageJsonDependencyGroup.OptionalDependencies */, info.optionalDependencies],
+ [4 /* PackageJsonDependencyGroup.PeerDependencies */, info.peerDependencies],
];
return __assign(__assign({}, info), { parseable: !!content, fileName: fileName, get: get, has: function (dependencyName, inGroups) {
return !!get(dependencyName, inGroups);
} });
function get(dependencyName, inGroups) {
- if (inGroups === void 0) { inGroups = 15 /* All */; }
+ if (inGroups === void 0) { inGroups = 15 /* PackageJsonDependencyGroup.All */; }
for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) {
var _a = dependencyGroups_1[_i], group_1 = _a[0], deps = _a[1];
if (deps && (inGroups & group_1)) {
@@ -127455,7 +129379,7 @@ var ts;
}
ts.getNameForExportedSymbol = getNameForExportedSymbol;
function needsNameFromDeclaration(symbol) {
- return !(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */);
+ return !(symbol.flags & 33554432 /* SymbolFlags.Transient */) && (symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */ || symbol.escapedName === "default" /* InternalSymbolName.Default */);
}
function getDefaultLikeExportNameFromDeclaration(symbol) {
return ts.firstDefined(symbol.declarations, function (d) { var _a; return ts.isExportAssignment(d) ? (_a = ts.tryCast(ts.skipOuterExpressions(d.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text : undefined; });
@@ -127501,7 +129425,7 @@ var ts;
}
ts.stringContainsAt = stringContainsAt;
function startsWithUnderscore(name) {
- return name.charCodeAt(0) === 95 /* _ */;
+ return name.charCodeAt(0) === 95 /* CharacterCodes._ */;
}
ts.startsWithUnderscore = startsWithUnderscore;
function isGlobalDeclaration(declaration) {
@@ -127519,7 +129443,7 @@ var ts;
}
ts.isNonGlobalDeclaration = isNonGlobalDeclaration;
function isDeprecatedDeclaration(decl) {
- return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* Deprecated */);
+ return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* ModifierFlags.Deprecated */);
}
ts.isDeprecatedDeclaration = isDeprecatedDeclaration;
function shouldUseUriStyleNodeCoreModules(file, program) {
@@ -127532,7 +129456,7 @@ var ts;
}
ts.shouldUseUriStyleNodeCoreModules = shouldUseUriStyleNodeCoreModules;
function getNewLineKind(newLineCharacter) {
- return newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */;
+ return newLineCharacter === "\n" ? 1 /* NewLineKind.LineFeed */ : 0 /* NewLineKind.CarriageReturnLineFeed */;
}
ts.getNewLineKind = getNewLineKind;
function diagnosticToString(diag) {
@@ -127551,6 +129475,10 @@ var ts;
return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore });
}
ts.getFormatCodeSettingsForWriting = getFormatCodeSettingsForWriting;
+ function jsxModeNeedsExplicitImport(jsx) {
+ return jsx === 2 /* JsxEmit.React */ || jsx === 3 /* JsxEmit.ReactNative */;
+ }
+ ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport;
// #endregion
})(ts || (ts = {}));
/*@internal*/
@@ -127607,7 +129535,7 @@ var ts;
packageName = ts.unmangleScopedPackageName(ts.getPackageNameFromTypesPackageName(moduleFile.fileName.substring(topLevelPackageNameIndex + 1, packageRootIndex)));
if (ts.startsWith(importingFile, moduleFile.path.substring(0, topLevelNodeModulesIndex))) {
var prevDeepestNodeModulesPath = packages.get(packageName);
- var nodeModulesPath = moduleFile.fileName.substring(0, topLevelPackageNameIndex);
+ var nodeModulesPath = moduleFile.fileName.substring(0, topLevelPackageNameIndex + 1);
if (prevDeepestNodeModulesPath) {
var prevDeepestNodeModulesIndex = prevDeepestNodeModulesPath.indexOf(ts.nodeModulesPathPart);
if (topLevelNodeModulesIndex > prevDeepestNodeModulesIndex) {
@@ -127620,7 +129548,7 @@ var ts;
}
}
}
- var isDefault = exportKind === 1 /* Default */;
+ var isDefault = exportKind === 1 /* ExportKind.Default */;
var namedSymbol = isDefault && ts.getLocalSymbolForExportDefault(symbol) || symbol;
// 1. A named export must be imported by its key in `moduleSymbol.exports` or `moduleSymbol.members`.
// 2. A re-export merged with an export from a module augmentation can result in `symbol`
@@ -127629,7 +129557,7 @@ var ts;
// 3. Otherwise, we have a default/namespace import that can be imported by any name, and
// `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to
// get a better name.
- var names = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
+ var names = exportKind === 0 /* ExportKind.Named */ || ts.isExternalModuleSymbol(namedSymbol)
? ts.unescapeLeadingUnderscores(symbolTableKey)
: ts.getNamesForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
var symbolName = typeof names === "string" ? names : names[0];
@@ -127637,8 +129565,8 @@ var ts;
var moduleName = ts.stripQuotes(moduleSymbol.name);
var id = exportInfoId++;
var target = ts.skipAlias(symbol, checker);
- var storedSymbol = symbol.flags & 33554432 /* Transient */ ? undefined : symbol;
- var storedModuleSymbol = moduleSymbol.flags & 33554432 /* Transient */ ? undefined : moduleSymbol;
+ var storedSymbol = symbol.flags & 33554432 /* SymbolFlags.Transient */ ? undefined : symbol;
+ var storedModuleSymbol = moduleSymbol.flags & 33554432 /* SymbolFlags.Transient */ ? undefined : moduleSymbol;
if (!storedSymbol || !storedModuleSymbol)
symbols.set(id, [symbol, moduleSymbol]);
exportInfo.add(key(symbolName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), {
@@ -127727,7 +129655,7 @@ var ts;
var moduleSymbol = info.moduleSymbol || cachedModuleSymbol || ts.Debug.checkDefined(info.moduleFile
? checker.getMergedSymbol(info.moduleFile.symbol)
: checker.tryFindAmbientModule(info.moduleName));
- var symbol = info.symbol || cachedSymbol || ts.Debug.checkDefined(exportKind === 2 /* ExportEquals */
+ var symbol = info.symbol || cachedSymbol || ts.Debug.checkDefined(exportKind === 2 /* ExportKind.ExportEquals */
? checker.resolveExternalModuleSymbol(moduleSymbol)
: checker.tryGetMemberInModuleExportsAndProperties(ts.unescapeLeadingUnderscores(info.symbolTableKey), moduleSymbol), "Could not find symbol '".concat(info.symbolName, "' by key '").concat(info.symbolTableKey, "' in module ").concat(moduleSymbol.name));
symbols.set(id, [symbol, moduleSymbol]);
@@ -127778,6 +129706,9 @@ var ts;
function isNotShadowedByDeeperNodeModulesPackage(info, packageName) {
if (!packageName || !info.moduleFileName)
return true;
+ var typingsCacheLocation = host.getGlobalTypingsCacheLocation();
+ if (typingsCacheLocation && ts.startsWith(info.moduleFileName, typingsCacheLocation))
+ return true;
var packageDeepestNodeModulesPath = packages.get(packageName);
return !packageDeepestNodeModulesPath || ts.startsWith(info.moduleFileName, packageDeepestNodeModulesPath);
}
@@ -127787,9 +129718,9 @@ var ts;
var _a;
if (from === to)
return false;
- var cachedResult = moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.get(from.path, to.path, preferences);
- if ((cachedResult === null || cachedResult === void 0 ? void 0 : cachedResult.isAutoImportable) !== undefined) {
- return cachedResult.isAutoImportable;
+ var cachedResult = moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.get(from.path, to.path, preferences, {});
+ if ((cachedResult === null || cachedResult === void 0 ? void 0 : cachedResult.isBlockedByPackageJsonDependencies) !== undefined) {
+ return !cachedResult.isBlockedByPackageJsonDependencies;
}
var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost);
var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost);
@@ -127803,7 +129734,7 @@ var ts;
});
if (packageJsonFilter) {
var isAutoImportable = hasImportablePath && packageJsonFilter.allowsImportingSourceFile(to, moduleSpecifierResolutionHost);
- moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.setIsAutoImportable(from.path, to.path, preferences, isAutoImportable);
+ moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.setBlockedByPackageJsonDependencies(from.path, to.path, preferences, {}, !isAutoImportable);
return isAutoImportable;
}
return hasImportablePath;
@@ -127856,6 +129787,7 @@ var ts;
var cache = ((_b = host.getCachedExportInfoMap) === null || _b === void 0 ? void 0 : _b.call(host)) || createCacheableExportInfoMap({
getCurrentProgram: function () { return program; },
getPackageJsonAutoImportProvider: function () { var _a; return (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host); },
+ getGlobalTypingsCacheLocation: function () { var _a; return (_a = host.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(host); },
});
if (cache.isUsableByFile(importingFile.path)) {
(_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, "getExportInfoMap: cache hit");
@@ -127864,23 +129796,30 @@ var ts;
(_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getExportInfoMap: cache miss or empty; calculating new results");
var compilerOptions = program.getCompilerOptions();
var moduleCount = 0;
- forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
- if (++moduleCount % 100 === 0)
- cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested();
- var seenExports = new ts.Map();
- var checker = program.getTypeChecker();
- var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
- // Note: I think we shouldn't actually see resolved module symbols here, but weird merges
- // can cause it to happen: see 'completionsImport_mergedReExport.ts'
- if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) {
- cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker);
- }
- checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) {
- if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) {
- cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker);
+ try {
+ forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
+ if (++moduleCount % 100 === 0)
+ cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested();
+ var seenExports = new ts.Map();
+ var checker = program.getTypeChecker();
+ var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
+ // Note: I think we shouldn't actually see resolved module symbols here, but weird merges
+ // can cause it to happen: see 'completionsImport_mergedReExport.ts'
+ if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) {
+ cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* ExportKind.Default */ ? "default" /* InternalSymbolName.Default */ : "export=" /* InternalSymbolName.ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker);
}
+ checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) {
+ if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) {
+ cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* ExportKind.Named */, isFromPackageJson, checker);
+ }
+ });
});
- });
+ }
+ catch (err) {
+ // Ensure cache is reset if operation is cancelled
+ cache.clear();
+ throw err;
+ }
(_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in ".concat(ts.timestamp() - start, " ms"));
return cache;
}
@@ -127900,10 +129839,10 @@ var ts;
function getDefaultLikeExportWorker(moduleSymbol, checker) {
var exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol);
if (exportEquals !== moduleSymbol)
- return { symbol: exportEquals, exportKind: 2 /* ExportEquals */ };
- var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol);
+ return { symbol: exportEquals, exportKind: 2 /* ExportKind.ExportEquals */ };
+ var defaultExport = checker.tryGetMemberInModuleExports("default" /* InternalSymbolName.Default */, moduleSymbol);
if (defaultExport)
- return { symbol: defaultExport, exportKind: 1 /* Default */ };
+ return { symbol: defaultExport, exportKind: 1 /* ExportKind.Default */ };
}
function getDefaultExportInfoWorker(defaultExport, checker, compilerOptions) {
var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport);
@@ -127912,7 +129851,7 @@ var ts;
var name = getNameForExportDefault(defaultExport);
if (name !== undefined)
return { symbolForMeaning: defaultExport, name: name };
- if (defaultExport.flags & 2097152 /* Alias */) {
+ if (defaultExport.flags & 2097152 /* SymbolFlags.Alias */) {
var aliased = checker.getImmediateAliasedSymbol(defaultExport);
if (aliased && aliased.parent) {
// - `aliased` will be undefined if the module is exporting an unresolvable name,
@@ -127922,8 +129861,8 @@ var ts;
return getDefaultExportInfoWorker(aliased, checker, compilerOptions);
}
}
- if (defaultExport.escapedName !== "default" /* Default */ &&
- defaultExport.escapedName !== "export=" /* ExportEquals */) {
+ if (defaultExport.escapedName !== "default" /* InternalSymbolName.Default */ &&
+ defaultExport.escapedName !== "export=" /* InternalSymbolName.ExportEquals */) {
return { symbolForMeaning: defaultExport, name: defaultExport.getName() };
}
return { symbolForMeaning: defaultExport, name: ts.getNameForExportedSymbol(defaultExport, compilerOptions.target) };
@@ -127935,7 +129874,7 @@ var ts;
return (_a = ts.tryCast(ts.skipOuterExpressions(declaration.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text;
}
else if (ts.isExportSpecifier(declaration)) {
- ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export");
+ ts.Debug.assert(declaration.name.text === "default" /* InternalSymbolName.Default */, "Expected the specifier to be a default export");
return declaration.propertyName && declaration.propertyName.text;
}
});
@@ -127945,15 +129884,15 @@ var ts;
(function (ts) {
/** The classifier is used for syntactic highlighting in editors via the TSServer */
function createClassifier() {
- var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false);
+ var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false);
function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) {
return convertClassificationsToResult(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text);
}
// If there is a syntactic classifier ('syntacticClassifierAbsent' is false),
// we will be more conservative in order to avoid conflicting with the syntactic classifier.
function getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent) {
- var token = 0 /* Unknown */;
- var lastNonTriviaToken = 0 /* Unknown */;
+ var token = 0 /* SyntaxKind.Unknown */;
+ var lastNonTriviaToken = 0 /* SyntaxKind.Unknown */;
// Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact)
// classification on template strings. Because of the context free nature of templates,
// the only precise way to classify a template portion would be by propagating the stack across
@@ -127979,10 +129918,10 @@ var ts;
text = prefix + text;
var offset = prefix.length;
if (pushTemplate) {
- templateStack.push(15 /* TemplateHead */);
+ templateStack.push(15 /* SyntaxKind.TemplateHead */);
}
scanner.setText(text);
- var endOfLineState = 0 /* None */;
+ var endOfLineState = 0 /* EndOfLineState.None */;
var spans = [];
// We can run into an unfortunate interaction between the lexical and syntactic classifier
// when the user is typing something generic. Consider the case where the user types:
@@ -128018,68 +129957,68 @@ var ts;
endOfLineState = end_1;
}
}
- } while (token !== 1 /* EndOfFileToken */);
+ } while (token !== 1 /* SyntaxKind.EndOfFileToken */);
function handleToken() {
switch (token) {
- case 43 /* SlashToken */:
- case 68 /* SlashEqualsToken */:
- if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) {
- token = 13 /* RegularExpressionLiteral */;
+ case 43 /* SyntaxKind.SlashToken */:
+ case 68 /* SyntaxKind.SlashEqualsToken */:
+ if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* SyntaxKind.RegularExpressionLiteral */) {
+ token = 13 /* SyntaxKind.RegularExpressionLiteral */;
}
break;
- case 29 /* LessThanToken */:
- if (lastNonTriviaToken === 79 /* Identifier */) {
+ case 29 /* SyntaxKind.LessThanToken */:
+ if (lastNonTriviaToken === 79 /* SyntaxKind.Identifier */) {
// Could be the start of something generic. Keep track of that by bumping
// up the current count of generic contexts we may be in.
angleBracketStack++;
}
break;
- case 31 /* GreaterThanToken */:
+ case 31 /* SyntaxKind.GreaterThanToken */:
if (angleBracketStack > 0) {
// If we think we're currently in something generic, then mark that that
// generic entity is complete.
angleBracketStack--;
}
break;
- case 130 /* AnyKeyword */:
- case 149 /* StringKeyword */:
- case 146 /* NumberKeyword */:
- case 133 /* BooleanKeyword */:
- case 150 /* SymbolKeyword */:
+ case 130 /* SyntaxKind.AnyKeyword */:
+ case 150 /* SyntaxKind.StringKeyword */:
+ case 147 /* SyntaxKind.NumberKeyword */:
+ case 133 /* SyntaxKind.BooleanKeyword */:
+ case 151 /* SyntaxKind.SymbolKeyword */:
if (angleBracketStack > 0 && !syntacticClassifierAbsent) {
// If it looks like we're could be in something generic, don't classify this
// as a keyword. We may just get overwritten by the syntactic classifier,
// causing a noisy experience for the user.
- token = 79 /* Identifier */;
+ token = 79 /* SyntaxKind.Identifier */;
}
break;
- case 15 /* TemplateHead */:
+ case 15 /* SyntaxKind.TemplateHead */:
templateStack.push(token);
break;
- case 18 /* OpenBraceToken */:
+ case 18 /* SyntaxKind.OpenBraceToken */:
// If we don't have anything on the template stack,
// then we aren't trying to keep track of a previously scanned template head.
if (templateStack.length > 0) {
templateStack.push(token);
}
break;
- case 19 /* CloseBraceToken */:
+ case 19 /* SyntaxKind.CloseBraceToken */:
// If we don't have anything on the template stack,
// then we aren't trying to keep track of a previously scanned template head.
if (templateStack.length > 0) {
var lastTemplateStackToken = ts.lastOrUndefined(templateStack);
- if (lastTemplateStackToken === 15 /* TemplateHead */) {
+ if (lastTemplateStackToken === 15 /* SyntaxKind.TemplateHead */) {
token = scanner.reScanTemplateToken(/* isTaggedTemplate */ false);
// Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us.
- if (token === 17 /* TemplateTail */) {
+ if (token === 17 /* SyntaxKind.TemplateTail */) {
templateStack.pop();
}
else {
- ts.Debug.assertEqual(token, 16 /* TemplateMiddle */, "Should have been a template middle.");
+ ts.Debug.assertEqual(token, 16 /* SyntaxKind.TemplateMiddle */, "Should have been a template middle.");
}
}
else {
- ts.Debug.assertEqual(lastTemplateStackToken, 18 /* OpenBraceToken */, "Should have been an open brace");
+ ts.Debug.assertEqual(lastTemplateStackToken, 18 /* SyntaxKind.OpenBraceToken */, "Should have been an open brace");
templateStack.pop();
}
}
@@ -128088,15 +130027,15 @@ var ts;
if (!ts.isKeyword(token)) {
break;
}
- if (lastNonTriviaToken === 24 /* DotToken */) {
- token = 79 /* Identifier */;
+ if (lastNonTriviaToken === 24 /* SyntaxKind.DotToken */) {
+ token = 79 /* SyntaxKind.Identifier */;
}
else if (ts.isKeyword(lastNonTriviaToken) && ts.isKeyword(token) && !canFollow(lastNonTriviaToken, token)) {
// We have two keywords in a row. Only treat the second as a keyword if
// it's a sequence that could legally occur in the language. Otherwise
// treat it as an identifier. This way, if someone writes "private var"
// we recognize that 'var' is actually an identifier here.
- token = 79 /* Identifier */;
+ token = 79 /* SyntaxKind.Identifier */;
}
}
}
@@ -128110,59 +130049,59 @@ var ts;
/// we have a series of divide operator. this list allows us to be more accurate by ruling out
/// locations where a regexp cannot exist.
var noRegexTable = ts.arrayToNumericMap([
- 79 /* Identifier */,
- 10 /* StringLiteral */,
- 8 /* NumericLiteral */,
- 9 /* BigIntLiteral */,
- 13 /* RegularExpressionLiteral */,
- 108 /* ThisKeyword */,
- 45 /* PlusPlusToken */,
- 46 /* MinusMinusToken */,
- 21 /* CloseParenToken */,
- 23 /* CloseBracketToken */,
- 19 /* CloseBraceToken */,
- 110 /* TrueKeyword */,
- 95 /* FalseKeyword */,
+ 79 /* SyntaxKind.Identifier */,
+ 10 /* SyntaxKind.StringLiteral */,
+ 8 /* SyntaxKind.NumericLiteral */,
+ 9 /* SyntaxKind.BigIntLiteral */,
+ 13 /* SyntaxKind.RegularExpressionLiteral */,
+ 108 /* SyntaxKind.ThisKeyword */,
+ 45 /* SyntaxKind.PlusPlusToken */,
+ 46 /* SyntaxKind.MinusMinusToken */,
+ 21 /* SyntaxKind.CloseParenToken */,
+ 23 /* SyntaxKind.CloseBracketToken */,
+ 19 /* SyntaxKind.CloseBraceToken */,
+ 110 /* SyntaxKind.TrueKeyword */,
+ 95 /* SyntaxKind.FalseKeyword */,
], function (token) { return token; }, function () { return true; });
function getNewEndOfLineState(scanner, token, lastOnTemplateStack) {
switch (token) {
- case 10 /* StringLiteral */: {
+ case 10 /* SyntaxKind.StringLiteral */: {
// Check to see if we finished up on a multiline string literal.
if (!scanner.isUnterminated())
return undefined;
var tokenText = scanner.getTokenText();
var lastCharIndex = tokenText.length - 1;
var numBackslashes = 0;
- while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* backslash */) {
+ while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* CharacterCodes.backslash */) {
numBackslashes++;
}
// If we have an odd number of backslashes, then the multiline string is unclosed
if ((numBackslashes & 1) === 0)
return undefined;
- return tokenText.charCodeAt(0) === 34 /* doubleQuote */ ? 3 /* InDoubleQuoteStringLiteral */ : 2 /* InSingleQuoteStringLiteral */;
+ return tokenText.charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */ ? 3 /* EndOfLineState.InDoubleQuoteStringLiteral */ : 2 /* EndOfLineState.InSingleQuoteStringLiteral */;
}
- case 3 /* MultiLineCommentTrivia */:
+ case 3 /* SyntaxKind.MultiLineCommentTrivia */:
// Check to see if the multiline comment was unclosed.
- return scanner.isUnterminated() ? 1 /* InMultiLineCommentTrivia */ : undefined;
+ return scanner.isUnterminated() ? 1 /* EndOfLineState.InMultiLineCommentTrivia */ : undefined;
default:
if (ts.isTemplateLiteralKind(token)) {
if (!scanner.isUnterminated()) {
return undefined;
}
switch (token) {
- case 17 /* TemplateTail */:
- return 5 /* InTemplateMiddleOrTail */;
- case 14 /* NoSubstitutionTemplateLiteral */:
- return 4 /* InTemplateHeadOrNoSubstitutionTemplate */;
+ case 17 /* SyntaxKind.TemplateTail */:
+ return 5 /* EndOfLineState.InTemplateMiddleOrTail */;
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
+ return 4 /* EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate */;
default:
return ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token);
}
}
- return lastOnTemplateStack === 15 /* TemplateHead */ ? 6 /* InTemplateSubstitutionPosition */ : undefined;
+ return lastOnTemplateStack === 15 /* SyntaxKind.TemplateHead */ ? 6 /* EndOfLineState.InTemplateSubstitutionPosition */ : undefined;
}
}
function pushEncodedClassification(start, end, offset, classification, result) {
- if (classification === 8 /* whiteSpace */) {
+ if (classification === 8 /* ClassificationType.whiteSpace */) {
// Don't bother with whitespace classifications. They're not needed.
return;
}
@@ -128204,23 +130143,23 @@ var ts;
}
function convertClassification(type) {
switch (type) {
- case 1 /* comment */: return ts.TokenClass.Comment;
- case 3 /* keyword */: return ts.TokenClass.Keyword;
- case 4 /* numericLiteral */: return ts.TokenClass.NumberLiteral;
- case 25 /* bigintLiteral */: return ts.TokenClass.BigIntLiteral;
- case 5 /* operator */: return ts.TokenClass.Operator;
- case 6 /* stringLiteral */: return ts.TokenClass.StringLiteral;
- case 8 /* whiteSpace */: return ts.TokenClass.Whitespace;
- case 10 /* punctuation */: return ts.TokenClass.Punctuation;
- case 2 /* identifier */:
- case 11 /* className */:
- case 12 /* enumName */:
- case 13 /* interfaceName */:
- case 14 /* moduleName */:
- case 15 /* typeParameterName */:
- case 16 /* typeAliasName */:
- case 9 /* text */:
- case 17 /* parameterName */:
+ case 1 /* ClassificationType.comment */: return ts.TokenClass.Comment;
+ case 3 /* ClassificationType.keyword */: return ts.TokenClass.Keyword;
+ case 4 /* ClassificationType.numericLiteral */: return ts.TokenClass.NumberLiteral;
+ case 25 /* ClassificationType.bigintLiteral */: return ts.TokenClass.BigIntLiteral;
+ case 5 /* ClassificationType.operator */: return ts.TokenClass.Operator;
+ case 6 /* ClassificationType.stringLiteral */: return ts.TokenClass.StringLiteral;
+ case 8 /* ClassificationType.whiteSpace */: return ts.TokenClass.Whitespace;
+ case 10 /* ClassificationType.punctuation */: return ts.TokenClass.Punctuation;
+ case 2 /* ClassificationType.identifier */:
+ case 11 /* ClassificationType.className */:
+ case 12 /* ClassificationType.enumName */:
+ case 13 /* ClassificationType.interfaceName */:
+ case 14 /* ClassificationType.moduleName */:
+ case 15 /* ClassificationType.typeParameterName */:
+ case 16 /* ClassificationType.typeAliasName */:
+ case 9 /* ClassificationType.text */:
+ case 17 /* ClassificationType.parameterName */:
return ts.TokenClass.Identifier;
default:
return undefined; // TODO: GH#18217 Debug.assertNever(type);
@@ -128234,10 +130173,10 @@ var ts;
return true;
}
switch (keyword2) {
- case 136 /* GetKeyword */:
- case 148 /* SetKeyword */:
- case 134 /* ConstructorKeyword */:
- case 124 /* StaticKeyword */:
+ case 136 /* SyntaxKind.GetKeyword */:
+ case 149 /* SyntaxKind.SetKeyword */:
+ case 134 /* SyntaxKind.ConstructorKeyword */:
+ case 124 /* SyntaxKind.StaticKeyword */:
return true; // Allow things like "public get", "public constructor" and "public static".
default:
return false; // Any other keyword following "public" is actually an identifier, not a real keyword.
@@ -128250,19 +130189,19 @@ var ts;
// If we're in a multiline comment, then prepend: /*
// (and a newline). That way when we lex we'll think we're still in a multiline comment.
switch (lexState) {
- case 3 /* InDoubleQuoteStringLiteral */:
+ case 3 /* EndOfLineState.InDoubleQuoteStringLiteral */:
return { prefix: "\"\\\n" };
- case 2 /* InSingleQuoteStringLiteral */:
+ case 2 /* EndOfLineState.InSingleQuoteStringLiteral */:
return { prefix: "'\\\n" };
- case 1 /* InMultiLineCommentTrivia */:
+ case 1 /* EndOfLineState.InMultiLineCommentTrivia */:
return { prefix: "/*\n" };
- case 4 /* InTemplateHeadOrNoSubstitutionTemplate */:
+ case 4 /* EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate */:
return { prefix: "`\n" };
- case 5 /* InTemplateMiddleOrTail */:
+ case 5 /* EndOfLineState.InTemplateMiddleOrTail */:
return { prefix: "}\n", pushTemplate: true };
- case 6 /* InTemplateSubstitutionPosition */:
+ case 6 /* EndOfLineState.InTemplateSubstitutionPosition */:
return { prefix: "", pushTemplate: true };
- case 0 /* None */:
+ case 0 /* EndOfLineState.None */:
return { prefix: "" };
default:
return ts.Debug.assertNever(lexState);
@@ -128270,47 +130209,47 @@ var ts;
}
function isBinaryExpressionOperatorToken(token) {
switch (token) {
- case 41 /* AsteriskToken */:
- case 43 /* SlashToken */:
- case 44 /* PercentToken */:
- case 39 /* PlusToken */:
- case 40 /* MinusToken */:
- case 47 /* LessThanLessThanToken */:
- case 48 /* GreaterThanGreaterThanToken */:
- case 49 /* GreaterThanGreaterThanGreaterThanToken */:
- case 29 /* LessThanToken */:
- case 31 /* GreaterThanToken */:
- case 32 /* LessThanEqualsToken */:
- case 33 /* GreaterThanEqualsToken */:
- case 102 /* InstanceOfKeyword */:
- case 101 /* InKeyword */:
- case 127 /* AsKeyword */:
- case 34 /* EqualsEqualsToken */:
- case 35 /* ExclamationEqualsToken */:
- case 36 /* EqualsEqualsEqualsToken */:
- case 37 /* ExclamationEqualsEqualsToken */:
- case 50 /* AmpersandToken */:
- case 52 /* CaretToken */:
- case 51 /* BarToken */:
- case 55 /* AmpersandAmpersandToken */:
- case 56 /* BarBarToken */:
- case 74 /* BarEqualsToken */:
- case 73 /* AmpersandEqualsToken */:
- case 78 /* CaretEqualsToken */:
- case 70 /* LessThanLessThanEqualsToken */:
- case 71 /* GreaterThanGreaterThanEqualsToken */:
- case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
- case 64 /* PlusEqualsToken */:
- case 65 /* MinusEqualsToken */:
- case 66 /* AsteriskEqualsToken */:
- case 68 /* SlashEqualsToken */:
- case 69 /* PercentEqualsToken */:
- case 63 /* EqualsToken */:
- case 27 /* CommaToken */:
- case 60 /* QuestionQuestionToken */:
- case 75 /* BarBarEqualsToken */:
- case 76 /* AmpersandAmpersandEqualsToken */:
- case 77 /* QuestionQuestionEqualsToken */:
+ case 41 /* SyntaxKind.AsteriskToken */:
+ case 43 /* SyntaxKind.SlashToken */:
+ case 44 /* SyntaxKind.PercentToken */:
+ case 39 /* SyntaxKind.PlusToken */:
+ case 40 /* SyntaxKind.MinusToken */:
+ case 47 /* SyntaxKind.LessThanLessThanToken */:
+ case 48 /* SyntaxKind.GreaterThanGreaterThanToken */:
+ case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */:
+ case 29 /* SyntaxKind.LessThanToken */:
+ case 31 /* SyntaxKind.GreaterThanToken */:
+ case 32 /* SyntaxKind.LessThanEqualsToken */:
+ case 33 /* SyntaxKind.GreaterThanEqualsToken */:
+ case 102 /* SyntaxKind.InstanceOfKeyword */:
+ case 101 /* SyntaxKind.InKeyword */:
+ case 127 /* SyntaxKind.AsKeyword */:
+ case 34 /* SyntaxKind.EqualsEqualsToken */:
+ case 35 /* SyntaxKind.ExclamationEqualsToken */:
+ case 36 /* SyntaxKind.EqualsEqualsEqualsToken */:
+ case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */:
+ case 50 /* SyntaxKind.AmpersandToken */:
+ case 52 /* SyntaxKind.CaretToken */:
+ case 51 /* SyntaxKind.BarToken */:
+ case 55 /* SyntaxKind.AmpersandAmpersandToken */:
+ case 56 /* SyntaxKind.BarBarToken */:
+ case 74 /* SyntaxKind.BarEqualsToken */:
+ case 73 /* SyntaxKind.AmpersandEqualsToken */:
+ case 78 /* SyntaxKind.CaretEqualsToken */:
+ case 70 /* SyntaxKind.LessThanLessThanEqualsToken */:
+ case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */:
+ case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */:
+ case 64 /* SyntaxKind.PlusEqualsToken */:
+ case 65 /* SyntaxKind.MinusEqualsToken */:
+ case 66 /* SyntaxKind.AsteriskEqualsToken */:
+ case 68 /* SyntaxKind.SlashEqualsToken */:
+ case 69 /* SyntaxKind.PercentEqualsToken */:
+ case 63 /* SyntaxKind.EqualsToken */:
+ case 27 /* SyntaxKind.CommaToken */:
+ case 60 /* SyntaxKind.QuestionQuestionToken */:
+ case 75 /* SyntaxKind.BarBarEqualsToken */:
+ case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */:
+ case 77 /* SyntaxKind.QuestionQuestionEqualsToken */:
return true;
default:
return false;
@@ -128318,12 +130257,12 @@ var ts;
}
function isPrefixUnaryExpressionOperatorToken(token) {
switch (token) {
- case 39 /* PlusToken */:
- case 40 /* MinusToken */:
- case 54 /* TildeToken */:
- case 53 /* ExclamationToken */:
- case 45 /* PlusPlusToken */:
- case 46 /* MinusMinusToken */:
+ case 39 /* SyntaxKind.PlusToken */:
+ case 40 /* SyntaxKind.MinusToken */:
+ case 54 /* SyntaxKind.TildeToken */:
+ case 53 /* SyntaxKind.ExclamationToken */:
+ case 45 /* SyntaxKind.PlusPlusToken */:
+ case 46 /* SyntaxKind.MinusMinusToken */:
return true;
default:
return false;
@@ -128331,36 +130270,36 @@ var ts;
}
function classFromKind(token) {
if (ts.isKeyword(token)) {
- return 3 /* keyword */;
+ return 3 /* ClassificationType.keyword */;
}
else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) {
- return 5 /* operator */;
+ return 5 /* ClassificationType.operator */;
}
- else if (token >= 18 /* FirstPunctuation */ && token <= 78 /* LastPunctuation */) {
- return 10 /* punctuation */;
+ else if (token >= 18 /* SyntaxKind.FirstPunctuation */ && token <= 78 /* SyntaxKind.LastPunctuation */) {
+ return 10 /* ClassificationType.punctuation */;
}
switch (token) {
- case 8 /* NumericLiteral */:
- return 4 /* numericLiteral */;
- case 9 /* BigIntLiteral */:
- return 25 /* bigintLiteral */;
- case 10 /* StringLiteral */:
- return 6 /* stringLiteral */;
- case 13 /* RegularExpressionLiteral */:
- return 7 /* regularExpressionLiteral */;
- case 7 /* ConflictMarkerTrivia */:
- case 3 /* MultiLineCommentTrivia */:
- case 2 /* SingleLineCommentTrivia */:
- return 1 /* comment */;
- case 5 /* WhitespaceTrivia */:
- case 4 /* NewLineTrivia */:
- return 8 /* whiteSpace */;
- case 79 /* Identifier */:
+ case 8 /* SyntaxKind.NumericLiteral */:
+ return 4 /* ClassificationType.numericLiteral */;
+ case 9 /* SyntaxKind.BigIntLiteral */:
+ return 25 /* ClassificationType.bigintLiteral */;
+ case 10 /* SyntaxKind.StringLiteral */:
+ return 6 /* ClassificationType.stringLiteral */;
+ case 13 /* SyntaxKind.RegularExpressionLiteral */:
+ return 7 /* ClassificationType.regularExpressionLiteral */;
+ case 7 /* SyntaxKind.ConflictMarkerTrivia */:
+ case 3 /* SyntaxKind.MultiLineCommentTrivia */:
+ case 2 /* SyntaxKind.SingleLineCommentTrivia */:
+ return 1 /* ClassificationType.comment */;
+ case 5 /* SyntaxKind.WhitespaceTrivia */:
+ case 4 /* SyntaxKind.NewLineTrivia */:
+ return 8 /* ClassificationType.whiteSpace */;
+ case 79 /* SyntaxKind.Identifier */:
default:
if (ts.isTemplateLiteralKind(token)) {
- return 6 /* stringLiteral */;
+ return 6 /* ClassificationType.stringLiteral */;
}
- return 2 /* identifier */;
+ return 2 /* ClassificationType.identifier */;
}
}
/* @internal */
@@ -128380,13 +130319,13 @@ var ts;
// That means we're calling back into the host around every 1.2k of the file we process.
// Lib.d.ts has similar numbers.
switch (kind) {
- case 260 /* ModuleDeclaration */:
- case 256 /* ClassDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 255 /* FunctionDeclaration */:
- case 225 /* ClassExpression */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
cancellationToken.throwIfCancellationRequested();
}
}
@@ -128411,7 +130350,7 @@ var ts;
}
node.forEachChild(cb);
});
- return { spans: spans, endOfLineState: 0 /* None */ };
+ return { spans: spans, endOfLineState: 0 /* EndOfLineState.None */ };
function pushClassification(start, end, type) {
var length = end - start;
ts.Debug.assert(length > 0, "Classification had non-positive length of ".concat(length));
@@ -128423,29 +130362,29 @@ var ts;
ts.getEncodedSemanticClassifications = getEncodedSemanticClassifications;
function classifySymbol(symbol, meaningAtPosition, checker) {
var flags = symbol.getFlags();
- if ((flags & 2885600 /* Classifiable */) === 0 /* None */) {
+ if ((flags & 2885600 /* SymbolFlags.Classifiable */) === 0 /* SymbolFlags.None */) {
return undefined;
}
- else if (flags & 32 /* Class */) {
- return 11 /* className */;
+ else if (flags & 32 /* SymbolFlags.Class */) {
+ return 11 /* ClassificationType.className */;
}
- else if (flags & 384 /* Enum */) {
- return 12 /* enumName */;
+ else if (flags & 384 /* SymbolFlags.Enum */) {
+ return 12 /* ClassificationType.enumName */;
}
- else if (flags & 524288 /* TypeAlias */) {
- return 16 /* typeAliasName */;
+ else if (flags & 524288 /* SymbolFlags.TypeAlias */) {
+ return 16 /* ClassificationType.typeAliasName */;
}
- else if (flags & 1536 /* Module */) {
+ else if (flags & 1536 /* SymbolFlags.Module */) {
// Only classify a module as such if
// - It appears in a namespace context.
// - There exists a module declaration which actually impacts the value side.
- return meaningAtPosition & 4 /* Namespace */ || meaningAtPosition & 1 /* Value */ && hasValueSideModule(symbol) ? 14 /* moduleName */ : undefined;
+ return meaningAtPosition & 4 /* SemanticMeaning.Namespace */ || meaningAtPosition & 1 /* SemanticMeaning.Value */ && hasValueSideModule(symbol) ? 14 /* ClassificationType.moduleName */ : undefined;
}
- else if (flags & 2097152 /* Alias */) {
+ else if (flags & 2097152 /* SymbolFlags.Alias */) {
return classifySymbol(checker.getAliasedSymbol(symbol), meaningAtPosition, checker);
}
- else if (meaningAtPosition & 2 /* Type */) {
- return flags & 64 /* Interface */ ? 13 /* interfaceName */ : flags & 262144 /* TypeParameter */ ? 15 /* typeParameterName */ : undefined;
+ else if (meaningAtPosition & 2 /* SemanticMeaning.Type */) {
+ return flags & 64 /* SymbolFlags.Interface */ ? 13 /* ClassificationType.interfaceName */ : flags & 262144 /* SymbolFlags.TypeParameter */ ? 15 /* ClassificationType.typeParameterName */ : undefined;
}
else {
return undefined;
@@ -128454,35 +130393,35 @@ var ts;
/** Returns true if there exists a module that introduces entities on the value side. */
function hasValueSideModule(symbol) {
return ts.some(symbol.declarations, function (declaration) {
- return ts.isModuleDeclaration(declaration) && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */;
+ return ts.isModuleDeclaration(declaration) && ts.getModuleInstanceState(declaration) === 1 /* ModuleInstanceState.Instantiated */;
});
}
function getClassificationTypeName(type) {
switch (type) {
- case 1 /* comment */: return "comment" /* comment */;
- case 2 /* identifier */: return "identifier" /* identifier */;
- case 3 /* keyword */: return "keyword" /* keyword */;
- case 4 /* numericLiteral */: return "number" /* numericLiteral */;
- case 25 /* bigintLiteral */: return "bigint" /* bigintLiteral */;
- case 5 /* operator */: return "operator" /* operator */;
- case 6 /* stringLiteral */: return "string" /* stringLiteral */;
- case 8 /* whiteSpace */: return "whitespace" /* whiteSpace */;
- case 9 /* text */: return "text" /* text */;
- case 10 /* punctuation */: return "punctuation" /* punctuation */;
- case 11 /* className */: return "class name" /* className */;
- case 12 /* enumName */: return "enum name" /* enumName */;
- case 13 /* interfaceName */: return "interface name" /* interfaceName */;
- case 14 /* moduleName */: return "module name" /* moduleName */;
- case 15 /* typeParameterName */: return "type parameter name" /* typeParameterName */;
- case 16 /* typeAliasName */: return "type alias name" /* typeAliasName */;
- case 17 /* parameterName */: return "parameter name" /* parameterName */;
- case 18 /* docCommentTagName */: return "doc comment tag name" /* docCommentTagName */;
- case 19 /* jsxOpenTagName */: return "jsx open tag name" /* jsxOpenTagName */;
- case 20 /* jsxCloseTagName */: return "jsx close tag name" /* jsxCloseTagName */;
- case 21 /* jsxSelfClosingTagName */: return "jsx self closing tag name" /* jsxSelfClosingTagName */;
- case 22 /* jsxAttribute */: return "jsx attribute" /* jsxAttribute */;
- case 23 /* jsxText */: return "jsx text" /* jsxText */;
- case 24 /* jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* jsxAttributeStringLiteralValue */;
+ case 1 /* ClassificationType.comment */: return "comment" /* ClassificationTypeNames.comment */;
+ case 2 /* ClassificationType.identifier */: return "identifier" /* ClassificationTypeNames.identifier */;
+ case 3 /* ClassificationType.keyword */: return "keyword" /* ClassificationTypeNames.keyword */;
+ case 4 /* ClassificationType.numericLiteral */: return "number" /* ClassificationTypeNames.numericLiteral */;
+ case 25 /* ClassificationType.bigintLiteral */: return "bigint" /* ClassificationTypeNames.bigintLiteral */;
+ case 5 /* ClassificationType.operator */: return "operator" /* ClassificationTypeNames.operator */;
+ case 6 /* ClassificationType.stringLiteral */: return "string" /* ClassificationTypeNames.stringLiteral */;
+ case 8 /* ClassificationType.whiteSpace */: return "whitespace" /* ClassificationTypeNames.whiteSpace */;
+ case 9 /* ClassificationType.text */: return "text" /* ClassificationTypeNames.text */;
+ case 10 /* ClassificationType.punctuation */: return "punctuation" /* ClassificationTypeNames.punctuation */;
+ case 11 /* ClassificationType.className */: return "class name" /* ClassificationTypeNames.className */;
+ case 12 /* ClassificationType.enumName */: return "enum name" /* ClassificationTypeNames.enumName */;
+ case 13 /* ClassificationType.interfaceName */: return "interface name" /* ClassificationTypeNames.interfaceName */;
+ case 14 /* ClassificationType.moduleName */: return "module name" /* ClassificationTypeNames.moduleName */;
+ case 15 /* ClassificationType.typeParameterName */: return "type parameter name" /* ClassificationTypeNames.typeParameterName */;
+ case 16 /* ClassificationType.typeAliasName */: return "type alias name" /* ClassificationTypeNames.typeAliasName */;
+ case 17 /* ClassificationType.parameterName */: return "parameter name" /* ClassificationTypeNames.parameterName */;
+ case 18 /* ClassificationType.docCommentTagName */: return "doc comment tag name" /* ClassificationTypeNames.docCommentTagName */;
+ case 19 /* ClassificationType.jsxOpenTagName */: return "jsx open tag name" /* ClassificationTypeNames.jsxOpenTagName */;
+ case 20 /* ClassificationType.jsxCloseTagName */: return "jsx close tag name" /* ClassificationTypeNames.jsxCloseTagName */;
+ case 21 /* ClassificationType.jsxSelfClosingTagName */: return "jsx self closing tag name" /* ClassificationTypeNames.jsxSelfClosingTagName */;
+ case 22 /* ClassificationType.jsxAttribute */: return "jsx attribute" /* ClassificationTypeNames.jsxAttribute */;
+ case 23 /* ClassificationType.jsxText */: return "jsx text" /* ClassificationTypeNames.jsxText */;
+ case 24 /* ClassificationType.jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* ClassificationTypeNames.jsxAttributeStringLiteralValue */;
default: return undefined; // TODO: GH#18217 throw Debug.assertNever(type);
}
}
@@ -128508,11 +130447,11 @@ var ts;
var spanStart = span.start;
var spanLength = span.length;
// Make a scanner we can get trivia from.
- var triviaScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text);
- var mergeConflictScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text);
+ var triviaScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text);
+ var mergeConflictScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text);
var result = [];
processElement(sourceFile);
- return { spans: result, endOfLineState: 0 /* None */ };
+ return { spans: result, endOfLineState: 0 /* EndOfLineState.None */ };
function pushClassification(start, length, type) {
result.push(start);
result.push(length);
@@ -128534,12 +130473,12 @@ var ts;
return start;
}
switch (kind) {
- case 4 /* NewLineTrivia */:
- case 5 /* WhitespaceTrivia */:
+ case 4 /* SyntaxKind.NewLineTrivia */:
+ case 5 /* SyntaxKind.WhitespaceTrivia */:
// Don't bother with newlines/whitespace.
continue;
- case 2 /* SingleLineCommentTrivia */:
- case 3 /* MultiLineCommentTrivia */:
+ case 2 /* SyntaxKind.SingleLineCommentTrivia */:
+ case 3 /* SyntaxKind.MultiLineCommentTrivia */:
// Only bother with the trivia if it at least intersects the span of interest.
classifyComment(token, kind, start, width);
// Classifying a comment might cause us to reuse the trivia scanner
@@ -128547,21 +130486,21 @@ var ts;
// sure we set the scanner position back to where it needs to be.
triviaScanner.setTextPos(end);
continue;
- case 7 /* ConflictMarkerTrivia */:
+ case 7 /* SyntaxKind.ConflictMarkerTrivia */:
var text = sourceFile.text;
var ch = text.charCodeAt(start);
// for the <<<<<<< and >>>>>>> markers, we just add them in as comments
// in the classification stream.
- if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) {
- pushClassification(start, width, 1 /* comment */);
+ if (ch === 60 /* CharacterCodes.lessThan */ || ch === 62 /* CharacterCodes.greaterThan */) {
+ pushClassification(start, width, 1 /* ClassificationType.comment */);
continue;
}
// for the ||||||| and ======== markers, add a comment for the first line,
// and then lex all subsequent lines up until the end of the conflict marker.
- ts.Debug.assert(ch === 124 /* bar */ || ch === 61 /* equals */);
+ ts.Debug.assert(ch === 124 /* CharacterCodes.bar */ || ch === 61 /* CharacterCodes.equals */);
classifyDisabledMergeCode(text, start, end);
break;
- case 6 /* ShebangTrivia */:
+ case 6 /* SyntaxKind.ShebangTrivia */:
// TODO: Maybe we should classify these.
break;
default:
@@ -128570,7 +130509,7 @@ var ts;
}
}
function classifyComment(token, kind, start, width) {
- if (kind === 3 /* MultiLineCommentTrivia */) {
+ if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) {
// See if this is a doc comment. If so, we'll classify certain portions of it
// specially.
var docCommentAndDiagnostics = ts.parseIsolatedJSDocComment(sourceFile.text, start, width);
@@ -128581,7 +130520,7 @@ var ts;
return;
}
}
- else if (kind === 2 /* SingleLineCommentTrivia */) {
+ else if (kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) {
if (tryClassifyTripleSlashComment(start, width)) {
return;
}
@@ -128590,7 +130529,7 @@ var ts;
pushCommentRange(start, width);
}
function pushCommentRange(start, width) {
- pushClassification(start, width, 1 /* comment */);
+ pushClassification(start, width, 1 /* ClassificationType.comment */);
}
function classifyJSDocComment(docComment) {
var _a, _b, _c, _d, _e, _f, _g;
@@ -128603,51 +130542,51 @@ var ts;
if (tag.pos !== pos) {
pushCommentRange(pos, tag.pos - pos);
}
- pushClassification(tag.pos, 1, 10 /* punctuation */); // "@"
- pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param"
+ pushClassification(tag.pos, 1, 10 /* ClassificationType.punctuation */); // "@"
+ pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* ClassificationType.docCommentTagName */); // e.g. "param"
pos = tag.tagName.end;
var commentStart = tag.tagName.end;
switch (tag.kind) {
- case 338 /* JSDocParameterTag */:
+ case 340 /* SyntaxKind.JSDocParameterTag */:
var param = tag;
processJSDocParameterTag(param);
commentStart = param.isNameFirst && ((_a = param.typeExpression) === null || _a === void 0 ? void 0 : _a.end) || param.name.end;
break;
- case 345 /* JSDocPropertyTag */:
+ case 347 /* SyntaxKind.JSDocPropertyTag */:
var prop = tag;
commentStart = prop.isNameFirst && ((_b = prop.typeExpression) === null || _b === void 0 ? void 0 : _b.end) || prop.name.end;
break;
- case 342 /* JSDocTemplateTag */:
+ case 344 /* SyntaxKind.JSDocTemplateTag */:
processJSDocTemplateTag(tag);
pos = tag.end;
commentStart = tag.typeParameters.end;
break;
- case 343 /* JSDocTypedefTag */:
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
var type = tag;
- commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 307 /* JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart;
+ commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 309 /* SyntaxKind.JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart;
break;
- case 336 /* JSDocCallbackTag */:
+ case 338 /* SyntaxKind.JSDocCallbackTag */:
commentStart = tag.typeExpression.end;
break;
- case 341 /* JSDocTypeTag */:
+ case 343 /* SyntaxKind.JSDocTypeTag */:
processElement(tag.typeExpression);
pos = tag.end;
commentStart = tag.typeExpression.end;
break;
- case 340 /* JSDocThisTag */:
- case 337 /* JSDocEnumTag */:
+ case 342 /* SyntaxKind.JSDocThisTag */:
+ case 339 /* SyntaxKind.JSDocEnumTag */:
commentStart = tag.typeExpression.end;
break;
- case 339 /* JSDocReturnTag */:
+ case 341 /* SyntaxKind.JSDocReturnTag */:
processElement(tag.typeExpression);
pos = tag.end;
commentStart = ((_f = tag.typeExpression) === null || _f === void 0 ? void 0 : _f.end) || commentStart;
break;
- case 344 /* JSDocSeeTag */:
+ case 346 /* SyntaxKind.JSDocSeeTag */:
commentStart = ((_g = tag.name) === null || _g === void 0 ? void 0 : _g.end) || commentStart;
break;
- case 326 /* JSDocAugmentsTag */:
- case 327 /* JSDocImplementsTag */:
+ case 328 /* SyntaxKind.JSDocAugmentsTag */:
+ case 329 /* SyntaxKind.JSDocImplementsTag */:
commentStart = tag.class.end;
break;
}
@@ -128666,7 +130605,7 @@ var ts;
function processJSDocParameterTag(tag) {
if (tag.isNameFirst) {
pushCommentRange(pos, tag.name.pos - pos);
- pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* parameterName */);
+ pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* ClassificationType.parameterName */);
pos = tag.name.end;
}
if (tag.typeExpression) {
@@ -128676,7 +130615,7 @@ var ts;
}
if (!tag.isNameFirst) {
pushCommentRange(pos, tag.name.pos - pos);
- pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* parameterName */);
+ pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* ClassificationType.parameterName */);
pos = tag.name.end;
}
}
@@ -128701,9 +130640,9 @@ var ts;
var pos = start;
pushCommentRange(pos, match[1].length); // ///
pos += match[1].length;
- pushClassification(pos, match[2].length, 10 /* punctuation */); // <
+ pushClassification(pos, match[2].length, 10 /* ClassificationType.punctuation */); // <
pos += match[2].length;
- pushClassification(pos, match[3].length, 21 /* jsxSelfClosingTagName */); // element name
+ pushClassification(pos, match[3].length, 21 /* ClassificationType.jsxSelfClosingTagName */); // element name
pos += match[3].length;
var attrText = match[4];
var attrPos = pos;
@@ -128717,19 +130656,19 @@ var ts;
pushCommentRange(attrPos, newAttrPos - attrPos);
attrPos = newAttrPos;
}
- pushClassification(attrPos, attrMatch[2].length, 22 /* jsxAttribute */); // attribute name
+ pushClassification(attrPos, attrMatch[2].length, 22 /* ClassificationType.jsxAttribute */); // attribute name
attrPos += attrMatch[2].length;
if (attrMatch[3].length) {
pushCommentRange(attrPos, attrMatch[3].length); // whitespace
attrPos += attrMatch[3].length;
}
- pushClassification(attrPos, attrMatch[4].length, 5 /* operator */); // =
+ pushClassification(attrPos, attrMatch[4].length, 5 /* ClassificationType.operator */); // =
attrPos += attrMatch[4].length;
if (attrMatch[5].length) {
pushCommentRange(attrPos, attrMatch[5].length); // whitespace
attrPos += attrMatch[5].length;
}
- pushClassification(attrPos, attrMatch[6].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value
+ pushClassification(attrPos, attrMatch[6].length, 24 /* ClassificationType.jsxAttributeStringLiteralValue */); // attribute value
attrPos += attrMatch[6].length;
}
pos += match[4].length;
@@ -128737,7 +130676,7 @@ var ts;
pushCommentRange(attrPos, pos - attrPos);
}
if (match[5]) {
- pushClassification(pos, match[5].length, 10 /* punctuation */); // />
+ pushClassification(pos, match[5].length, 10 /* ClassificationType.punctuation */); // />
pos += match[5].length;
}
var end = start + width;
@@ -128761,7 +130700,7 @@ var ts;
break;
}
}
- pushClassification(start, i - start, 1 /* comment */);
+ pushClassification(start, i - start, 1 /* ClassificationType.comment */);
mergeConflictScanner.setTextPos(i);
while (mergeConflictScanner.getTextPos() < end) {
classifyDisabledCodeToken();
@@ -128788,10 +130727,10 @@ var ts;
return true;
}
var classifiedElementName = tryClassifyJsxElementName(node);
- if (!ts.isToken(node) && node.kind !== 11 /* JsxText */ && classifiedElementName === undefined) {
+ if (!ts.isToken(node) && node.kind !== 11 /* SyntaxKind.JsxText */ && classifiedElementName === undefined) {
return false;
}
- var tokenStart = node.kind === 11 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node);
+ var tokenStart = node.kind === 11 /* SyntaxKind.JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node);
var tokenWidth = node.end - tokenStart;
ts.Debug.assert(tokenWidth >= 0);
if (tokenWidth > 0) {
@@ -128804,24 +130743,24 @@ var ts;
}
function tryClassifyJsxElementName(token) {
switch (token.parent && token.parent.kind) {
- case 279 /* JsxOpeningElement */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
if (token.parent.tagName === token) {
- return 19 /* jsxOpenTagName */;
+ return 19 /* ClassificationType.jsxOpenTagName */;
}
break;
- case 280 /* JsxClosingElement */:
+ case 281 /* SyntaxKind.JsxClosingElement */:
if (token.parent.tagName === token) {
- return 20 /* jsxCloseTagName */;
+ return 20 /* ClassificationType.jsxCloseTagName */;
}
break;
- case 278 /* JsxSelfClosingElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
if (token.parent.tagName === token) {
- return 21 /* jsxSelfClosingTagName */;
+ return 21 /* ClassificationType.jsxSelfClosingTagName */;
}
break;
- case 284 /* JsxAttribute */:
+ case 285 /* SyntaxKind.JsxAttribute */:
if (token.parent.name === token) {
- return 22 /* jsxAttribute */;
+ return 22 /* ClassificationType.jsxAttribute */;
}
break;
}
@@ -128832,97 +130771,97 @@ var ts;
// classify based on that instead.
function classifyTokenType(tokenKind, token) {
if (ts.isKeyword(tokenKind)) {
- return 3 /* keyword */;
+ return 3 /* ClassificationType.keyword */;
}
// Special case `<` and `>`: If they appear in a generic context they are punctuation,
// not operators.
- if (tokenKind === 29 /* LessThanToken */ || tokenKind === 31 /* GreaterThanToken */) {
+ if (tokenKind === 29 /* SyntaxKind.LessThanToken */ || tokenKind === 31 /* SyntaxKind.GreaterThanToken */) {
// If the node owning the token has a type argument list or type parameter list, then
// we can effectively assume that a '<' and '>' belong to those lists.
if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) {
- return 10 /* punctuation */;
+ return 10 /* ClassificationType.punctuation */;
}
}
if (ts.isPunctuation(tokenKind)) {
if (token) {
var parent = token.parent;
- if (tokenKind === 63 /* EqualsToken */) {
+ if (tokenKind === 63 /* SyntaxKind.EqualsToken */) {
// the '=' in a variable declaration is special cased here.
- if (parent.kind === 253 /* VariableDeclaration */ ||
- parent.kind === 166 /* PropertyDeclaration */ ||
- parent.kind === 163 /* Parameter */ ||
- parent.kind === 284 /* JsxAttribute */) {
- return 5 /* operator */;
+ if (parent.kind === 254 /* SyntaxKind.VariableDeclaration */ ||
+ parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ ||
+ parent.kind === 164 /* SyntaxKind.Parameter */ ||
+ parent.kind === 285 /* SyntaxKind.JsxAttribute */) {
+ return 5 /* ClassificationType.operator */;
}
}
- if (parent.kind === 220 /* BinaryExpression */ ||
- parent.kind === 218 /* PrefixUnaryExpression */ ||
- parent.kind === 219 /* PostfixUnaryExpression */ ||
- parent.kind === 221 /* ConditionalExpression */) {
- return 5 /* operator */;
+ if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ ||
+ parent.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ ||
+ parent.kind === 220 /* SyntaxKind.PostfixUnaryExpression */ ||
+ parent.kind === 222 /* SyntaxKind.ConditionalExpression */) {
+ return 5 /* ClassificationType.operator */;
}
}
- return 10 /* punctuation */;
+ return 10 /* ClassificationType.punctuation */;
}
- else if (tokenKind === 8 /* NumericLiteral */) {
- return 4 /* numericLiteral */;
+ else if (tokenKind === 8 /* SyntaxKind.NumericLiteral */) {
+ return 4 /* ClassificationType.numericLiteral */;
}
- else if (tokenKind === 9 /* BigIntLiteral */) {
- return 25 /* bigintLiteral */;
+ else if (tokenKind === 9 /* SyntaxKind.BigIntLiteral */) {
+ return 25 /* ClassificationType.bigintLiteral */;
}
- else if (tokenKind === 10 /* StringLiteral */) {
- return token && token.parent.kind === 284 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */;
+ else if (tokenKind === 10 /* SyntaxKind.StringLiteral */) {
+ return token && token.parent.kind === 285 /* SyntaxKind.JsxAttribute */ ? 24 /* ClassificationType.jsxAttributeStringLiteralValue */ : 6 /* ClassificationType.stringLiteral */;
}
- else if (tokenKind === 13 /* RegularExpressionLiteral */) {
+ else if (tokenKind === 13 /* SyntaxKind.RegularExpressionLiteral */) {
// TODO: we should get another classification type for these literals.
- return 6 /* stringLiteral */;
+ return 6 /* ClassificationType.stringLiteral */;
}
else if (ts.isTemplateLiteralKind(tokenKind)) {
// TODO (drosen): we should *also* get another classification type for these literals.
- return 6 /* stringLiteral */;
+ return 6 /* ClassificationType.stringLiteral */;
}
- else if (tokenKind === 11 /* JsxText */) {
- return 23 /* jsxText */;
+ else if (tokenKind === 11 /* SyntaxKind.JsxText */) {
+ return 23 /* ClassificationType.jsxText */;
}
- else if (tokenKind === 79 /* Identifier */) {
+ else if (tokenKind === 79 /* SyntaxKind.Identifier */) {
if (token) {
switch (token.parent.kind) {
- case 256 /* ClassDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
if (token.parent.name === token) {
- return 11 /* className */;
+ return 11 /* ClassificationType.className */;
}
return;
- case 162 /* TypeParameter */:
+ case 163 /* SyntaxKind.TypeParameter */:
if (token.parent.name === token) {
- return 15 /* typeParameterName */;
+ return 15 /* ClassificationType.typeParameterName */;
}
return;
- case 257 /* InterfaceDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
if (token.parent.name === token) {
- return 13 /* interfaceName */;
+ return 13 /* ClassificationType.interfaceName */;
}
return;
- case 259 /* EnumDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
if (token.parent.name === token) {
- return 12 /* enumName */;
+ return 12 /* ClassificationType.enumName */;
}
return;
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
if (token.parent.name === token) {
- return 14 /* moduleName */;
+ return 14 /* ClassificationType.moduleName */;
}
return;
- case 163 /* Parameter */:
+ case 164 /* SyntaxKind.Parameter */:
if (token.parent.name === token) {
- return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */;
+ return ts.isThisIdentifier(token) ? 3 /* ClassificationType.keyword */ : 17 /* ClassificationType.parameterName */;
}
return;
}
if (ts.isConstTypeReference(token.parent)) {
- return 3 /* keyword */;
+ return 3 /* ClassificationType.keyword */;
}
}
- return 2 /* identifier */;
+ return 2 /* ClassificationType.identifier */;
}
}
function processElement(element) {
@@ -128998,14 +130937,14 @@ var ts;
function getEncodedSemanticClassifications(program, cancellationToken, sourceFile, span) {
return {
spans: getSemanticTokens(program, sourceFile, span, cancellationToken),
- endOfLineState: 0 /* None */
+ endOfLineState: 0 /* EndOfLineState.None */
};
}
v2020.getEncodedSemanticClassifications = getEncodedSemanticClassifications;
function getSemanticTokens(program, sourceFile, span, cancellationToken) {
var resultTokens = [];
var collector = function (node, typeIdx, modifierSet) {
- resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << 8 /* typeOffset */) + modifierSet);
+ resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << 8 /* TokenEncodingConsts.typeOffset */) + modifierSet);
};
if (program && sourceFile) {
collectTokens(program, sourceFile, span, collector, cancellationToken);
@@ -129017,13 +130956,13 @@ var ts;
var inJSXElement = false;
function visit(node) {
switch (node.kind) {
- case 260 /* ModuleDeclaration */:
- case 256 /* ClassDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 255 /* FunctionDeclaration */:
- case 225 /* ClassExpression */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
cancellationToken.throwIfCancellationRequested();
}
if (!node || !ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth()) || node.getFullWidth() === 0) {
@@ -129039,7 +130978,7 @@ var ts;
if (ts.isIdentifier(node) && !inJSXElement && !inImportClause(node) && !ts.isInfinityOrNaNString(node.escapedText)) {
var symbol = typeChecker.getSymbolAtLocation(node);
if (symbol) {
- if (symbol.flags & 2097152 /* Alias */) {
+ if (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
symbol = typeChecker.getAliasedSymbol(symbol);
}
var typeIdx = classifySymbol(symbol, ts.getMeaningFromLocation(node));
@@ -129048,38 +130987,38 @@ var ts;
if (node.parent) {
var parentIsDeclaration = (ts.isBindingElement(node.parent) || tokenFromDeclarationMapping.get(node.parent.kind) === typeIdx);
if (parentIsDeclaration && node.parent.name === node) {
- modifierSet = 1 << 0 /* declaration */;
+ modifierSet = 1 << 0 /* TokenModifier.declaration */;
}
}
// property declaration in constructor
- if (typeIdx === 6 /* parameter */ && isRightSideOfQualifiedNameOrPropertyAccess(node)) {
- typeIdx = 9 /* property */;
+ if (typeIdx === 6 /* TokenType.parameter */ && isRightSideOfQualifiedNameOrPropertyAccess(node)) {
+ typeIdx = 9 /* TokenType.property */;
}
typeIdx = reclassifyByType(typeChecker, node, typeIdx);
var decl = symbol.valueDeclaration;
if (decl) {
var modifiers = ts.getCombinedModifierFlags(decl);
var nodeFlags = ts.getCombinedNodeFlags(decl);
- if (modifiers & 32 /* Static */) {
- modifierSet |= 1 << 1 /* static */;
+ if (modifiers & 32 /* ModifierFlags.Static */) {
+ modifierSet |= 1 << 1 /* TokenModifier.static */;
}
- if (modifiers & 256 /* Async */) {
- modifierSet |= 1 << 2 /* async */;
+ if (modifiers & 256 /* ModifierFlags.Async */) {
+ modifierSet |= 1 << 2 /* TokenModifier.async */;
}
- if (typeIdx !== 0 /* class */ && typeIdx !== 2 /* interface */) {
- if ((modifiers & 64 /* Readonly */) || (nodeFlags & 2 /* Const */) || (symbol.getFlags() & 8 /* EnumMember */)) {
- modifierSet |= 1 << 3 /* readonly */;
+ if (typeIdx !== 0 /* TokenType.class */ && typeIdx !== 2 /* TokenType.interface */) {
+ if ((modifiers & 64 /* ModifierFlags.Readonly */) || (nodeFlags & 2 /* NodeFlags.Const */) || (symbol.getFlags() & 8 /* SymbolFlags.EnumMember */)) {
+ modifierSet |= 1 << 3 /* TokenModifier.readonly */;
}
}
- if ((typeIdx === 7 /* variable */ || typeIdx === 10 /* function */) && isLocalDeclaration(decl, sourceFile)) {
- modifierSet |= 1 << 5 /* local */;
+ if ((typeIdx === 7 /* TokenType.variable */ || typeIdx === 10 /* TokenType.function */) && isLocalDeclaration(decl, sourceFile)) {
+ modifierSet |= 1 << 5 /* TokenModifier.local */;
}
if (program.isSourceFileDefaultLibrary(decl.getSourceFile())) {
- modifierSet |= 1 << 4 /* defaultLibrary */;
+ modifierSet |= 1 << 4 /* TokenModifier.defaultLibrary */;
}
}
else if (symbol.declarations && symbol.declarations.some(function (d) { return program.isSourceFileDefaultLibrary(d.getSourceFile()); })) {
- modifierSet |= 1 << 4 /* defaultLibrary */;
+ modifierSet |= 1 << 4 /* TokenModifier.defaultLibrary */;
}
collector(node, typeIdx, modifierSet);
}
@@ -129092,22 +131031,22 @@ var ts;
}
function classifySymbol(symbol, meaning) {
var flags = symbol.getFlags();
- if (flags & 32 /* Class */) {
- return 0 /* class */;
+ if (flags & 32 /* SymbolFlags.Class */) {
+ return 0 /* TokenType.class */;
}
- else if (flags & 384 /* Enum */) {
- return 1 /* enum */;
+ else if (flags & 384 /* SymbolFlags.Enum */) {
+ return 1 /* TokenType.enum */;
}
- else if (flags & 524288 /* TypeAlias */) {
- return 5 /* type */;
+ else if (flags & 524288 /* SymbolFlags.TypeAlias */) {
+ return 5 /* TokenType.type */;
}
- else if (flags & 64 /* Interface */) {
- if (meaning & 2 /* Type */) {
- return 2 /* interface */;
+ else if (flags & 64 /* SymbolFlags.Interface */) {
+ if (meaning & 2 /* SemanticMeaning.Type */) {
+ return 2 /* TokenType.interface */;
}
}
- else if (flags & 262144 /* TypeParameter */) {
- return 4 /* typeParameter */;
+ else if (flags & 262144 /* SymbolFlags.TypeParameter */) {
+ return 4 /* TokenType.typeParameter */;
}
var decl = symbol.valueDeclaration || symbol.declarations && symbol.declarations[0];
if (decl && ts.isBindingElement(decl)) {
@@ -129117,17 +131056,17 @@ var ts;
}
function reclassifyByType(typeChecker, node, typeIdx) {
// type based classifications
- if (typeIdx === 7 /* variable */ || typeIdx === 9 /* property */ || typeIdx === 6 /* parameter */) {
+ if (typeIdx === 7 /* TokenType.variable */ || typeIdx === 9 /* TokenType.property */ || typeIdx === 6 /* TokenType.parameter */) {
var type_1 = typeChecker.getTypeAtLocation(node);
if (type_1) {
var test = function (condition) {
return condition(type_1) || type_1.isUnion() && type_1.types.some(condition);
};
- if (typeIdx !== 6 /* parameter */ && test(function (t) { return t.getConstructSignatures().length > 0; })) {
- return 0 /* class */;
+ if (typeIdx !== 6 /* TokenType.parameter */ && test(function (t) { return t.getConstructSignatures().length > 0; })) {
+ return 0 /* TokenType.class */;
}
if (test(function (t) { return t.getCallSignatures().length > 0; }) && !test(function (t) { return t.getProperties().length > 0; }) || isExpressionInCallExpression(node)) {
- return typeIdx === 9 /* property */ ? 11 /* member */ : 10 /* function */;
+ return typeIdx === 9 /* TokenType.property */ ? 11 /* TokenType.member */ : 10 /* TokenType.function */;
}
}
}
@@ -129169,25 +131108,25 @@ var ts;
return (ts.isQualifiedName(node.parent) && node.parent.right === node) || (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node);
}
var tokenFromDeclarationMapping = new ts.Map([
- [253 /* VariableDeclaration */, 7 /* variable */],
- [163 /* Parameter */, 6 /* parameter */],
- [166 /* PropertyDeclaration */, 9 /* property */],
- [260 /* ModuleDeclaration */, 3 /* namespace */],
- [259 /* EnumDeclaration */, 1 /* enum */],
- [297 /* EnumMember */, 8 /* enumMember */],
- [256 /* ClassDeclaration */, 0 /* class */],
- [168 /* MethodDeclaration */, 11 /* member */],
- [255 /* FunctionDeclaration */, 10 /* function */],
- [212 /* FunctionExpression */, 10 /* function */],
- [167 /* MethodSignature */, 11 /* member */],
- [171 /* GetAccessor */, 9 /* property */],
- [172 /* SetAccessor */, 9 /* property */],
- [165 /* PropertySignature */, 9 /* property */],
- [257 /* InterfaceDeclaration */, 2 /* interface */],
- [258 /* TypeAliasDeclaration */, 5 /* type */],
- [162 /* TypeParameter */, 4 /* typeParameter */],
- [294 /* PropertyAssignment */, 9 /* property */],
- [295 /* ShorthandPropertyAssignment */, 9 /* property */]
+ [254 /* SyntaxKind.VariableDeclaration */, 7 /* TokenType.variable */],
+ [164 /* SyntaxKind.Parameter */, 6 /* TokenType.parameter */],
+ [167 /* SyntaxKind.PropertyDeclaration */, 9 /* TokenType.property */],
+ [261 /* SyntaxKind.ModuleDeclaration */, 3 /* TokenType.namespace */],
+ [260 /* SyntaxKind.EnumDeclaration */, 1 /* TokenType.enum */],
+ [299 /* SyntaxKind.EnumMember */, 8 /* TokenType.enumMember */],
+ [257 /* SyntaxKind.ClassDeclaration */, 0 /* TokenType.class */],
+ [169 /* SyntaxKind.MethodDeclaration */, 11 /* TokenType.member */],
+ [256 /* SyntaxKind.FunctionDeclaration */, 10 /* TokenType.function */],
+ [213 /* SyntaxKind.FunctionExpression */, 10 /* TokenType.function */],
+ [168 /* SyntaxKind.MethodSignature */, 11 /* TokenType.member */],
+ [172 /* SyntaxKind.GetAccessor */, 9 /* TokenType.property */],
+ [173 /* SyntaxKind.SetAccessor */, 9 /* TokenType.property */],
+ [166 /* SyntaxKind.PropertySignature */, 9 /* TokenType.property */],
+ [258 /* SyntaxKind.InterfaceDeclaration */, 2 /* TokenType.interface */],
+ [259 /* SyntaxKind.TypeAliasDeclaration */, 5 /* TokenType.type */],
+ [163 /* SyntaxKind.TypeParameter */, 4 /* TokenType.typeParameter */],
+ [296 /* SyntaxKind.PropertyAssignment */, 9 /* TokenType.property */],
+ [297 /* SyntaxKind.ShorthandPropertyAssignment */, 9 /* TokenType.property */]
]);
})(v2020 = classifier.v2020 || (classifier.v2020 = {}));
})(classifier = ts.classifier || (ts.classifier = {}));
@@ -129218,19 +131157,19 @@ var ts;
}
var optionalReplacementSpan = ts.createTextSpanFromStringLiteralLikeContent(contextToken);
switch (completion.kind) {
- case 0 /* Paths */:
+ case 0 /* StringLiteralCompletionKind.Paths */:
return convertPathCompletions(completion.paths);
- case 1 /* Properties */: {
+ case 1 /* StringLiteralCompletionKind.Properties */: {
var entries = ts.createSortedArray();
- Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options,
+ Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ScriptTarget.ESNext */, log, 4 /* CompletionKind.String */, preferences, options,
/*formatContext*/ undefined); // Target will not be used, so arbitrary
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries };
}
- case 2 /* Types */: {
+ case 2 /* StringLiteralCompletionKind.Types */: {
var entries = completion.types.map(function (type) { return ({
name: type.value,
- kindModifiers: "" /* none */,
- kind: "string" /* string */,
+ kindModifiers: "" /* ScriptElementKindModifier.none */,
+ kind: "string" /* ScriptElementKind.string */,
sortText: Completions.SortText.LocationPriority,
replacementSpan: ts.getReplacementSpanForContextToken(contextToken)
}); });
@@ -129249,16 +131188,16 @@ var ts;
StringCompletions.getStringLiteralCompletionDetails = getStringLiteralCompletionDetails;
function stringLiteralCompletionDetails(name, location, completion, sourceFile, checker, cancellationToken) {
switch (completion.kind) {
- case 0 /* Paths */: {
+ case 0 /* StringLiteralCompletionKind.Paths */: {
var match = ts.find(completion.paths, function (p) { return p.name === name; });
return match && Completions.createCompletionDetails(name, kindModifiersFromExtension(match.extension), match.kind, [ts.textPart(name)]);
}
- case 1 /* Properties */: {
+ case 1 /* StringLiteralCompletionKind.Properties */: {
var match = ts.find(completion.symbols, function (s) { return s.name === name; });
return match && Completions.createCompletionDetailsForSymbol(match, checker, sourceFile, location, cancellationToken);
}
- case 2 /* Types */:
- return ts.find(completion.types, function (t) { return t.value === name; }) ? Completions.createCompletionDetails(name, "" /* none */, "type" /* typeElement */, [ts.textPart(name)]) : undefined;
+ case 2 /* StringLiteralCompletionKind.Types */:
+ return ts.find(completion.types, function (t) { return t.value === name; }) ? Completions.createCompletionDetails(name, "" /* ScriptElementKindModifier.none */, "type" /* ScriptElementKind.typeElement */, [ts.textPart(name)]) : undefined;
default:
return ts.Debug.assertNever(completion);
}
@@ -129274,20 +131213,20 @@ var ts;
}
function kindModifiersFromExtension(extension) {
switch (extension) {
- case ".d.ts" /* Dts */: return ".d.ts" /* dtsModifier */;
- case ".js" /* Js */: return ".js" /* jsModifier */;
- case ".json" /* Json */: return ".json" /* jsonModifier */;
- case ".jsx" /* Jsx */: return ".jsx" /* jsxModifier */;
- case ".ts" /* Ts */: return ".ts" /* tsModifier */;
- case ".tsx" /* Tsx */: return ".tsx" /* tsxModifier */;
- case ".d.mts" /* Dmts */: return ".d.mts" /* dmtsModifier */;
- case ".mjs" /* Mjs */: return ".mjs" /* mjsModifier */;
- case ".mts" /* Mts */: return ".mts" /* mtsModifier */;
- case ".d.cts" /* Dcts */: return ".d.cts" /* dctsModifier */;
- case ".cjs" /* Cjs */: return ".cjs" /* cjsModifier */;
- case ".cts" /* Cts */: return ".cts" /* ctsModifier */;
- case ".tsbuildinfo" /* TsBuildInfo */: return ts.Debug.fail("Extension ".concat(".tsbuildinfo" /* TsBuildInfo */, " is unsupported."));
- case undefined: return "" /* none */;
+ case ".d.ts" /* Extension.Dts */: return ".d.ts" /* ScriptElementKindModifier.dtsModifier */;
+ case ".js" /* Extension.Js */: return ".js" /* ScriptElementKindModifier.jsModifier */;
+ case ".json" /* Extension.Json */: return ".json" /* ScriptElementKindModifier.jsonModifier */;
+ case ".jsx" /* Extension.Jsx */: return ".jsx" /* ScriptElementKindModifier.jsxModifier */;
+ case ".ts" /* Extension.Ts */: return ".ts" /* ScriptElementKindModifier.tsModifier */;
+ case ".tsx" /* Extension.Tsx */: return ".tsx" /* ScriptElementKindModifier.tsxModifier */;
+ case ".d.mts" /* Extension.Dmts */: return ".d.mts" /* ScriptElementKindModifier.dmtsModifier */;
+ case ".mjs" /* Extension.Mjs */: return ".mjs" /* ScriptElementKindModifier.mjsModifier */;
+ case ".mts" /* Extension.Mts */: return ".mts" /* ScriptElementKindModifier.mtsModifier */;
+ case ".d.cts" /* Extension.Dcts */: return ".d.cts" /* ScriptElementKindModifier.dctsModifier */;
+ case ".cjs" /* Extension.Cjs */: return ".cjs" /* ScriptElementKindModifier.cjsModifier */;
+ case ".cts" /* Extension.Cts */: return ".cts" /* ScriptElementKindModifier.ctsModifier */;
+ case ".tsbuildinfo" /* Extension.TsBuildInfo */: return ts.Debug.fail("Extension ".concat(".tsbuildinfo" /* Extension.TsBuildInfo */, " is unsupported."));
+ case undefined: return "" /* ScriptElementKindModifier.none */;
default:
return ts.Debug.assertNever(extension);
}
@@ -129301,18 +131240,18 @@ var ts;
function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host, preferences) {
var parent = walkUpParentheses(node.parent);
switch (parent.kind) {
- case 195 /* LiteralType */: {
+ case 196 /* SyntaxKind.LiteralType */: {
var grandParent = walkUpParentheses(parent.parent);
switch (grandParent.kind) {
- case 177 /* TypeReference */: {
+ case 178 /* SyntaxKind.TypeReference */: {
var typeReference_1 = grandParent;
var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; });
if (typeArgument) {
- return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false };
+ return { kind: 2 /* StringLiteralCompletionKind.Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false };
}
return undefined;
}
- case 193 /* IndexedAccessType */:
+ case 194 /* SyntaxKind.IndexedAccessType */:
// Get all apparent property names
// i.e. interface Foo {
// foo: string;
@@ -129324,21 +131263,21 @@ var ts;
return undefined;
}
return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(objectType));
- case 199 /* ImportType */:
- return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) };
- case 186 /* UnionType */: {
+ case 200 /* SyntaxKind.ImportType */:
+ return { kind: 0 /* StringLiteralCompletionKind.Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) };
+ case 187 /* SyntaxKind.UnionType */: {
if (!ts.isTypeReferenceNode(grandParent.parent)) {
return undefined;
}
var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(grandParent, parent);
var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(grandParent)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); });
- return { kind: 2 /* Types */, types: types, isNewIdentifier: false };
+ return { kind: 2 /* StringLiteralCompletionKind.Types */, types: types, isNewIdentifier: false };
}
default:
return undefined;
}
}
- case 294 /* PropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) {
// Get quoted name of properties of the object literal expression
// i.e. interface ConfigFiles {
@@ -129355,7 +131294,7 @@ var ts;
return stringLiteralCompletionsForObjectLiteral(typeChecker, parent.parent);
}
return fromContextualType();
- case 206 /* ElementAccessExpression */: {
+ case 207 /* SyntaxKind.ElementAccessExpression */: {
var _b = parent, expression = _b.expression, argumentExpression = _b.argumentExpression;
if (node === ts.skipParentheses(argumentExpression)) {
// Get all names of properties on the expression
@@ -129368,40 +131307,41 @@ var ts;
}
return undefined;
}
- case 207 /* CallExpression */:
- case 208 /* NewExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
+ case 285 /* SyntaxKind.JsxAttribute */:
if (!isRequireCallArgument(node) && !ts.isImportCall(parent)) {
- var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile);
+ var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* SyntaxKind.JsxAttribute */ ? parent.parent : node, position, sourceFile);
// Get string literal completions from specialized signatures of the target
// i.e. declare function f(a: 'A');
// f("/*completion position*/")
- return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType();
+ return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) : fromContextualType();
}
// falls through (is `require("")` or `require(""` or `import("")`)
- case 265 /* ImportDeclaration */:
- case 271 /* ExportDeclaration */:
- case 276 /* ExternalModuleReference */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
+ case 277 /* SyntaxKind.ExternalModuleReference */:
// Get all known external module names or complete a path to a module
// i.e. import * as ns from "/*completion position*/";
// var y = import("/*completion position*/");
// import x = require("/*completion position*/");
// var y = require("/*completion position*/");
// export * from "/*completion position*/";
- return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) };
+ return { kind: 0 /* StringLiteralCompletionKind.Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) };
default:
return fromContextualType();
}
function fromContextualType() {
// Get completion for string literal from string literal type
// i.e. var x: "hi" | "hello" = "/*completion position*/"
- return { kind: 2 /* Types */, types: getStringLiteralTypes(ts.getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false };
+ return { kind: 2 /* StringLiteralCompletionKind.Types */, types: getStringLiteralTypes(ts.getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false };
}
}
function walkUpParentheses(node) {
switch (node.kind) {
- case 190 /* ParenthesizedType */:
+ case 191 /* SyntaxKind.ParenthesizedType */:
return ts.walkUpParenthesizedTypes(node);
- case 211 /* ParenthesizedExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
return ts.walkUpParenthesizedExpressions(node);
default:
return node;
@@ -129412,23 +131352,30 @@ var ts;
return type !== current && ts.isLiteralTypeNode(type) && ts.isStringLiteral(type.literal) ? type.literal.text : undefined;
});
}
- function getStringLiteralCompletionsFromSignature(argumentInfo, checker) {
+ function getStringLiteralCompletionsFromSignature(call, arg, argumentInfo, checker) {
var isNewIdentifier = false;
var uniques = new ts.Map();
var candidates = [];
- checker.getResolvedSignature(argumentInfo.invocation, candidates, argumentInfo.argumentCount);
+ var editingArgument = ts.isJsxOpeningLikeElement(call) ? ts.Debug.checkDefined(ts.findAncestor(arg.parent, ts.isJsxAttribute)) : arg;
+ checker.getResolvedSignatureForStringLiteralCompletions(call, editingArgument, candidates);
var types = ts.flatMap(candidates, function (candidate) {
if (!ts.signatureHasRestParameter(candidate) && argumentInfo.argumentCount > candidate.parameters.length)
return;
var type = candidate.getTypeParameterAtPosition(argumentInfo.argumentIndex);
- isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */);
+ if (ts.isJsxOpeningLikeElement(call)) {
+ var propType = checker.getTypeOfPropertyOfType(type, editingArgument.name.text);
+ if (propType) {
+ type = propType;
+ }
+ }
+ isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* TypeFlags.String */);
return getStringLiteralTypes(type, uniques);
});
- return { kind: 2 /* Types */, types: types, isNewIdentifier: isNewIdentifier };
+ return { kind: 2 /* StringLiteralCompletionKind.Types */, types: types, isNewIdentifier: isNewIdentifier };
}
function stringLiteralCompletionsFromProperties(type) {
return type && {
- kind: 1 /* Properties */,
+ kind: 1 /* StringLiteralCompletionKind.Properties */,
symbols: ts.filter(type.getApparentProperties(), function (prop) { return !(prop.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(prop.valueDeclaration)); }),
hasIndexSignature: ts.hasIndexSignature(type)
};
@@ -129437,10 +131384,10 @@ var ts;
var contextualType = checker.getContextualType(objectLiteralExpression);
if (!contextualType)
return undefined;
- var completionsType = checker.getContextualType(objectLiteralExpression, 4 /* Completions */);
+ var completionsType = checker.getContextualType(objectLiteralExpression, 4 /* ContextFlags.Completions */);
var symbols = Completions.getPropertiesForObjectExpression(contextualType, completionsType, objectLiteralExpression, checker);
return {
- kind: 1 /* Properties */,
+ kind: 1 /* StringLiteralCompletionKind.Properties */,
symbols: symbols,
hasIndexSignature: ts.hasIndexSignature(contextualType)
};
@@ -129451,13 +131398,13 @@ var ts;
return ts.emptyArray;
type = ts.skipConstraint(type);
return type.isUnion() ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) :
- type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray;
+ type.isStringLiteral() && !(type.flags & 1024 /* TypeFlags.EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray;
}
function nameAndKind(name, kind, extension) {
return { name: name, kind: kind, extension: extension };
}
function directoryResult(name) {
- return nameAndKind(name, "directory" /* directory */, /*extension*/ undefined);
+ return nameAndKind(name, "directory" /* ScriptElementKind.directory */, /*extension*/ undefined);
}
function addReplacementSpans(text, textStart, names) {
var span = getDirectoryFragmentTextSpan(text, textStart);
@@ -129479,11 +131426,11 @@ var ts;
: getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker);
function getIncludeExtensionOption() {
var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined;
- return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */;
+ return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* IncludeExtensionsOption.ModuleSpecifierCompletion */ : 0 /* IncludeExtensionsOption.Exclude */;
}
}
function getExtensionOptions(compilerOptions, includeExtensionsOption) {
- if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* Exclude */; }
+ if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* IncludeExtensionsOption.Exclude */; }
return { extensions: ts.flatten(getSupportedExtensionsForModuleResolution(compilerOptions)), includeExtensionsOption: includeExtensionsOption };
}
function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, includeExtensions) {
@@ -129495,9 +131442,18 @@ var ts;
return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath);
}
}
+ function isEmitResolutionKindUsingNodeModules(compilerOptions) {
+ return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs ||
+ ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 ||
+ ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext;
+ }
+ function isEmitModuleResolutionRespectingExportMaps(compilerOptions) {
+ return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 ||
+ ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext;
+ }
function getSupportedExtensionsForModuleResolution(compilerOptions) {
var extensions = ts.getSupportedExtensions(compilerOptions);
- return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs ?
+ return isEmitResolutionKindUsingNodeModules(compilerOptions) ?
ts.getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, extensions) :
extensions;
}
@@ -129567,16 +131523,16 @@ var ts;
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
var filePath = files_1[_i];
filePath = ts.normalizePath(filePath);
- if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) {
+ if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* Comparison.EqualTo */) {
continue;
}
var foundFileName = void 0;
var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(filePath, host.getCompilationSettings());
- if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) {
+ if (includeExtensionsOption === 0 /* IncludeExtensionsOption.Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Extension.Json */, ".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */])) {
foundFileName = ts.removeFileExtension(ts.getBaseFileName(filePath));
foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath));
}
- else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) {
+ else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */]) || includeExtensionsOption === 2 /* IncludeExtensionsOption.ModuleSpecifierCompletion */) && outputExtension) {
foundFileName = ts.changeExtension(ts.getBaseFileName(filePath), outputExtension);
foundFiles.set(foundFileName, outputExtension);
}
@@ -129586,7 +131542,7 @@ var ts;
}
}
foundFiles.forEach(function (ext, foundFile) {
- result.push(nameAndKind(foundFile, "script" /* scriptElement */, ext));
+ result.push(nameAndKind(foundFile, "script" /* ScriptElementKind.scriptElement */, ext));
});
}
// If possible, get folder completion as well
@@ -129657,10 +131613,10 @@ var ts;
var fragmentDirectory = getFragmentDirectory(fragment);
for (var _i = 0, _a = getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker); _i < _a.length; _i++) {
var ambientName = _a[_i];
- result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined));
+ result.push(nameAndKind(ambientName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined));
}
getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result);
- if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs) {
+ if (isEmitResolutionKindUsingNodeModules(compilerOptions)) {
// If looking for a global package name, don't just include everything in `node_modules` because that includes dependencies' own dependencies.
// (But do if we didn't find anything, e.g. 'package.json' missing.)
var foundGlobal = false;
@@ -129668,7 +131624,7 @@ var ts;
var _loop_4 = function (moduleName) {
if (!result.some(function (entry) { return entry.name === moduleName; })) {
foundGlobal = true;
- result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined));
+ result.push(nameAndKind(moduleName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined));
}
};
for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) {
@@ -129677,12 +131633,68 @@ var ts;
}
}
if (!foundGlobal) {
- ts.forEachAncestorDirectory(scriptPath, function (ancestor) {
+ var ancestorLookup = function (ancestor) {
var nodeModules = ts.combinePaths(ancestor, "node_modules");
if (ts.tryDirectoryExists(host, nodeModules)) {
getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*exclude*/ undefined, result);
}
- });
+ };
+ if (fragmentDirectory && isEmitModuleResolutionRespectingExportMaps(compilerOptions)) {
+ var nodeModulesDirectoryLookup_1 = ancestorLookup;
+ ancestorLookup = function (ancestor) {
+ var components = ts.getPathComponents(fragment);
+ components.shift(); // shift off empty root
+ var packagePath = components.shift();
+ if (!packagePath) {
+ return nodeModulesDirectoryLookup_1(ancestor);
+ }
+ if (ts.startsWith(packagePath, "@")) {
+ var subName = components.shift();
+ if (!subName) {
+ return nodeModulesDirectoryLookup_1(ancestor);
+ }
+ packagePath = ts.combinePaths(packagePath, subName);
+ }
+ var packageFile = ts.combinePaths(ancestor, "node_modules", packagePath, "package.json");
+ if (ts.tryFileExists(host, packageFile)) {
+ var packageJson = ts.readJson(packageFile, host);
+ var exports = packageJson.exports;
+ if (exports) {
+ if (typeof exports !== "object" || exports === null) { // eslint-disable-line no-null/no-null
+ return; // null exports or entrypoint only, no sub-modules available
+ }
+ var keys = ts.getOwnKeys(exports);
+ var fragmentSubpath_1 = components.join("/");
+ var processedKeys = ts.mapDefined(keys, function (k) {
+ if (k === ".")
+ return undefined;
+ if (!ts.startsWith(k, "./"))
+ return undefined;
+ var subpath = k.substring(2);
+ if (!ts.startsWith(subpath, fragmentSubpath_1))
+ return undefined;
+ // subpath is a valid export (barring conditions, which we don't currently check here)
+ if (!ts.stringContains(subpath, "*")) {
+ return subpath;
+ }
+ // pattern export - only return everything up to the `*`, so the user can autocomplete, then
+ // keep filling in the pattern (we could speculatively return a list of options by hitting disk,
+ // but conditions will make that somewhat awkward, as each condition may have a different set of possible
+ // options for the `*`.
+ return subpath.slice(0, subpath.indexOf("*"));
+ });
+ ts.forEach(processedKeys, function (k) {
+ if (k) {
+ result.push(nameAndKind(k, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined));
+ }
+ });
+ return;
+ }
+ }
+ return nodeModulesDirectoryLookup_1(ancestor);
+ };
+ }
+ ts.forEachAncestorDirectory(scriptPath, ancestorLookup);
}
}
return result;
@@ -129732,7 +131744,7 @@ var ts;
var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) {
var extension = ts.tryGetExtensionFromPath(match);
var name = trimPrefixAndSuffix(match);
- return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension);
+ return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* ScriptElementKind.scriptElement */, extension);
});
var directories = ts.mapDefined(ts.tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) {
var name = trimPrefixAndSuffix(dir);
@@ -129777,7 +131789,7 @@ var ts;
}
var prefix = match[1], kind = match[2], toComplete = match[3];
var scriptPath = ts.getDirectoryPath(sourceFile.path);
- var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* Include */), host, sourceFile.path)
+ var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* IncludeExtensionsOption.Include */), host, sourceFile.path)
: kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions))
: ts.Debug.fail();
return addReplacementSpans(toComplete, range.pos + prefix.length, names);
@@ -129808,7 +131820,7 @@ var ts;
continue;
if (fragmentDirectory === undefined) {
if (!seen.has(packageName)) {
- result.push(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined));
+ result.push(nameAndKind(packageName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined));
seen.set(packageName, true);
}
}
@@ -129850,14 +131862,14 @@ var ts;
var offset = index !== -1 ? index + 1 : 0;
// If the range is an identifier, span is unnecessary.
var length = text.length - offset;
- return length === 0 || ts.isIdentifierText(text.substr(offset, length), 99 /* ESNext */) ? undefined : ts.createTextSpan(textStart + offset, length);
+ return length === 0 || ts.isIdentifierText(text.substr(offset, length), 99 /* ScriptTarget.ESNext */) ? undefined : ts.createTextSpan(textStart + offset, length);
}
// Returns true if the path is explicitly relative to the script (i.e. relative to . or ..)
function isPathRelativeToScript(path) {
- if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* dot */) {
- var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* dot */ ? 2 : 1;
+ if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* CharacterCodes.dot */) {
+ var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* CharacterCodes.dot */ ? 2 : 1;
var slashCharCode = path.charCodeAt(slashIndex);
- return slashCharCode === 47 /* slash */ || slashCharCode === 92 /* backslash */;
+ return slashCharCode === 47 /* CharacterCodes.slash */ || slashCharCode === 92 /* CharacterCodes.backslash */;
}
return false;
}
@@ -129898,42 +131910,28 @@ var ts;
// Exported only for tests
Completions.moduleSpecifierResolutionLimit = 100;
Completions.moduleSpecifierResolutionCacheAttemptLimit = 1000;
- // NOTE: Make sure that each entry has the exact same number of digits
- // since many implementations will sort by string contents,
- // where "10" is considered less than "2".
- var SortText;
- (function (SortText) {
- SortText["LocalDeclarationPriority"] = "10";
- SortText["LocationPriority"] = "11";
- SortText["OptionalMember"] = "12";
- SortText["MemberDeclaredBySpreadAssignment"] = "13";
- SortText["SuggestedClassMembers"] = "14";
- SortText["GlobalsOrKeywords"] = "15";
- SortText["AutoImportSuggestions"] = "16";
- SortText["JavascriptIdentifiers"] = "17";
- SortText["DeprecatedLocalDeclarationPriority"] = "18";
- SortText["DeprecatedLocationPriority"] = "19";
- SortText["DeprecatedOptionalMember"] = "20";
- SortText["DeprecatedMemberDeclaredBySpreadAssignment"] = "21";
- SortText["DeprecatedSuggestedClassMembers"] = "22";
- SortText["DeprecatedGlobalsOrKeywords"] = "23";
- SortText["DeprecatedAutoImportSuggestions"] = "24";
- })(SortText = Completions.SortText || (Completions.SortText = {}));
- var SortTextId;
- (function (SortTextId) {
- SortTextId[SortTextId["LocalDeclarationPriority"] = 10] = "LocalDeclarationPriority";
- SortTextId[SortTextId["LocationPriority"] = 11] = "LocationPriority";
- SortTextId[SortTextId["OptionalMember"] = 12] = "OptionalMember";
- SortTextId[SortTextId["MemberDeclaredBySpreadAssignment"] = 13] = "MemberDeclaredBySpreadAssignment";
- SortTextId[SortTextId["SuggestedClassMembers"] = 14] = "SuggestedClassMembers";
- SortTextId[SortTextId["GlobalsOrKeywords"] = 15] = "GlobalsOrKeywords";
- SortTextId[SortTextId["AutoImportSuggestions"] = 16] = "AutoImportSuggestions";
- // Don't use these directly.
- SortTextId[SortTextId["_JavaScriptIdentifiers"] = 17] = "_JavaScriptIdentifiers";
- SortTextId[SortTextId["_DeprecatedStart"] = 18] = "_DeprecatedStart";
- SortTextId[SortTextId["_First"] = 10] = "_First";
- SortTextId[SortTextId["DeprecatedOffset"] = 8] = "DeprecatedOffset";
- })(SortTextId || (SortTextId = {}));
+ Completions.SortText = {
+ // Presets
+ LocalDeclarationPriority: "10",
+ LocationPriority: "11",
+ OptionalMember: "12",
+ MemberDeclaredBySpreadAssignment: "13",
+ SuggestedClassMembers: "14",
+ GlobalsOrKeywords: "15",
+ AutoImportSuggestions: "16",
+ ClassMemberSnippets: "17",
+ JavascriptIdentifiers: "18",
+ // Transformations
+ Deprecated: function (sortText) {
+ return "z" + sortText;
+ },
+ ObjectLiteralProperty: function (presetSortText, symbolDisplayName) {
+ return "".concat(presetSortText, "\0").concat(symbolDisplayName, "\0");
+ },
+ SortBelow: function (sortText) {
+ return sortText + "1";
+ },
+ };
/**
* Special values for `CompletionInfo['source']` used to disambiguate
* completion items with the same `name`. (Each completion item must
@@ -129953,6 +131951,8 @@ var ts;
CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
/** A type-only import that needs to be promoted in order to be used at the completion location */
CompletionSource["TypeOnlyAlias"] = "TypeOnlyAlias/";
+ /** Auto-import that comes attached to an object literal method snippet */
+ CompletionSource["ObjectLiteralMethodSnippet"] = "ObjectLiteralMethodSnippet/";
})(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
var SymbolOriginInfoKind;
(function (SymbolOriginInfoKind) {
@@ -129963,20 +131963,21 @@ var ts;
SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable";
SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport";
SymbolOriginInfoKind[SymbolOriginInfoKind["TypeOnlyAlias"] = 64] = "TypeOnlyAlias";
+ SymbolOriginInfoKind[SymbolOriginInfoKind["ObjectLiteralMethod"] = 128] = "ObjectLiteralMethod";
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport";
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport";
})(SymbolOriginInfoKind || (SymbolOriginInfoKind = {}));
function originIsThisType(origin) {
- return !!(origin.kind & 1 /* ThisType */);
+ return !!(origin.kind & 1 /* SymbolOriginInfoKind.ThisType */);
}
function originIsSymbolMember(origin) {
- return !!(origin.kind & 2 /* SymbolMember */);
+ return !!(origin.kind & 2 /* SymbolOriginInfoKind.SymbolMember */);
}
function originIsExport(origin) {
- return !!(origin && origin.kind & 4 /* Export */);
+ return !!(origin && origin.kind & 4 /* SymbolOriginInfoKind.Export */);
}
function originIsResolvedExport(origin) {
- return !!(origin && origin.kind === 32 /* ResolvedExport */);
+ return !!(origin && origin.kind === 32 /* SymbolOriginInfoKind.ResolvedExport */);
}
function originIncludesSymbolName(origin) {
return originIsExport(origin) || originIsResolvedExport(origin);
@@ -129985,13 +131986,16 @@ var ts;
return (originIsExport(origin) || originIsResolvedExport(origin)) && !!origin.isFromPackageJson;
}
function originIsPromise(origin) {
- return !!(origin.kind & 8 /* Promise */);
+ return !!(origin.kind & 8 /* SymbolOriginInfoKind.Promise */);
}
function originIsNullableMember(origin) {
- return !!(origin.kind & 16 /* Nullable */);
+ return !!(origin.kind & 16 /* SymbolOriginInfoKind.Nullable */);
}
function originIsTypeOnlyAlias(origin) {
- return !!(origin && origin.kind & 64 /* TypeOnlyAlias */);
+ return !!(origin && origin.kind & 64 /* SymbolOriginInfoKind.TypeOnlyAlias */);
+ }
+ function originIsObjectLiteralMethod(origin) {
+ return !!(origin && origin.kind & 128 /* SymbolOriginInfoKind.ObjectLiteralMethod */);
}
var KeywordCompletionFilters;
(function (KeywordCompletionFilters) {
@@ -130004,7 +132008,7 @@ var ts;
KeywordCompletionFilters[KeywordCompletionFilters["TypeAssertionKeywords"] = 6] = "TypeAssertionKeywords";
KeywordCompletionFilters[KeywordCompletionFilters["TypeKeywords"] = 7] = "TypeKeywords";
KeywordCompletionFilters[KeywordCompletionFilters["TypeKeyword"] = 8] = "TypeKeyword";
- KeywordCompletionFilters[KeywordCompletionFilters["Last"] = 7] = "Last";
+ KeywordCompletionFilters[KeywordCompletionFilters["Last"] = 8] = "Last";
})(KeywordCompletionFilters || (KeywordCompletionFilters = {}));
var GlobalsSearch;
(function (GlobalsSearch) {
@@ -130012,43 +132016,54 @@ var ts;
GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success";
GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail";
})(GlobalsSearch || (GlobalsSearch = {}));
- function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, preferences, isForImportStatementCompletion, cb) {
+ function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) {
var _a, _b, _c;
var start = ts.timestamp();
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
- var resolutionLimitExceeded = false;
+ // Under `--moduleResolution nodenext`, we have to resolve module specifiers up front, because
+ // package.json exports can mean we *can't* resolve a module specifier (that doesn't include a
+ // relative path into node_modules), and we want to filter those completions out entirely.
+ // Import statement completions always need specifier resolution because the module specifier is
+ // part of their `insertText`, not the `codeActions` creating edits away from the cursor.
+ var needsFullResolution = isForImportStatementCompletion || ts.moduleResolutionRespectsExports(ts.getEmitModuleResolutionKind(program.getCompilerOptions()));
+ var skippedAny = false;
var ambientCount = 0;
var resolvedCount = 0;
var resolvedFromCacheCount = 0;
var cacheAttemptCount = 0;
- var result = cb({ tryResolve: tryResolve, resolutionLimitExceeded: function () { return resolutionLimitExceeded; } });
+ var result = cb({
+ tryResolve: tryResolve,
+ skippedAny: function () { return skippedAny; },
+ resolvedAny: function () { return resolvedCount > 0; },
+ resolvedBeyondLimit: function () { return resolvedCount > Completions.moduleSpecifierResolutionLimit; },
+ });
var hitRateMessage = cacheAttemptCount ? " (".concat((resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1), "% hit rate)") : "";
(_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "".concat(logPrefix, ": resolved ").concat(resolvedCount, " module specifiers, plus ").concat(ambientCount, " ambient and ").concat(resolvedFromCacheCount, " from cache").concat(hitRateMessage));
- (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "".concat(logPrefix, ": response is ").concat(resolutionLimitExceeded ? "incomplete" : "complete"));
+ (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "".concat(logPrefix, ": response is ").concat(skippedAny ? "incomplete" : "complete"));
(_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, "".concat(logPrefix, ": ").concat(ts.timestamp() - start));
return result;
- function tryResolve(exportInfo, isFromAmbientModule) {
+ function tryResolve(exportInfo, symbolName, isFromAmbientModule) {
if (isFromAmbientModule) {
- var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences);
+ var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences);
if (result_1) {
ambientCount++;
}
- return result_1;
+ return result_1 || "failed";
}
- var shouldResolveModuleSpecifier = isForImportStatementCompletion || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
+ var shouldResolveModuleSpecifier = needsFullResolution || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit;
var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache)
- ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
+ ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
: undefined;
if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) {
- resolutionLimitExceeded = true;
+ skippedAny = true;
}
resolvedCount += (result === null || result === void 0 ? void 0 : result.computedWithoutCacheCount) || 0;
- resolvedFromCacheCount += exportInfo.length - resolvedCount;
+ resolvedFromCacheCount += exportInfo.length - ((result === null || result === void 0 ? void 0 : result.computedWithoutCacheCount) || 0);
if (shouldGetModuleSpecifierFromCache) {
cacheAttemptCount++;
}
- return result;
+ return result || (needsFullResolution ? "failed" : "skipped");
}
}
function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext) {
@@ -130068,7 +132083,7 @@ var ts;
// we can continue it from the cached previous response.
var compilerOptions = program.getCompilerOptions();
var incompleteCompletionsCache = preferences.allowIncompleteCompletions ? (_a = host.getIncompleteCompletionsCache) === null || _a === void 0 ? void 0 : _a.call(host) : undefined;
- if (incompleteCompletionsCache && completionKind === 3 /* TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) {
+ if (incompleteCompletionsCache && completionKind === 3 /* CompletionTriggerKind.TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) {
var incompleteContinuation = continuePreviousIncompleteResponse(incompleteCompletionsCache, sourceFile, previousToken, program, host, preferences, cancellationToken);
if (incompleteContinuation) {
return incompleteContinuation;
@@ -130082,29 +132097,29 @@ var ts;
return stringCompletions;
}
if (previousToken && ts.isBreakOrContinueStatement(previousToken.parent)
- && (previousToken.kind === 81 /* BreakKeyword */ || previousToken.kind === 86 /* ContinueKeyword */ || previousToken.kind === 79 /* Identifier */)) {
+ && (previousToken.kind === 81 /* SyntaxKind.BreakKeyword */ || previousToken.kind === 86 /* SyntaxKind.ContinueKeyword */ || previousToken.kind === 79 /* SyntaxKind.Identifier */)) {
return getLabelCompletionAtPosition(previousToken.parent);
}
- var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, preferences, /*detailsEntryId*/ undefined, host, cancellationToken);
+ var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, /*detailsEntryId*/ undefined, host, formatContext, cancellationToken);
if (!completionData) {
return undefined;
}
switch (completionData.kind) {
- case 0 /* Data */:
+ case 0 /* CompletionDataKind.Data */:
var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position);
if (response === null || response === void 0 ? void 0 : response.isIncomplete) {
incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response);
}
return response;
- case 1 /* JsDocTagName */:
+ case 1 /* CompletionDataKind.JsDocTagName */:
// If the current position is a jsDoc tag name, only tag names should be provided for completion
return jsdocCompletionInfo(ts.JsDoc.getJSDocTagNameCompletions());
- case 2 /* JsDocTag */:
+ case 2 /* CompletionDataKind.JsDocTag */:
// If the current position is a jsDoc tag, only tags should be provided for completion
return jsdocCompletionInfo(ts.JsDoc.getJSDocTagCompletions());
- case 3 /* JsDocParameterName */:
+ case 3 /* CompletionDataKind.JsDocParameterName */:
return jsdocCompletionInfo(ts.JsDoc.getJSDocParameterNameCompletions(completionData.tag));
- case 4 /* Keywords */:
+ case 4 /* CompletionDataKind.Keywords */:
return specificKeywordCompletionInfo(completionData.keywordCompletions, completionData.isNewIdentifierLocation);
default:
return ts.Debug.assertNever(completionData);
@@ -130121,16 +132136,16 @@ var ts;
function compareCompletionEntries(entryInArray, entryToInsert) {
var _a, _b;
var result = ts.compareStringsCaseSensitiveUI(entryInArray.sortText, entryToInsert.sortText);
- if (result === 0 /* EqualTo */) {
+ if (result === 0 /* Comparison.EqualTo */) {
result = ts.compareStringsCaseSensitiveUI(entryInArray.name, entryToInsert.name);
}
- if (result === 0 /* EqualTo */ && ((_a = entryInArray.data) === null || _a === void 0 ? void 0 : _a.moduleSpecifier) && ((_b = entryToInsert.data) === null || _b === void 0 ? void 0 : _b.moduleSpecifier)) {
+ if (result === 0 /* Comparison.EqualTo */ && ((_a = entryInArray.data) === null || _a === void 0 ? void 0 : _a.moduleSpecifier) && ((_b = entryToInsert.data) === null || _b === void 0 ? void 0 : _b.moduleSpecifier)) {
// Sort same-named auto-imports by module specifier
result = ts.compareNumberOfDirectorySeparators(entryInArray.data.moduleSpecifier, entryToInsert.data.moduleSpecifier);
}
- if (result === 0 /* EqualTo */) {
+ if (result === 0 /* Comparison.EqualTo */) {
// Fall back to symbol order - if we return `EqualTo`, `insertSorted` will put later symbols first.
- return -1 /* LessThan */;
+ return -1 /* Comparison.LessThan */;
}
return result;
}
@@ -130143,9 +132158,10 @@ var ts;
return undefined;
var lowerCaseTokenText = location.text.toLowerCase();
var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
- var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, preferences,
- /*isForImportStatementCompletion*/ false, function (context) {
+ var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, location.getStart(), preferences,
+ /*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
var entries = ts.mapDefined(previousResponse.entries, function (entry) {
+ var _a;
if (!entry.hasAction || !entry.source || !entry.data || completionEntryDataIsResolved(entry.data)) {
// Not an auto import or already resolved; keep as is
return entry;
@@ -130156,10 +132172,14 @@ var ts;
}
var origin = ts.Debug.checkDefined(getAutoImportSymbolFromCompletionEntryData(entry.name, entry.data, program, host)).origin;
var info = exportMap.get(file.path, entry.data.exportMapKey);
- var result = info && context.tryResolve(info, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name)));
- if (!result)
+ var result = info && context.tryResolve(info, entry.name, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name)));
+ if (result === "skipped")
return entry;
- var newOrigin = __assign(__assign({}, origin), { kind: 32 /* ResolvedExport */, moduleSpecifier: result.moduleSpecifier });
+ if (!result || result === "failed") {
+ (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "Unexpected failure resolving auto import for '".concat(entry.name, "' from '").concat(entry.source, "'"));
+ return undefined;
+ }
+ var newOrigin = __assign(__assign({}, origin), { kind: 32 /* SymbolOriginInfoKind.ResolvedExport */, moduleSpecifier: result.moduleSpecifier });
// Mutating for performance... feels sketchy but nobody else uses the cache,
// so why bother allocating a bunch of new objects?
entry.data = originToCompletionEntryData(newOrigin);
@@ -130167,12 +132187,13 @@ var ts;
entry.sourceDisplay = [ts.textPart(newOrigin.moduleSpecifier)];
return entry;
});
- if (!context.resolutionLimitExceeded()) {
+ if (!context.skippedAny()) {
previousResponse.isIncomplete = undefined;
}
return entries;
});
previousResponse.entries = newEntries;
+ previousResponse.flags = (previousResponse.flags || 0) | 4 /* CompletionInfoFlags.IsContinuation */;
return previousResponse;
}
function jsdocCompletionInfo(entries) {
@@ -130181,9 +132202,9 @@ var ts;
function keywordToCompletionEntry(keyword) {
return {
name: ts.tokenToString(keyword),
- kind: "keyword" /* keyword */,
- kindModifiers: "" /* none */,
- sortText: SortText.GlobalsOrKeywords,
+ kind: "keyword" /* ScriptElementKind.keyword */,
+ kindModifiers: "" /* ScriptElementKindModifier.none */,
+ sortText: Completions.SortText.GlobalsOrKeywords,
};
}
function specificKeywordCompletionInfo(entries, isNewIdentifierLocation) {
@@ -130196,25 +132217,25 @@ var ts;
}
function keywordCompletionData(keywordFilters, filterOutTsOnlyKeywords, isNewIdentifierLocation) {
return {
- kind: 4 /* Keywords */,
+ kind: 4 /* CompletionDataKind.Keywords */,
keywordCompletions: getKeywordCompletions(keywordFilters, filterOutTsOnlyKeywords),
isNewIdentifierLocation: isNewIdentifierLocation,
};
}
function keywordFiltersFromSyntaxKind(keywordCompletion) {
switch (keywordCompletion) {
- case 151 /* TypeKeyword */: return 8 /* TypeKeyword */;
+ case 152 /* SyntaxKind.TypeKeyword */: return 8 /* KeywordCompletionFilters.TypeKeyword */;
default: ts.Debug.fail("Unknown mapping from SyntaxKind to KeywordCompletionFilters");
}
}
function getOptionalReplacementSpan(location) {
// StringLiteralLike locations are handled separately in stringCompletions.ts
- return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
+ return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* SyntaxKind.Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
}
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) {
- var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
+ var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
// Verify if the file is JSX language variant
- if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
+ if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* LanguageVariant.JSX */) {
var completionInfo = getJsxClosingTagCompletion(location, sourceFile);
if (completionInfo) {
return completionInfo;
@@ -130223,21 +132244,21 @@ var ts;
var entries = ts.createSortedArray();
if (isUncheckedFile(sourceFile, compilerOptions)) {
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
- /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
+ /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag);
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
}
else {
- if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
+ if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* KeywordCompletionFilters.None */) {
return undefined;
}
getCompletionEntriesFromSymbols(symbols, entries,
- /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
+ /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag);
}
- if (keywordFilters !== 0 /* None */) {
+ if (keywordFilters !== 0 /* KeywordCompletionFilters.None */) {
var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; }));
for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
var keywordEntry = _a[_i];
- if (!entryNames_1.has(keywordEntry.name)) {
+ if (isTypeOnlyLocation && ts.isTypeKeyword(ts.stringToToken(keywordEntry.name)) || !entryNames_1.has(keywordEntry.name)) {
ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
}
}
@@ -130254,12 +132275,13 @@ var ts;
ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
}
return {
+ flags: completionData.flags,
isGlobalCompletion: isInSnippetScope,
isIncomplete: preferences.allowIncompleteCompletions && hasUnresolvedAutoImports ? true : undefined,
isMemberCompletion: isMemberCompletionKind(completionKind),
isNewIdentifierLocation: isNewIdentifierLocation,
optionalReplacementSpan: getOptionalReplacementSpan(location),
- entries: entries
+ entries: entries,
};
}
function isUncheckedFile(sourceFile, compilerOptions) {
@@ -130267,9 +132289,9 @@ var ts;
}
function isMemberCompletionKind(kind) {
switch (kind) {
- case 0 /* ObjectPropertyDeclaration */:
- case 3 /* MemberLike */:
- case 2 /* PropertyAccess */:
+ case 0 /* CompletionKind.ObjectPropertyDeclaration */:
+ case 3 /* CompletionKind.MemberLike */:
+ case 2 /* CompletionKind.PropertyAccess */:
return true;
default:
return false;
@@ -130279,12 +132301,12 @@ var ts;
// We wanna walk up the tree till we find a JSX closing element
var jsxClosingElement = ts.findAncestor(location, function (node) {
switch (node.kind) {
- case 280 /* JsxClosingElement */:
+ case 281 /* SyntaxKind.JsxClosingElement */:
return true;
- case 43 /* SlashToken */:
- case 31 /* GreaterThanToken */:
- case 79 /* Identifier */:
- case 205 /* PropertyAccessExpression */:
+ case 43 /* SyntaxKind.SlashToken */:
+ case 31 /* SyntaxKind.GreaterThanToken */:
+ case 79 /* SyntaxKind.Identifier */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
return false;
default:
return "quit";
@@ -130303,16 +132325,16 @@ var ts;
// var x = <MainComponent.Child> </ MainComponent /*1*/ >
// var y = <MainComponent.Child> </ /*2*/ MainComponent >
// the completion list at "1" and "2" will contain "MainComponent.Child" with a replacement span of closing tag name
- var hasClosingAngleBracket = !!ts.findChildOfKind(jsxClosingElement, 31 /* GreaterThanToken */, sourceFile);
+ var hasClosingAngleBracket = !!ts.findChildOfKind(jsxClosingElement, 31 /* SyntaxKind.GreaterThanToken */, sourceFile);
var tagName = jsxClosingElement.parent.openingElement.tagName;
var closingTag = tagName.getText(sourceFile);
var fullClosingTag = closingTag + (hasClosingAngleBracket ? "" : ">");
var replacementSpan = ts.createTextSpanFromNode(jsxClosingElement.tagName);
var entry = {
name: fullClosingTag,
- kind: "class" /* classElement */,
+ kind: "class" /* ScriptElementKind.classElement */,
kindModifiers: undefined,
- sortText: SortText.LocationPriority,
+ sortText: Completions.SortText.LocationPriority,
};
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, optionalReplacementSpan: replacementSpan, entries: [entry] };
}
@@ -130329,9 +132351,9 @@ var ts;
uniqueNames.add(realName);
ts.insertSorted(entries, {
name: realName,
- kind: "warning" /* warning */,
+ kind: "warning" /* ScriptElementKind.warning */,
kindModifiers: "",
- sortText: SortText.JavascriptIdentifiers,
+ sortText: Completions.SortText.JavascriptIdentifiers,
isFromUncheckedFile: true
}, compareCompletionEntries);
}
@@ -130342,7 +132364,7 @@ var ts;
ts.isString(literal) ? ts.quote(sourceFile, preferences, literal) : JSON.stringify(literal);
}
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
- return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
+ return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* ScriptElementKind.string */, kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.LocationPriority };
}
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) {
var _a, _b;
@@ -130353,6 +132375,7 @@ var ts;
var source = getSourceFromOrigin(origin);
var sourceDisplay;
var hasAction;
+ var labelDetails;
var typeChecker = program.getTypeChecker();
var insertQuestionDot = origin && originIsNullableMember(origin);
var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess;
@@ -130368,8 +132391,8 @@ var ts;
if (insertQuestionDot || propertyAccessToConvert.questionDotToken) {
insertText = "?.".concat(insertText);
}
- var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile) ||
- ts.findChildOfKind(propertyAccessToConvert, 28 /* QuestionDotToken */, sourceFile);
+ var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* SyntaxKind.DotToken */, sourceFile) ||
+ ts.findChildOfKind(propertyAccessToConvert, 28 /* SyntaxKind.QuestionDotToken */, sourceFile);
if (!dot) {
return undefined;
}
@@ -130404,28 +132427,38 @@ var ts;
isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
}
}
- if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
+ if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* SymbolOriginInfoKind.TypeOnlyAlias */) {
hasAction = true;
}
if (preferences.includeCompletionsWithClassMemberSnippets &&
preferences.includeCompletionsWithInsertText &&
- completionKind === 3 /* MemberLike */ &&
+ completionKind === 3 /* CompletionKind.MemberLike */ &&
isClassLikeMemberCompletion(symbol, location)) {
var importAdder = void 0;
- (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder);
+ (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan);
+ sortText = Completions.SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
hasAction = true;
source = CompletionSource.ClassMemberSnippet;
}
}
+ if (origin && originIsObjectLiteralMethod(origin)) {
+ (insertText = origin.insertText, isSnippet = origin.isSnippet, labelDetails = origin.labelDetails);
+ if (!preferences.useLabelDetailsInCompletionEntries) {
+ name = name + labelDetails.detail;
+ labelDetails = undefined;
+ }
+ source = CompletionSource.ObjectLiteralMethodSnippet;
+ sortText = Completions.SortText.SortBelow(sortText);
+ }
if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
// If is boolean like or undefined, don't return a snippet we want just to return the completion.
if (preferences.jsxAttributeCompletionStyle === "auto"
- && !(type.flags & 528 /* BooleanLike */)
- && !(type.flags & 1048576 /* Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* BooleanLike */); }))) {
- if (type.flags & 402653316 /* StringLike */ || (type.flags & 1048576 /* Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* StringLike */ | 32768 /* Undefined */)); }))) {
+ && !(type.flags & 528 /* TypeFlags.BooleanLike */)
+ && !(type.flags & 1048576 /* TypeFlags.Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* TypeFlags.BooleanLike */); }))) {
+ if (type.flags & 402653316 /* TypeFlags.StringLike */ || (type.flags & 1048576 /* TypeFlags.Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* TypeFlags.StringLike */ | 32768 /* TypeFlags.Undefined */)); }))) {
// If is string like or undefined use quotes
insertText = "".concat(ts.escapeSnippetText(name), "=").concat(ts.quote(sourceFile, preferences, "$1"));
isSnippet = true;
@@ -130465,6 +132498,7 @@ var ts;
insertText: insertText,
replacementSpan: replacementSpan,
sourceDisplay: sourceDisplay,
+ labelDetails: labelDetails,
isSnippet: isSnippet,
isPackageJsonImport: originIsPackageJsonImport(origin) || undefined,
isImportStatementCompletion: !!importCompletionNode || undefined,
@@ -130477,8 +132511,8 @@ var ts;
return false;
}
// Completion symbol must be for a class member.
- var memberFlags = 106500 /* ClassMember */
- & 900095 /* EnumMemberExcludes */;
+ var memberFlags = 106500 /* SymbolFlags.ClassMember */
+ & 900095 /* SymbolFlags.EnumMemberExcludes */;
/* In
`class C {
|
@@ -130516,6 +132550,7 @@ var ts;
return { insertText: name };
}
var isSnippet;
+ var replacementSpan;
var insertText = name;
var checker = program.getTypeChecker();
var sourceFile = location.getSourceFile();
@@ -130536,18 +132571,16 @@ var ts;
// Note: this assumes we won't have more than one body in the completion nodes, which should be the case.
var emptyStmt = ts.factory.createEmptyStatement();
body = ts.factory.createBlock([emptyStmt], /* multiline */ true);
- ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 });
+ ts.setSnippetElement(emptyStmt, { kind: 0 /* SnippetKind.TabStop */, order: 0 });
}
else {
body = ts.factory.createBlock([], /* multiline */ true);
}
- var modifiers = 0 /* None */;
+ var modifiers = 0 /* ModifierFlags.None */;
// Whether the suggested member should be abstract.
// e.g. in `abstract class C { abstract | }`, we should offer abstract method signatures at position `|`.
- // Note: We are relying on checking if the context token is `abstract`,
- // since other visibility modifiers (e.g. `protected`) should come *before* `abstract`.
- // However, that is not true for the e.g. `override` modifier, so this check has its limitations.
- var isAbstract = contextToken && isModifierLike(contextToken) === 126 /* AbstractKeyword */;
+ var _a = getPresentModifiers(contextToken), presentModifiers = _a.modifiers, modifiersSpan = _a.span;
+ var isAbstract = !!(presentModifiers & 128 /* ModifierFlags.Abstract */);
var completionNodes = [];
ts.codefix.addNewNodeForMemberSymbol(symbol, classLikeDeclaration, sourceFile, { program: program, host: host }, preferences, importAdder,
// `addNewNodeForMemberSymbol` calls this callback function for each new member node
@@ -130558,56 +132591,44 @@ var ts;
// - One node;
// - More than one node if the member is overloaded (e.g. a method with overload signatures).
function (node) {
- var requiredModifiers = 0 /* None */;
+ var requiredModifiers = 0 /* ModifierFlags.None */;
if (isAbstract) {
- requiredModifiers |= 128 /* Abstract */;
+ requiredModifiers |= 128 /* ModifierFlags.Abstract */;
}
if (ts.isClassElement(node)
- && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* NeedsOverride */) {
- requiredModifiers |= 16384 /* Override */;
+ && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* MemberOverrideStatus.NeedsOverride */) {
+ requiredModifiers |= 16384 /* ModifierFlags.Override */;
}
- var presentModifiers = 0 /* None */;
if (!completionNodes.length) {
- // Omit already present modifiers from the first completion node/signature.
- if (contextToken) {
- presentModifiers = getPresentModifiers(contextToken);
- }
// Keep track of added missing required modifiers and modifiers already present.
// This is needed when we have overloaded signatures,
// so this callback will be called for multiple nodes/signatures,
// and we need to make sure the modifiers are uniform for all nodes/signatures.
modifiers = node.modifierFlagsCache | requiredModifiers | presentModifiers;
}
- node = ts.factory.updateModifiers(node, modifiers & (~presentModifiers));
+ node = ts.factory.updateModifiers(node, modifiers);
completionNodes.push(node);
- }, body, 2 /* Property */, isAbstract);
+ }, body, 2 /* codefix.PreserveOptionalFlags.Property */, isAbstract);
if (completionNodes.length) {
+ var format = 1 /* ListFormat.MultiLine */ | 131072 /* ListFormat.NoTrailingNewLine */;
+ replacementSpan = modifiersSpan;
// If we have access to formatting settings, we print the nodes using the emitter,
// and then format the printed text.
if (formatContext) {
- var syntheticFile_1 = {
- text: printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile),
- getLineAndCharacterOfPosition: function (pos) {
- return ts.getLineAndCharacterOfPosition(this, pos);
- },
- };
- var formatOptions_1 = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
- var changes = ts.flatMap(completionNodes, function (node) {
- var nodeWithPos = ts.textChanges.assignPositionsToNode(node);
- return ts.formatting.formatNodeGivenIndentation(nodeWithPos, syntheticFile_1, sourceFile.languageVariant,
- /* indentation */ 0,
- /* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions_1 }));
- });
- insertText = ts.textChanges.applyChanges(syntheticFile_1.text, changes);
+ insertText = printer.printAndFormatSnippetList(format, ts.factory.createNodeArray(completionNodes), sourceFile, formatContext);
}
else { // Otherwise, just use emitter to print the new nodes.
- insertText = printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile);
+ insertText = printer.printSnippetList(format, ts.factory.createNodeArray(completionNodes), sourceFile);
}
}
- return { insertText: insertText, isSnippet: isSnippet, importAdder: importAdder };
+ return { insertText: insertText, isSnippet: isSnippet, importAdder: importAdder, replacementSpan: replacementSpan };
}
function getPresentModifiers(contextToken) {
- var modifiers = 0 /* None */;
+ if (!contextToken) {
+ return { modifiers: 0 /* ModifierFlags.None */ };
+ }
+ var modifiers = 0 /* ModifierFlags.None */;
+ var span;
var contextMod;
/*
Cases supported:
@@ -130630,11 +132651,13 @@ var ts;
*/
if (contextMod = isModifierLike(contextToken)) {
modifiers |= ts.modifierToFlag(contextMod);
+ span = ts.createTextSpanFromNode(contextToken);
}
if (ts.isPropertyDeclaration(contextToken.parent)) {
modifiers |= ts.modifiersToFlags(contextToken.parent.modifiers);
+ span = ts.createTextSpanFromNode(contextToken.parent);
}
- return modifiers;
+ return { modifiers: modifiers, span: span };
}
function isModifierLike(node) {
if (ts.isModifier(node)) {
@@ -130645,19 +132668,162 @@ var ts;
}
return undefined;
}
+ function getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, options, preferences, formatContext) {
+ var isSnippet = preferences.includeCompletionsWithSnippetText || undefined;
+ var insertText = name;
+ var sourceFile = enclosingDeclaration.getSourceFile();
+ var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences);
+ if (!method) {
+ return undefined;
+ }
+ var printer = createSnippetPrinter({
+ removeComments: true,
+ module: options.module,
+ target: options.target,
+ omitTrailingSemicolon: false,
+ newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))),
+ });
+ if (formatContext) {
+ insertText = printer.printAndFormatSnippetList(16 /* ListFormat.CommaDelimited */ | 64 /* ListFormat.AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext);
+ }
+ else {
+ insertText = printer.printSnippetList(16 /* ListFormat.CommaDelimited */ | 64 /* ListFormat.AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile);
+ }
+ var signaturePrinter = ts.createPrinter({
+ removeComments: true,
+ module: options.module,
+ target: options.target,
+ omitTrailingSemicolon: true,
+ });
+ // The `labelDetails.detail` will be displayed right beside the method name,
+ // so we drop the name (and modifiers) from the signature.
+ var methodSignature = ts.factory.createMethodSignature(
+ /*modifiers*/ undefined,
+ /*name*/ "", method.questionToken, method.typeParameters, method.parameters, method.type);
+ var labelDetails = { detail: signaturePrinter.printNode(4 /* EmitHint.Unspecified */, methodSignature, sourceFile) };
+ return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails };
+ }
+ ;
+ function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences) {
+ var declarations = symbol.getDeclarations();
+ if (!(declarations && declarations.length)) {
+ return undefined;
+ }
+ var checker = program.getTypeChecker();
+ var declaration = declarations[0];
+ var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
+ var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
+ var quotePreference = ts.getQuotePreference(sourceFile, preferences);
+ var builderFlags = quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : undefined;
+ switch (declaration.kind) {
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 169 /* SyntaxKind.MethodDeclaration */: {
+ var effectiveType = type.flags & 1048576 /* TypeFlags.Union */ && type.types.length < 10
+ ? checker.getUnionType(type.types, 2 /* UnionReduction.Subtype */)
+ : type;
+ if (effectiveType.flags & 1048576 /* TypeFlags.Union */) {
+ // Only offer the completion if there's a single function type component.
+ var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */).length > 0; });
+ if (functionTypes.length === 1) {
+ effectiveType = functionTypes[0];
+ }
+ else {
+ return undefined;
+ }
+ }
+ var signatures = checker.getSignaturesOfType(effectiveType, 0 /* SignatureKind.Call */);
+ if (signatures.length !== 1) {
+ // We don't support overloads in object literals.
+ return undefined;
+ }
+ var typeNode = checker.typeToTypeNode(effectiveType, enclosingDeclaration, builderFlags, ts.codefix.getNoopSymbolTrackerWithResolver({ program: program, host: host }));
+ if (!typeNode || !ts.isFunctionTypeNode(typeNode)) {
+ return undefined;
+ }
+ var body = void 0;
+ if (preferences.includeCompletionsWithSnippetText) {
+ var emptyStmt = ts.factory.createEmptyStatement();
+ body = ts.factory.createBlock([emptyStmt], /* multiline */ true);
+ ts.setSnippetElement(emptyStmt, { kind: 0 /* SnippetKind.TabStop */, order: 0 });
+ }
+ else {
+ body = ts.factory.createBlock([], /* multiline */ true);
+ }
+ var parameters = typeNode.parameters.map(function (typedParam) {
+ return ts.factory.createParameterDeclaration(
+ /*decorators*/ undefined,
+ /*modifiers*/ undefined, typedParam.dotDotDotToken, typedParam.name, typedParam.questionToken,
+ /*type*/ undefined, typedParam.initializer);
+ });
+ return ts.factory.createMethodDeclaration(
+ /*decorators*/ undefined,
+ /*modifiers*/ undefined,
+ /*asteriskToken*/ undefined, name,
+ /*questionToken*/ undefined,
+ /*typeParameters*/ undefined, parameters,
+ /*type*/ undefined, body);
+ }
+ default:
+ return undefined;
+ }
+ }
function createSnippetPrinter(printerOptions) {
+ var escapes;
var baseWriter = ts.textChanges.createWriter(ts.getNewLineCharacter(printerOptions));
var printer = ts.createPrinter(printerOptions, baseWriter);
- var writer = __assign(__assign({}, baseWriter), { write: function (s) { return baseWriter.write(ts.escapeSnippetText(s)); }, nonEscapingWrite: baseWriter.write, writeLiteral: function (s) { return baseWriter.writeLiteral(ts.escapeSnippetText(s)); }, writeStringLiteral: function (s) { return baseWriter.writeStringLiteral(ts.escapeSnippetText(s)); }, writeSymbol: function (s, symbol) { return baseWriter.writeSymbol(ts.escapeSnippetText(s), symbol); }, writeParameter: function (s) { return baseWriter.writeParameter(ts.escapeSnippetText(s)); }, writeComment: function (s) { return baseWriter.writeComment(ts.escapeSnippetText(s)); }, writeProperty: function (s) { return baseWriter.writeProperty(ts.escapeSnippetText(s)); } });
+ var writer = __assign(__assign({}, baseWriter), { write: function (s) { return escapingWrite(s, function () { return baseWriter.write(s); }); }, nonEscapingWrite: baseWriter.write, writeLiteral: function (s) { return escapingWrite(s, function () { return baseWriter.writeLiteral(s); }); }, writeStringLiteral: function (s) { return escapingWrite(s, function () { return baseWriter.writeStringLiteral(s); }); }, writeSymbol: function (s, symbol) { return escapingWrite(s, function () { return baseWriter.writeSymbol(s, symbol); }); }, writeParameter: function (s) { return escapingWrite(s, function () { return baseWriter.writeParameter(s); }); }, writeComment: function (s) { return escapingWrite(s, function () { return baseWriter.writeComment(s); }); }, writeProperty: function (s) { return escapingWrite(s, function () { return baseWriter.writeProperty(s); }); } });
return {
printSnippetList: printSnippetList,
+ printAndFormatSnippetList: printAndFormatSnippetList,
};
+ // The formatter/scanner will have issues with snippet-escaped text,
+ // so instead of writing the escaped text directly to the writer,
+ // generate a set of changes that can be applied to the unescaped text
+ // to escape it post-formatting.
+ function escapingWrite(s, write) {
+ var escaped = ts.escapeSnippetText(s);
+ if (escaped !== s) {
+ var start = baseWriter.getTextPos();
+ write();
+ var end = baseWriter.getTextPos();
+ escapes = ts.append(escapes || (escapes = []), { newText: escaped, span: { start: start, length: end - start } });
+ }
+ else {
+ write();
+ }
+ }
/* Snippet-escaping version of `printer.printList`. */
function printSnippetList(format, list, sourceFile) {
+ var unescaped = printUnescapedSnippetList(format, list, sourceFile);
+ return escapes ? ts.textChanges.applyChanges(unescaped, escapes) : unescaped;
+ }
+ function printUnescapedSnippetList(format, list, sourceFile) {
+ escapes = undefined;
writer.clear();
printer.writeList(format, list, sourceFile, writer);
return writer.getText();
}
+ function printAndFormatSnippetList(format, list, sourceFile, formatContext) {
+ var syntheticFile = {
+ text: printUnescapedSnippetList(format, list, sourceFile),
+ getLineAndCharacterOfPosition: function (pos) {
+ return ts.getLineAndCharacterOfPosition(this, pos);
+ },
+ };
+ var formatOptions = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
+ var changes = ts.flatMap(list, function (node) {
+ var nodeWithPos = ts.textChanges.assignPositionsToNode(node);
+ return ts.formatting.formatNodeGivenIndentation(nodeWithPos, syntheticFile, sourceFile.languageVariant,
+ /* indentation */ 0,
+ /* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions }));
+ });
+ var allChanges = escapes
+ ? ts.stableSort(ts.concatenate(changes, escapes), function (a, b) { return ts.compareTextSpans(a.span, b.span); })
+ : changes;
+ return ts.textChanges.applyChanges(syntheticFile.text, allChanges);
+ }
}
function originToCompletionEntryData(origin) {
var ambientModuleName = origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name);
@@ -130682,11 +132848,11 @@ var ts;
return unresolvedData;
}
function completionEntryDataToSymbolOriginInfo(data, completionName, moduleSymbol) {
- var isDefaultExport = data.exportName === "default" /* Default */;
+ var isDefaultExport = data.exportName === "default" /* InternalSymbolName.Default */;
var isFromPackageJson = !!data.isPackageJsonImport;
if (completionEntryDataIsResolved(data)) {
var resolvedOrigin = {
- kind: 32 /* ResolvedExport */,
+ kind: 32 /* SymbolOriginInfoKind.ResolvedExport */,
exportName: data.exportName,
moduleSpecifier: data.moduleSpecifier,
symbolName: completionName,
@@ -130698,7 +132864,7 @@ var ts;
return resolvedOrigin;
}
var unresolvedOrigin = {
- kind: 4 /* Export */,
+ kind: 4 /* SymbolOriginInfoKind.Export */,
exportName: data.exportName,
exportMapKey: data.exportMapKey,
symbolName: completionName,
@@ -130714,21 +132880,21 @@ var ts;
var sourceFile = importCompletionNode.getSourceFile();
var replacementSpan = ts.createTextSpanFromNode(ts.findAncestor(importCompletionNode, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration)) || importCompletionNode, sourceFile);
var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier);
- var exportKind = origin.isDefaultExport ? 1 /* Default */ :
- origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ :
- 0 /* Named */;
+ var exportKind = origin.isDefaultExport ? 1 /* ExportKind.Default */ :
+ origin.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ExportKind.ExportEquals */ :
+ 0 /* ExportKind.Named */;
var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : "";
var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options, /*forceImportKeyword*/ true);
var isTopLevelTypeOnly = ((_b = (_a = ts.tryCast(importCompletionNode, ts.isImportDeclaration)) === null || _a === void 0 ? void 0 : _a.importClause) === null || _b === void 0 ? void 0 : _b.isTypeOnly) || ((_c = ts.tryCast(importCompletionNode, ts.isImportEqualsDeclaration)) === null || _c === void 0 ? void 0 : _c.isTypeOnly);
var isImportSpecifierTypeOnly = couldBeTypeOnlyImportSpecifier(importCompletionNode, contextToken);
- var topLevelTypeOnlyText = isTopLevelTypeOnly ? " ".concat(ts.tokenToString(151 /* TypeKeyword */), " ") : " ";
- var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? "".concat(ts.tokenToString(151 /* TypeKeyword */), " ") : "";
+ var topLevelTypeOnlyText = isTopLevelTypeOnly ? " ".concat(ts.tokenToString(152 /* SyntaxKind.TypeKeyword */), " ") : " ";
+ var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? "".concat(ts.tokenToString(152 /* SyntaxKind.TypeKeyword */), " ") : "";
var suffix = useSemicolons ? ";" : "";
switch (importKind) {
- case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " = require(").concat(quotedModuleSpecifier, ")").concat(suffix) };
- case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " from ").concat(quotedModuleSpecifier).concat(suffix) };
- case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText, "* as ").concat(ts.escapeSnippetText(name), " from ").concat(quotedModuleSpecifier).concat(suffix) };
- case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText, "{ ").concat(importSpecifierTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " } from ").concat(quotedModuleSpecifier).concat(suffix) };
+ case 3 /* ImportKind.CommonJS */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " = require(").concat(quotedModuleSpecifier, ")").concat(suffix) };
+ case 1 /* ImportKind.Default */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " from ").concat(quotedModuleSpecifier).concat(suffix) };
+ case 2 /* ImportKind.Namespace */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText, "* as ").concat(ts.escapeSnippetText(name), " from ").concat(quotedModuleSpecifier).concat(suffix) };
+ case 0 /* ImportKind.Named */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText, "{ ").concat(importSpecifierTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " } from ").concat(quotedModuleSpecifier).concat(suffix) };
}
}
function quotePropertyName(sourceFile, preferences, name) {
@@ -130739,7 +132905,7 @@ var ts;
}
function isRecommendedCompletionMatch(localSymbol, recommendedCompletion, checker) {
return localSymbol === recommendedCompletion ||
- !!(localSymbol.flags & 1048576 /* ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion;
+ !!(localSymbol.flags & 1048576 /* SymbolFlags.ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion;
}
function getSourceFromOrigin(origin) {
if (originIsExport(origin)) {
@@ -130748,14 +132914,14 @@ var ts;
if (originIsResolvedExport(origin)) {
return origin.moduleSpecifier;
}
- if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) {
+ if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* SymbolOriginInfoKind.ThisType */) {
return CompletionSource.ThisProperty;
}
- if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
+ if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* SymbolOriginInfoKind.TypeOnlyAlias */) {
return CompletionSource.TypeOnlyAlias;
}
}
- function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag) {
+ function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag) {
var _a;
var start = ts.timestamp();
var variableDeclaration = getVariableDeclaration(location);
@@ -130770,12 +132936,12 @@ var ts;
var symbol = symbols[i];
var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i];
var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected);
- if (!info || uniques.get(info.name) || kind === 1 /* Global */ && symbolToSortTextIdMap && !shouldIncludeSymbol(symbol, symbolToSortTextIdMap)) {
+ if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* CompletionKind.Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) {
continue;
}
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
- var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
- var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
+ var originalSortText = (_a = symbolToSortTextMap === null || symbolToSortTextMap === void 0 ? void 0 : symbolToSortTextMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority;
+ var sortText = (isDeprecated(symbol, typeChecker) ? Completions.SortText.Deprecated(originalSortText) : originalSortText);
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag);
if (!entry) {
continue;
@@ -130793,7 +132959,7 @@ var ts;
has: function (name) { return uniques.has(name); },
add: function (name) { return uniques.set(name, true); },
};
- function shouldIncludeSymbol(symbol, symbolToSortTextIdMap) {
+ function shouldIncludeSymbol(symbol, symbolToSortTextMap) {
var allFlags = symbol.flags;
if (!ts.isSourceFile(location)) {
// export = /**/ here we want to get all meanings, so any symbol is ok
@@ -130815,15 +132981,15 @@ var ts;
// Auto Imports are not available for scripts so this conditional is always false
if (!!sourceFile.externalModuleIndicator
&& !compilerOptions.allowUmdGlobalAccess
- && symbolToSortTextIdMap[ts.getSymbolId(symbol)] === 15 /* GlobalsOrKeywords */
- && (symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === 16 /* AutoImportSuggestions */
- || symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === 11 /* LocationPriority */)) {
+ && symbolToSortTextMap[ts.getSymbolId(symbol)] === Completions.SortText.GlobalsOrKeywords
+ && (symbolToSortTextMap[ts.getSymbolId(symbolOrigin)] === Completions.SortText.AutoImportSuggestions
+ || symbolToSortTextMap[ts.getSymbolId(symbolOrigin)] === Completions.SortText.LocationPriority)) {
return false;
}
allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin);
// import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace)
if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) {
- return !!(allFlags & 1920 /* Namespace */);
+ return !!(allFlags & 1920 /* SymbolFlags.Namespace */);
}
if (isTypeOnlyLocation) {
// It's a type, but you can reach it by namespace.type as well
@@ -130831,7 +132997,7 @@ var ts;
}
}
// expressions are value space (which includes the value namespaces)
- return !!(allFlags & 111551 /* Value */);
+ return !!(allFlags & 111551 /* SymbolFlags.Value */);
}
}
Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols;
@@ -130855,9 +133021,9 @@ var ts;
uniques.set(name, true);
entries.push({
name: name,
- kindModifiers: "" /* none */,
- kind: "label" /* label */,
- sortText: SortText.LocationPriority
+ kindModifiers: "" /* ScriptElementKindModifier.none */,
+ kind: "label" /* ScriptElementKind.label */,
+ sortText: Completions.SortText.LocationPriority
});
}
}
@@ -130883,11 +133049,11 @@ var ts;
}
}
var compilerOptions = program.getCompilerOptions();
- var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host);
+ var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host, /*formatContext*/ undefined);
if (!completionData) {
return { type: "none" };
}
- if (completionData.kind !== 0 /* Data */) {
+ if (completionData.kind !== 0 /* CompletionDataKind.Data */) {
return { type: "request", request: completionData };
}
var symbols = completionData.symbols, literals = completionData.literals, location = completionData.location, completionKind = completionData.completionKind, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, contextToken = completionData.contextToken, previousToken = completionData.previousToken, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation;
@@ -130901,7 +133067,9 @@ var ts;
return ts.firstDefined(symbols, function (symbol, index) {
var origin = symbolToOriginInfoMap[index];
var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected);
- return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */ || getSourceFromOrigin(origin) === entryId.source)
+ return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* SymbolFlags.ClassMember */
+ || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */)
+ || getSourceFromOrigin(origin) === entryId.source)
? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation }
: undefined;
}) || { type: "none" };
@@ -130920,14 +133088,14 @@ var ts;
case "request": {
var request = symbolCompletion.request;
switch (request.kind) {
- case 1 /* JsDocTagName */:
+ case 1 /* CompletionDataKind.JsDocTagName */:
return ts.JsDoc.getJSDocTagNameCompletionDetails(name);
- case 2 /* JsDocTag */:
+ case 2 /* CompletionDataKind.JsDocTag */:
return ts.JsDoc.getJSDocTagCompletionDetails(name);
- case 3 /* JsDocParameterName */:
+ case 3 /* CompletionDataKind.JsDocParameterName */:
return ts.JsDoc.getJSDocParameterNameCompletionDetails(name);
- case 4 /* Keywords */:
- return ts.some(request.keywordCompletions, function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined;
+ case 4 /* CompletionDataKind.Keywords */:
+ return ts.some(request.keywordCompletions, function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* ScriptElementKind.keyword */, ts.SymbolDisplayPartKind.keyword) : undefined;
default:
return ts.Debug.assertNever(request);
}
@@ -130939,22 +133107,22 @@ var ts;
}
case "literal": {
var literal = symbolCompletion.literal;
- return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral);
+ return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* ScriptElementKind.string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral);
}
case "none":
// Didn't find a symbol with this name. See if we can find a keyword instead.
- return allKeywordsCompletions().some(function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined;
+ return allKeywordsCompletions().some(function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* ScriptElementKind.keyword */, ts.SymbolDisplayPartKind.keyword) : undefined;
default:
ts.Debug.assertNever(symbolCompletion);
}
}
Completions.getCompletionEntryDetails = getCompletionEntryDetails;
function createSimpleDetails(name, kind, kind2) {
- return createCompletionDetails(name, "" /* none */, kind, [ts.displayPart(name, kind2)]);
+ return createCompletionDetails(name, "" /* ScriptElementKindModifier.none */, kind, [ts.displayPart(name, kind2)]);
}
function createCompletionDetailsForSymbol(symbol, checker, sourceFile, location, cancellationToken, codeActions, sourceDisplay) {
var _a = checker.runWithCancellationToken(cancellationToken, function (checker) {
- return ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, sourceFile, location, location, 7 /* All */);
+ return ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, sourceFile, location, location, 7 /* SemanticMeaning.All */);
}), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags;
return createCompletionDetails(symbol.name, ts.SymbolDisplay.getSymbolModifiers(checker, symbol), symbolKind, displayParts, documentation, tags, codeActions, sourceDisplay);
}
@@ -130994,7 +133162,7 @@ var ts;
var checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker();
var moduleSymbol = origin.moduleSymbol;
var targetSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker));
- var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent);
+ var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* SyntaxKind.LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent);
var _a = ts.codefix.getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), isJsxOpeningTagName), isJsxOpeningTagName, host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction;
ts.Debug.assert(!(data === null || data === void 0 ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier);
return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] };
@@ -131026,7 +133194,7 @@ var ts;
return ts.firstDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (type) {
var symbol = type && type.symbol;
// Don't include make a recommended completion for an abstract class
- return symbol && (symbol.flags & (8 /* EnumMember */ | 384 /* Enum */ | 32 /* Class */) && !ts.isAbstractConstructorSymbol(symbol))
+ return symbol && (symbol.flags & (8 /* SymbolFlags.EnumMember */ | 384 /* SymbolFlags.Enum */ | 32 /* SymbolFlags.Class */) && !ts.isAbstractConstructorSymbol(symbol))
? getFirstSymbolInChain(symbol, previousToken, checker)
: undefined;
});
@@ -131034,31 +133202,31 @@ var ts;
function getContextualType(previousToken, position, sourceFile, checker) {
var parent = previousToken.parent;
switch (previousToken.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return ts.getContextualTypeFromParent(previousToken, checker);
- case 63 /* EqualsToken */:
+ case 63 /* SyntaxKind.EqualsToken */:
switch (parent.kind) {
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return checker.getContextualType(parent.initializer); // TODO: GH#18217
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return checker.getTypeAtLocation(parent.left);
- case 284 /* JsxAttribute */:
+ case 285 /* SyntaxKind.JsxAttribute */:
return checker.getContextualTypeForJsxAttribute(parent);
default:
return undefined;
}
- case 103 /* NewKeyword */:
+ case 103 /* SyntaxKind.NewKeyword */:
return checker.getContextualType(parent);
- case 82 /* CaseKeyword */:
+ case 82 /* SyntaxKind.CaseKeyword */:
var caseClause = ts.tryCast(parent, ts.isCaseClause);
return caseClause ? ts.getSwitchedType(caseClause, checker) : undefined;
- case 18 /* OpenBraceToken */:
+ case 18 /* SyntaxKind.OpenBraceToken */:
return ts.isJsxExpression(parent) && !ts.isJsxElement(parent.parent) && !ts.isJsxFragment(parent.parent) ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined;
default:
var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile);
return argInfo ?
// At `,`, treat this as the next argument after the comma.
- checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) :
+ checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* SyntaxKind.CommaToken */ ? 1 : 0)) :
ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) ?
// completion at `x ===/**/` should be for the right side
checker.getTypeAtLocation(parent.left) :
@@ -131066,17 +133234,18 @@ var ts;
}
}
function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) {
- var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* All */, /*useOnlyExternalAliasing*/ false);
+ var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* SymbolFlags.All */, /*useOnlyExternalAliasing*/ false);
if (chain)
return ts.first(chain);
return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker));
}
function isModuleSymbol(symbol) {
var _a;
- return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 303 /* SourceFile */; }));
+ return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SyntaxKind.SourceFile */; }));
}
- function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId, host, cancellationToken) {
+ function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) {
var typeChecker = program.getTypeChecker();
+ var inUncheckedFile = isUncheckedFile(sourceFile, compilerOptions);
var start = ts.timestamp();
var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853
// We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.)
@@ -131088,10 +133257,10 @@ var ts;
var isInSnippetScope = false;
if (insideComment) {
if (ts.hasDocComment(sourceFile, position)) {
- if (sourceFile.text.charCodeAt(position - 1) === 64 /* at */) {
+ if (sourceFile.text.charCodeAt(position - 1) === 64 /* CharacterCodes.at */) {
// The current position is next to the '@' sign, when no tag name being provided yet.
// Provide a full list of tag names
- return { kind: 1 /* JsDocTagName */ };
+ return { kind: 1 /* CompletionDataKind.JsDocTagName */ };
}
else {
// When completion is requested without "@", we will have check to make sure that
@@ -131112,7 +133281,7 @@ var ts;
// */
var lineStart = ts.getLineStartPositionForPosition(position, sourceFile);
if (!/[^\*|\s(/)]/.test(sourceFile.text.substring(lineStart, position))) {
- return { kind: 2 /* JsDocTag */ };
+ return { kind: 2 /* CompletionDataKind.JsDocTag */ };
}
}
}
@@ -131122,20 +133291,21 @@ var ts;
var tag = getJsDocTagAtPosition(currentToken, position);
if (tag) {
if (tag.tagName.pos <= position && position <= tag.tagName.end) {
- return { kind: 1 /* JsDocTagName */ };
+ return { kind: 1 /* CompletionDataKind.JsDocTagName */ };
}
- if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 307 /* JSDocTypeExpression */) {
+ var typeExpression = tryGetTypeExpressionFromTag(tag);
+ if (typeExpression) {
currentToken = ts.getTokenAtPosition(sourceFile, position);
if (!currentToken ||
(!ts.isDeclarationName(currentToken) &&
- (currentToken.parent.kind !== 345 /* JSDocPropertyTag */ ||
+ (currentToken.parent.kind !== 347 /* SyntaxKind.JSDocPropertyTag */ ||
currentToken.parent.name !== currentToken))) {
// Use as type location if inside tag's type expression
- insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression);
+ insideJsDocTagTypeExpression = isCurrentlyEditingNode(typeExpression);
}
}
if (!insideJsDocTagTypeExpression && ts.isJSDocParameterTag(tag) && (ts.nodeIsMissing(tag.name) || tag.name.pos <= position && position <= tag.name.end)) {
- return { kind: 3 /* JsDocParameterName */, tag: tag };
+ return { kind: 3 /* CompletionDataKind.JsDocParameterName */, tag: tag };
}
}
if (!insideJsDocTagTypeExpression) {
@@ -131166,15 +133336,16 @@ var ts;
var isJsxIdentifierExpected = false;
var importCompletionNode;
var location = ts.getTouchingPropertyName(sourceFile, position);
- var keywordFilters = 0 /* None */;
+ var keywordFilters = 0 /* KeywordCompletionFilters.None */;
var isNewIdentifierLocation = false;
+ var flags = 0 /* CompletionInfoFlags.None */;
if (contextToken) {
var importStatementCompletion = getImportStatementCompletionInfo(contextToken);
isNewIdentifierLocation = importStatementCompletion.isNewIdentifierLocation;
if (importStatementCompletion.keywordCompletion) {
if (importStatementCompletion.isKeywordOnlyCompletion) {
return {
- kind: 4 /* Keywords */,
+ kind: 4 /* CompletionDataKind.Keywords */,
keywordCompletions: [keywordToCompletionEntry(importStatementCompletion.keywordCompletion)],
isNewIdentifierLocation: isNewIdentifierLocation,
};
@@ -131187,6 +133358,7 @@ var ts;
// is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients
// to opt in with the `includeCompletionsForImportStatements` user preference.
importCompletionNode = importStatementCompletion.replacementNode;
+ flags |= 2 /* CompletionInfoFlags.IsImportStatementCompletion */;
}
// Bail out if this is a known invalid completion location
if (!importCompletionNode && isCompletionListBlocker(contextToken)) {
@@ -131196,11 +133368,11 @@ var ts;
: undefined;
}
var parent = contextToken.parent;
- if (contextToken.kind === 24 /* DotToken */ || contextToken.kind === 28 /* QuestionDotToken */) {
- isRightOfDot = contextToken.kind === 24 /* DotToken */;
- isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */;
+ if (contextToken.kind === 24 /* SyntaxKind.DotToken */ || contextToken.kind === 28 /* SyntaxKind.QuestionDotToken */) {
+ isRightOfDot = contextToken.kind === 24 /* SyntaxKind.DotToken */;
+ isRightOfQuestionDot = contextToken.kind === 28 /* SyntaxKind.QuestionDotToken */;
switch (parent.kind) {
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
propertyAccessToConvert = parent;
node = propertyAccessToConvert.expression;
var leftmostAccessExpression = ts.getLeftmostAccessExpression(propertyAccessToConvert);
@@ -131208,7 +133380,7 @@ var ts;
((ts.isCallExpression(node) || ts.isFunctionLike(node)) &&
node.end === contextToken.pos &&
node.getChildCount(sourceFile) &&
- ts.last(node.getChildren(sourceFile)).kind !== 21 /* CloseParenToken */)) {
+ ts.last(node.getChildren(sourceFile)).kind !== 21 /* SyntaxKind.CloseParenToken */)) {
// This is likely dot from incorrectly parsed expression and user is starting to write spread
// eg: Math.min(./**/)
// const x = function (./**/) {}
@@ -131216,18 +133388,18 @@ var ts;
return undefined;
}
break;
- case 160 /* QualifiedName */:
+ case 161 /* SyntaxKind.QualifiedName */:
node = parent.left;
break;
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
node = parent.name;
break;
- case 199 /* ImportType */:
+ case 200 /* SyntaxKind.ImportType */:
node = parent;
break;
- case 230 /* MetaProperty */:
+ case 231 /* SyntaxKind.MetaProperty */:
node = parent.getFirstToken(sourceFile);
- ts.Debug.assert(node.kind === 100 /* ImportKeyword */ || node.kind === 103 /* NewKeyword */);
+ ts.Debug.assert(node.kind === 100 /* SyntaxKind.ImportKeyword */ || node.kind === 103 /* SyntaxKind.NewKeyword */);
break;
default:
// There is nothing that precedes the dot, so this likely just a stray character
@@ -131235,58 +133407,58 @@ var ts;
return undefined;
}
}
- else if (!importCompletionNode && sourceFile.languageVariant === 1 /* JSX */) {
+ else if (!importCompletionNode && sourceFile.languageVariant === 1 /* LanguageVariant.JSX */) {
// <UI.Test /* completion position */ />
// If the tagname is a property access expression, we will then walk up to the top most of property access expression.
// Then, try to get a JSX container and its associated attributes type.
- if (parent && parent.kind === 205 /* PropertyAccessExpression */) {
+ if (parent && parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) {
contextToken = parent;
parent = parent.parent;
}
// Fix location
if (currentToken.parent === location) {
switch (currentToken.kind) {
- case 31 /* GreaterThanToken */:
- if (currentToken.parent.kind === 277 /* JsxElement */ || currentToken.parent.kind === 279 /* JsxOpeningElement */) {
+ case 31 /* SyntaxKind.GreaterThanToken */:
+ if (currentToken.parent.kind === 278 /* SyntaxKind.JsxElement */ || currentToken.parent.kind === 280 /* SyntaxKind.JsxOpeningElement */) {
location = currentToken;
}
break;
- case 43 /* SlashToken */:
- if (currentToken.parent.kind === 278 /* JsxSelfClosingElement */) {
+ case 43 /* SyntaxKind.SlashToken */:
+ if (currentToken.parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */) {
location = currentToken;
}
break;
}
}
switch (parent.kind) {
- case 280 /* JsxClosingElement */:
- if (contextToken.kind === 43 /* SlashToken */) {
+ case 281 /* SyntaxKind.JsxClosingElement */:
+ if (contextToken.kind === 43 /* SyntaxKind.SlashToken */) {
isStartingCloseTag = true;
location = contextToken;
}
break;
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
if (!binaryExpressionMayBeOpenTag(parent)) {
break;
}
// falls through
- case 278 /* JsxSelfClosingElement */:
- case 277 /* JsxElement */:
- case 279 /* JsxOpeningElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
+ case 278 /* SyntaxKind.JsxElement */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
isJsxIdentifierExpected = true;
- if (contextToken.kind === 29 /* LessThanToken */) {
+ if (contextToken.kind === 29 /* SyntaxKind.LessThanToken */) {
isRightOfOpenTag = true;
location = contextToken;
}
break;
- case 287 /* JsxExpression */:
- case 286 /* JsxSpreadAttribute */:
+ case 288 /* SyntaxKind.JsxExpression */:
+ case 287 /* SyntaxKind.JsxSpreadAttribute */:
// For `<div foo={true} [||] ></div>`, `parent` will be `{true}` and `previousToken` will be `}`
- if (previousToken.kind === 19 /* CloseBraceToken */ && currentToken.kind === 31 /* GreaterThanToken */) {
+ if (previousToken.kind === 19 /* SyntaxKind.CloseBraceToken */ && currentToken.kind === 31 /* SyntaxKind.GreaterThanToken */) {
isJsxIdentifierExpected = true;
}
break;
- case 284 /* JsxAttribute */:
+ case 285 /* SyntaxKind.JsxAttribute */:
// For `<div className="x" [||] ></div>`, `parent` will be JsxAttribute and `previousToken` will be its initializer
if (parent.initializer === previousToken &&
previousToken.end < position) {
@@ -131294,16 +133466,16 @@ var ts;
break;
}
switch (previousToken.kind) {
- case 63 /* EqualsToken */:
+ case 63 /* SyntaxKind.EqualsToken */:
isJsxInitializer = true;
break;
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
isJsxIdentifierExpected = true;
// For `<div x=[|f/**/|]`, `parent` will be `x` and `previousToken.parent` will be `f` (which is its own JsxAttribute)
// Note for `<div someBool f>` we don't want to treat this as a jsx inializer, instead it's the attribute name.
if (parent !== previousToken.parent &&
!parent.initializer &&
- ts.findChildOfKind(parent, 63 /* EqualsToken */, sourceFile)) {
+ ts.findChildOfKind(parent, 63 /* SyntaxKind.EqualsToken */, sourceFile)) {
isJsxInitializer = previousToken;
}
}
@@ -131312,13 +133484,13 @@ var ts;
}
}
var semanticStart = ts.timestamp();
- var completionKind = 5 /* None */;
+ var completionKind = 5 /* CompletionKind.None */;
var isNonContextualObjectLiteral = false;
var hasUnresolvedAutoImports = false;
// This also gets mutated in nested-functions after the return
var symbols = [];
var symbolToOriginInfoMap = [];
- var symbolToSortTextIdMap = [];
+ var symbolToSortTextMap = [];
var seenPropertySymbols = new ts.Map();
var isTypeOnlyLocation = isTypeOnlyCompletion();
var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
@@ -131331,8 +133503,8 @@ var ts;
symbols = typeChecker.getJsxIntrinsicTagNamesAt(location);
ts.Debug.assertEachIsDefined(symbols, "getJsxIntrinsicTagNames() should all be defined");
tryGetGlobalSymbols();
- completionKind = 1 /* Global */;
- keywordFilters = 0 /* None */;
+ completionKind = 1 /* CompletionKind.Global */;
+ keywordFilters = 0 /* KeywordCompletionFilters.None */;
}
else if (isStartingCloseTag) {
var tagName = contextToken.parent.parent.openingElement.tagName;
@@ -131340,8 +133512,8 @@ var ts;
if (tagSymbol) {
symbols = [tagSymbol];
}
- completionKind = 1 /* Global */;
- keywordFilters = 0 /* None */;
+ completionKind = 1 /* CompletionKind.Global */;
+ keywordFilters = 0 /* KeywordCompletionFilters.None */;
}
else {
// For JavaScript or TypeScript, if we're not after a dot, then just try to get the
@@ -131355,10 +133527,10 @@ var ts;
}
log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart));
var contextualType = previousToken && getContextualType(previousToken, position, sourceFile, typeChecker);
- var literals = ts.mapDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (t) { return t.isLiteral() && !(t.flags & 1024 /* EnumLiteral */) ? t.value : undefined; });
+ var literals = ts.mapDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (t) { return t.isLiteral() && !(t.flags & 1024 /* TypeFlags.EnumLiteral */) ? t.value : undefined; });
var recommendedCompletion = previousToken && contextualType && getRecommendedCompletion(previousToken, contextualType, typeChecker);
return {
- kind: 0 /* Data */,
+ kind: 0 /* CompletionDataKind.Data */,
symbols: symbols,
completionKind: completionKind,
isInSnippetScope: isInSnippetScope,
@@ -131373,28 +133545,38 @@ var ts;
contextToken: contextToken,
isJsxInitializer: isJsxInitializer,
insideJsDocTagTypeExpression: insideJsDocTagTypeExpression,
- symbolToSortTextIdMap: symbolToSortTextIdMap,
+ symbolToSortTextMap: symbolToSortTextMap,
isTypeOnlyLocation: isTypeOnlyLocation,
isJsxIdentifierExpected: isJsxIdentifierExpected,
isRightOfOpenTag: isRightOfOpenTag,
importCompletionNode: importCompletionNode,
hasUnresolvedAutoImports: hasUnresolvedAutoImports,
+ flags: flags,
};
function isTagWithTypeExpression(tag) {
switch (tag.kind) {
- case 338 /* JSDocParameterTag */:
- case 345 /* JSDocPropertyTag */:
- case 339 /* JSDocReturnTag */:
- case 341 /* JSDocTypeTag */:
- case 343 /* JSDocTypedefTag */:
+ case 340 /* SyntaxKind.JSDocParameterTag */:
+ case 347 /* SyntaxKind.JSDocPropertyTag */:
+ case 341 /* SyntaxKind.JSDocReturnTag */:
+ case 343 /* SyntaxKind.JSDocTypeTag */:
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
return true;
+ case 344 /* SyntaxKind.JSDocTemplateTag */:
+ return !!tag.constraint;
default:
return false;
}
}
+ function tryGetTypeExpressionFromTag(tag) {
+ if (isTagWithTypeExpression(tag)) {
+ var typeExpression = ts.isJSDocTemplateTag(tag) ? tag.constraint : tag.typeExpression;
+ return typeExpression && typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */ ? typeExpression : undefined;
+ }
+ return undefined;
+ }
function getTypeScriptMemberSymbols() {
// Right of dot member completion list
- completionKind = 2 /* PropertyAccess */;
+ completionKind = 2 /* CompletionKind.PropertyAccess */;
// Since this is qualified name check it's a type node location
var isImportType = ts.isLiteralImportTypeNode(node);
var isTypeLocation = insideJsDocTagTypeExpression
@@ -131409,7 +133591,7 @@ var ts;
var symbol = typeChecker.getSymbolAtLocation(node);
if (symbol) {
symbol = ts.skipAlias(symbol, typeChecker);
- if (symbol.flags & (1536 /* Module */ | 384 /* Enum */)) {
+ if (symbol.flags & (1536 /* SymbolFlags.Module */ | 384 /* SymbolFlags.Enum */)) {
// Extract module or enum members
var exportedSymbols = typeChecker.getExportsOfModule(symbol);
ts.Debug.assertEachIsDefined(exportedSymbols, "getExportsOfModule() should all be defined");
@@ -131417,7 +133599,7 @@ var ts;
var isValidTypeAccess_1 = function (symbol) { return symbolCanBeReferencedAtTypeLocation(symbol, typeChecker); };
var isValidAccess = isNamespaceName
// At `namespace N.M/**/`, if this is the only declaration of `M`, don't include `M` as a completion.
- ? function (symbol) { var _a; return !!(symbol.flags & 1920 /* Namespace */) && !((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return d.parent === node.parent; })); }
+ ? function (symbol) { var _a; return !!(symbol.flags & 1920 /* SymbolFlags.Namespace */) && !((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return d.parent === node.parent; })); }
: isRhsOfImportDeclaration ?
// Any kind is allowed when dotting off namespace in internal import equals declaration
function (symbol) { return isValidTypeAccess_1(symbol) || isValidValueAccess_1(symbol); } :
@@ -131431,7 +133613,7 @@ var ts;
// If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods).
if (!isTypeLocation &&
symbol.declarations &&
- symbol.declarations.some(function (d) { return d.kind !== 303 /* SourceFile */ && d.kind !== 260 /* ModuleDeclaration */ && d.kind !== 259 /* EnumDeclaration */; })) {
+ symbol.declarations.some(function (d) { return d.kind !== 305 /* SyntaxKind.SourceFile */ && d.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && d.kind !== 260 /* SyntaxKind.EnumDeclaration */; })) {
var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType();
var insertQuestionDot = false;
if (type.isNullableType()) {
@@ -131445,7 +133627,7 @@ var ts;
}
}
}
- addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot);
+ addTypeProperties(type, !!(node.flags & 32768 /* NodeFlags.AwaitContext */), insertQuestionDot);
}
return;
}
@@ -131469,7 +133651,7 @@ var ts;
}
}
}
- addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot);
+ addTypeProperties(type, !!(node.flags & 32768 /* NodeFlags.AwaitContext */), insertQuestionDot);
}
}
function addTypeProperties(type, insertAwait, insertQuestionDot) {
@@ -131477,8 +133659,8 @@ var ts;
if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) {
isNewIdentifierLocation = true;
}
- var propertyAccess = node.kind === 199 /* ImportType */ ? node : node.parent;
- if (isUncheckedFile) {
+ var propertyAccess = node.kind === 200 /* SyntaxKind.ImportType */ ? node : node.parent;
+ if (inUncheckedFile) {
// In javascript files, for union types, we don't just get the members that
// the individual types have in common, we also include all the members that
// each individual type has. This is because we're going to add all identifiers
@@ -131524,21 +133706,21 @@ var ts;
if (!moduleSymbol ||
!ts.isExternalModuleSymbol(moduleSymbol) ||
typeChecker.tryGetMemberInModuleExportsAndProperties(firstAccessibleSymbol.name, moduleSymbol) !== firstAccessibleSymbol) {
- symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) };
+ symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolOriginInfoKind.SymbolMemberNoExport */) };
}
else {
var fileName = ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? (_a = ts.getSourceFileOfModule(moduleSymbol)) === null || _a === void 0 ? void 0 : _a.fileName : undefined;
var moduleSpecifier = (ts.codefix.getModuleSpecifierForBestExportInfo([{
- exportKind: 0 /* Named */,
+ exportKind: 0 /* ExportKind.Named */,
moduleFileName: fileName,
isFromPackageJson: false,
moduleSymbol: moduleSymbol,
symbol: firstAccessibleSymbol,
targetFlags: ts.skipAlias(firstAccessibleSymbol, typeChecker).flags,
- }], sourceFile, program, host, preferences) || {}).moduleSpecifier;
+ }], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location), sourceFile, program, host, preferences) || {}).moduleSpecifier;
if (moduleSpecifier) {
var origin = {
- kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */),
+ kind: getNullableSymbolOriginInfoKind(6 /* SymbolOriginInfoKind.SymbolMemberExport */),
moduleSymbol: moduleSymbol,
isDefaultExport: false,
symbolName: firstAccessibleSymbol.name,
@@ -131563,21 +133745,21 @@ var ts;
}
function addSymbolSortInfo(symbol) {
if (isStaticProperty(symbol)) {
- symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 10 /* LocalDeclarationPriority */;
+ symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.LocalDeclarationPriority;
}
}
function addSymbolOriginInfo(symbol) {
if (preferences.includeCompletionsWithInsertText) {
if (insertAwait && ts.addToSeen(seenPropertySymbols, ts.getSymbolId(symbol))) {
- symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) };
+ symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* SymbolOriginInfoKind.Promise */) };
}
else if (insertQuestionDot) {
- symbolToOriginInfoMap[symbols.length] = { kind: 16 /* Nullable */ };
+ symbolToOriginInfoMap[symbols.length] = { kind: 16 /* SymbolOriginInfoKind.Nullable */ };
}
}
}
function getNullableSymbolOriginInfoKind(kind) {
- return insertQuestionDot ? kind | 16 /* Nullable */ : kind;
+ return insertQuestionDot ? kind | 16 /* SymbolOriginInfoKind.Nullable */ : kind;
}
}
/** Given 'a.b.c', returns 'a'. */
@@ -131593,44 +133775,44 @@ var ts;
|| tryGetConstructorCompletion()
|| tryGetClassLikeCompletionSymbols()
|| tryGetJsxCompletionSymbols()
- || (getGlobalCompletions(), 1 /* Success */);
- return result === 1 /* Success */;
+ || (getGlobalCompletions(), 1 /* GlobalsSearch.Success */);
+ return result === 1 /* GlobalsSearch.Success */;
}
function tryGetConstructorCompletion() {
if (!tryGetConstructorLikeCompletionContainer(contextToken))
- return 0 /* Continue */;
+ return 0 /* GlobalsSearch.Continue */;
// no members, only keywords
- completionKind = 5 /* None */;
+ completionKind = 5 /* CompletionKind.None */;
// Declaring new property/method/accessor
isNewIdentifierLocation = true;
// Has keywords for constructor parameter
- keywordFilters = 4 /* ConstructorParameterKeywords */;
- return 1 /* Success */;
+ keywordFilters = 4 /* KeywordCompletionFilters.ConstructorParameterKeywords */;
+ return 1 /* GlobalsSearch.Success */;
}
function tryGetJsxCompletionSymbols() {
var jsxContainer = tryGetContainingJsxElement(contextToken);
// Cursor is inside a JSX self-closing element or opening element
var attrsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes);
if (!attrsType)
- return 0 /* Continue */;
- var completionsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes, 4 /* Completions */);
+ return 0 /* GlobalsSearch.Continue */;
+ var completionsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes, 4 /* ContextFlags.Completions */);
symbols = ts.concatenate(symbols, filterJsxAttributes(getPropertiesForObjectExpression(attrsType, completionsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties));
setSortTextToOptionalMember();
- completionKind = 3 /* MemberLike */;
+ completionKind = 3 /* CompletionKind.MemberLike */;
isNewIdentifierLocation = false;
- return 1 /* Success */;
+ return 1 /* GlobalsSearch.Success */;
}
function tryGetImportCompletionSymbols() {
if (!importCompletionNode)
- return 0 /* Continue */;
+ return 0 /* GlobalsSearch.Continue */;
isNewIdentifierLocation = true;
collectAutoImports();
- return 1 /* Success */;
+ return 1 /* GlobalsSearch.Success */;
}
function getGlobalCompletions() {
- keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* FunctionLikeBodyKeywords */ : 1 /* All */;
+ keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* KeywordCompletionFilters.FunctionLikeBodyKeywords */ : 1 /* KeywordCompletionFilters.All */;
// Get all entities in the current scope.
- completionKind = 1 /* Global */;
+ completionKind = 1 /* CompletionKind.Global */;
isNewIdentifierLocation = isNewIdentifierDefinitionLocation();
if (previousToken !== contextToken) {
ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'.");
@@ -131665,7 +133847,7 @@ var ts;
position;
var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
isInSnippetScope = isSnippetScope(scopeNode);
- var symbolMeanings = (isTypeOnlyLocation ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */;
+ var symbolMeanings = (isTypeOnlyLocation ? 0 /* SymbolFlags.None */ : 111551 /* SymbolFlags.Value */) | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */;
var typeOnlyAliasNeedsPromotion = previousToken && !ts.isValidTypeOnlyAliasUseSite(previousToken);
symbols = ts.concatenate(symbols, typeChecker.getSymbolsInScope(scopeNode, symbolMeanings));
ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined");
@@ -131673,33 +133855,33 @@ var ts;
var symbol = symbols[i];
if (!typeChecker.isArgumentsSymbol(symbol) &&
!ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
- symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 15 /* GlobalsOrKeywords */;
+ symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.GlobalsOrKeywords;
}
- if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) {
+ if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* SymbolFlags.Value */)) {
var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
if (typeOnlyAliasDeclaration) {
- var origin = { kind: 64 /* TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration };
+ var origin = { kind: 64 /* SymbolOriginInfoKind.TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration };
symbolToOriginInfoMap[i] = origin;
}
}
}
// Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
- if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 303 /* SourceFile */) {
+ if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SyntaxKind.SourceFile */) {
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
var symbol = _a[_i];
- symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ };
+ symbolToOriginInfoMap[symbols.length] = { kind: 1 /* SymbolOriginInfoKind.ThisType */ };
symbols.push(symbol);
- symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 14 /* SuggestedClassMembers */;
+ symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.SuggestedClassMembers;
}
}
}
collectAutoImports();
if (isTypeOnlyLocation) {
keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent)
- ? 6 /* TypeAssertionKeywords */
- : 7 /* TypeKeywords */;
+ ? 6 /* KeywordCompletionFilters.TypeAssertionKeywords */
+ : 7 /* KeywordCompletionFilters.TypeKeywords */;
}
}
function shouldOfferImportCompletions() {
@@ -131723,10 +133905,10 @@ var ts;
}
function isSnippetScope(scopeNode) {
switch (scopeNode.kind) {
- case 303 /* SourceFile */:
- case 222 /* TemplateExpression */:
- case 287 /* JsxExpression */:
- case 234 /* Block */:
+ case 305 /* SyntaxKind.SourceFile */:
+ case 223 /* SyntaxKind.TemplateExpression */:
+ case 288 /* SyntaxKind.JsxExpression */:
+ case 235 /* SyntaxKind.Block */:
return true;
default:
return ts.isStatement(scopeNode);
@@ -131742,34 +133924,34 @@ var ts;
}
function isContextTokenValueLocation(contextToken) {
return contextToken &&
- ((contextToken.kind === 112 /* TypeOfKeyword */ &&
- (contextToken.parent.kind === 180 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) ||
- (contextToken.kind === 128 /* AssertsKeyword */ && contextToken.parent.kind === 176 /* TypePredicate */));
+ ((contextToken.kind === 112 /* SyntaxKind.TypeOfKeyword */ &&
+ (contextToken.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) ||
+ (contextToken.kind === 128 /* SyntaxKind.AssertsKeyword */ && contextToken.parent.kind === 177 /* SyntaxKind.TypePredicate */));
}
function isContextTokenTypeLocation(contextToken) {
if (contextToken) {
var parentKind = contextToken.parent.kind;
switch (contextToken.kind) {
- case 58 /* ColonToken */:
- return parentKind === 166 /* PropertyDeclaration */ ||
- parentKind === 165 /* PropertySignature */ ||
- parentKind === 163 /* Parameter */ ||
- parentKind === 253 /* VariableDeclaration */ ||
+ case 58 /* SyntaxKind.ColonToken */:
+ return parentKind === 167 /* SyntaxKind.PropertyDeclaration */ ||
+ parentKind === 166 /* SyntaxKind.PropertySignature */ ||
+ parentKind === 164 /* SyntaxKind.Parameter */ ||
+ parentKind === 254 /* SyntaxKind.VariableDeclaration */ ||
ts.isFunctionLikeKind(parentKind);
- case 63 /* EqualsToken */:
- return parentKind === 258 /* TypeAliasDeclaration */;
- case 127 /* AsKeyword */:
- return parentKind === 228 /* AsExpression */;
- case 29 /* LessThanToken */:
- return parentKind === 177 /* TypeReference */ ||
- parentKind === 210 /* TypeAssertionExpression */;
- case 94 /* ExtendsKeyword */:
- return parentKind === 162 /* TypeParameter */;
+ case 63 /* SyntaxKind.EqualsToken */:
+ return parentKind === 259 /* SyntaxKind.TypeAliasDeclaration */;
+ case 127 /* SyntaxKind.AsKeyword */:
+ return parentKind === 229 /* SyntaxKind.AsExpression */;
+ case 29 /* SyntaxKind.LessThanToken */:
+ return parentKind === 178 /* SyntaxKind.TypeReference */ ||
+ parentKind === 211 /* SyntaxKind.TypeAssertionExpression */;
+ case 94 /* SyntaxKind.ExtendsKeyword */:
+ return parentKind === 163 /* SyntaxKind.TypeParameter */;
}
}
return false;
}
- /** Mutates `symbols`, `symbolToOriginInfoMap`, and `symbolToSortTextIdMap` */
+ /** Mutates `symbols`, `symbolToOriginInfoMap`, and `symbolToSortTextMap` */
function collectAutoImports() {
var _a, _b;
if (!shouldOfferImportCompletions())
@@ -131779,6 +133961,7 @@ var ts;
// Asking for completion details for an item that is not an auto-import
return;
}
+ flags |= 1 /* CompletionInfoFlags.MayIncludeAutoImports */;
// import { type | -> token text should be blank
var isAfterTypeOnlyImportSpecifierModifier = previousToken === contextToken
&& importCompletionNode
@@ -131790,50 +133973,72 @@ var ts;
var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken);
var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
- resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
+ resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
exportInfo.search(sourceFile.path,
/*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
return false;
if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
return false;
- if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* Value */))
+ if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* SymbolFlags.Value */))
return false;
- if (isTypeOnlyLocation && !(targetFlags & (1536 /* Module */ | 788968 /* Type */)))
+ if (isTypeOnlyLocation && !(targetFlags & (1536 /* SymbolFlags.Module */ | 788968 /* SymbolFlags.Type */)))
return false;
// Do not try to auto-import something with a lowercase first letter for a JSX tag
var firstChar = symbolName.charCodeAt(0);
- if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */))
+ if (isRightOfOpenTag && (firstChar < 65 /* CharacterCodes.A */ || firstChar > 90 /* CharacterCodes.Z */))
return false;
if (detailsEntryId)
return true;
return charactersFuzzyMatchInString(symbolName, lowerCaseTokenText);
}, function (info, symbolName, isFromAmbientModule, exportMapKey) {
+ var _a;
if (detailsEntryId && !ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); })) {
return;
}
- var defaultExportInfo = ts.find(info, isImportableExportInfo);
- if (!defaultExportInfo) {
+ // Do a relatively cheap check to bail early if all re-exports are non-importable
+ // due to file location or package.json dependency filtering. For non-node16+
+ // module resolution modes, getting past this point guarantees that we'll be
+ // able to generate a suitable module specifier, so we can safely show a completion,
+ // even if we defer computing the module specifier.
+ var firstImportableExportInfo = ts.find(info, isImportableExportInfo);
+ if (!firstImportableExportInfo) {
return;
}
- // If we don't need to resolve module specifiers, we can use any re-export that is importable at all
- // (We need to ensure that at least one is importable to show a completion.)
- var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
- var isDefaultExport = exportInfo.exportKind === 1 /* Default */;
+ // In node16+, module specifier resolution can fail due to modules being blocked
+ // by package.json `exports`. If that happens, don't show a completion item.
+ // N.B. in this resolution mode we always try to resolve module specifiers here,
+ // because we have to know now if it's going to fail so we can omit the completion
+ // from the list.
+ var result = context.tryResolve(info, symbolName, isFromAmbientModule) || {};
+ if (result === "failed")
+ return;
+ // If we skipped resolving module specifiers, our selection of which ExportInfo
+ // to use here is arbitrary, since the info shown in the completion list derived from
+ // it should be identical regardless of which one is used. During the subsequent
+ // `CompletionEntryDetails` request, we'll get all the ExportInfos again and pick
+ // the best one based on the module specifier it produces.
+ var exportInfo = firstImportableExportInfo, moduleSpecifier;
+ if (result !== "skipped") {
+ (_a = result.exportInfo, exportInfo = _a === void 0 ? firstImportableExportInfo : _a, moduleSpecifier = result.moduleSpecifier);
+ }
+ var isDefaultExport = exportInfo.exportKind === 1 /* ExportKind.Default */;
var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol;
pushAutoImportSymbol(symbol, {
- kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
+ kind: moduleSpecifier ? 32 /* SymbolOriginInfoKind.ResolvedExport */ : 4 /* SymbolOriginInfoKind.Export */,
moduleSpecifier: moduleSpecifier,
symbolName: symbolName,
exportMapKey: exportMapKey,
- exportName: exportInfo.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo.symbol.name,
+ exportName: exportInfo.exportKind === 2 /* ExportKind.ExportEquals */ ? "export=" /* InternalSymbolName.ExportEquals */ : exportInfo.symbol.name,
fileName: exportInfo.moduleFileName,
isDefaultExport: isDefaultExport,
moduleSymbol: exportInfo.moduleSymbol,
isFromPackageJson: exportInfo.isFromPackageJson,
});
});
- hasUnresolvedAutoImports = context.resolutionLimitExceeded();
+ hasUnresolvedAutoImports = context.skippedAny();
+ flags |= context.resolvedAny() ? 8 /* CompletionInfoFlags.ResolvedModuleSpecifiers */ : 0;
+ flags |= context.resolvedBeyondLimit() ? 16 /* CompletionInfoFlags.ResolvedModuleSpecifiersBeyondLimit */ : 0;
});
function isImportableExportInfo(info) {
var moduleFile = ts.tryCast(info.moduleSymbol.valueDeclaration, ts.isSourceFile);
@@ -131851,14 +134056,56 @@ var ts;
}
function pushAutoImportSymbol(symbol, origin) {
var symbolId = ts.getSymbolId(symbol);
- if (symbolToSortTextIdMap[symbolId] === 15 /* GlobalsOrKeywords */) {
+ if (symbolToSortTextMap[symbolId] === Completions.SortText.GlobalsOrKeywords) {
// If an auto-importable symbol is available as a global, don't add the auto import
return;
}
symbolToOriginInfoMap[symbols.length] = origin;
- symbolToSortTextIdMap[symbolId] = importCompletionNode ? 11 /* LocationPriority */ : 16 /* AutoImportSuggestions */;
+ symbolToSortTextMap[symbolId] = importCompletionNode ? Completions.SortText.LocationPriority : Completions.SortText.AutoImportSuggestions;
symbols.push(symbol);
}
+ /* Mutates `symbols` and `symbolToOriginInfoMap`. */
+ function collectObjectLiteralMethodSymbols(members, enclosingDeclaration) {
+ // TODO: support JS files.
+ if (ts.isInJSFile(location)) {
+ return;
+ }
+ members.forEach(function (member) {
+ if (!isObjectLiteralMethodSymbol(member)) {
+ return;
+ }
+ var displayName = getCompletionEntryDisplayNameForSymbol(member, ts.getEmitScriptTarget(compilerOptions),
+ /*origin*/ undefined, 0 /* CompletionKind.ObjectPropertyDeclaration */,
+ /*jsxIdentifierExpected*/ false);
+ if (!displayName) {
+ return;
+ }
+ var name = displayName.name;
+ var entryProps = getEntryForObjectLiteralMethodCompletion(member, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext);
+ if (!entryProps) {
+ return;
+ }
+ var origin = __assign({ kind: 128 /* SymbolOriginInfoKind.ObjectLiteralMethod */ }, entryProps);
+ flags |= 32 /* CompletionInfoFlags.MayIncludeMethodSnippets */;
+ symbolToOriginInfoMap[symbols.length] = origin;
+ symbols.push(member);
+ });
+ }
+ function isObjectLiteralMethodSymbol(symbol) {
+ /*
+ For an object type
+ `type Foo = {
+ bar(x: number): void;
+ foo: (x: string) => string;
+ }`,
+ `bar` will have symbol flag `Method`,
+ `foo` will have symbol flag `Property`.
+ */
+ if (!(symbol.flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */))) {
+ return false;
+ }
+ return true;
+ }
/**
* Finds the first node that "embraces" the position, so that one may
* accurately aggregate locals from the closest containing scope.
@@ -131881,27 +134128,27 @@ var ts;
return result;
}
function isInJsxText(contextToken) {
- if (contextToken.kind === 11 /* JsxText */) {
+ if (contextToken.kind === 11 /* SyntaxKind.JsxText */) {
return true;
}
- if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) {
+ if (contextToken.kind === 31 /* SyntaxKind.GreaterThanToken */ && contextToken.parent) {
// <Component<string> /**/ />
// <Component<string> /**/ ><Component>
// - contextToken: GreaterThanToken (before cursor)
// - location: JsxSelfClosingElement or JsxOpeningElement
// - contextToken.parent === location
- if (location === contextToken.parent && (location.kind === 279 /* JsxOpeningElement */ || location.kind === 278 /* JsxSelfClosingElement */)) {
+ if (location === contextToken.parent && (location.kind === 280 /* SyntaxKind.JsxOpeningElement */ || location.kind === 279 /* SyntaxKind.JsxSelfClosingElement */)) {
return false;
}
- if (contextToken.parent.kind === 279 /* JsxOpeningElement */) {
+ if (contextToken.parent.kind === 280 /* SyntaxKind.JsxOpeningElement */) {
// <div>/**/
// - contextToken: GreaterThanToken (before cursor)
// - location: JSXElement
// - different parents (JSXOpeningElement, JSXElement)
- return location.parent.kind !== 279 /* JsxOpeningElement */;
+ return location.parent.kind !== 280 /* SyntaxKind.JsxOpeningElement */;
}
- if (contextToken.parent.kind === 280 /* JsxClosingElement */ || contextToken.parent.kind === 278 /* JsxSelfClosingElement */) {
- return !!contextToken.parent.parent && contextToken.parent.parent.kind === 277 /* JsxElement */;
+ if (contextToken.parent.kind === 281 /* SyntaxKind.JsxClosingElement */ || contextToken.parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */) {
+ return !!contextToken.parent.parent && contextToken.parent.parent.kind === 278 /* SyntaxKind.JsxElement */;
}
}
return false;
@@ -131912,45 +134159,45 @@ var ts;
var tokenKind = keywordForNode(contextToken);
// Previous token may have been a keyword that was converted to an identifier.
switch (tokenKind) {
- case 27 /* CommaToken */:
- return containingNodeKind === 207 /* CallExpression */ // func( a, |
- || containingNodeKind === 170 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */
- || containingNodeKind === 208 /* NewExpression */ // new C(a, |
- || containingNodeKind === 203 /* ArrayLiteralExpression */ // [a, |
- || containingNodeKind === 220 /* BinaryExpression */ // const x = (a, |
- || containingNodeKind === 178 /* FunctionType */ // var x: (s: string, list|
- || containingNodeKind === 204 /* ObjectLiteralExpression */; // const obj = { x, |
- case 20 /* OpenParenToken */:
- return containingNodeKind === 207 /* CallExpression */ // func( |
- || containingNodeKind === 170 /* Constructor */ // constructor( |
- || containingNodeKind === 208 /* NewExpression */ // new C(a|
- || containingNodeKind === 211 /* ParenthesizedExpression */ // const x = (a|
- || containingNodeKind === 190 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */
- case 22 /* OpenBracketToken */:
- return containingNodeKind === 203 /* ArrayLiteralExpression */ // [ |
- || containingNodeKind === 175 /* IndexSignature */ // [ | : string ]
- || containingNodeKind === 161 /* ComputedPropertyName */; // [ | /* this can become an index signature */
- case 141 /* ModuleKeyword */: // module |
- case 142 /* NamespaceKeyword */: // namespace |
- case 100 /* ImportKeyword */: // import |
+ case 27 /* SyntaxKind.CommaToken */:
+ return containingNodeKind === 208 /* SyntaxKind.CallExpression */ // func( a, |
+ || containingNodeKind === 171 /* SyntaxKind.Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */
+ || containingNodeKind === 209 /* SyntaxKind.NewExpression */ // new C(a, |
+ || containingNodeKind === 204 /* SyntaxKind.ArrayLiteralExpression */ // [a, |
+ || containingNodeKind === 221 /* SyntaxKind.BinaryExpression */ // const x = (a, |
+ || containingNodeKind === 179 /* SyntaxKind.FunctionType */ // var x: (s: string, list|
+ || containingNodeKind === 205 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { x, |
+ case 20 /* SyntaxKind.OpenParenToken */:
+ return containingNodeKind === 208 /* SyntaxKind.CallExpression */ // func( |
+ || containingNodeKind === 171 /* SyntaxKind.Constructor */ // constructor( |
+ || containingNodeKind === 209 /* SyntaxKind.NewExpression */ // new C(a|
+ || containingNodeKind === 212 /* SyntaxKind.ParenthesizedExpression */ // const x = (a|
+ || containingNodeKind === 191 /* SyntaxKind.ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */
+ case 22 /* SyntaxKind.OpenBracketToken */:
+ return containingNodeKind === 204 /* SyntaxKind.ArrayLiteralExpression */ // [ |
+ || containingNodeKind === 176 /* SyntaxKind.IndexSignature */ // [ | : string ]
+ || containingNodeKind === 162 /* SyntaxKind.ComputedPropertyName */; // [ | /* this can become an index signature */
+ case 141 /* SyntaxKind.ModuleKeyword */: // module |
+ case 142 /* SyntaxKind.NamespaceKeyword */: // namespace |
+ case 100 /* SyntaxKind.ImportKeyword */: // import |
return true;
- case 24 /* DotToken */:
- return containingNodeKind === 260 /* ModuleDeclaration */; // module A.|
- case 18 /* OpenBraceToken */:
- return containingNodeKind === 256 /* ClassDeclaration */ // class A { |
- || containingNodeKind === 204 /* ObjectLiteralExpression */; // const obj = { |
- case 63 /* EqualsToken */:
- return containingNodeKind === 253 /* VariableDeclaration */ // const x = a|
- || containingNodeKind === 220 /* BinaryExpression */; // x = a|
- case 15 /* TemplateHead */:
- return containingNodeKind === 222 /* TemplateExpression */; // `aa ${|
- case 16 /* TemplateMiddle */:
- return containingNodeKind === 232 /* TemplateSpan */; // `aa ${10} dd ${|
- case 131 /* AsyncKeyword */:
- return containingNodeKind === 168 /* MethodDeclaration */ // const obj = { async c|()
- || containingNodeKind === 295 /* ShorthandPropertyAssignment */; // const obj = { async c|
- case 41 /* AsteriskToken */:
- return containingNodeKind === 168 /* MethodDeclaration */; // const obj = { * c|
+ case 24 /* SyntaxKind.DotToken */:
+ return containingNodeKind === 261 /* SyntaxKind.ModuleDeclaration */; // module A.|
+ case 18 /* SyntaxKind.OpenBraceToken */:
+ return containingNodeKind === 257 /* SyntaxKind.ClassDeclaration */ // class A { |
+ || containingNodeKind === 205 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { |
+ case 63 /* SyntaxKind.EqualsToken */:
+ return containingNodeKind === 254 /* SyntaxKind.VariableDeclaration */ // const x = a|
+ || containingNodeKind === 221 /* SyntaxKind.BinaryExpression */; // x = a|
+ case 15 /* SyntaxKind.TemplateHead */:
+ return containingNodeKind === 223 /* SyntaxKind.TemplateExpression */; // `aa ${|
+ case 16 /* SyntaxKind.TemplateMiddle */:
+ return containingNodeKind === 233 /* SyntaxKind.TemplateSpan */; // `aa ${10} dd ${|
+ case 131 /* SyntaxKind.AsyncKeyword */:
+ return containingNodeKind === 169 /* SyntaxKind.MethodDeclaration */ // const obj = { async c|()
+ || containingNodeKind === 297 /* SyntaxKind.ShorthandPropertyAssignment */; // const obj = { async c|
+ case 41 /* SyntaxKind.AsteriskToken */:
+ return containingNodeKind === 169 /* SyntaxKind.MethodDeclaration */; // const obj = { * c|
}
if (isClassMemberCompletionKeyword(tokenKind)) {
return true;
@@ -131969,21 +134216,21 @@ var ts;
function tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() {
var typeLiteralNode = tryGetTypeLiteralNode(contextToken);
if (!typeLiteralNode)
- return 0 /* Continue */;
+ return 0 /* GlobalsSearch.Continue */;
var intersectionTypeNode = ts.isIntersectionTypeNode(typeLiteralNode.parent) ? typeLiteralNode.parent : undefined;
var containerTypeNode = intersectionTypeNode || typeLiteralNode;
var containerExpectedType = getConstraintOfTypeArgumentProperty(containerTypeNode, typeChecker);
if (!containerExpectedType)
- return 0 /* Continue */;
+ return 0 /* GlobalsSearch.Continue */;
var containerActualType = typeChecker.getTypeFromTypeNode(containerTypeNode);
var members = getPropertiesForCompletion(containerExpectedType, typeChecker);
var existingMembers = getPropertiesForCompletion(containerActualType, typeChecker);
var existingMemberEscapedNames = new ts.Set();
existingMembers.forEach(function (s) { return existingMemberEscapedNames.add(s.escapedName); });
symbols = ts.concatenate(symbols, ts.filter(members, function (s) { return !existingMemberEscapedNames.has(s.escapedName); }));
- completionKind = 0 /* ObjectPropertyDeclaration */;
+ completionKind = 0 /* CompletionKind.ObjectPropertyDeclaration */;
isNewIdentifierLocation = true;
- return 1 /* Success */;
+ return 1 /* GlobalsSearch.Success */;
}
/**
* Aggregates relevant symbols for completion in object literals and object binding patterns.
@@ -131992,24 +134239,25 @@ var ts;
* @returns true if 'symbols' was successfully populated; false otherwise.
*/
function tryGetObjectLikeCompletionSymbols() {
+ var symbolsStartIndex = symbols.length;
var objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken);
if (!objectLikeContainer)
- return 0 /* Continue */;
+ return 0 /* GlobalsSearch.Continue */;
// We're looking up possible property names from contextual/inferred/declared type.
- completionKind = 0 /* ObjectPropertyDeclaration */;
+ completionKind = 0 /* CompletionKind.ObjectPropertyDeclaration */;
var typeMembers;
var existingMembers;
- if (objectLikeContainer.kind === 204 /* ObjectLiteralExpression */) {
+ if (objectLikeContainer.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) {
var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker);
// Check completions for Object property value shorthand
if (instantiatedType === undefined) {
- if (objectLikeContainer.flags & 16777216 /* InWithStatement */) {
- return 2 /* Fail */;
+ if (objectLikeContainer.flags & 33554432 /* NodeFlags.InWithStatement */) {
+ return 2 /* GlobalsSearch.Fail */;
}
isNonContextualObjectLiteral = true;
- return 0 /* Continue */;
+ return 0 /* GlobalsSearch.Continue */;
}
- var completionsType = typeChecker.getContextualType(objectLikeContainer, 4 /* Completions */);
+ var completionsType = typeChecker.getContextualType(objectLikeContainer, 4 /* ContextFlags.Completions */);
var hasStringIndexType = (completionsType || instantiatedType).getStringIndexType();
var hasNumberIndextype = (completionsType || instantiatedType).getNumberIndexType();
isNewIdentifierLocation = !!hasStringIndexType || !!hasNumberIndextype;
@@ -132019,12 +134267,12 @@ var ts;
// Edge case: If NumberIndexType exists
if (!hasNumberIndextype) {
isNonContextualObjectLiteral = true;
- return 0 /* Continue */;
+ return 0 /* GlobalsSearch.Continue */;
}
}
}
else {
- ts.Debug.assert(objectLikeContainer.kind === 200 /* ObjectBindingPattern */);
+ ts.Debug.assert(objectLikeContainer.kind === 201 /* SyntaxKind.ObjectBindingPattern */);
// We are *only* completing on properties from the type being destructured.
isNewIdentifierLocation = false;
var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent);
@@ -132035,19 +134283,19 @@ var ts;
// through type declaration or inference.
// Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed -
// type of parameter will flow in from the contextual type of the function
- var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 243 /* ForOfStatement */;
- if (!canGetType && rootDeclaration.kind === 163 /* Parameter */) {
+ var canGetType = ts.hasInitializer(rootDeclaration) || !!ts.getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */;
+ if (!canGetType && rootDeclaration.kind === 164 /* SyntaxKind.Parameter */) {
if (ts.isExpression(rootDeclaration.parent)) {
canGetType = !!typeChecker.getContextualType(rootDeclaration.parent);
}
- else if (rootDeclaration.parent.kind === 168 /* MethodDeclaration */ || rootDeclaration.parent.kind === 172 /* SetAccessor */) {
+ else if (rootDeclaration.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ || rootDeclaration.parent.kind === 173 /* SyntaxKind.SetAccessor */) {
canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent);
}
}
if (canGetType) {
var typeForObject_1 = typeChecker.getTypeAtLocation(objectLikeContainer);
if (!typeForObject_1)
- return 2 /* Fail */;
+ return 2 /* GlobalsSearch.Fail */;
typeMembers = typeChecker.getPropertiesOfType(typeForObject_1).filter(function (propertySymbol) {
return typeChecker.isPropertyAccessible(objectLikeContainer, /*isSuper*/ false, /*writing*/ false, typeForObject_1, propertySymbol);
});
@@ -132056,10 +134304,17 @@ var ts;
}
if (typeMembers && typeMembers.length > 0) {
// Add filtered items to the completion list
- symbols = ts.concatenate(symbols, filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers)));
+ var filteredMembers = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers));
+ symbols = ts.concatenate(symbols, filteredMembers);
+ setSortTextToOptionalMember();
+ if (objectLikeContainer.kind === 205 /* SyntaxKind.ObjectLiteralExpression */
+ && preferences.includeCompletionsWithObjectLiteralMethodSnippets
+ && preferences.includeCompletionsWithInsertText) {
+ transformObjectLiteralMembersSortText(symbolsStartIndex);
+ collectObjectLiteralMethodSymbols(filteredMembers, objectLikeContainer);
+ }
}
- setSortTextToOptionalMember();
- return 1 /* Success */;
+ return 1 /* GlobalsSearch.Success */;
}
/**
* Aggregates relevant symbols for completion in import clauses and export clauses
@@ -132076,38 +134331,38 @@ var ts;
*/
function tryGetImportOrExportClauseCompletionSymbols() {
if (!contextToken)
- return 0 /* Continue */;
+ return 0 /* GlobalsSearch.Continue */;
// `import { |` or `import { a as 0, | }` or `import { type | }`
- var namedImportsOrExports = contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */ ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) :
+ var namedImportsOrExports = contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || contextToken.kind === 27 /* SyntaxKind.CommaToken */ ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) :
ts.isTypeKeywordTokenOrIdentifier(contextToken) ? ts.tryCast(contextToken.parent.parent, ts.isNamedImportsOrExports) : undefined;
if (!namedImportsOrExports)
- return 0 /* Continue */;
+ return 0 /* GlobalsSearch.Continue */;
// We can at least offer `type` at `import { |`
if (!ts.isTypeKeywordTokenOrIdentifier(contextToken)) {
- keywordFilters = 8 /* TypeKeyword */;
+ keywordFilters = 8 /* KeywordCompletionFilters.TypeKeyword */;
}
// try to show exported member for imported/re-exported module
- var moduleSpecifier = (namedImportsOrExports.kind === 268 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier;
+ var moduleSpecifier = (namedImportsOrExports.kind === 269 /* SyntaxKind.NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier;
if (!moduleSpecifier) {
isNewIdentifierLocation = true;
- return namedImportsOrExports.kind === 268 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */;
+ return namedImportsOrExports.kind === 269 /* SyntaxKind.NamedImports */ ? 2 /* GlobalsSearch.Fail */ : 0 /* GlobalsSearch.Continue */;
}
var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217
if (!moduleSpecifierSymbol) {
isNewIdentifierLocation = true;
- return 2 /* Fail */;
+ return 2 /* GlobalsSearch.Fail */;
}
- completionKind = 3 /* MemberLike */;
+ completionKind = 3 /* CompletionKind.MemberLike */;
isNewIdentifierLocation = false;
var exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol);
var existing = new ts.Set(namedImportsOrExports.elements.filter(function (n) { return !isCurrentlyEditingNode(n); }).map(function (n) { return (n.propertyName || n.name).escapedText; }));
- var uniques = exports.filter(function (e) { return e.escapedName !== "default" /* Default */ && !existing.has(e.escapedName); });
+ var uniques = exports.filter(function (e) { return e.escapedName !== "default" /* InternalSymbolName.Default */ && !existing.has(e.escapedName); });
symbols = ts.concatenate(symbols, uniques);
if (!uniques.length) {
// If there's nothing else to import, don't offer `type` either
- keywordFilters = 0 /* None */;
+ keywordFilters = 0 /* KeywordCompletionFilters.None */;
}
- return 1 /* Success */;
+ return 1 /* GlobalsSearch.Success */;
}
/**
* Adds local declarations for completions in named exports:
@@ -132120,23 +134375,23 @@ var ts;
*/
function tryGetLocalNamedExportCompletionSymbols() {
var _a;
- var namedExports = contextToken && (contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */)
+ var namedExports = contextToken && (contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || contextToken.kind === 27 /* SyntaxKind.CommaToken */)
? ts.tryCast(contextToken.parent, ts.isNamedExports)
: undefined;
if (!namedExports) {
- return 0 /* Continue */;
+ return 0 /* GlobalsSearch.Continue */;
}
var localsContainer = ts.findAncestor(namedExports, ts.or(ts.isSourceFile, ts.isModuleDeclaration));
- completionKind = 5 /* None */;
+ completionKind = 5 /* CompletionKind.None */;
isNewIdentifierLocation = false;
(_a = localsContainer.locals) === null || _a === void 0 ? void 0 : _a.forEach(function (symbol, name) {
var _a, _b;
symbols.push(symbol);
if ((_b = (_a = localsContainer.symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has(name)) {
- symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 12 /* OptionalMember */;
+ symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.OptionalMember;
}
});
- return 1 /* Success */;
+ return 1 /* GlobalsSearch.Success */;
}
/**
* Aggregates relevant symbols for completion in class declaration
@@ -132145,71 +134400,48 @@ var ts;
function tryGetClassLikeCompletionSymbols() {
var decl = tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position);
if (!decl)
- return 0 /* Continue */;
+ return 0 /* GlobalsSearch.Continue */;
// We're looking up possible property names from parent type.
- completionKind = 3 /* MemberLike */;
+ completionKind = 3 /* CompletionKind.MemberLike */;
// Declaring new property/method/accessor
isNewIdentifierLocation = true;
- keywordFilters = contextToken.kind === 41 /* AsteriskToken */ ? 0 /* None */ :
- ts.isClassLike(decl) ? 2 /* ClassElementKeywords */ : 3 /* InterfaceElementKeywords */;
+ keywordFilters = contextToken.kind === 41 /* SyntaxKind.AsteriskToken */ ? 0 /* KeywordCompletionFilters.None */ :
+ ts.isClassLike(decl) ? 2 /* KeywordCompletionFilters.ClassElementKeywords */ : 3 /* KeywordCompletionFilters.InterfaceElementKeywords */;
// If you're in an interface you don't want to repeat things from super-interface. So just stop here.
if (!ts.isClassLike(decl))
- return 1 /* Success */;
- var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent;
- var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* None */;
+ return 1 /* GlobalsSearch.Success */;
+ var classElement = contextToken.kind === 26 /* SyntaxKind.SemicolonToken */ ? contextToken.parent.parent : contextToken.parent;
+ var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* ModifierFlags.None */;
// If this is context token is not something we are editing now, consider if this would lead to be modifier
- if (contextToken.kind === 79 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) {
+ if (contextToken.kind === 79 /* SyntaxKind.Identifier */ && !isCurrentlyEditingNode(contextToken)) {
switch (contextToken.getText()) {
case "private":
- classElementModifierFlags = classElementModifierFlags | 8 /* Private */;
+ classElementModifierFlags = classElementModifierFlags | 8 /* ModifierFlags.Private */;
break;
case "static":
- classElementModifierFlags = classElementModifierFlags | 32 /* Static */;
+ classElementModifierFlags = classElementModifierFlags | 32 /* ModifierFlags.Static */;
break;
case "override":
- classElementModifierFlags = classElementModifierFlags | 16384 /* Override */;
+ classElementModifierFlags = classElementModifierFlags | 16384 /* ModifierFlags.Override */;
break;
}
}
if (ts.isClassStaticBlockDeclaration(classElement)) {
- classElementModifierFlags |= 32 /* Static */;
+ classElementModifierFlags |= 32 /* ModifierFlags.Static */;
}
// No member list for private methods
- if (!(classElementModifierFlags & 8 /* Private */)) {
+ if (!(classElementModifierFlags & 8 /* ModifierFlags.Private */)) {
// List of property symbols of base type that are not private and already implemented
- var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* Override */ ? ts.singleElementArray(ts.getEffectiveBaseTypeNode(decl)) : ts.getAllSuperTypeNodes(decl);
+ var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* ModifierFlags.Override */ ? ts.singleElementArray(ts.getEffectiveBaseTypeNode(decl)) : ts.getAllSuperTypeNodes(decl);
var baseSymbols = ts.flatMap(baseTypeNodes, function (baseTypeNode) {
var type = typeChecker.getTypeAtLocation(baseTypeNode);
- return classElementModifierFlags & 32 /* Static */ ?
+ return classElementModifierFlags & 32 /* ModifierFlags.Static */ ?
(type === null || type === void 0 ? void 0 : type.symbol) && typeChecker.getPropertiesOfType(typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl)) :
type && typeChecker.getPropertiesOfType(type);
});
symbols = ts.concatenate(symbols, filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags));
}
- return 1 /* Success */;
- }
- /**
- * Returns the immediate owning object literal or binding pattern of a context token,
- * on the condition that one exists and that the context implies completion should be given.
- */
- function tryGetObjectLikeCompletionContainer(contextToken) {
- if (contextToken) {
- var parent = contextToken.parent;
- switch (contextToken.kind) {
- case 18 /* OpenBraceToken */: // const x = { |
- case 27 /* CommaToken */: // const x = { a: 0, |
- if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) {
- return parent;
- }
- break;
- case 41 /* AsteriskToken */:
- return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined;
- case 79 /* Identifier */:
- return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent)
- ? contextToken.parent.parent : undefined;
- }
- }
- return undefined;
+ return 1 /* GlobalsSearch.Success */;
}
function isConstructorParameterCompletion(node) {
return !!node.parent && ts.isParameter(node.parent) && ts.isConstructorDeclaration(node.parent.parent)
@@ -132223,8 +134455,8 @@ var ts;
if (contextToken) {
var parent = contextToken.parent;
switch (contextToken.kind) {
- case 20 /* OpenParenToken */:
- case 27 /* CommaToken */:
+ case 20 /* SyntaxKind.OpenParenToken */:
+ case 27 /* SyntaxKind.CommaToken */:
return ts.isConstructorDeclaration(contextToken.parent) ? contextToken.parent : undefined;
default:
if (isConstructorParameterCompletion(contextToken)) {
@@ -132254,23 +134486,23 @@ var ts;
if (contextToken) {
var parent = contextToken.parent;
switch (contextToken.kind) {
- case 31 /* GreaterThanToken */: // End of a type argument list
- case 30 /* LessThanSlashToken */:
- case 43 /* SlashToken */:
- case 79 /* Identifier */:
- case 205 /* PropertyAccessExpression */:
- case 285 /* JsxAttributes */:
- case 284 /* JsxAttribute */:
- case 286 /* JsxSpreadAttribute */:
- if (parent && (parent.kind === 278 /* JsxSelfClosingElement */ || parent.kind === 279 /* JsxOpeningElement */)) {
- if (contextToken.kind === 31 /* GreaterThanToken */) {
+ case 31 /* SyntaxKind.GreaterThanToken */: // End of a type argument list
+ case 30 /* SyntaxKind.LessThanSlashToken */:
+ case 43 /* SyntaxKind.SlashToken */:
+ case 79 /* SyntaxKind.Identifier */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 286 /* SyntaxKind.JsxAttributes */:
+ case 285 /* SyntaxKind.JsxAttribute */:
+ case 287 /* SyntaxKind.JsxSpreadAttribute */:
+ if (parent && (parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */ || parent.kind === 280 /* SyntaxKind.JsxOpeningElement */)) {
+ if (contextToken.kind === 31 /* SyntaxKind.GreaterThanToken */) {
var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined);
- if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */))
+ if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SyntaxKind.SlashToken */))
break;
}
return parent;
}
- else if (parent.kind === 284 /* JsxAttribute */) {
+ else if (parent.kind === 285 /* SyntaxKind.JsxAttribute */) {
// Currently we parse JsxOpeningLikeElement as:
// JsxOpeningLikeElement
// attributes: JsxAttributes
@@ -132281,8 +134513,8 @@ var ts;
// The context token is the closing } or " of an attribute, which means
// its parent is a JsxExpression, whose parent is a JsxAttribute,
// whose parent is a JsxOpeningLikeElement
- case 10 /* StringLiteral */:
- if (parent && ((parent.kind === 284 /* JsxAttribute */) || (parent.kind === 286 /* JsxSpreadAttribute */))) {
+ case 10 /* SyntaxKind.StringLiteral */:
+ if (parent && ((parent.kind === 285 /* SyntaxKind.JsxAttribute */) || (parent.kind === 287 /* SyntaxKind.JsxSpreadAttribute */))) {
// Currently we parse JsxOpeningLikeElement as:
// JsxOpeningLikeElement
// attributes: JsxAttributes
@@ -132290,10 +134522,10 @@ var ts;
return parent.parent.parent;
}
break;
- case 19 /* CloseBraceToken */:
+ case 19 /* SyntaxKind.CloseBraceToken */:
if (parent &&
- parent.kind === 287 /* JsxExpression */ &&
- parent.parent && parent.parent.kind === 284 /* JsxAttribute */) {
+ parent.kind === 288 /* SyntaxKind.JsxExpression */ &&
+ parent.parent && parent.parent.kind === 285 /* SyntaxKind.JsxAttribute */) {
// Currently we parse JsxOpeningLikeElement as:
// JsxOpeningLikeElement
// attributes: JsxAttributes
@@ -132301,7 +134533,7 @@ var ts;
// each JsxAttribute can have initializer as JsxExpression
return parent.parent.parent.parent;
}
- if (parent && parent.kind === 286 /* JsxSpreadAttribute */) {
+ if (parent && parent.kind === 287 /* SyntaxKind.JsxSpreadAttribute */) {
// Currently we parse JsxOpeningLikeElement as:
// JsxOpeningLikeElement
// attributes: JsxAttributes
@@ -132320,75 +134552,75 @@ var ts;
var parent = contextToken.parent;
var containingNodeKind = parent.kind;
switch (contextToken.kind) {
- case 27 /* CommaToken */:
- return containingNodeKind === 253 /* VariableDeclaration */ ||
+ case 27 /* SyntaxKind.CommaToken */:
+ return containingNodeKind === 254 /* SyntaxKind.VariableDeclaration */ ||
isVariableDeclarationListButNotTypeArgument(contextToken) ||
- containingNodeKind === 236 /* VariableStatement */ ||
- containingNodeKind === 259 /* EnumDeclaration */ || // enum a { foo, |
+ containingNodeKind === 237 /* SyntaxKind.VariableStatement */ ||
+ containingNodeKind === 260 /* SyntaxKind.EnumDeclaration */ || // enum a { foo, |
isFunctionLikeButNotConstructor(containingNodeKind) ||
- containingNodeKind === 257 /* InterfaceDeclaration */ || // interface A<T, |
- containingNodeKind === 201 /* ArrayBindingPattern */ || // var [x, y|
- containingNodeKind === 258 /* TypeAliasDeclaration */ || // type Map, K, |
+ containingNodeKind === 258 /* SyntaxKind.InterfaceDeclaration */ || // interface A<T, |
+ containingNodeKind === 202 /* SyntaxKind.ArrayBindingPattern */ || // var [x, y|
+ containingNodeKind === 259 /* SyntaxKind.TypeAliasDeclaration */ || // type Map, K, |
// class A<T, |
// var C = class D<T, |
(ts.isClassLike(parent) &&
!!parent.typeParameters &&
parent.typeParameters.end >= contextToken.pos);
- case 24 /* DotToken */:
- return containingNodeKind === 201 /* ArrayBindingPattern */; // var [.|
- case 58 /* ColonToken */:
- return containingNodeKind === 202 /* BindingElement */; // var {x :html|
- case 22 /* OpenBracketToken */:
- return containingNodeKind === 201 /* ArrayBindingPattern */; // var [x|
- case 20 /* OpenParenToken */:
- return containingNodeKind === 291 /* CatchClause */ ||
+ case 24 /* SyntaxKind.DotToken */:
+ return containingNodeKind === 202 /* SyntaxKind.ArrayBindingPattern */; // var [.|
+ case 58 /* SyntaxKind.ColonToken */:
+ return containingNodeKind === 203 /* SyntaxKind.BindingElement */; // var {x :html|
+ case 22 /* SyntaxKind.OpenBracketToken */:
+ return containingNodeKind === 202 /* SyntaxKind.ArrayBindingPattern */; // var [x|
+ case 20 /* SyntaxKind.OpenParenToken */:
+ return containingNodeKind === 292 /* SyntaxKind.CatchClause */ ||
isFunctionLikeButNotConstructor(containingNodeKind);
- case 18 /* OpenBraceToken */:
- return containingNodeKind === 259 /* EnumDeclaration */; // enum a { |
- case 29 /* LessThanToken */:
- return containingNodeKind === 256 /* ClassDeclaration */ || // class A< |
- containingNodeKind === 225 /* ClassExpression */ || // var C = class D< |
- containingNodeKind === 257 /* InterfaceDeclaration */ || // interface A< |
- containingNodeKind === 258 /* TypeAliasDeclaration */ || // type List< |
+ case 18 /* SyntaxKind.OpenBraceToken */:
+ return containingNodeKind === 260 /* SyntaxKind.EnumDeclaration */; // enum a { |
+ case 29 /* SyntaxKind.LessThanToken */:
+ return containingNodeKind === 257 /* SyntaxKind.ClassDeclaration */ || // class A< |
+ containingNodeKind === 226 /* SyntaxKind.ClassExpression */ || // var C = class D< |
+ containingNodeKind === 258 /* SyntaxKind.InterfaceDeclaration */ || // interface A< |
+ containingNodeKind === 259 /* SyntaxKind.TypeAliasDeclaration */ || // type List< |
ts.isFunctionLikeKind(containingNodeKind);
- case 124 /* StaticKeyword */:
- return containingNodeKind === 166 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent);
- case 25 /* DotDotDotToken */:
- return containingNodeKind === 163 /* Parameter */ ||
- (!!parent.parent && parent.parent.kind === 201 /* ArrayBindingPattern */); // var [...z|
- case 123 /* PublicKeyword */:
- case 121 /* PrivateKeyword */:
- case 122 /* ProtectedKeyword */:
- return containingNodeKind === 163 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent);
- case 127 /* AsKeyword */:
- return containingNodeKind === 269 /* ImportSpecifier */ ||
- containingNodeKind === 274 /* ExportSpecifier */ ||
- containingNodeKind === 267 /* NamespaceImport */;
- case 136 /* GetKeyword */:
- case 148 /* SetKeyword */:
+ case 124 /* SyntaxKind.StaticKeyword */:
+ return containingNodeKind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isClassLike(parent.parent);
+ case 25 /* SyntaxKind.DotDotDotToken */:
+ return containingNodeKind === 164 /* SyntaxKind.Parameter */ ||
+ (!!parent.parent && parent.parent.kind === 202 /* SyntaxKind.ArrayBindingPattern */); // var [...z|
+ case 123 /* SyntaxKind.PublicKeyword */:
+ case 121 /* SyntaxKind.PrivateKeyword */:
+ case 122 /* SyntaxKind.ProtectedKeyword */:
+ return containingNodeKind === 164 /* SyntaxKind.Parameter */ && !ts.isConstructorDeclaration(parent.parent);
+ case 127 /* SyntaxKind.AsKeyword */:
+ return containingNodeKind === 270 /* SyntaxKind.ImportSpecifier */ ||
+ containingNodeKind === 275 /* SyntaxKind.ExportSpecifier */ ||
+ containingNodeKind === 268 /* SyntaxKind.NamespaceImport */;
+ case 136 /* SyntaxKind.GetKeyword */:
+ case 149 /* SyntaxKind.SetKeyword */:
return !isFromObjectTypeDeclaration(contextToken);
- case 79 /* Identifier */:
- if (containingNodeKind === 269 /* ImportSpecifier */ &&
+ case 79 /* SyntaxKind.Identifier */:
+ if (containingNodeKind === 270 /* SyntaxKind.ImportSpecifier */ &&
contextToken === parent.name &&
contextToken.text === "type") {
// import { type | }
return false;
}
break;
- case 84 /* ClassKeyword */:
- case 92 /* EnumKeyword */:
- case 118 /* InterfaceKeyword */:
- case 98 /* FunctionKeyword */:
- case 113 /* VarKeyword */:
- case 100 /* ImportKeyword */:
- case 119 /* LetKeyword */:
- case 85 /* ConstKeyword */:
- case 137 /* InferKeyword */:
+ case 84 /* SyntaxKind.ClassKeyword */:
+ case 92 /* SyntaxKind.EnumKeyword */:
+ case 118 /* SyntaxKind.InterfaceKeyword */:
+ case 98 /* SyntaxKind.FunctionKeyword */:
+ case 113 /* SyntaxKind.VarKeyword */:
+ case 100 /* SyntaxKind.ImportKeyword */:
+ case 119 /* SyntaxKind.LetKeyword */:
+ case 85 /* SyntaxKind.ConstKeyword */:
+ case 137 /* SyntaxKind.InferKeyword */:
return true;
- case 151 /* TypeKeyword */:
+ case 152 /* SyntaxKind.TypeKeyword */:
// import { type foo| }
- return containingNodeKind !== 269 /* ImportSpecifier */;
- case 41 /* AsteriskToken */:
+ return containingNodeKind !== 270 /* SyntaxKind.ImportSpecifier */;
+ case 41 /* SyntaxKind.AsteriskToken */:
return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent);
}
// If the previous token is keyword corresponding to class member completion keyword
@@ -132409,21 +134641,21 @@ var ts;
}
// Previous token may have been a keyword that was converted to an identifier.
switch (keywordForNode(contextToken)) {
- case 126 /* AbstractKeyword */:
- case 84 /* ClassKeyword */:
- case 85 /* ConstKeyword */:
- case 135 /* DeclareKeyword */:
- case 92 /* EnumKeyword */:
- case 98 /* FunctionKeyword */:
- case 118 /* InterfaceKeyword */:
- case 119 /* LetKeyword */:
- case 121 /* PrivateKeyword */:
- case 122 /* ProtectedKeyword */:
- case 123 /* PublicKeyword */:
- case 124 /* StaticKeyword */:
- case 113 /* VarKeyword */:
+ case 126 /* SyntaxKind.AbstractKeyword */:
+ case 84 /* SyntaxKind.ClassKeyword */:
+ case 85 /* SyntaxKind.ConstKeyword */:
+ case 135 /* SyntaxKind.DeclareKeyword */:
+ case 92 /* SyntaxKind.EnumKeyword */:
+ case 98 /* SyntaxKind.FunctionKeyword */:
+ case 118 /* SyntaxKind.InterfaceKeyword */:
+ case 119 /* SyntaxKind.LetKeyword */:
+ case 121 /* SyntaxKind.PrivateKeyword */:
+ case 122 /* SyntaxKind.ProtectedKeyword */:
+ case 123 /* SyntaxKind.PublicKeyword */:
+ case 124 /* SyntaxKind.StaticKeyword */:
+ case 113 /* SyntaxKind.VarKeyword */:
return true;
- case 131 /* AsyncKeyword */:
+ case 131 /* SyntaxKind.AsyncKeyword */:
return ts.isPropertyDeclaration(contextToken.parent);
}
// If we are inside a class declaration, and `constructor` is totally not present,
@@ -132432,7 +134664,7 @@ var ts;
if (ancestorClassLike && contextToken === previousToken && isPreviousPropertyDeclarationTerminated(contextToken, position)) {
return false; // Don't block completions.
}
- var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 166 /* PropertyDeclaration */);
+ var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 167 /* SyntaxKind.PropertyDeclaration */);
// If we are inside a class declaration and typing `constructor` after property declaration...
if (ancestorPropertyDeclaraion
&& contextToken !== previousToken
@@ -132443,7 +134675,7 @@ var ts;
if (isPreviousPropertyDeclarationTerminated(contextToken, previousToken.end)) {
return false; // Don't block completions.
}
- else if (contextToken.kind !== 63 /* EqualsToken */
+ else if (contextToken.kind !== 63 /* SyntaxKind.EqualsToken */
// Should not block: `class C { blah = c/**/ }`
// But should block: `class C { blah = somewhat c/**/ }` and `class C { blah: SomeType c/**/ }`
&& (ts.isInitializedProperty(ancestorPropertyDeclaraion)
@@ -132459,22 +134691,22 @@ var ts;
&& !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end));
}
function isPreviousPropertyDeclarationTerminated(contextToken, position) {
- return contextToken.kind !== 63 /* EqualsToken */ &&
- (contextToken.kind === 26 /* SemicolonToken */
+ return contextToken.kind !== 63 /* SyntaxKind.EqualsToken */ &&
+ (contextToken.kind === 26 /* SyntaxKind.SemicolonToken */
|| !ts.positionsAreOnSameLine(contextToken.end, position, sourceFile));
}
function isFunctionLikeButNotConstructor(kind) {
- return ts.isFunctionLikeKind(kind) && kind !== 170 /* Constructor */;
+ return ts.isFunctionLikeKind(kind) && kind !== 171 /* SyntaxKind.Constructor */;
}
function isDotOfNumericLiteral(contextToken) {
- if (contextToken.kind === 8 /* NumericLiteral */) {
+ if (contextToken.kind === 8 /* SyntaxKind.NumericLiteral */) {
var text = contextToken.getFullText();
return text.charAt(text.length - 1) === ".";
}
return false;
}
function isVariableDeclarationListButNotTypeArgument(node) {
- return node.parent.kind === 254 /* VariableDeclarationList */
+ return node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */
&& !ts.isPossiblyTypeArgumentPosition(node, sourceFile, typeChecker);
}
/**
@@ -132492,13 +134724,13 @@ var ts;
for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) {
var m = existingMembers_1[_i];
// Ignore omitted expressions for missing members
- if (m.kind !== 294 /* PropertyAssignment */ &&
- m.kind !== 295 /* ShorthandPropertyAssignment */ &&
- m.kind !== 202 /* BindingElement */ &&
- m.kind !== 168 /* MethodDeclaration */ &&
- m.kind !== 171 /* GetAccessor */ &&
- m.kind !== 172 /* SetAccessor */ &&
- m.kind !== 296 /* SpreadAssignment */) {
+ if (m.kind !== 296 /* SyntaxKind.PropertyAssignment */ &&
+ m.kind !== 297 /* SyntaxKind.ShorthandPropertyAssignment */ &&
+ m.kind !== 203 /* SyntaxKind.BindingElement */ &&
+ m.kind !== 169 /* SyntaxKind.MethodDeclaration */ &&
+ m.kind !== 172 /* SyntaxKind.GetAccessor */ &&
+ m.kind !== 173 /* SyntaxKind.SetAccessor */ &&
+ m.kind !== 298 /* SyntaxKind.SpreadAssignment */) {
continue;
}
// If this is the current item we are editing right now, do not filter it out
@@ -132511,7 +134743,7 @@ var ts;
}
else if (ts.isBindingElement(m) && m.propertyName) {
// include only identifiers in completion list
- if (m.propertyName.kind === 79 /* Identifier */) {
+ if (m.propertyName.kind === 79 /* SyntaxKind.Identifier */) {
existingName = m.propertyName.escapedText;
}
}
@@ -132545,9 +134777,9 @@ var ts;
function setSortTextToOptionalMember() {
symbols.forEach(function (m) {
var _a;
- if (m.flags & 16777216 /* Optional */) {
+ if (m.flags & 16777216 /* SymbolFlags.Optional */) {
var symbolId = ts.getSymbolId(m);
- symbolToSortTextIdMap[symbolId] = (_a = symbolToSortTextIdMap[symbolId]) !== null && _a !== void 0 ? _a : 12 /* OptionalMember */;
+ symbolToSortTextMap[symbolId] = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.OptionalMember;
}
});
}
@@ -132559,7 +134791,23 @@ var ts;
for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) {
var contextualMemberSymbol = contextualMemberSymbols_1[_i];
if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) {
- symbolToSortTextIdMap[ts.getSymbolId(contextualMemberSymbol)] = 13 /* MemberDeclaredBySpreadAssignment */;
+ symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = Completions.SortText.MemberDeclaredBySpreadAssignment;
+ }
+ }
+ }
+ function transformObjectLiteralMembersSortText(start) {
+ var _a;
+ for (var i = start; i < symbols.length; i++) {
+ var symbol = symbols[i];
+ var symbolId = ts.getSymbolId(symbol);
+ var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i];
+ var target = ts.getEmitScriptTarget(compilerOptions);
+ var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* CompletionKind.ObjectPropertyDeclaration */,
+ /*jsxIdentifierExpected*/ false);
+ if (displayName) {
+ var originalSortText = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority;
+ var name = displayName.name;
+ symbolToSortTextMap[symbolId] = Completions.SortText.ObjectLiteralProperty(originalSortText, name);
}
}
}
@@ -132573,10 +134821,10 @@ var ts;
for (var _i = 0, existingMembers_2 = existingMembers; _i < existingMembers_2.length; _i++) {
var m = existingMembers_2[_i];
// Ignore omitted expressions for missing members
- if (m.kind !== 166 /* PropertyDeclaration */ &&
- m.kind !== 168 /* MethodDeclaration */ &&
- m.kind !== 171 /* GetAccessor */ &&
- m.kind !== 172 /* SetAccessor */) {
+ if (m.kind !== 167 /* SyntaxKind.PropertyDeclaration */ &&
+ m.kind !== 169 /* SyntaxKind.MethodDeclaration */ &&
+ m.kind !== 172 /* SyntaxKind.GetAccessor */ &&
+ m.kind !== 173 /* SyntaxKind.SetAccessor */) {
continue;
}
// If this is the current item we are editing right now, do not filter it out
@@ -132584,11 +134832,11 @@ var ts;
continue;
}
// Dont filter member even if the name matches if it is declared private in the list
- if (ts.hasEffectiveModifier(m, 8 /* Private */)) {
+ if (ts.hasEffectiveModifier(m, 8 /* ModifierFlags.Private */)) {
continue;
}
// do not filter it out if the static presence doesnt match
- if (ts.isStatic(m) !== !!(currentClassElementModifierFlags & 32 /* Static */)) {
+ if (ts.isStatic(m) !== !!(currentClassElementModifierFlags & 32 /* ModifierFlags.Static */)) {
continue;
}
var existingName = ts.getPropertyNameForPropertyNameNode(m.name);
@@ -132599,7 +134847,7 @@ var ts;
return baseSymbols.filter(function (propertySymbol) {
return !existingMemberNames.has(propertySymbol.escapedName) &&
!!propertySymbol.declarations &&
- !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* Private */) &&
+ !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* ModifierFlags.Private */) &&
!(propertySymbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(propertySymbol.valueDeclaration));
});
}
@@ -132618,7 +134866,7 @@ var ts;
if (isCurrentlyEditingNode(attr)) {
continue;
}
- if (attr.kind === 284 /* JsxAttribute */) {
+ if (attr.kind === 285 /* SyntaxKind.JsxAttribute */) {
seenNames.add(attr.name.escapedText);
}
else if (ts.isJsxSpreadAttribute(attr)) {
@@ -132633,6 +134881,29 @@ var ts;
return node.getStart(sourceFile) <= position && position <= node.getEnd();
}
}
+ /**
+ * Returns the immediate owning object literal or binding pattern of a context token,
+ * on the condition that one exists and that the context implies completion should be given.
+ */
+ function tryGetObjectLikeCompletionContainer(contextToken) {
+ if (contextToken) {
+ var parent = contextToken.parent;
+ switch (contextToken.kind) {
+ case 18 /* SyntaxKind.OpenBraceToken */: // const x = { |
+ case 27 /* SyntaxKind.CommaToken */: // const x = { a: 0, |
+ if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) {
+ return parent;
+ }
+ break;
+ case 41 /* SyntaxKind.AsteriskToken */:
+ return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined;
+ case 79 /* SyntaxKind.Identifier */:
+ return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent)
+ ? contextToken.parent.parent : undefined;
+ }
+ }
+ return undefined;
+ }
function getRelevantTokens(position, sourceFile) {
var previousToken = ts.findPrecedingToken(position, sourceFile);
if (previousToken && position <= previousToken.end && (ts.isMemberName(previousToken) || ts.isKeyword(previousToken.kind))) {
@@ -132649,12 +134920,12 @@ var ts;
undefined;
if (!moduleSymbol)
return undefined;
- var symbol = data.exportName === "export=" /* ExportEquals */
+ var symbol = data.exportName === "export=" /* InternalSymbolName.ExportEquals */
? checker.resolveExternalModuleSymbol(moduleSymbol)
: checker.tryGetMemberInModuleExportsAndProperties(data.exportName, moduleSymbol);
if (!symbol)
return undefined;
- var isDefaultExport = data.exportName === "default" /* Default */;
+ var isDefaultExport = data.exportName === "default" /* InternalSymbolName.Default */;
symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(symbol) || symbol;
return { symbol: symbol, origin: completionEntryDataToSymbolOriginInfo(data, name, moduleSymbol) };
}
@@ -132663,27 +134934,27 @@ var ts;
if (name === undefined
// If the symbol is external module, don't show it in the completion list
// (i.e declare module "http" { const x; } | // <= request completion here, "http" should not be there)
- || symbol.flags & 1536 /* Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0))
+ || symbol.flags & 1536 /* SymbolFlags.Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0))
// If the symbol is the internal name of an ES symbol, it is not a valid entry. Internal names for ES symbols start with "__@"
|| ts.isKnownSymbol(symbol)) {
return undefined;
}
var validNameResult = { name: name, needsConvertPropertyAccess: false };
- if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) {
+ if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* LanguageVariant.JSX */ : 0 /* LanguageVariant.Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) {
return validNameResult;
}
switch (kind) {
- case 3 /* MemberLike */:
+ case 3 /* CompletionKind.MemberLike */:
return undefined;
- case 0 /* ObjectPropertyDeclaration */:
+ case 0 /* CompletionKind.ObjectPropertyDeclaration */:
// TODO: GH#18169
return { name: JSON.stringify(name), needsConvertPropertyAccess: false };
- case 2 /* PropertyAccess */:
- case 1 /* Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name.
+ case 2 /* CompletionKind.PropertyAccess */:
+ case 1 /* CompletionKind.Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name.
// Don't add a completion for a name starting with a space. See https://github.com/Microsoft/TypeScript/pull/20547
- return name.charCodeAt(0) === 32 /* space */ ? undefined : { name: name, needsConvertPropertyAccess: true };
- case 5 /* None */:
- case 4 /* String */:
+ return name.charCodeAt(0) === 32 /* CharacterCodes.space */ ? undefined : { name: name, needsConvertPropertyAccess: true };
+ case 5 /* CompletionKind.None */:
+ case 4 /* CompletionKind.String */:
return validNameResult;
default:
ts.Debug.assertNever(kind);
@@ -132693,12 +134964,12 @@ var ts;
var _keywordCompletions = [];
var allKeywordsCompletions = ts.memoize(function () {
var res = [];
- for (var i = 81 /* FirstKeyword */; i <= 159 /* LastKeyword */; i++) {
+ for (var i = 81 /* SyntaxKind.FirstKeyword */; i <= 160 /* SyntaxKind.LastKeyword */; i++) {
res.push({
name: ts.tokenToString(i),
- kind: "keyword" /* keyword */,
- kindModifiers: "" /* none */,
- sortText: SortText.GlobalsOrKeywords
+ kind: "keyword" /* ScriptElementKind.keyword */,
+ kindModifiers: "" /* ScriptElementKindModifier.none */,
+ sortText: Completions.SortText.GlobalsOrKeywords
});
}
return res;
@@ -132706,7 +134977,7 @@ var ts;
function getKeywordCompletions(keywordFilter, filterOutTsOnlyKeywords) {
if (!filterOutTsOnlyKeywords)
return getTypescriptKeywordCompletions(keywordFilter);
- var index = keywordFilter + 7 /* Last */ + 1;
+ var index = keywordFilter + 8 /* KeywordCompletionFilters.Last */ + 1;
return _keywordCompletions[index] ||
(_keywordCompletions[index] = getTypescriptKeywordCompletions(keywordFilter)
.filter(function (entry) { return !isTypeScriptOnlyKeyword(ts.stringToToken(entry.name)); }));
@@ -132715,30 +134986,30 @@ var ts;
return _keywordCompletions[keywordFilter] || (_keywordCompletions[keywordFilter] = allKeywordsCompletions().filter(function (entry) {
var kind = ts.stringToToken(entry.name);
switch (keywordFilter) {
- case 0 /* None */:
+ case 0 /* KeywordCompletionFilters.None */:
return false;
- case 1 /* All */:
+ case 1 /* KeywordCompletionFilters.All */:
return isFunctionLikeBodyKeyword(kind)
- || kind === 135 /* DeclareKeyword */
- || kind === 141 /* ModuleKeyword */
- || kind === 151 /* TypeKeyword */
- || kind === 142 /* NamespaceKeyword */
- || kind === 126 /* AbstractKeyword */
- || ts.isTypeKeyword(kind) && kind !== 152 /* UndefinedKeyword */;
- case 5 /* FunctionLikeBodyKeywords */:
+ || kind === 135 /* SyntaxKind.DeclareKeyword */
+ || kind === 141 /* SyntaxKind.ModuleKeyword */
+ || kind === 152 /* SyntaxKind.TypeKeyword */
+ || kind === 142 /* SyntaxKind.NamespaceKeyword */
+ || kind === 126 /* SyntaxKind.AbstractKeyword */
+ || ts.isTypeKeyword(kind) && kind !== 153 /* SyntaxKind.UndefinedKeyword */;
+ case 5 /* KeywordCompletionFilters.FunctionLikeBodyKeywords */:
return isFunctionLikeBodyKeyword(kind);
- case 2 /* ClassElementKeywords */:
+ case 2 /* KeywordCompletionFilters.ClassElementKeywords */:
return isClassMemberCompletionKeyword(kind);
- case 3 /* InterfaceElementKeywords */:
+ case 3 /* KeywordCompletionFilters.InterfaceElementKeywords */:
return isInterfaceOrTypeLiteralCompletionKeyword(kind);
- case 4 /* ConstructorParameterKeywords */:
+ case 4 /* KeywordCompletionFilters.ConstructorParameterKeywords */:
return ts.isParameterPropertyModifier(kind);
- case 6 /* TypeAssertionKeywords */:
- return ts.isTypeKeyword(kind) || kind === 85 /* ConstKeyword */;
- case 7 /* TypeKeywords */:
+ case 6 /* KeywordCompletionFilters.TypeAssertionKeywords */:
+ return ts.isTypeKeyword(kind) || kind === 85 /* SyntaxKind.ConstKeyword */;
+ case 7 /* KeywordCompletionFilters.TypeKeywords */:
return ts.isTypeKeyword(kind);
- case 8 /* TypeKeyword */:
- return kind === 151 /* TypeKeyword */;
+ case 8 /* KeywordCompletionFilters.TypeKeyword */:
+ return kind === 152 /* SyntaxKind.TypeKeyword */;
default:
return ts.Debug.assertNever(keywordFilter);
}
@@ -132746,63 +135017,63 @@ var ts;
}
function isTypeScriptOnlyKeyword(kind) {
switch (kind) {
- case 126 /* AbstractKeyword */:
- case 130 /* AnyKeyword */:
- case 157 /* BigIntKeyword */:
- case 133 /* BooleanKeyword */:
- case 135 /* DeclareKeyword */:
- case 92 /* EnumKeyword */:
- case 156 /* GlobalKeyword */:
- case 117 /* ImplementsKeyword */:
- case 137 /* InferKeyword */:
- case 118 /* InterfaceKeyword */:
- case 139 /* IsKeyword */:
- case 140 /* KeyOfKeyword */:
- case 141 /* ModuleKeyword */:
- case 142 /* NamespaceKeyword */:
- case 143 /* NeverKeyword */:
- case 146 /* NumberKeyword */:
- case 147 /* ObjectKeyword */:
- case 158 /* OverrideKeyword */:
- case 121 /* PrivateKeyword */:
- case 122 /* ProtectedKeyword */:
- case 123 /* PublicKeyword */:
- case 144 /* ReadonlyKeyword */:
- case 149 /* StringKeyword */:
- case 150 /* SymbolKeyword */:
- case 151 /* TypeKeyword */:
- case 153 /* UniqueKeyword */:
- case 154 /* UnknownKeyword */:
+ case 126 /* SyntaxKind.AbstractKeyword */:
+ case 130 /* SyntaxKind.AnyKeyword */:
+ case 158 /* SyntaxKind.BigIntKeyword */:
+ case 133 /* SyntaxKind.BooleanKeyword */:
+ case 135 /* SyntaxKind.DeclareKeyword */:
+ case 92 /* SyntaxKind.EnumKeyword */:
+ case 157 /* SyntaxKind.GlobalKeyword */:
+ case 117 /* SyntaxKind.ImplementsKeyword */:
+ case 137 /* SyntaxKind.InferKeyword */:
+ case 118 /* SyntaxKind.InterfaceKeyword */:
+ case 139 /* SyntaxKind.IsKeyword */:
+ case 140 /* SyntaxKind.KeyOfKeyword */:
+ case 141 /* SyntaxKind.ModuleKeyword */:
+ case 142 /* SyntaxKind.NamespaceKeyword */:
+ case 143 /* SyntaxKind.NeverKeyword */:
+ case 147 /* SyntaxKind.NumberKeyword */:
+ case 148 /* SyntaxKind.ObjectKeyword */:
+ case 159 /* SyntaxKind.OverrideKeyword */:
+ case 121 /* SyntaxKind.PrivateKeyword */:
+ case 122 /* SyntaxKind.ProtectedKeyword */:
+ case 123 /* SyntaxKind.PublicKeyword */:
+ case 145 /* SyntaxKind.ReadonlyKeyword */:
+ case 150 /* SyntaxKind.StringKeyword */:
+ case 151 /* SyntaxKind.SymbolKeyword */:
+ case 152 /* SyntaxKind.TypeKeyword */:
+ case 154 /* SyntaxKind.UniqueKeyword */:
+ case 155 /* SyntaxKind.UnknownKeyword */:
return true;
default:
return false;
}
}
function isInterfaceOrTypeLiteralCompletionKeyword(kind) {
- return kind === 144 /* ReadonlyKeyword */;
+ return kind === 145 /* SyntaxKind.ReadonlyKeyword */;
}
function isClassMemberCompletionKeyword(kind) {
switch (kind) {
- case 126 /* AbstractKeyword */:
- case 134 /* ConstructorKeyword */:
- case 136 /* GetKeyword */:
- case 148 /* SetKeyword */:
- case 131 /* AsyncKeyword */:
- case 135 /* DeclareKeyword */:
- case 158 /* OverrideKeyword */:
+ case 126 /* SyntaxKind.AbstractKeyword */:
+ case 134 /* SyntaxKind.ConstructorKeyword */:
+ case 136 /* SyntaxKind.GetKeyword */:
+ case 149 /* SyntaxKind.SetKeyword */:
+ case 131 /* SyntaxKind.AsyncKeyword */:
+ case 135 /* SyntaxKind.DeclareKeyword */:
+ case 159 /* SyntaxKind.OverrideKeyword */:
return true;
default:
return ts.isClassMemberModifier(kind);
}
}
function isFunctionLikeBodyKeyword(kind) {
- return kind === 131 /* AsyncKeyword */
- || kind === 132 /* AwaitKeyword */
- || kind === 127 /* AsKeyword */
+ return kind === 131 /* SyntaxKind.AsyncKeyword */
+ || kind === 132 /* SyntaxKind.AwaitKeyword */
+ || kind === 127 /* SyntaxKind.AsKeyword */
|| !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind);
}
function keywordForNode(node) {
- return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind;
+ return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* SyntaxKind.Unknown */ : node.kind;
}
function getContextualKeywords(contextToken, position) {
var entries = [];
@@ -132823,10 +135094,10 @@ var ts;
&& contextToken === parent.moduleSpecifier
&& tokenLine === currentLine) {
entries.push({
- name: ts.tokenToString(129 /* AssertKeyword */),
- kind: "keyword" /* keyword */,
- kindModifiers: "" /* none */,
- sortText: SortText.GlobalsOrKeywords,
+ name: ts.tokenToString(129 /* SyntaxKind.AssertKeyword */),
+ kind: "keyword" /* ScriptElementKind.keyword */,
+ kindModifiers: "" /* ScriptElementKindModifier.none */,
+ sortText: Completions.SortText.GlobalsOrKeywords,
});
}
}
@@ -132841,7 +135112,7 @@ var ts;
}
function getPropertiesForObjectExpression(contextualType, completionsType, obj, checker) {
var hasCompletionsType = completionsType && completionsType !== contextualType;
- var type = hasCompletionsType && !(completionsType.flags & 3 /* AnyOrUnknown */)
+ var type = hasCompletionsType && !(completionsType.flags & 3 /* TypeFlags.AnyOrUnknown */)
? checker.getUnionType([contextualType, completionsType])
: contextualType;
var properties = getApparentProperties(type, obj, checker);
@@ -132863,7 +135134,7 @@ var ts;
if (!type.isUnion())
return type.getApparentProperties();
return checker.getAllPossiblePropertiesOfTypes(ts.filter(type.types, function (memberType) {
- return !(memberType.flags & 131068 /* Primitive */
+ return !(memberType.flags & 131068 /* TypeFlags.Primitive */
|| checker.isArrayLikeType(memberType)
|| checker.isTypeInvalidDueToUnionDiscriminant(memberType, node)
|| ts.typeHasCallOrConstructSignatures(memberType, checker)
@@ -132871,7 +135142,7 @@ var ts;
}));
}
function containsNonPublicProperties(props) {
- return ts.some(props, function (p) { return !!(ts.getDeclarationModifierFlagsFromSymbol(p) & 24 /* NonPublicAccessibilityModifier */); });
+ return ts.some(props, function (p) { return !!(ts.getDeclarationModifierFlagsFromSymbol(p) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */); });
}
/**
* Gets all properties on a type, but if that type is a union of several types,
@@ -132889,15 +135160,15 @@ var ts;
function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) {
// class c { method() { } | method2() { } }
switch (location.kind) {
- case 346 /* SyntaxList */:
+ case 348 /* SyntaxKind.SyntaxList */:
return ts.tryCast(location.parent, ts.isObjectTypeDeclaration);
- case 1 /* EndOfFileToken */:
+ case 1 /* SyntaxKind.EndOfFileToken */:
var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration);
- if (cls && !ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile)) {
+ if (cls && !ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile)) {
return cls;
}
break;
- case 79 /* Identifier */: {
+ case 79 /* SyntaxKind.Identifier */: {
// class c { public prop = c| }
if (ts.isPropertyDeclaration(location.parent) && location.parent.initializer === location) {
return undefined;
@@ -132911,22 +135182,22 @@ var ts;
if (!contextToken)
return undefined;
// class C { blah; constructor/**/ } and so on
- if (location.kind === 134 /* ConstructorKeyword */
+ if (location.kind === 134 /* SyntaxKind.ConstructorKeyword */
// class C { blah \n constructor/**/ }
|| (ts.isIdentifier(contextToken) && ts.isPropertyDeclaration(contextToken.parent) && ts.isClassLike(location))) {
return ts.findAncestor(contextToken, ts.isClassLike);
}
switch (contextToken.kind) {
- case 63 /* EqualsToken */: // class c { public prop = | /* global completions */ }
+ case 63 /* SyntaxKind.EqualsToken */: // class c { public prop = | /* global completions */ }
return undefined;
- case 26 /* SemicolonToken */: // class c {getValue(): number; | }
- case 19 /* CloseBraceToken */: // class c { method() { } | }
+ case 26 /* SyntaxKind.SemicolonToken */: // class c {getValue(): number; | }
+ case 19 /* SyntaxKind.CloseBraceToken */: // class c { method() { } | }
// class c { method() { } b| }
return isFromObjectTypeDeclaration(location) && location.parent.name === location
? location.parent.parent
: ts.tryCast(location, ts.isObjectTypeDeclaration);
- case 18 /* OpenBraceToken */: // class c { |
- case 27 /* CommaToken */: // class c {getValue(): number, | }
+ case 18 /* SyntaxKind.OpenBraceToken */: // class c { |
+ case 27 /* SyntaxKind.CommaToken */: // class c {getValue(): number, | }
return ts.tryCast(contextToken.parent, ts.isObjectTypeDeclaration);
default:
if (!isFromObjectTypeDeclaration(contextToken)) {
@@ -132937,7 +135208,7 @@ var ts;
return undefined;
}
var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword;
- return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217
+ return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* SyntaxKind.AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217
? contextToken.parent.parent : undefined;
}
}
@@ -132946,15 +135217,15 @@ var ts;
return undefined;
var parent = node.parent;
switch (node.kind) {
- case 18 /* OpenBraceToken */:
+ case 18 /* SyntaxKind.OpenBraceToken */:
if (ts.isTypeLiteralNode(parent)) {
return parent;
}
break;
- case 26 /* SemicolonToken */:
- case 27 /* CommaToken */:
- case 79 /* Identifier */:
- if (parent.kind === 165 /* PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) {
+ case 26 /* SyntaxKind.SemicolonToken */:
+ case 27 /* SyntaxKind.CommaToken */:
+ case 79 /* SyntaxKind.Identifier */:
+ if (parent.kind === 166 /* SyntaxKind.PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) {
return parent.parent;
}
break;
@@ -132971,11 +135242,11 @@ var ts;
if (!t)
return undefined;
switch (node.kind) {
- case 165 /* PropertySignature */:
+ case 166 /* SyntaxKind.PropertySignature */:
return checker.getTypeOfPropertyOfContextualType(t, node.symbol.escapedName);
- case 187 /* IntersectionType */:
- case 181 /* TypeLiteral */:
- case 186 /* UnionType */:
+ case 188 /* SyntaxKind.IntersectionType */:
+ case 182 /* SyntaxKind.TypeLiteral */:
+ case 187 /* SyntaxKind.UnionType */:
return t;
}
}
@@ -132997,13 +135268,13 @@ var ts;
return !!contextToken && ts.isPrivateIdentifier(contextToken) && !!ts.getContainingClass(contextToken);
case "<":
// Opening JSX tag
- return !!contextToken && contextToken.kind === 29 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent));
+ return !!contextToken && contextToken.kind === 29 /* SyntaxKind.LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent));
case "/":
return !!contextToken && (ts.isStringLiteralLike(contextToken)
? !!ts.tryGetImportFromModuleSpecifier(contextToken)
- : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent));
+ : contextToken.kind === 43 /* SyntaxKind.SlashToken */ && ts.isJsxClosingElement(contextToken.parent));
case " ":
- return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 303 /* SourceFile */;
+ return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 305 /* SyntaxKind.SourceFile */;
default:
return ts.Debug.assertNever(triggerCharacter);
}
@@ -133016,31 +135287,36 @@ var ts;
function isProbablyGlobalType(type, sourceFile, checker) {
// The type of `self` and `window` is the same in lib.dom.d.ts, but `window` does not exist in
// lib.webworker.d.ts, so checking against `self` is also a check against `window` when it exists.
- var selfSymbol = checker.resolveName("self", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false);
+ var selfSymbol = checker.resolveName("self", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false);
if (selfSymbol && checker.getTypeOfSymbolAtLocation(selfSymbol, sourceFile) === type) {
return true;
}
- var globalSymbol = checker.resolveName("global", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false);
+ var globalSymbol = checker.resolveName("global", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false);
if (globalSymbol && checker.getTypeOfSymbolAtLocation(globalSymbol, sourceFile) === type) {
return true;
}
- var globalThisSymbol = checker.resolveName("globalThis", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false);
+ var globalThisSymbol = checker.resolveName("globalThis", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false);
if (globalThisSymbol && checker.getTypeOfSymbolAtLocation(globalThisSymbol, sourceFile) === type) {
return true;
}
return false;
}
function isStaticProperty(symbol) {
- return !!(symbol.valueDeclaration && ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 32 /* Static */ && ts.isClassLike(symbol.valueDeclaration.parent));
+ return !!(symbol.valueDeclaration && ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 32 /* ModifierFlags.Static */ && ts.isClassLike(symbol.valueDeclaration.parent));
}
function tryGetObjectLiteralContextualType(node, typeChecker) {
var type = typeChecker.getContextualType(node);
if (type) {
return type;
}
- if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ && node === node.parent.left) {
+ var parent = ts.walkUpParenthesizedExpressions(node.parent);
+ if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && node === parent.left) {
// Object literal is assignment pattern: ({ | } = x)
- return typeChecker.getTypeAtLocation(node.parent);
+ return typeChecker.getTypeAtLocation(parent);
+ }
+ if (ts.isExpression(parent)) {
+ // f(() => (({ | })));
+ return typeChecker.getContextualType(parent);
}
return undefined;
}
@@ -133051,7 +135327,7 @@ var ts;
return {
isKeywordOnlyCompletion: isKeywordOnlyCompletion,
keywordCompletion: keywordCompletion,
- isNewIdentifierLocation: !!(candidate || keywordCompletion === 151 /* TypeKeyword */),
+ isNewIdentifierLocation: !!(candidate || keywordCompletion === 152 /* SyntaxKind.TypeKeyword */),
replacementNode: candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile())
? candidate
: undefined
@@ -133059,23 +135335,23 @@ var ts;
function getCandidate() {
var parent = contextToken.parent;
if (ts.isImportEqualsDeclaration(parent)) {
- keywordCompletion = contextToken.kind === 151 /* TypeKeyword */ ? undefined : 151 /* TypeKeyword */;
+ keywordCompletion = contextToken.kind === 152 /* SyntaxKind.TypeKeyword */ ? undefined : 152 /* SyntaxKind.TypeKeyword */;
return isModuleSpecifierMissingOrEmpty(parent.moduleReference) ? parent : undefined;
}
if (couldBeTypeOnlyImportSpecifier(parent, contextToken) && canCompleteFromNamedBindings(parent.parent)) {
return parent;
}
if (ts.isNamedImports(parent) || ts.isNamespaceImport(parent)) {
- if (!parent.parent.isTypeOnly && (contextToken.kind === 18 /* OpenBraceToken */ ||
- contextToken.kind === 100 /* ImportKeyword */ ||
- contextToken.kind === 27 /* CommaToken */)) {
- keywordCompletion = 151 /* TypeKeyword */;
+ if (!parent.parent.isTypeOnly && (contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ ||
+ contextToken.kind === 100 /* SyntaxKind.ImportKeyword */ ||
+ contextToken.kind === 27 /* SyntaxKind.CommaToken */)) {
+ keywordCompletion = 152 /* SyntaxKind.TypeKeyword */;
}
if (canCompleteFromNamedBindings(parent)) {
// At `import { ... } |` or `import * as Foo |`, the only possible completion is `from`
- if (contextToken.kind === 19 /* CloseBraceToken */ || contextToken.kind === 79 /* Identifier */) {
+ if (contextToken.kind === 19 /* SyntaxKind.CloseBraceToken */ || contextToken.kind === 79 /* SyntaxKind.Identifier */) {
isKeywordOnlyCompletion = true;
- keywordCompletion = 155 /* FromKeyword */;
+ keywordCompletion = 156 /* SyntaxKind.FromKeyword */;
}
else {
return parent.parent.parent;
@@ -133085,12 +135361,12 @@ var ts;
}
if (ts.isImportKeyword(contextToken) && ts.isSourceFile(parent)) {
// A lone import keyword with nothing following it does not parse as a statement at all
- keywordCompletion = 151 /* TypeKeyword */;
+ keywordCompletion = 152 /* SyntaxKind.TypeKeyword */;
return contextToken;
}
if (ts.isImportKeyword(contextToken) && ts.isImportDeclaration(parent)) {
// `import s| from`
- keywordCompletion = 151 /* TypeKeyword */;
+ keywordCompletion = 152 /* SyntaxKind.TypeKeyword */;
return isModuleSpecifierMissingOrEmpty(parent.moduleSpecifier) ? parent : undefined;
}
return undefined;
@@ -133130,8 +135406,8 @@ var ts;
// This code used to just test the result of `skipAlias`, but that would ignore any locally introduced meanings.
return nonAliasCanBeReferencedAtTypeLocation(symbol) || nonAliasCanBeReferencedAtTypeLocation(ts.skipAlias(symbol.exportSymbol || symbol, checker));
function nonAliasCanBeReferencedAtTypeLocation(symbol) {
- return !!(symbol.flags & 788968 /* Type */) || checker.isUnknownSymbol(symbol) ||
- !!(symbol.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) &&
+ return !!(symbol.flags & 788968 /* SymbolFlags.Type */) || checker.isUnknownSymbol(symbol) ||
+ !!(symbol.flags & 1536 /* SymbolFlags.Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) &&
checker.getExportsOfModule(symbol).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); });
}
}
@@ -133168,8 +135444,8 @@ var ts;
var testChar = lowercaseCharacters.charCodeAt(characterIndex);
if (strChar === testChar || strChar === toUpperCharCode(testChar)) {
matchedFirstCharacter || (matchedFirstCharacter = prevChar === undefined || // Beginning of word
- 97 /* a */ <= prevChar && prevChar <= 122 /* z */ && 65 /* A */ <= strChar && strChar <= 90 /* Z */ || // camelCase transition
- prevChar === 95 /* _ */ && strChar !== 95 /* _ */); // snake_case transition
+ 97 /* CharacterCodes.a */ <= prevChar && prevChar <= 122 /* CharacterCodes.z */ && 65 /* CharacterCodes.A */ <= strChar && strChar <= 90 /* CharacterCodes.Z */ || // camelCase transition
+ prevChar === 95 /* CharacterCodes._ */ && strChar !== 95 /* CharacterCodes._ */); // snake_case transition
if (matchedFirstCharacter) {
characterIndex++;
}
@@ -133183,7 +135459,7 @@ var ts;
return false;
}
function toUpperCharCode(charCode) {
- if (97 /* a */ <= charCode && charCode <= 122 /* z */) {
+ if (97 /* CharacterCodes.a */ <= charCode && charCode <= 122 /* CharacterCodes.z */) {
return charCode - 32;
}
return charCode;
@@ -133213,7 +135489,7 @@ var ts;
return {
fileName: sourceFile.fileName,
textSpan: ts.createTextSpanFromNode(node, sourceFile),
- kind: "none" /* none */
+ kind: "none" /* HighlightSpanKind.none */
};
}
function getSemanticDocumentHighlights(position, node, program, cancellationToken, sourceFilesToSearch) {
@@ -133243,45 +135519,47 @@ var ts;
}
function getHighlightSpans(node, sourceFile) {
switch (node.kind) {
- case 99 /* IfKeyword */:
- case 91 /* ElseKeyword */:
+ case 99 /* SyntaxKind.IfKeyword */:
+ case 91 /* SyntaxKind.ElseKeyword */:
return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined;
- case 105 /* ReturnKeyword */:
+ case 105 /* SyntaxKind.ReturnKeyword */:
return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences);
- case 109 /* ThrowKeyword */:
+ case 109 /* SyntaxKind.ThrowKeyword */:
return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences);
- case 111 /* TryKeyword */:
- case 83 /* CatchKeyword */:
- case 96 /* FinallyKeyword */:
- var tryStatement = node.kind === 83 /* CatchKeyword */ ? node.parent.parent : node.parent;
+ case 111 /* SyntaxKind.TryKeyword */:
+ case 83 /* SyntaxKind.CatchKeyword */:
+ case 96 /* SyntaxKind.FinallyKeyword */:
+ var tryStatement = node.kind === 83 /* SyntaxKind.CatchKeyword */ ? node.parent.parent : node.parent;
return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences);
- case 107 /* SwitchKeyword */:
+ case 107 /* SyntaxKind.SwitchKeyword */:
return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences);
- case 82 /* CaseKeyword */:
- case 88 /* DefaultKeyword */: {
+ case 82 /* SyntaxKind.CaseKeyword */:
+ case 88 /* SyntaxKind.DefaultKeyword */: {
if (ts.isDefaultClause(node.parent) || ts.isCaseClause(node.parent)) {
return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences);
}
return undefined;
}
- case 81 /* BreakKeyword */:
- case 86 /* ContinueKeyword */:
+ case 81 /* SyntaxKind.BreakKeyword */:
+ case 86 /* SyntaxKind.ContinueKeyword */:
return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences);
- case 97 /* ForKeyword */:
- case 115 /* WhileKeyword */:
- case 90 /* DoKeyword */:
+ case 97 /* SyntaxKind.ForKeyword */:
+ case 115 /* SyntaxKind.WhileKeyword */:
+ case 90 /* SyntaxKind.DoKeyword */:
return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences);
- case 134 /* ConstructorKeyword */:
- return getFromAllDeclarations(ts.isConstructorDeclaration, [134 /* ConstructorKeyword */]);
- case 136 /* GetKeyword */:
- case 148 /* SetKeyword */:
- return getFromAllDeclarations(ts.isAccessor, [136 /* GetKeyword */, 148 /* SetKeyword */]);
- case 132 /* AwaitKeyword */:
+ case 134 /* SyntaxKind.ConstructorKeyword */:
+ return getFromAllDeclarations(ts.isConstructorDeclaration, [134 /* SyntaxKind.ConstructorKeyword */]);
+ case 136 /* SyntaxKind.GetKeyword */:
+ case 149 /* SyntaxKind.SetKeyword */:
+ return getFromAllDeclarations(ts.isAccessor, [136 /* SyntaxKind.GetKeyword */, 149 /* SyntaxKind.SetKeyword */]);
+ case 132 /* SyntaxKind.AwaitKeyword */:
return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences);
- case 131 /* AsyncKeyword */:
+ case 131 /* SyntaxKind.AsyncKeyword */:
return highlightSpans(getAsyncAndAwaitOccurrences(node));
- case 125 /* YieldKeyword */:
+ case 125 /* SyntaxKind.YieldKeyword */:
return highlightSpans(getYieldOccurrences(node));
+ case 101 /* SyntaxKind.InKeyword */:
+ return undefined;
default:
return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent))
? highlightSpans(getModifierOccurrences(node.kind, node.parent))
@@ -133323,7 +135601,7 @@ var ts;
var child = throwStatement;
while (child.parent) {
var parent = child.parent;
- if (ts.isFunctionBlock(parent) || parent.kind === 303 /* SourceFile */) {
+ if (ts.isFunctionBlock(parent) || parent.kind === 305 /* SyntaxKind.SourceFile */) {
return parent;
}
// A throw-statement is only owned by a try-statement if the try-statement has
@@ -133355,16 +135633,16 @@ var ts;
function getBreakOrContinueOwner(statement) {
return ts.findAncestor(statement, function (node) {
switch (node.kind) {
- case 248 /* SwitchStatement */:
- if (statement.kind === 244 /* ContinueStatement */) {
+ case 249 /* SyntaxKind.SwitchStatement */:
+ if (statement.kind === 245 /* SyntaxKind.ContinueStatement */) {
return false;
}
// falls through
- case 241 /* ForStatement */:
- case 242 /* ForInStatement */:
- case 243 /* ForOfStatement */:
- case 240 /* WhileStatement */:
- case 239 /* DoStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
return !statement.label || isLabeledBy(node, statement.label.escapedText);
default:
// Don't cross function boundaries.
@@ -133380,41 +135658,41 @@ var ts;
// Types of node whose children might have modifiers.
var container = declaration.parent;
switch (container.kind) {
- case 261 /* ModuleBlock */:
- case 303 /* SourceFile */:
- case 234 /* Block */:
- case 288 /* CaseClause */:
- case 289 /* DefaultClause */:
+ case 262 /* SyntaxKind.ModuleBlock */:
+ case 305 /* SyntaxKind.SourceFile */:
+ case 235 /* SyntaxKind.Block */:
+ case 289 /* SyntaxKind.CaseClause */:
+ case 290 /* SyntaxKind.DefaultClause */:
// Container is either a class declaration or the declaration is a classDeclaration
- if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) {
+ if (modifierFlag & 128 /* ModifierFlags.Abstract */ && ts.isClassDeclaration(declaration)) {
return __spreadArray(__spreadArray([], declaration.members, true), [declaration], false);
}
else {
return container.statements;
}
- case 170 /* Constructor */:
- case 168 /* MethodDeclaration */:
- case 255 /* FunctionDeclaration */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
return __spreadArray(__spreadArray([], container.parameters, true), (ts.isClassLike(container.parent) ? container.parent.members : []), true);
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- case 257 /* InterfaceDeclaration */:
- case 181 /* TypeLiteral */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 182 /* SyntaxKind.TypeLiteral */:
var nodes = container.members;
// If we're an accessibility modifier, we're in an instance member and should search
// the constructor's parameter list for instance members as well.
- if (modifierFlag & (28 /* AccessibilityModifier */ | 64 /* Readonly */)) {
+ if (modifierFlag & (28 /* ModifierFlags.AccessibilityModifier */ | 64 /* ModifierFlags.Readonly */)) {
var constructor = ts.find(container.members, ts.isConstructorDeclaration);
if (constructor) {
return __spreadArray(__spreadArray([], nodes, true), constructor.parameters, true);
}
}
- else if (modifierFlag & 128 /* Abstract */) {
+ else if (modifierFlag & 128 /* ModifierFlags.Abstract */) {
return __spreadArray(__spreadArray([], nodes, true), [container], false);
}
return nodes;
// Syntactically invalid positions that the parser might produce anyway
- case 204 /* ObjectLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
return undefined;
default:
ts.Debug.assertNever(container, "Invalid container kind.");
@@ -133433,12 +135711,12 @@ var ts;
}
function getLoopBreakContinueOccurrences(loopNode) {
var keywords = [];
- if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* ForKeyword */, 115 /* WhileKeyword */, 90 /* DoKeyword */)) {
+ if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* SyntaxKind.ForKeyword */, 115 /* SyntaxKind.WhileKeyword */, 90 /* SyntaxKind.DoKeyword */)) {
// If we succeeded and got a do-while loop, then start looking for a 'while' keyword.
- if (loopNode.kind === 239 /* DoStatement */) {
+ if (loopNode.kind === 240 /* SyntaxKind.DoStatement */) {
var loopTokens = loopNode.getChildren();
for (var i = loopTokens.length - 1; i >= 0; i--) {
- if (pushKeywordIf(keywords, loopTokens[i], 115 /* WhileKeyword */)) {
+ if (pushKeywordIf(keywords, loopTokens[i], 115 /* SyntaxKind.WhileKeyword */)) {
break;
}
}
@@ -133446,7 +135724,7 @@ var ts;
}
ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) {
if (ownsBreakOrContinueStatement(loopNode, statement)) {
- pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */, 86 /* ContinueKeyword */);
+ pushKeywordIf(keywords, statement.getFirstToken(), 81 /* SyntaxKind.BreakKeyword */, 86 /* SyntaxKind.ContinueKeyword */);
}
});
return keywords;
@@ -133455,13 +135733,13 @@ var ts;
var owner = getBreakOrContinueOwner(breakOrContinueStatement);
if (owner) {
switch (owner.kind) {
- case 241 /* ForStatement */:
- case 242 /* ForInStatement */:
- case 243 /* ForOfStatement */:
- case 239 /* DoStatement */:
- case 240 /* WhileStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
return getLoopBreakContinueOccurrences(owner);
- case 248 /* SwitchStatement */:
+ case 249 /* SyntaxKind.SwitchStatement */:
return getSwitchCaseDefaultOccurrences(owner);
}
}
@@ -133469,13 +135747,13 @@ var ts;
}
function getSwitchCaseDefaultOccurrences(switchStatement) {
var keywords = [];
- pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* SwitchKeyword */);
+ pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* SyntaxKind.SwitchKeyword */);
// Go through each clause in the switch statement, collecting the 'case'/'default' keywords.
ts.forEach(switchStatement.caseBlock.clauses, function (clause) {
- pushKeywordIf(keywords, clause.getFirstToken(), 82 /* CaseKeyword */, 88 /* DefaultKeyword */);
+ pushKeywordIf(keywords, clause.getFirstToken(), 82 /* SyntaxKind.CaseKeyword */, 88 /* SyntaxKind.DefaultKeyword */);
ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) {
if (ownsBreakOrContinueStatement(switchStatement, statement)) {
- pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */);
+ pushKeywordIf(keywords, statement.getFirstToken(), 81 /* SyntaxKind.BreakKeyword */);
}
});
});
@@ -133483,13 +135761,13 @@ var ts;
}
function getTryCatchFinallyOccurrences(tryStatement, sourceFile) {
var keywords = [];
- pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* TryKeyword */);
+ pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* SyntaxKind.TryKeyword */);
if (tryStatement.catchClause) {
- pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* CatchKeyword */);
+ pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* SyntaxKind.CatchKeyword */);
}
if (tryStatement.finallyBlock) {
- var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile);
- pushKeywordIf(keywords, finallyKeyword, 96 /* FinallyKeyword */);
+ var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* SyntaxKind.FinallyKeyword */, sourceFile);
+ pushKeywordIf(keywords, finallyKeyword, 96 /* SyntaxKind.FinallyKeyword */);
}
return keywords;
}
@@ -133500,13 +135778,13 @@ var ts;
}
var keywords = [];
ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) {
- keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile));
+ keywords.push(ts.findChildOfKind(throwStatement, 109 /* SyntaxKind.ThrowKeyword */, sourceFile));
});
// If the "owner" is a function, then we equate 'return' and 'throw' statements in their
// ability to "jump out" of the function, and include occurrences for both.
if (ts.isFunctionBlock(owner)) {
ts.forEachReturnStatement(owner, function (returnStatement) {
- keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile));
+ keywords.push(ts.findChildOfKind(returnStatement, 105 /* SyntaxKind.ReturnKeyword */, sourceFile));
});
}
return keywords;
@@ -133518,11 +135796,11 @@ var ts;
}
var keywords = [];
ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) {
- keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile));
+ keywords.push(ts.findChildOfKind(returnStatement, 105 /* SyntaxKind.ReturnKeyword */, sourceFile));
});
// Include 'throw' statements that do not occur within a try block.
ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) {
- keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile));
+ keywords.push(ts.findChildOfKind(throwStatement, 109 /* SyntaxKind.ThrowKeyword */, sourceFile));
});
return keywords;
}
@@ -133534,13 +135812,13 @@ var ts;
var keywords = [];
if (func.modifiers) {
func.modifiers.forEach(function (modifier) {
- pushKeywordIf(keywords, modifier, 131 /* AsyncKeyword */);
+ pushKeywordIf(keywords, modifier, 131 /* SyntaxKind.AsyncKeyword */);
});
}
ts.forEachChild(func, function (child) {
traverseWithoutCrossingFunction(child, function (node) {
if (ts.isAwaitExpression(node)) {
- pushKeywordIf(keywords, node.getFirstToken(), 132 /* AwaitKeyword */);
+ pushKeywordIf(keywords, node.getFirstToken(), 132 /* SyntaxKind.AwaitKeyword */);
}
});
});
@@ -133555,7 +135833,7 @@ var ts;
ts.forEachChild(func, function (child) {
traverseWithoutCrossingFunction(child, function (node) {
if (ts.isYieldExpression(node)) {
- pushKeywordIf(keywords, node.getFirstToken(), 125 /* YieldKeyword */);
+ pushKeywordIf(keywords, node.getFirstToken(), 125 /* SyntaxKind.YieldKeyword */);
}
});
});
@@ -133574,7 +135852,7 @@ var ts;
// We'd like to highlight else/ifs together if they are only separated by whitespace
// (i.e. the keywords are separated by no comments, no newlines).
for (var i = 0; i < keywords.length; i++) {
- if (keywords[i].kind === 91 /* ElseKeyword */ && i < keywords.length - 1) {
+ if (keywords[i].kind === 91 /* SyntaxKind.ElseKeyword */ && i < keywords.length - 1) {
var elseKeyword = keywords[i];
var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword.
var shouldCombineElseAndIf = true;
@@ -133589,7 +135867,7 @@ var ts;
result.push({
fileName: sourceFile.fileName,
textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end),
- kind: "reference" /* reference */
+ kind: "reference" /* HighlightSpanKind.reference */
});
i++; // skip the next keyword
continue;
@@ -133609,10 +135887,10 @@ var ts;
// Now traverse back down through the else branches, aggregating if/else keywords of if-statements.
while (true) {
var children = ifStatement.getChildren(sourceFile);
- pushKeywordIf(keywords, children[0], 99 /* IfKeyword */);
+ pushKeywordIf(keywords, children[0], 99 /* SyntaxKind.IfKeyword */);
// Generally the 'else' keyword is second-to-last, so we traverse backwards.
for (var i = children.length - 1; i >= 0; i--) {
- if (pushKeywordIf(keywords, children[i], 91 /* ElseKeyword */)) {
+ if (pushKeywordIf(keywords, children[i], 91 /* SyntaxKind.ElseKeyword */)) {
break;
}
}
@@ -133672,9 +135950,15 @@ var ts;
});
return JSON.stringify(bucketInfoArray, undefined, 2);
}
+ function getCompilationSettings(settingsOrHost) {
+ if (typeof settingsOrHost.getCompilationSettings === "function") {
+ return settingsOrHost.getCompilationSettings();
+ }
+ return settingsOrHost;
+ }
function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) {
var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
- var key = getKeyForCompilationSettings(compilationSettings);
+ var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
}
function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) {
@@ -133682,20 +135966,28 @@ var ts;
}
function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) {
var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
- var key = getKeyForCompilationSettings(compilationSettings);
+ var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
}
function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) {
- return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
+ return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
}
function getDocumentRegistryEntry(bucketEntry, scriptKind) {
var entry = isDocumentRegistryEntry(bucketEntry) ? bucketEntry : bucketEntry.get(ts.Debug.checkDefined(scriptKind, "If there are more than one scriptKind's for same document the scriptKind should be provided"));
ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:".concat(scriptKind, " and sourceFile.scriptKind: ").concat(entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind, ", !entry: ").concat(!entry));
return entry;
}
- function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) {
+ function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind) {
+ var _a, _b, _c, _d;
scriptKind = ts.ensureScriptKind(fileName, scriptKind);
- var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings);
+ var compilationSettings = getCompilationSettings(compilationSettingsOrHost);
+ var host = compilationSettingsOrHost === compilationSettings ? undefined : compilationSettingsOrHost;
+ var scriptTarget = scriptKind === 6 /* ScriptKind.JSON */ ? 100 /* ScriptTarget.JSON */ : ts.getEmitScriptTarget(compilationSettings);
+ var sourceFileOptions = {
+ languageVersion: scriptTarget,
+ impliedNodeFormat: host && ts.getImpliedNodeFormatForFile(path, (_d = (_c = (_b = (_a = host.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getModuleResolutionCache) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.getPackageJsonInfoCache(), host, compilationSettings),
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(compilationSettings)
+ };
var oldBucketCount = buckets.size;
var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); });
if (ts.tracing) {
@@ -133703,15 +135995,15 @@ var ts;
// It is interesting, but not definitively problematic if a build requires multiple document registry buckets -
// perhaps they are for two projects that don't have any overlap.
// Bonus: these events can help us interpret the more interesting event below.
- ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key });
+ ts.tracing.instant("session" /* tracing.Phase.Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key });
}
// It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
// If this occurs unexpectedly, the fix is likely to synchronize the project settings.
// Skip .d.ts files to reduce noise (should also cover most of node_modules).
- var otherBucketKey = !ts.fileExtensionIs(path, ".d.ts" /* Dts */) &&
+ var otherBucketKey = !ts.isDeclarationFileName(path) &&
ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; });
if (otherBucketKey) {
- ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key });
+ ts.tracing.instant("session" /* tracing.Phase.Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key });
}
}
var bucketEntry = bucket.get(path);
@@ -133729,7 +136021,7 @@ var ts;
}
if (!entry) {
// Have never seen this file with these settings. Create a new source file for it.
- var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, /*setNodeParents*/ false, scriptKind);
+ var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, sourceFileOptions, version, /*setNodeParents*/ false, scriptKind);
if (externalCache) {
externalCache.setDocument(key, path, sourceFile);
}
@@ -133819,8 +136111,24 @@ var ts;
};
}
ts.createDocumentRegistryInternal = createDocumentRegistryInternal;
+ function compilerOptionValueToString(value) {
+ var _a;
+ if (value === null || typeof value !== "object") { // eslint-disable-line no-null/no-null
+ return "" + value;
+ }
+ if (ts.isArray(value)) {
+ return "[".concat((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(","), "]");
+ }
+ var str = "{";
+ for (var key in value) {
+ if (ts.hasOwnProperty.call(value, key)) { // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier
+ str += "".concat(key, ": ").concat(compilerOptionValueToString(value[key]));
+ }
+ }
+ return str + "}";
+ }
function getKeyForCompilationSettings(settings) {
- return ts.sourceFileAffectingCompilerOptions.map(function (option) { return ts.getCompilerOptionValue(settings, option); }).join("|");
+ return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|".concat(settings.pathsBasePath) : undefined);
}
})(ts || (ts = {}));
/* Code for finding imports of an exported symbol. Used only by FindAllReferences. */
@@ -133887,43 +136195,43 @@ var ts;
if (cancellationToken)
cancellationToken.throwIfCancellationRequested();
switch (direct.kind) {
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
if (ts.isImportCall(direct)) {
handleImportCall(direct);
break;
}
if (!isAvailableThroughGlobal) {
var parent = direct.parent;
- if (exportKind === 2 /* ExportEquals */ && parent.kind === 253 /* VariableDeclaration */) {
+ if (exportKind === 2 /* ExportKind.ExportEquals */ && parent.kind === 254 /* SyntaxKind.VariableDeclaration */) {
var name = parent.name;
- if (name.kind === 79 /* Identifier */) {
+ if (name.kind === 79 /* SyntaxKind.Identifier */) {
directImports.push(name);
break;
}
}
}
break;
- case 79 /* Identifier */: // for 'const x = require("y");
+ case 79 /* SyntaxKind.Identifier */: // for 'const x = require("y");
break; // TODO: GH#23879
- case 264 /* ImportEqualsDeclaration */:
- handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false);
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* ModifierFlags.Export */), /*alreadyAddedDirect*/ false);
break;
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
directImports.push(direct);
var namedBindings = direct.importClause && direct.importClause.namedBindings;
- if (namedBindings && namedBindings.kind === 267 /* NamespaceImport */) {
+ if (namedBindings && namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) {
handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true);
}
else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) {
addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports
}
break;
- case 271 /* ExportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
if (!direct.exportClause) {
// This is `export * from "foo"`, so imports of this module may import the export too.
handleDirectImports(getContainingModuleSymbol(direct, checker));
}
- else if (direct.exportClause.kind === 273 /* NamespaceExport */) {
+ else if (direct.exportClause.kind === 274 /* SyntaxKind.NamespaceExport */) {
// `export * as foo from "foo"` add to indirect uses
addIndirectUser(getSourceFileLikeForImportDeclaration(direct), /** addTransitiveDependencies */ true);
}
@@ -133932,7 +136240,7 @@ var ts;
directImports.push(direct);
}
break;
- case 199 /* ImportType */:
+ case 200 /* SyntaxKind.ImportType */:
// Only check for typeof import('xyz')
if (direct.isTypeOf && !direct.qualifier && isExported(direct)) {
addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true);
@@ -133954,18 +136262,18 @@ var ts;
return ts.findAncestor(node, function (node) {
if (stopAtAmbientModule && isAmbientModuleDeclaration(node))
return "quit";
- return ts.some(node.modifiers, function (mod) { return mod.kind === 93 /* ExportKeyword */; });
+ return ts.some(node.modifiers, function (mod) { return mod.kind === 93 /* SyntaxKind.ExportKeyword */; });
});
}
function handleNamespaceImport(importDeclaration, name, isReExport, alreadyAddedDirect) {
- if (exportKind === 2 /* ExportEquals */) {
+ if (exportKind === 2 /* ExportKind.ExportEquals */) {
// This is a direct import, not import-as-namespace.
if (!alreadyAddedDirect)
directImports.push(importDeclaration);
}
else if (!isAvailableThroughGlobal) {
var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration);
- ts.Debug.assert(sourceFileLike.kind === 303 /* SourceFile */ || sourceFileLike.kind === 260 /* ModuleDeclaration */);
+ ts.Debug.assert(sourceFileLike.kind === 305 /* SyntaxKind.SourceFile */ || sourceFileLike.kind === 261 /* SyntaxKind.ModuleDeclaration */);
if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) {
addIndirectUser(sourceFileLike, /** addTransitiveDependencies */ true);
}
@@ -133987,7 +136295,7 @@ var ts;
var moduleSymbol = checker.getMergedSymbol(sourceFileLike.symbol);
if (!moduleSymbol)
return;
- ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* Module */));
+ ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* SymbolFlags.Module */));
var directImports = getDirectImports(moduleSymbol);
if (directImports) {
for (var _i = 0, directImports_1 = directImports; _i < directImports_1.length; _i++) {
@@ -134021,33 +136329,33 @@ var ts;
}
return { importSearches: importSearches, singleReferences: singleReferences };
function handleImport(decl) {
- if (decl.kind === 264 /* ImportEqualsDeclaration */) {
+ if (decl.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
if (isExternalModuleImportEquals(decl)) {
handleNamespaceImportLike(decl.name);
}
return;
}
- if (decl.kind === 79 /* Identifier */) {
+ if (decl.kind === 79 /* SyntaxKind.Identifier */) {
handleNamespaceImportLike(decl);
return;
}
- if (decl.kind === 199 /* ImportType */) {
+ if (decl.kind === 200 /* SyntaxKind.ImportType */) {
if (decl.qualifier) {
var firstIdentifier = ts.getFirstIdentifier(decl.qualifier);
if (firstIdentifier.escapedText === ts.symbolName(exportSymbol)) {
singleReferences.push(firstIdentifier);
}
}
- else if (exportKind === 2 /* ExportEquals */) {
+ else if (exportKind === 2 /* ExportKind.ExportEquals */) {
singleReferences.push(decl.argument.literal);
}
return;
}
// Ignore if there's a grammar error
- if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) {
+ if (decl.moduleSpecifier.kind !== 10 /* SyntaxKind.StringLiteral */) {
return;
}
- if (decl.kind === 271 /* ExportDeclaration */) {
+ if (decl.kind === 272 /* SyntaxKind.ExportDeclaration */) {
if (decl.exportClause && ts.isNamedExports(decl.exportClause)) {
searchForNamedImport(decl.exportClause);
}
@@ -134056,12 +136364,12 @@ var ts;
var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings;
if (namedBindings) {
switch (namedBindings.kind) {
- case 267 /* NamespaceImport */:
+ case 268 /* SyntaxKind.NamespaceImport */:
handleNamespaceImportLike(namedBindings.name);
break;
- case 268 /* NamedImports */:
+ case 269 /* SyntaxKind.NamedImports */:
// 'default' might be accessed as a named import `{ default as foo }`.
- if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) {
+ if (exportKind === 0 /* ExportKind.Named */ || exportKind === 1 /* ExportKind.Default */) {
searchForNamedImport(namedBindings);
}
break;
@@ -134072,7 +136380,7 @@ var ts;
// `export =` might be imported by a default import if `--allowSyntheticDefaultImports` is on, so this handles both ExportKind.Default and ExportKind.ExportEquals.
// If a default import has the same name as the default export, allow to rename it.
// Given `import f` and `export default function f`, we will rename both, but for `import g` we will rename just that.
- if (name && (exportKind === 1 /* Default */ || exportKind === 2 /* ExportEquals */) && (!isForRename || name.escapedText === ts.symbolEscapedNameNoDefault(exportSymbol))) {
+ if (name && (exportKind === 1 /* ExportKind.Default */ || exportKind === 2 /* ExportKind.ExportEquals */) && (!isForRename || name.escapedText === ts.symbolEscapedNameNoDefault(exportSymbol))) {
var defaultImportAlias = checker.getSymbolAtLocation(name);
addSearch(name, defaultImportAlias);
}
@@ -134084,7 +136392,7 @@ var ts;
*/
function handleNamespaceImportLike(importName) {
// Don't rename an import that already has a different name than the export.
- if (exportKind === 2 /* ExportEquals */ && (!isForRename || isNameMatch(importName.escapedText))) {
+ if (exportKind === 2 /* ExportKind.ExportEquals */ && (!isForRename || isNameMatch(importName.escapedText))) {
addSearch(importName, checker.getSymbolAtLocation(importName));
}
}
@@ -134109,7 +136417,7 @@ var ts;
}
}
else {
- var localSymbol = element.kind === 274 /* ExportSpecifier */ && element.propertyName
+ var localSymbol = element.kind === 275 /* SyntaxKind.ExportSpecifier */ && element.propertyName
? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol.
: checker.getSymbolAtLocation(name);
addSearch(name, localSymbol);
@@ -134118,7 +136426,7 @@ var ts;
}
function isNameMatch(name) {
// Use name of "default" even in `export =` case because we may have allowSyntheticDefaultImports
- return name === exportSymbol.escapedName || exportKind !== 0 /* Named */ && name === "default" /* Default */;
+ return name === exportSymbol.escapedName || exportKind !== 0 /* ExportKind.Named */ && name === "default" /* InternalSymbolName.Default */;
}
}
/** Returns 'true' is the namespace 'name' is re-exported from this module, and 'false' if it is only used locally. */
@@ -134138,7 +136446,7 @@ var ts;
for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) {
var referencingFile = sourceFiles_1[_i];
var searchSourceFile = searchModuleSymbol.valueDeclaration;
- if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 303 /* SourceFile */) {
+ if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 305 /* SyntaxKind.SourceFile */) {
for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) {
var ref = _b[_a];
if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) {
@@ -134147,7 +136455,7 @@ var ts;
}
for (var _c = 0, _d = referencingFile.typeReferenceDirectives; _c < _d.length; _c++) {
var ref = _d[_c];
- var referenced = program.getResolvedTypeReferenceDirectives().get(ref.fileName);
+ var referenced = program.getResolvedTypeReferenceDirectives().get(ref.fileName, ref.resolutionMode || referencingFile.impliedNodeFormat);
if (referenced !== undefined && referenced.resolvedFileName === searchSourceFile.fileName) {
refs.push({ kind: "reference", referencingFile: referencingFile, ref: ref });
}
@@ -134186,7 +136494,7 @@ var ts;
}
/** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */
function forEachPossibleImportOrExportStatement(sourceFileLike, action) {
- return ts.forEach(sourceFileLike.kind === 303 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) {
+ return ts.forEach(sourceFileLike.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) {
return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action));
});
}
@@ -134201,15 +136509,15 @@ var ts;
else {
forEachPossibleImportOrExportStatement(sourceFile, function (statement) {
switch (statement.kind) {
- case 271 /* ExportDeclaration */:
- case 265 /* ImportDeclaration */: {
+ case 272 /* SyntaxKind.ExportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */: {
var decl = statement;
if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) {
action(decl, decl.moduleSpecifier);
}
break;
}
- case 264 /* ImportEqualsDeclaration */: {
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */: {
var decl = statement;
if (isExternalModuleImportEquals(decl)) {
action(decl, decl.moduleReference.expression);
@@ -134234,7 +136542,7 @@ var ts;
var parent = node.parent;
var grandparent = parent.parent;
if (symbol.exportSymbol) {
- if (parent.kind === 205 /* PropertyAccessExpression */) {
+ if (parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) {
// When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use.
// So check that we are at the declaration.
return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === parent; })) && ts.isBinaryExpression(grandparent)
@@ -134247,21 +136555,21 @@ var ts;
}
else {
var exportNode = getExportNode(parent, node);
- if (exportNode && ts.hasSyntacticModifier(exportNode, 1 /* Export */)) {
+ if (exportNode && ts.hasSyntacticModifier(exportNode, 1 /* ModifierFlags.Export */)) {
if (ts.isImportEqualsDeclaration(exportNode) && exportNode.moduleReference === node) {
// We're at `Y` in `export import X = Y`. This is not the exported symbol, the left-hand-side is. So treat this as an import statement.
if (comingFromExport) {
return undefined;
}
var lhsSymbol = checker.getSymbolAtLocation(exportNode.name);
- return { kind: 0 /* Import */, symbol: lhsSymbol };
+ return { kind: 0 /* ImportExport.Import */, symbol: lhsSymbol };
}
else {
return exportInfo(symbol, getExportKindForDeclaration(exportNode));
}
}
else if (ts.isNamespaceExport(parent)) {
- return exportInfo(symbol, 0 /* Named */);
+ return exportInfo(symbol, 0 /* ExportKind.Named */);
}
// If we are in `export = a;` or `export default a;`, `parent` is the export assignment.
else if (ts.isExportAssignment(parent)) {
@@ -134279,24 +136587,24 @@ var ts;
return getSpecialPropertyExport(grandparent, /*useLhsSymbol*/ true);
}
else if (ts.isJSDocTypedefTag(parent)) {
- return exportInfo(symbol, 0 /* Named */);
+ return exportInfo(symbol, 0 /* ExportKind.Named */);
}
}
function getExportAssignmentExport(ex) {
// Get the symbol for the `export =` node; its parent is the module it's the export of.
if (!ex.symbol.parent)
return undefined;
- var exportKind = ex.isExportEquals ? 2 /* ExportEquals */ : 1 /* Default */;
- return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } };
+ var exportKind = ex.isExportEquals ? 2 /* ExportKind.ExportEquals */ : 1 /* ExportKind.Default */;
+ return { kind: 1 /* ImportExport.Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } };
}
function getSpecialPropertyExport(node, useLhsSymbol) {
var kind;
switch (ts.getAssignmentDeclarationKind(node)) {
- case 1 /* ExportsProperty */:
- kind = 0 /* Named */;
+ case 1 /* AssignmentDeclarationKind.ExportsProperty */:
+ kind = 0 /* ExportKind.Named */;
break;
- case 2 /* ModuleExports */:
- kind = 2 /* ExportEquals */;
+ case 2 /* AssignmentDeclarationKind.ModuleExports */:
+ kind = 2 /* ExportKind.ExportEquals */;
break;
default:
return undefined;
@@ -134323,22 +136631,22 @@ var ts;
// If `importedName` is undefined, do continue searching as the export is anonymous.
// (All imports returned from this function will be ignored anyway if we are in rename and this is a not a named export.)
var importedName = ts.symbolEscapedNameNoDefault(importedSymbol);
- if (importedName === undefined || importedName === "default" /* Default */ || importedName === symbol.escapedName) {
- return { kind: 0 /* Import */, symbol: importedSymbol };
+ if (importedName === undefined || importedName === "default" /* InternalSymbolName.Default */ || importedName === symbol.escapedName) {
+ return { kind: 0 /* ImportExport.Import */, symbol: importedSymbol };
}
}
function exportInfo(symbol, kind) {
var exportInfo = getExportInfo(symbol, kind, checker);
- return exportInfo && { kind: 1 /* Export */, symbol: symbol, exportInfo: exportInfo };
+ return exportInfo && { kind: 1 /* ImportExport.Export */, symbol: symbol, exportInfo: exportInfo };
}
// Not meant for use with export specifiers or export assignment.
function getExportKindForDeclaration(node) {
- return ts.hasSyntacticModifier(node, 512 /* Default */) ? 1 /* Default */ : 0 /* Named */;
+ return ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */;
}
}
FindAllReferences.getImportOrExportSymbol = getImportOrExportSymbol;
function getExportEqualsLocalSymbol(importedSymbol, checker) {
- if (importedSymbol.flags & 2097152 /* Alias */) {
+ if (importedSymbol.flags & 2097152 /* SymbolFlags.Alias */) {
return ts.Debug.checkDefined(checker.getImmediateAliasedSymbol(importedSymbol));
}
var decl = ts.Debug.checkDefined(importedSymbol.valueDeclaration);
@@ -134368,16 +136676,16 @@ var ts;
function isNodeImport(node) {
var parent = node.parent;
switch (parent.kind) {
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return parent.name === node && isExternalModuleImportEquals(parent);
- case 269 /* ImportSpecifier */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
// For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`.
return !parent.propertyName;
- case 266 /* ImportClause */:
- case 267 /* NamespaceImport */:
+ case 267 /* SyntaxKind.ImportClause */:
+ case 268 /* SyntaxKind.NamespaceImport */:
ts.Debug.assert(parent.name === node);
return true;
- case 202 /* BindingElement */:
+ case 203 /* SyntaxKind.BindingElement */:
return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
default:
return false;
@@ -134407,7 +136715,7 @@ var ts;
}
else if (ts.isShorthandPropertyAssignment(declaration)
&& ts.isBinaryExpression(declaration.parent.parent)
- && ts.getAssignmentDeclarationKind(declaration.parent.parent) === 2 /* ModuleExports */) {
+ && ts.getAssignmentDeclarationKind(declaration.parent.parent) === 2 /* AssignmentDeclarationKind.ModuleExports */) {
return checker.getExportSpecifierLocalTargetSymbol(declaration.name);
}
}
@@ -134418,21 +136726,21 @@ var ts;
return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol);
}
function getSourceFileLikeForImportDeclaration(node) {
- if (node.kind === 207 /* CallExpression */) {
+ if (node.kind === 208 /* SyntaxKind.CallExpression */) {
return node.getSourceFile();
}
var parent = node.parent;
- if (parent.kind === 303 /* SourceFile */) {
+ if (parent.kind === 305 /* SyntaxKind.SourceFile */) {
return parent;
}
- ts.Debug.assert(parent.kind === 261 /* ModuleBlock */);
+ ts.Debug.assert(parent.kind === 262 /* SyntaxKind.ModuleBlock */);
return ts.cast(parent.parent, isAmbientModuleDeclaration);
}
function isAmbientModuleDeclaration(node) {
- return node.kind === 260 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */;
+ return node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && node.name.kind === 10 /* SyntaxKind.StringLiteral */;
}
function isExternalModuleImportEquals(eq) {
- return eq.moduleReference.kind === 276 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */;
+ return eq.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* SyntaxKind.StringLiteral */;
}
})(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {}));
})(ts || (ts = {}));
@@ -134459,7 +136767,7 @@ var ts;
EntryKind[EntryKind["SearchedPropertyFoundLocal"] = 4] = "SearchedPropertyFoundLocal";
})(EntryKind = FindAllReferences.EntryKind || (FindAllReferences.EntryKind = {}));
function nodeEntry(node, kind) {
- if (kind === void 0) { kind = 1 /* Node */; }
+ if (kind === void 0) { kind = 1 /* EntryKind.Node */; }
return {
kind: kind,
node: node.name || node,
@@ -134487,7 +136795,7 @@ var ts;
node.parent.parent.left === node.parent ?
node.parent.parent :
undefined;
- if (binaryExpression && ts.getAssignmentDeclarationKind(binaryExpression) !== 0 /* None */) {
+ if (binaryExpression && ts.getAssignmentDeclarationKind(binaryExpression) !== 0 /* AssignmentDeclarationKind.None */) {
return getContextNode(binaryExpression);
}
}
@@ -134526,7 +136834,7 @@ var ts;
((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent))
&& node.parent.propertyName === node) ||
// Is default export
- (node.kind === 88 /* DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ExportDefault */))) {
+ (node.kind === 88 /* SyntaxKind.DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ModifierFlags.ExportDefault */))) {
return getContextNode(node.parent);
}
return undefined;
@@ -134535,7 +136843,7 @@ var ts;
if (!node)
return undefined;
switch (node.kind) {
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ?
node :
ts.isVariableStatement(node.parent.parent) ?
@@ -134543,28 +136851,28 @@ var ts;
ts.isForInOrOfStatement(node.parent.parent) ?
getContextNode(node.parent.parent) :
node.parent;
- case 202 /* BindingElement */:
+ case 203 /* SyntaxKind.BindingElement */:
return getContextNode(node.parent.parent);
- case 269 /* ImportSpecifier */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
return node.parent.parent.parent;
- case 274 /* ExportSpecifier */:
- case 267 /* NamespaceImport */:
+ case 275 /* SyntaxKind.ExportSpecifier */:
+ case 268 /* SyntaxKind.NamespaceImport */:
return node.parent.parent;
- case 266 /* ImportClause */:
- case 273 /* NamespaceExport */:
+ case 267 /* SyntaxKind.ImportClause */:
+ case 274 /* SyntaxKind.NamespaceExport */:
return node.parent;
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return ts.isExpressionStatement(node.parent) ?
node.parent :
node;
- case 243 /* ForOfStatement */:
- case 242 /* ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
return {
start: node.initializer,
end: node.expression
};
- case 294 /* PropertyAssignment */:
- case 295 /* ShorthandPropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ?
getContextNode(ts.findAncestor(node.parent, function (node) {
return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node);
@@ -134605,27 +136913,36 @@ var ts;
})(FindReferencesUse = FindAllReferences.FindReferencesUse || (FindAllReferences.FindReferencesUse = {}));
function findReferencedSymbols(program, cancellationToken, sourceFiles, sourceFile, position) {
var node = ts.getTouchingPropertyName(sourceFile, position);
- var referencedSymbols = Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, { use: 1 /* References */ });
+ var options = { use: 1 /* FindReferencesUse.References */ };
+ var referencedSymbols = Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options);
var checker = program.getTypeChecker();
- var symbol = checker.getSymbolAtLocation(node);
+ // Unless the starting node is a declaration (vs e.g. JSDoc), don't attempt to compute isDefinition
+ var adjustedNode = Core.getAdjustedNode(node, options);
+ var symbol = isDefinitionForReference(adjustedNode) ? checker.getSymbolAtLocation(adjustedNode) : undefined;
return !referencedSymbols || !referencedSymbols.length ? undefined : ts.mapDefined(referencedSymbols, function (_a) {
var definition = _a.definition, references = _a.references;
// Only include referenced symbols that have a valid definition.
return definition && {
definition: checker.runWithCancellationToken(cancellationToken, function (checker) { return definitionToReferencedSymbolDefinitionInfo(definition, checker, node); }),
- references: references.map(function (r) { return toReferenceEntry(r, symbol); })
+ references: references.map(function (r) { return toReferencedSymbolEntry(r, symbol); })
};
});
}
FindAllReferences.findReferencedSymbols = findReferencedSymbols;
+ function isDefinitionForReference(node) {
+ return node.kind === 88 /* SyntaxKind.DefaultKeyword */
+ || !!ts.getDeclarationFromName(node)
+ || ts.isLiteralComputedPropertyDeclarationName(node)
+ || (node.kind === 134 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent));
+ }
function getImplementationsAtPosition(program, cancellationToken, sourceFiles, sourceFile, position) {
var node = ts.getTouchingPropertyName(sourceFile, position);
var referenceEntries;
var entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position);
- if (node.parent.kind === 205 /* PropertyAccessExpression */
- || node.parent.kind === 202 /* BindingElement */
- || node.parent.kind === 206 /* ElementAccessExpression */
- || node.kind === 106 /* SuperKeyword */) {
+ if (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */
+ || node.parent.kind === 203 /* SyntaxKind.BindingElement */
+ || node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */
+ || node.kind === 106 /* SyntaxKind.SuperKeyword */) {
referenceEntries = entries && __spreadArray([], entries, true);
}
else {
@@ -134648,18 +136965,18 @@ var ts;
}
FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition;
function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) {
- if (node.kind === 303 /* SourceFile */) {
+ if (node.kind === 305 /* SyntaxKind.SourceFile */) {
return undefined;
}
var checker = program.getTypeChecker();
// If invoked directly on a shorthand property assignment, then return
// the declaration of the symbol being assigned (not the symbol being assigned to).
- if (node.parent.kind === 295 /* ShorthandPropertyAssignment */) {
+ if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) {
var result_2 = [];
Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_2.push(nodeEntry(node)); });
return result_2;
}
- else if (node.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) {
+ else if (node.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(node.parent)) {
// References to and accesses on the super keyword only have one possible implementation, so no
// need to "Find all References"
var symbol = checker.getSymbolAtLocation(node);
@@ -134667,7 +136984,7 @@ var ts;
}
else {
// Perform "Find all References" and retrieve only those that are implementations
- return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true, use: 1 /* References */ });
+ return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true, use: 1 /* FindReferencesUse.References */ });
}
}
function findReferenceOrRenameEntries(program, cancellationToken, sourceFiles, node, position, options, convertEntry) {
@@ -134686,7 +137003,7 @@ var ts;
function definitionToReferencedSymbolDefinitionInfo(def, checker, originalNode) {
var info = (function () {
switch (def.type) {
- case 0 /* Symbol */: {
+ case 0 /* DefinitionKind.Symbol */: {
var symbol = def.symbol;
var _a = getDefinitionKindAndDisplayParts(symbol, checker, originalNode), displayParts_1 = _a.displayParts, kind_1 = _a.kind;
var name_1 = displayParts_1.map(function (p) { return p.text; }).join("");
@@ -134694,31 +137011,31 @@ var ts;
var node = declaration ? (ts.getNameOfDeclaration(declaration) || declaration) : originalNode;
return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_1, kind: kind_1, displayParts: displayParts_1, context: getContextNode(declaration) });
}
- case 1 /* Label */: {
+ case 1 /* DefinitionKind.Label */: {
var node = def.node;
- return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "label" /* label */, displayParts: [ts.displayPart(node.text, ts.SymbolDisplayPartKind.text)] });
+ return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "label" /* ScriptElementKind.label */, displayParts: [ts.displayPart(node.text, ts.SymbolDisplayPartKind.text)] });
}
- case 2 /* Keyword */: {
+ case 2 /* DefinitionKind.Keyword */: {
var node = def.node;
var name_2 = ts.tokenToString(node.kind);
- return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_2, kind: "keyword" /* keyword */, displayParts: [{ text: name_2, kind: "keyword" /* keyword */ }] });
+ return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_2, kind: "keyword" /* ScriptElementKind.keyword */, displayParts: [{ text: name_2, kind: "keyword" /* ScriptElementKind.keyword */ }] });
}
- case 3 /* This */: {
+ case 3 /* DefinitionKind.This */: {
var node = def.node;
var symbol = checker.getSymbolAtLocation(node);
var displayParts_2 = symbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node.getSourceFile(), ts.getContainerNode(node), node).displayParts || [ts.textPart("this")];
- return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: "this", kind: "var" /* variableElement */, displayParts: displayParts_2 });
+ return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: "this", kind: "var" /* ScriptElementKind.variableElement */, displayParts: displayParts_2 });
}
- case 4 /* String */: {
+ case 4 /* DefinitionKind.String */: {
var node = def.node;
- return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "var" /* variableElement */, displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] });
+ return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "var" /* ScriptElementKind.variableElement */, displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] });
}
- case 5 /* TripleSlashReference */: {
+ case 5 /* DefinitionKind.TripleSlashReference */: {
return {
textSpan: ts.createTextSpanFromRange(def.reference),
sourceFile: def.file,
name: def.reference.fileName,
- kind: "string" /* string */,
+ kind: "string" /* ScriptElementKind.string */,
displayParts: [ts.displayPart("\"".concat(def.reference.fileName, "\""), ts.SymbolDisplayPartKind.stringLiteral)]
};
}
@@ -134727,7 +137044,7 @@ var ts;
}
})();
var sourceFile = info.sourceFile, textSpan = info.textSpan, name = info.name, kind = info.kind, displayParts = info.displayParts, context = info.context;
- return __assign({ containerKind: "" /* unknown */, containerName: "", fileName: sourceFile.fileName, kind: kind, name: name, textSpan: textSpan, displayParts: displayParts }, toContextSpan(textSpan, sourceFile, context));
+ return __assign({ containerKind: "" /* ScriptElementKind.unknown */, containerName: "", fileName: sourceFile.fileName, kind: kind, name: name, textSpan: textSpan, displayParts: displayParts }, toContextSpan(textSpan, sourceFile, context));
}
function getFileAndTextSpanFromNode(node) {
var sourceFile = node.getSourceFile();
@@ -134746,17 +137063,23 @@ var ts;
return __assign(__assign({}, entryToDocumentSpan(entry)), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker)));
}
FindAllReferences.toRenameLocation = toRenameLocation;
- function toReferenceEntry(entry, symbol) {
+ function toReferencedSymbolEntry(entry, symbol) {
+ var referenceEntry = toReferenceEntry(entry);
+ if (!symbol)
+ return referenceEntry;
+ return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* EntryKind.Span */ && isDeclarationOfSymbol(entry.node, symbol) });
+ }
+ function toReferenceEntry(entry) {
var documentSpan = entryToDocumentSpan(entry);
- if (entry.kind === 0 /* Span */) {
- return __assign(__assign({}, documentSpan), { isWriteAccess: false, isDefinition: false });
+ if (entry.kind === 0 /* EntryKind.Span */) {
+ return __assign(__assign({}, documentSpan), { isWriteAccess: false });
}
var kind = entry.kind, node = entry.node;
- return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: isDeclarationOfSymbol(node, symbol), isInString: kind === 2 /* StringLiteral */ ? true : undefined });
+ return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* EntryKind.StringLiteral */ ? true : undefined });
}
FindAllReferences.toReferenceEntry = toReferenceEntry;
function entryToDocumentSpan(entry) {
- if (entry.kind === 0 /* Span */) {
+ if (entry.kind === 0 /* EntryKind.Span */) {
return { textSpan: entry.textSpan, fileName: entry.fileName };
}
else {
@@ -134766,7 +137089,7 @@ var ts;
}
}
function getPrefixAndSuffixText(entry, originalNode, checker) {
- if (entry.kind !== 0 /* Span */ && ts.isIdentifier(originalNode)) {
+ if (entry.kind !== 0 /* EntryKind.Span */ && ts.isIdentifier(originalNode)) {
var node = entry.node, kind = entry.kind;
var parent = node.parent;
var name = originalNode.text;
@@ -134774,10 +137097,10 @@ var ts;
if (isShorthandAssignment || (ts.isObjectBindingElementWithoutPropertyName(parent) && parent.name === node && parent.dotDotDotToken === undefined)) {
var prefixColon = { prefixText: name + ": " };
var suffixColon = { suffixText: ": " + name };
- if (kind === 3 /* SearchedLocalFoundProperty */) {
+ if (kind === 3 /* EntryKind.SearchedLocalFoundProperty */) {
return prefixColon;
}
- if (kind === 4 /* SearchedPropertyFoundLocal */) {
+ if (kind === 4 /* EntryKind.SearchedPropertyFoundLocal */) {
return suffixColon;
}
// In `const o = { x }; o.x`, symbolAtLocation at `x` in `{ x }` is the property symbol.
@@ -134811,12 +137134,12 @@ var ts;
}
function toImplementationLocation(entry, checker) {
var documentSpan = entryToDocumentSpan(entry);
- if (entry.kind !== 0 /* Span */) {
+ if (entry.kind !== 0 /* EntryKind.Span */) {
var node = entry.node;
return __assign(__assign({}, documentSpan), implementationKindDisplayParts(node, checker));
}
else {
- return __assign(__assign({}, documentSpan), { kind: "" /* unknown */, displayParts: [] });
+ return __assign(__assign({}, documentSpan), { kind: "" /* ScriptElementKind.unknown */, displayParts: [] });
}
}
function implementationKindDisplayParts(node, checker) {
@@ -134824,16 +137147,16 @@ var ts;
if (symbol) {
return getDefinitionKindAndDisplayParts(symbol, checker, node);
}
- else if (node.kind === 204 /* ObjectLiteralExpression */) {
+ else if (node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) {
return {
- kind: "interface" /* interfaceElement */,
- displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)]
+ kind: "interface" /* ScriptElementKind.interfaceElement */,
+ displayParts: [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)]
};
}
- else if (node.kind === 225 /* ClassExpression */) {
+ else if (node.kind === 226 /* SyntaxKind.ClassExpression */) {
return {
- kind: "local class" /* localClassElement */,
- displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)]
+ kind: "local class" /* ScriptElementKind.localClassElement */,
+ displayParts: [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)]
};
}
else {
@@ -134842,17 +137165,17 @@ var ts;
}
function toHighlightSpan(entry) {
var documentSpan = entryToDocumentSpan(entry);
- if (entry.kind === 0 /* Span */) {
+ if (entry.kind === 0 /* EntryKind.Span */) {
return {
fileName: documentSpan.fileName,
span: {
textSpan: documentSpan.textSpan,
- kind: "reference" /* reference */
+ kind: "reference" /* HighlightSpanKind.reference */
}
};
}
var writeAccess = isWriteAccessForReference(entry.node);
- var span = __assign({ textSpan: documentSpan.textSpan, kind: writeAccess ? "writtenReference" /* writtenReference */ : "reference" /* reference */, isInString: entry.kind === 2 /* StringLiteral */ ? true : undefined }, documentSpan.contextSpan && { contextSpan: documentSpan.contextSpan });
+ var span = __assign({ textSpan: documentSpan.textSpan, kind: writeAccess ? "writtenReference" /* HighlightSpanKind.writtenReference */ : "reference" /* HighlightSpanKind.reference */, isInString: entry.kind === 2 /* EntryKind.StringLiteral */ ? true : undefined }, documentSpan.contextSpan && { contextSpan: documentSpan.contextSpan });
return { fileName: documentSpan.fileName, span: span };
}
FindAllReferences.toHighlightSpan = toHighlightSpan;
@@ -134867,14 +137190,14 @@ var ts;
return ts.createTextSpanFromBounds(start, end);
}
function getTextSpanOfEntry(entry) {
- return entry.kind === 0 /* Span */ ? entry.textSpan :
+ return entry.kind === 0 /* EntryKind.Span */ ? entry.textSpan :
getTextSpan(entry.node, entry.node.getSourceFile());
}
FindAllReferences.getTextSpanOfEntry = getTextSpanOfEntry;
/** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */
function isWriteAccessForReference(node) {
var decl = ts.getDeclarationFromName(node);
- return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* DefaultKeyword */ || ts.isWriteAccess(node);
+ return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* SyntaxKind.DefaultKeyword */ || ts.isWriteAccess(node);
}
/** Whether a reference, `node`, is a definition of the `target` symbol */
function isDeclarationOfSymbol(node, target) {
@@ -134882,9 +137205,9 @@ var ts;
if (!target)
return false;
var source = ts.getDeclarationFromName(node) ||
- (node.kind === 88 /* DefaultKeyword */ ? node.parent
+ (node.kind === 88 /* SyntaxKind.DefaultKeyword */ ? node.parent
: ts.isLiteralComputedPropertyDeclarationName(node) ? node.parent.parent
- : node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent) ? node.parent.parent
+ : node.kind === 134 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent) ? node.parent.parent
: undefined);
var commonjsSource = source && ts.isBinaryExpression(source) ? source.left : undefined;
return !!(source && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === source || d === commonjsSource; })));
@@ -134895,50 +137218,50 @@ var ts;
*/
function declarationIsWriteAccess(decl) {
// Consider anything in an ambient declaration to be a write access since it may be coming from JS.
- if (!!(decl.flags & 8388608 /* Ambient */))
+ if (!!(decl.flags & 16777216 /* NodeFlags.Ambient */))
return true;
switch (decl.kind) {
- case 220 /* BinaryExpression */:
- case 202 /* BindingElement */:
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- case 88 /* DefaultKeyword */:
- case 259 /* EnumDeclaration */:
- case 297 /* EnumMember */:
- case 274 /* ExportSpecifier */:
- case 266 /* ImportClause */: // default import
- case 264 /* ImportEqualsDeclaration */:
- case 269 /* ImportSpecifier */:
- case 257 /* InterfaceDeclaration */:
- case 336 /* JSDocCallbackTag */:
- case 343 /* JSDocTypedefTag */:
- case 284 /* JsxAttribute */:
- case 260 /* ModuleDeclaration */:
- case 263 /* NamespaceExportDeclaration */:
- case 267 /* NamespaceImport */:
- case 273 /* NamespaceExport */:
- case 163 /* Parameter */:
- case 295 /* ShorthandPropertyAssignment */:
- case 258 /* TypeAliasDeclaration */:
- case 162 /* TypeParameter */:
+ case 221 /* SyntaxKind.BinaryExpression */:
+ case 203 /* SyntaxKind.BindingElement */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 88 /* SyntaxKind.DefaultKeyword */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 299 /* SyntaxKind.EnumMember */:
+ case 275 /* SyntaxKind.ExportSpecifier */:
+ case 267 /* SyntaxKind.ImportClause */: // default import
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 338 /* SyntaxKind.JSDocCallbackTag */:
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
+ case 285 /* SyntaxKind.JsxAttribute */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 264 /* SyntaxKind.NamespaceExportDeclaration */:
+ case 268 /* SyntaxKind.NamespaceImport */:
+ case 274 /* SyntaxKind.NamespaceExport */:
+ case 164 /* SyntaxKind.Parameter */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 163 /* SyntaxKind.TypeParameter */:
return true;
- case 294 /* PropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
// In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.)
return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent);
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 170 /* Constructor */:
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
return !!decl.body;
- case 253 /* VariableDeclaration */:
- case 166 /* PropertyDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
return !!decl.initializer || ts.isCatchClause(decl.parent);
- case 167 /* MethodSignature */:
- case 165 /* PropertySignature */:
- case 345 /* JSDocPropertyTag */:
- case 338 /* JSDocParameterTag */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 347 /* SyntaxKind.JSDocPropertyTag */:
+ case 340 /* SyntaxKind.JSDocParameterTag */:
return false;
default:
return ts.Debug.failBadSyntaxKind(decl);
@@ -134952,12 +137275,7 @@ var ts;
var _a, _b;
if (options === void 0) { options = {}; }
if (sourceFilesSet === void 0) { sourceFilesSet = new ts.Set(sourceFiles.map(function (f) { return f.fileName; })); }
- if (options.use === 1 /* References */) {
- node = ts.getAdjustedReferenceLocation(node);
- }
- else if (options.use === 2 /* Rename */) {
- node = ts.getAdjustedRenameLocation(node);
- }
+ node = getAdjustedNode(node, options);
if (ts.isSourceFile(node)) {
var resolvedRef = ts.GoToDefinition.getReferenceAtPosition(node, position, program);
if (!(resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file)) {
@@ -134972,7 +137290,7 @@ var ts;
return undefined;
}
return [{
- definition: { type: 5 /* TripleSlashReference */, reference: resolvedRef.reference, file: node },
+ definition: { type: 5 /* DefinitionKind.TripleSlashReference */, reference: resolvedRef.reference, file: node },
references: getReferencesForNonModule(resolvedRef.file, fileIncludeReasons, program) || ts.emptyArray
}];
}
@@ -134994,7 +137312,7 @@ var ts;
var referencedFileName = (_b = (_a = node.getSourceFile().resolvedModules) === null || _a === void 0 ? void 0 : _a.get(node.text, ts.getModeForUsageLocation(node.getSourceFile(), node))) === null || _b === void 0 ? void 0 : _b.resolvedFileName;
var referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined;
if (referencedFile) {
- return [{ definition: { type: 4 /* String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }];
+ return [{ definition: { type: 4 /* DefinitionKind.String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }];
}
// Fall through to string literal references. This is not very likely to return
// anything useful, but I guess it's better than nothing, and there's an existing
@@ -135004,11 +137322,11 @@ var ts;
}
return undefined;
}
- if (symbol.escapedName === "export=" /* ExportEquals */) {
+ if (symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) {
return getReferencedSymbolsForModule(program, symbol.parent, /*excludeImportTypeOfExportEquals*/ false, sourceFiles, sourceFilesSet);
}
var moduleReferences = getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol, program, sourceFiles, cancellationToken, options, sourceFilesSet);
- if (moduleReferences && !(symbol.flags & 33554432 /* Transient */)) {
+ if (moduleReferences && !(symbol.flags & 33554432 /* SymbolFlags.Transient */)) {
return moduleReferences;
}
var aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(node, symbol, checker);
@@ -135018,6 +137336,16 @@ var ts;
return mergeReferences(program, moduleReferences, references, moduleReferencesOfExportTarget);
}
Core.getReferencedSymbolsForNode = getReferencedSymbolsForNode;
+ function getAdjustedNode(node, options) {
+ if (options.use === 1 /* FindReferencesUse.References */) {
+ node = ts.getAdjustedReferenceLocation(node);
+ }
+ else if (options.use === 2 /* FindReferencesUse.Rename */) {
+ node = ts.getAdjustedRenameLocation(node);
+ }
+ return node;
+ }
+ Core.getAdjustedNode = getAdjustedNode;
function getReferencesForFileName(fileName, program, sourceFiles, sourceFilesSet) {
var _a, _b;
if (sourceFilesSet === void 0) { sourceFilesSet = new ts.Set(sourceFiles.map(function (f) { return f.fileName; })); }
@@ -135040,7 +137368,7 @@ var ts;
var location = ts.getReferencedFileLocation(program.getSourceFileByPath, ref);
if (ts.isReferenceFileLocation(location)) {
entries = ts.append(entries, {
- kind: 0 /* Span */,
+ kind: 0 /* EntryKind.Span */,
fileName: referencingFile.fileName,
textSpan: ts.createTextSpanFromRange(location)
});
@@ -135060,10 +137388,10 @@ var ts;
return undefined;
}
function getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol, program, sourceFiles, cancellationToken, options, sourceFilesSet) {
- var moduleSourceFile = (symbol.flags & 1536 /* Module */) && symbol.declarations && ts.find(symbol.declarations, ts.isSourceFile);
+ var moduleSourceFile = (symbol.flags & 1536 /* SymbolFlags.Module */) && symbol.declarations && ts.find(symbol.declarations, ts.isSourceFile);
if (!moduleSourceFile)
return undefined;
- var exportEquals = symbol.exports.get("export=" /* ExportEquals */);
+ var exportEquals = symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */);
// If !!exportEquals, we're about to add references to `import("mod")` anyway, so don't double-count them.
var moduleReferences = getReferencedSymbolsForModule(program, symbol, !!exportEquals, sourceFiles, sourceFilesSet);
if (!exportEquals || !sourceFilesSet.has(moduleSourceFile.fileName))
@@ -135091,13 +137419,13 @@ var ts;
continue;
}
var _loop_5 = function (entry) {
- if (!entry.definition || entry.definition.type !== 0 /* Symbol */) {
+ if (!entry.definition || entry.definition.type !== 0 /* DefinitionKind.Symbol */) {
result.push(entry);
return "continue";
}
var symbol = entry.definition.symbol;
var refIndex = ts.findIndex(result, function (ref) { return !!ref.definition &&
- ref.definition.type === 0 /* Symbol */ &&
+ ref.definition.type === 0 /* DefinitionKind.Symbol */ &&
ref.definition.symbol === symbol; });
if (refIndex === -1) {
result.push(entry);
@@ -135128,7 +137456,7 @@ var ts;
return result;
}
function getSourceFileIndexOfEntry(program, entry) {
- var sourceFile = entry.kind === 0 /* Span */ ?
+ var sourceFile = entry.kind === 0 /* EntryKind.Span */ ?
program.getSourceFile(entry.fileName) :
entry.node.getSourceFile();
return program.getSourceFiles().indexOf(sourceFile);
@@ -135149,7 +137477,7 @@ var ts;
}
else {
return {
- kind: 0 /* Span */,
+ kind: 0 /* EntryKind.Span */,
fileName: reference.referencingFile.fileName,
textSpan: ts.createTextSpanFromRange(reference.ref),
};
@@ -135159,21 +137487,21 @@ var ts;
for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
var decl = _a[_i];
switch (decl.kind) {
- case 303 /* SourceFile */:
+ case 305 /* SyntaxKind.SourceFile */:
// Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.)
break;
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
if (sourceFilesSet.has(decl.getSourceFile().fileName)) {
references.push(nodeEntry(decl.name));
}
break;
default:
// This may be merged with something.
- ts.Debug.assert(!!(symbol.flags & 33554432 /* Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration.");
+ ts.Debug.assert(!!(symbol.flags & 33554432 /* SymbolFlags.Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration.");
}
}
}
- var exported = symbol.exports.get("export=" /* ExportEquals */);
+ var exported = symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */);
if (exported === null || exported === void 0 ? void 0 : exported.declarations) {
for (var _b = 0, _c = exported.declarations; _b < _c.length; _b++) {
var decl = _c[_b];
@@ -135181,38 +137509,41 @@ var ts;
if (sourceFilesSet.has(sourceFile.fileName)) {
// At `module.exports = ...`, reference node is `module`
var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression :
- ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* ExportKeyword */, sourceFile)) :
+ ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* SyntaxKind.ExportKeyword */, sourceFile)) :
ts.getNameOfDeclaration(decl) || decl;
references.push(nodeEntry(node));
}
}
}
- return references.length ? [{ definition: { type: 0 /* Symbol */, symbol: symbol }, references: references }] : ts.emptyArray;
+ return references.length ? [{ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: symbol }, references: references }] : ts.emptyArray;
}
/** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */
function isReadonlyTypeOperator(node) {
- return node.kind === 144 /* ReadonlyKeyword */
+ return node.kind === 145 /* SyntaxKind.ReadonlyKeyword */
&& ts.isTypeOperatorNode(node.parent)
- && node.parent.operator === 144 /* ReadonlyKeyword */;
+ && node.parent.operator === 145 /* SyntaxKind.ReadonlyKeyword */;
}
/** getReferencedSymbols for special node kinds. */
function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) {
if (ts.isTypeKeyword(node.kind)) {
// A void expression (i.e., `void foo()`) is not special, but the `void` type is.
- if (node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(node.parent)) {
+ if (node.kind === 114 /* SyntaxKind.VoidKeyword */ && ts.isVoidExpression(node.parent)) {
return undefined;
}
// A modifier readonly (like on a property declaration) is not special;
// a readonly type keyword (like `readonly string[]`) is.
- if (node.kind === 144 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) {
+ if (node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) {
return undefined;
}
// Likewise, when we *are* looking for a special keyword, make sure we
// *don’t* include readonly member modifiers.
- return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 144 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined);
+ return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined);
+ }
+ if (ts.isImportMeta(node.parent) && node.parent.name === node) {
+ return getAllReferencesForImportMeta(sourceFiles, cancellationToken);
}
if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
- return [{ definition: { type: 2 /* Keyword */, node: node }, references: [nodeEntry(node)] }];
+ return [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: node }, references: [nodeEntry(node)] }];
}
// Labels
if (ts.isJumpStatementTarget(node)) {
@@ -135228,7 +137559,7 @@ var ts;
if (ts.isThis(node)) {
return getReferencesForThisKeyword(node, sourceFiles, cancellationToken);
}
- if (node.kind === 106 /* SuperKeyword */) {
+ if (node.kind === 106 /* SyntaxKind.SuperKeyword */) {
return getReferencesForSuperKeyword(node);
}
return undefined;
@@ -135237,20 +137568,20 @@ var ts;
function getReferencedSymbolsForSymbol(originalSymbol, node, sourceFiles, sourceFilesSet, checker, cancellationToken, options) {
var symbol = node && skipPastExportOrImportSpecifierOrUnion(originalSymbol, node, checker, /*useLocalSymbolForExportSpecifier*/ !isForRenameWithPrefixAndSuffixText(options)) || originalSymbol;
// Compute the meaning from the location and the symbol it references
- var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* All */;
+ var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* SemanticMeaning.All */;
var result = [];
- var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* None */, checker, cancellationToken, searchMeaning, options, result);
+ var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* SpecialSearchKind.None */, checker, cancellationToken, searchMeaning, options, result);
var exportSpecifier = !isForRenameWithPrefixAndSuffixText(options) || !symbol.declarations ? undefined : ts.find(symbol.declarations, ts.isExportSpecifier);
if (exportSpecifier) {
// When renaming at an export specifier, rename the export and not the thing being exported.
getReferencesAtExportSpecifier(exportSpecifier.name, symbol, exportSpecifier, state.createSearch(node, originalSymbol, /*comingFrom*/ undefined), state, /*addReferencesHere*/ true, /*alwaysGetReferences*/ true);
}
- else if (node && node.kind === 88 /* DefaultKeyword */ && symbol.escapedName === "default" /* Default */ && symbol.parent) {
+ else if (node && node.kind === 88 /* SyntaxKind.DefaultKeyword */ && symbol.escapedName === "default" /* InternalSymbolName.Default */ && symbol.parent) {
addReference(node, symbol, state);
- searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* Default */ }, state);
+ searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* ExportKind.Default */ }, state);
}
else {
- var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.use === 2 /* Rename */, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] });
+ var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.use === 2 /* FindReferencesUse.Rename */, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] });
getReferencesInContainerOrFiles(symbol, state, search);
}
return result;
@@ -135273,17 +137604,17 @@ var ts;
}
function getSpecialSearchKind(node) {
switch (node.kind) {
- case 170 /* Constructor */:
- case 134 /* ConstructorKeyword */:
- return 1 /* Constructor */;
- case 79 /* Identifier */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 134 /* SyntaxKind.ConstructorKeyword */:
+ return 1 /* SpecialSearchKind.Constructor */;
+ case 79 /* SyntaxKind.Identifier */:
if (ts.isClassLike(node.parent)) {
ts.Debug.assert(node.parent.name === node);
- return 2 /* Class */;
+ return 2 /* SpecialSearchKind.Class */;
}
// falls through
default:
- return 0 /* None */;
+ return 0 /* SpecialSearchKind.None */;
}
}
/** Handle a few special cases relating to export/import specifiers. */
@@ -135296,7 +137627,7 @@ var ts;
return ts.firstDefined(symbol.declarations, function (decl) {
if (!decl.parent) {
// Ignore UMD module and global merge
- if (symbol.flags & 33554432 /* Transient */)
+ if (symbol.flags & 33554432 /* SymbolFlags.Transient */)
return undefined;
// Assertions for GH#21814. We should be handling SourceFile symbols in `getReferencedSymbolsForModule` instead of getting here.
ts.Debug.fail("Unexpected symbol at ".concat(ts.Debug.formatSyntaxKind(node.kind), ": ").concat(ts.Debug.formatSymbol(symbol)));
@@ -135313,7 +137644,7 @@ var ts;
SpecialSearchKind[SpecialSearchKind["Class"] = 2] = "Class";
})(SpecialSearchKind || (SpecialSearchKind = {}));
function getNonModuleSymbolOfMergedModuleSymbol(symbol) {
- if (!(symbol.flags & (1536 /* Module */ | 33554432 /* Transient */)))
+ if (!(symbol.flags & (1536 /* SymbolFlags.Module */ | 33554432 /* SymbolFlags.Transient */)))
return undefined;
var decl = symbol.declarations && ts.find(symbol.declarations, function (d) { return !ts.isSourceFile(d) && !ts.isModuleDeclaration(d); });
return decl && decl.symbol;
@@ -135365,7 +137696,7 @@ var ts;
State.prototype.getImportSearches = function (exportSymbol, exportInfo) {
if (!this.importTracker)
this.importTracker = FindAllReferences.createImportTracker(this.sourceFiles, this.sourceFilesSet, this.checker, this.cancellationToken);
- return this.importTracker(exportSymbol, exportInfo, this.options.use === 2 /* Rename */);
+ return this.importTracker(exportSymbol, exportInfo, this.options.use === 2 /* FindReferencesUse.Rename */);
};
/** @param allSearchSymbols set of additional symbols for use by `includes`. */
State.prototype.createSearch = function (location, symbol, comingFrom, searchOptions) {
@@ -135388,7 +137719,7 @@ var ts;
var references = this.symbolIdToReferences[symbolId];
if (!references) {
references = this.symbolIdToReferences[symbolId] = [];
- this.result.push({ definition: { type: 0 /* Symbol */, symbol: searchSymbol }, references: references });
+ this.result.push({ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: searchSymbol }, references: references });
}
return function (node, kind) { return references.push(nodeEntry(node, kind)); };
};
@@ -135396,7 +137727,7 @@ var ts;
State.prototype.addStringOrCommentReference = function (fileName, textSpan) {
this.result.push({
definition: undefined,
- references: [{ kind: 0 /* Span */, fileName: fileName, textSpan: textSpan }]
+ references: [{ kind: 0 /* EntryKind.Span */, fileName: fileName, textSpan: textSpan }]
});
};
/** Returns `true` the first time we search for a symbol in a file and `false` afterwards. */
@@ -135427,19 +137758,19 @@ var ts;
// For each import, find all references to that import in its source file.
for (var _b = 0, importSearches_1 = importSearches; _b < importSearches_1.length; _b++) {
var _c = importSearches_1[_b], importLocation = _c[0], importSymbol = _c[1];
- getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1 /* Export */), state);
+ getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1 /* ImportExport.Export */), state);
}
if (indirectUsers.length) {
var indirectSearch = void 0;
switch (exportInfo.exportKind) {
- case 0 /* Named */:
- indirectSearch = state.createSearch(exportLocation, exportSymbol, 1 /* Export */);
+ case 0 /* ExportKind.Named */:
+ indirectSearch = state.createSearch(exportLocation, exportSymbol, 1 /* ImportExport.Export */);
break;
- case 1 /* Default */:
+ case 1 /* ExportKind.Default */:
// Search for a property access to '.default'. This can't be renamed.
- indirectSearch = state.options.use === 2 /* Rename */ ? undefined : state.createSearch(exportLocation, exportSymbol, 1 /* Export */, { text: "default" });
+ indirectSearch = state.options.use === 2 /* FindReferencesUse.Rename */ ? undefined : state.createSearch(exportLocation, exportSymbol, 1 /* ImportExport.Export */, { text: "default" });
break;
- case 2 /* ExportEquals */:
+ case 2 /* ExportKind.ExportEquals */:
break;
}
if (indirectSearch) {
@@ -135452,15 +137783,21 @@ var ts;
}
function eachExportReference(sourceFiles, checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName, isDefaultExport, cb) {
var importTracker = FindAllReferences.createImportTracker(sourceFiles, new ts.Set(sourceFiles.map(function (f) { return f.fileName; })), checker, cancellationToken);
- var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers;
+ var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences;
for (var _i = 0, importSearches_2 = importSearches; _i < importSearches_2.length; _i++) {
var importLocation = importSearches_2[_i][0];
cb(importLocation);
}
- for (var _b = 0, indirectUsers_2 = indirectUsers; _b < indirectUsers_2.length; _b++) {
- var indirectUser = indirectUsers_2[_b];
- for (var _c = 0, _d = getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName); _c < _d.length; _c++) {
- var node = _d[_c];
+ for (var _b = 0, singleReferences_2 = singleReferences; _b < singleReferences_2.length; _b++) {
+ var singleReference = singleReferences_2[_b];
+ if (ts.isIdentifier(singleReference) && ts.isImportTypeNode(singleReference.parent)) {
+ cb(singleReference);
+ }
+ }
+ for (var _c = 0, indirectUsers_2 = indirectUsers; _c < indirectUsers_2.length; _c++) {
+ var indirectUser = indirectUsers_2[_c];
+ for (var _d = 0, _e = getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName); _d < _e.length; _d++) {
+ var node = _e[_d];
// Import specifiers should be handled by importSearches
var symbol = checker.getSymbolAtLocation(node);
var hasExportAssignmentDeclaration = ts.some(symbol === null || symbol === void 0 ? void 0 : symbol.declarations, function (d) { return ts.tryCast(d, ts.isExportAssignment) ? true : false; });
@@ -135474,13 +137811,13 @@ var ts;
function shouldAddSingleReference(singleRef, state) {
if (!hasMatchingMeaning(singleRef, state))
return false;
- if (state.options.use !== 2 /* Rename */)
+ if (state.options.use !== 2 /* FindReferencesUse.Rename */)
return true;
// Don't rename an import type `import("./module-name")` when renaming `name` in `export = name;`
if (!ts.isIdentifier(singleRef))
return false;
// At `default` in `import { default as x }` or `export { default as x }`, do add a reference, but do not rename.
- return !(ts.isImportOrExportSpecifier(singleRef.parent) && singleRef.escapedText === "default" /* Default */);
+ return !(ts.isImportOrExportSpecifier(singleRef.parent) && singleRef.escapedText === "default" /* InternalSymbolName.Default */);
}
// Go to the symbol we imported from and find references for it.
function searchForImportedSymbol(symbol, state) {
@@ -135490,7 +137827,7 @@ var ts;
var declaration = _a[_i];
var exportingFile = declaration.getSourceFile();
// Need to search in the file even if it's not in the search-file set, because it might export the symbol.
- getReferencesInSourceFile(exportingFile, state.createSearch(declaration, symbol, 0 /* Import */), state, state.includesSourceFile(exportingFile));
+ getReferencesInSourceFile(exportingFile, state.createSearch(declaration, symbol, 0 /* ImportExport.Import */), state, state.includesSourceFile(exportingFile));
}
}
/** Search for all occurrences of an identifier in a source file (and filter out the ones that match). */
@@ -135516,17 +137853,17 @@ var ts;
// If this is the symbol of a named function expression or named class expression,
// then named references are limited to its own scope.
var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration;
- if (valueDeclaration && (valueDeclaration.kind === 212 /* FunctionExpression */ || valueDeclaration.kind === 225 /* ClassExpression */)) {
+ if (valueDeclaration && (valueDeclaration.kind === 213 /* SyntaxKind.FunctionExpression */ || valueDeclaration.kind === 226 /* SyntaxKind.ClassExpression */)) {
return valueDeclaration;
}
if (!declarations) {
return undefined;
}
// If this is private property or method, the scope is the containing class
- if (flags & (4 /* Property */ | 8192 /* Method */)) {
- var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); });
+ if (flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */)) {
+ var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* ModifierFlags.Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); });
if (privateDeclaration) {
- return ts.getAncestor(privateDeclaration, 256 /* ClassDeclaration */);
+ return ts.getAncestor(privateDeclaration, 257 /* SyntaxKind.ClassDeclaration */);
}
// Else this is a public property and could be accessed from anywhere.
return undefined;
@@ -135543,7 +137880,7 @@ var ts;
- The parent is an external module: then we should only search in the module (and recurse on the export later).
- But if the parent has `export as namespace`, the symbol is globally visible through that namespace.
*/
- var exposedByParent = parent && !(symbol.flags & 262144 /* TypeParameter */);
+ var exposedByParent = parent && !(symbol.flags & 262144 /* SymbolFlags.TypeParameter */);
if (exposedByParent && !(ts.isExternalModuleSymbol(parent) && !parent.globalExports)) {
return undefined;
}
@@ -135555,7 +137892,7 @@ var ts;
// Different declarations have different containers, bail out
return undefined;
}
- if (!container || container.kind === 303 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) {
+ if (!container || container.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(container)) {
// This is a global variable and not an external module, any declaration defined
// within this scope is visible outside the file
return undefined;
@@ -135603,6 +137940,30 @@ var ts;
}
}
Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile;
+ function getTopMostDeclarationNamesInFile(declarationName, sourceFile) {
+ var candidates = ts.filter(getPossibleSymbolReferenceNodes(sourceFile, declarationName), function (name) { return !!ts.getDeclarationFromName(name); });
+ return candidates.reduce(function (topMost, decl) {
+ var depth = getDepth(decl);
+ if (!ts.some(topMost.declarationNames) || depth === topMost.depth) {
+ topMost.declarationNames.push(decl);
+ topMost.depth = depth;
+ }
+ else if (depth < topMost.depth) {
+ topMost.declarationNames = [decl];
+ topMost.depth = depth;
+ }
+ return topMost;
+ }, { depth: Infinity, declarationNames: [] }).declarationNames;
+ function getDepth(declaration) {
+ var depth = 0;
+ while (declaration) {
+ declaration = ts.getContainerNode(declaration);
+ depth++;
+ }
+ return depth;
+ }
+ }
+ Core.getTopMostDeclarationNamesInFile = getTopMostDeclarationNamesInFile;
function someSignatureUsage(signature, sourceFiles, checker, cb) {
if (!signature.name || !ts.isIdentifier(signature.name))
return false;
@@ -135650,8 +138011,8 @@ var ts;
// We found a match. Make sure it's not part of a larger word (i.e. the char
// before and after it have to be a non-identifier char).
var endPosition = position + symbolNameLength;
- if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 99 /* Latest */)) &&
- (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 99 /* Latest */))) {
+ if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 99 /* ScriptTarget.Latest */)) &&
+ (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 99 /* ScriptTarget.Latest */))) {
// Found a real match. Keep searching.
positions.push(position);
}
@@ -135666,32 +138027,44 @@ var ts;
// Only pick labels that are either the target label, or have a target that is the target label
return node === targetLabel || (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel) ? nodeEntry(node) : undefined;
});
- return [{ definition: { type: 1 /* Label */, node: targetLabel }, references: references }];
+ return [{ definition: { type: 1 /* DefinitionKind.Label */, node: targetLabel }, references: references }];
}
function isValidReferencePosition(node, searchSymbolName) {
// Compare the length so we filter out strict superstrings of the symbol we are looking for
switch (node.kind) {
- case 80 /* PrivateIdentifier */:
+ case 80 /* SyntaxKind.PrivateIdentifier */:
if (ts.isJSDocMemberName(node.parent)) {
return true;
}
// falls through I guess
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return node.text.length === searchSymbolName.length;
- case 14 /* NoSubstitutionTemplateLiteral */:
- case 10 /* StringLiteral */: {
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
+ case 10 /* SyntaxKind.StringLiteral */: {
var str = node;
return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || (ts.isCallExpression(node.parent) && ts.isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node)) &&
str.text.length === searchSymbolName.length;
}
- case 8 /* NumericLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length;
- case 88 /* DefaultKeyword */:
+ case 88 /* SyntaxKind.DefaultKeyword */:
return "default".length === searchSymbolName.length;
default:
return false;
}
}
+ function getAllReferencesForImportMeta(sourceFiles, cancellationToken) {
+ var references = ts.flatMap(sourceFiles, function (sourceFile) {
+ cancellationToken.throwIfCancellationRequested();
+ return ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "meta", sourceFile), function (node) {
+ var parent = node.parent;
+ if (ts.isImportMeta(parent)) {
+ return nodeEntry(parent);
+ }
+ });
+ });
+ return references.length ? [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: references[0].node }, references: references }] : undefined;
+ }
function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken, filter) {
var references = ts.flatMap(sourceFiles, function (sourceFile) {
cancellationToken.throwIfCancellationRequested();
@@ -135701,7 +138074,7 @@ var ts;
}
});
});
- return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined;
+ return references.length ? [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: references[0].node }, references: references }] : undefined;
}
function getReferencesInSourceFile(sourceFile, search, state, addReferencesHere) {
if (addReferencesHere === void 0) { addReferencesHere = true; }
@@ -135752,7 +138125,7 @@ var ts;
return;
}
if (ts.isExportSpecifier(parent)) {
- ts.Debug.assert(referenceLocation.kind === 79 /* Identifier */);
+ ts.Debug.assert(referenceLocation.kind === 79 /* SyntaxKind.Identifier */);
getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere);
return;
}
@@ -135762,14 +138135,14 @@ var ts;
return;
}
switch (state.specialSearchKind) {
- case 0 /* None */:
+ case 0 /* SpecialSearchKind.None */:
if (addReferencesHere)
addReference(referenceLocation, relatedSymbol, state);
break;
- case 1 /* Constructor */:
+ case 1 /* SpecialSearchKind.Constructor */:
addConstructorReferences(referenceLocation, sourceFile, search, state);
break;
- case 2 /* Class */:
+ case 2 /* SpecialSearchKind.Class */:
addClassStaticThisReferences(referenceLocation, search, state);
break;
default:
@@ -135777,7 +138150,7 @@ var ts;
}
// Use the parent symbol if the location is commonjs require syntax on javascript files only.
if (ts.isInJSFile(referenceLocation)
- && referenceLocation.parent.kind === 202 /* BindingElement */
+ && referenceLocation.parent.kind === 203 /* SyntaxKind.BindingElement */
&& ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
referenceSymbol = referenceLocation.parent.symbol;
// The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
@@ -135797,7 +138170,7 @@ var ts;
}
if (!propertyName) {
// Don't rename at `export { default } from "m";`. (but do continue to search for imports of the re-export)
- if (!(state.options.use === 2 /* Rename */ && (name.escapedText === "default" /* Default */))) {
+ if (!(state.options.use === 2 /* FindReferencesUse.Rename */ && (name.escapedText === "default" /* InternalSymbolName.Default */))) {
addRef();
}
}
@@ -135807,7 +138180,7 @@ var ts;
if (!exportDeclaration.moduleSpecifier) {
addRef();
}
- if (addReferencesHere && state.options.use !== 2 /* Rename */ && state.markSeenReExportRHS(name)) {
+ if (addReferencesHere && state.options.use !== 2 /* FindReferencesUse.Rename */ && state.markSeenReExportRHS(name)) {
addReference(name, ts.Debug.checkDefined(exportSpecifier.symbol), state);
}
}
@@ -135818,9 +138191,9 @@ var ts;
}
// For `export { foo as bar }`, rename `foo`, but not `bar`.
if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) {
- var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* DefaultKeyword */
- || exportSpecifier.name.originalKeywordKind === 88 /* DefaultKeyword */;
- var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */;
+ var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */
+ || exportSpecifier.name.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */;
+ var exportKind = isDefaultExport ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */;
var exportSymbol = ts.Debug.checkDefined(exportSpecifier.symbol);
var exportInfo = FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker);
if (exportInfo) {
@@ -135828,7 +138201,7 @@ var ts;
}
}
// At `export { x } from "foo"`, also search for the imported symbol `"foo".x`.
- if (search.comingFrom !== 1 /* Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) {
+ if (search.comingFrom !== 1 /* ImportExport.Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) {
var imported = state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier);
if (imported)
searchForImportedSymbol(imported, state);
@@ -135855,11 +138228,11 @@ var ts;
}
}
function getImportOrExportReferences(referenceLocation, referenceSymbol, search, state) {
- var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1 /* Export */);
+ var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1 /* ImportExport.Export */);
if (!importOrExport)
return;
var symbol = importOrExport.symbol;
- if (importOrExport.kind === 0 /* Import */) {
+ if (importOrExport.kind === 0 /* ImportExport.Import */) {
if (!(isForRenameWithPrefixAndSuffixText(state.options))) {
searchForImportedSymbol(symbol, state);
}
@@ -135879,12 +138252,16 @@ var ts;
* the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the
* position of property accessing, the referenceEntry of such position will be handled in the first case.
*/
- if (!(flags & 33554432 /* Transient */) && name && search.includes(shorthandValueSymbol)) {
+ if (!(flags & 33554432 /* SymbolFlags.Transient */) && name && search.includes(shorthandValueSymbol)) {
addReference(name, shorthandValueSymbol, state);
}
}
function addReference(referenceLocation, relatedSymbol, state) {
var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator
+ // if rename symbol from default export anonymous function, for example `export default function() {}`, we do not need to add reference
+ if (state.options.use === 2 /* FindReferencesUse.Rename */ && referenceLocation.kind === 88 /* SyntaxKind.DefaultKeyword */) {
+ return;
+ }
var addRef = state.referenceAdder(symbol);
if (state.options.implementations) {
addImplementationReferences(referenceLocation, addRef, state);
@@ -135900,7 +138277,7 @@ var ts;
}
var pusher = function () { return state.referenceAdder(search.symbol); };
if (ts.isClassLike(referenceLocation.parent)) {
- ts.Debug.assert(referenceLocation.kind === 88 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation);
+ ts.Debug.assert(referenceLocation.kind === 88 /* SyntaxKind.DefaultKeyword */ || referenceLocation.parent.name === referenceLocation);
// This is the class declaration containing the constructor.
findOwnConstructorReferences(search.symbol, sourceFile, pusher());
}
@@ -135916,7 +138293,7 @@ var ts;
function addClassStaticThisReferences(referenceLocation, search, state) {
addReference(referenceLocation, search.symbol, state);
var classLike = referenceLocation.parent;
- if (state.options.use === 2 /* Rename */ || !ts.isClassLike(classLike))
+ if (state.options.use === 2 /* FindReferencesUse.Rename */ || !ts.isClassLike(classLike))
return;
ts.Debug.assert(classLike.name === referenceLocation);
var addRef = state.referenceAdder(search.symbol);
@@ -135927,7 +138304,7 @@ var ts;
}
if (member.body) {
member.body.forEachChild(function cb(node) {
- if (node.kind === 108 /* ThisKeyword */) {
+ if (node.kind === 108 /* SyntaxKind.ThisKeyword */) {
addRef(node);
}
else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) {
@@ -135946,18 +138323,18 @@ var ts;
if (constructorSymbol && constructorSymbol.declarations) {
for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) {
var decl = _a[_i];
- var ctrKeyword = ts.findChildOfKind(decl, 134 /* ConstructorKeyword */, sourceFile);
- ts.Debug.assert(decl.kind === 170 /* Constructor */ && !!ctrKeyword);
+ var ctrKeyword = ts.findChildOfKind(decl, 134 /* SyntaxKind.ConstructorKeyword */, sourceFile);
+ ts.Debug.assert(decl.kind === 171 /* SyntaxKind.Constructor */ && !!ctrKeyword);
addNode(ctrKeyword);
}
}
if (classSymbol.exports) {
classSymbol.exports.forEach(function (member) {
var decl = member.valueDeclaration;
- if (decl && decl.kind === 168 /* MethodDeclaration */) {
+ if (decl && decl.kind === 169 /* SyntaxKind.MethodDeclaration */) {
var body = decl.body;
if (body) {
- forEachDescendantOfKind(body, 108 /* ThisKeyword */, function (thisKeyword) {
+ forEachDescendantOfKind(body, 108 /* SyntaxKind.ThisKeyword */, function (thisKeyword) {
if (ts.isNewExpressionTarget(thisKeyword)) {
addNode(thisKeyword);
}
@@ -135968,7 +138345,7 @@ var ts;
}
}
function getClassConstructorSymbol(classSymbol) {
- return classSymbol.members && classSymbol.members.get("__constructor" /* Constructor */);
+ return classSymbol.members && classSymbol.members.get("__constructor" /* InternalSymbolName.Constructor */);
}
/** Find references to `super` in the constructor of an extending class. */
function findSuperConstructorAccesses(classDeclaration, addNode) {
@@ -135978,10 +138355,10 @@ var ts;
}
for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) {
var decl = _a[_i];
- ts.Debug.assert(decl.kind === 170 /* Constructor */);
+ ts.Debug.assert(decl.kind === 171 /* SyntaxKind.Constructor */);
var body = decl.body;
if (body) {
- forEachDescendantOfKind(body, 106 /* SuperKeyword */, function (node) {
+ forEachDescendantOfKind(body, 106 /* SyntaxKind.SuperKeyword */, function (node) {
if (ts.isCallExpressionTarget(node)) {
addNode(node);
}
@@ -136005,10 +138382,10 @@ var ts;
addReference(refNode);
return;
}
- if (refNode.kind !== 79 /* Identifier */) {
+ if (refNode.kind !== 79 /* SyntaxKind.Identifier */) {
return;
}
- if (refNode.parent.kind === 295 /* ShorthandPropertyAssignment */) {
+ if (refNode.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) {
// Go ahead and dereference the shorthand assignment by going to its definition
getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference);
}
@@ -136028,7 +138405,7 @@ var ts;
}
else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) {
var body = typeHavingNode.body;
- if (body.kind === 234 /* Block */) {
+ if (body.kind === 235 /* SyntaxKind.Block */) {
ts.forEachReturnStatement(body, function (returnStatement) {
if (returnStatement.expression)
addIfImplementation(returnStatement.expression);
@@ -136056,13 +138433,13 @@ var ts;
*/
function isImplementationExpression(node) {
switch (node.kind) {
- case 211 /* ParenthesizedExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
return isImplementationExpression(node.expression);
- case 213 /* ArrowFunction */:
- case 212 /* FunctionExpression */:
- case 204 /* ObjectLiteralExpression */:
- case 225 /* ClassExpression */:
- case 203 /* ArrayLiteralExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
return true;
default:
return false;
@@ -136113,15 +138490,15 @@ var ts;
return undefined;
}
// Whether 'super' occurs in a static context within a class.
- var staticFlag = 32 /* Static */;
+ var staticFlag = 32 /* ModifierFlags.Static */;
switch (searchSpaceNode.kind) {
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 170 /* Constructor */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode);
searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class
break;
@@ -136130,7 +138507,7 @@ var ts;
}
var sourceFile = searchSpaceNode.getSourceFile();
var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) {
- if (node.kind !== 106 /* SuperKeyword */) {
+ if (node.kind !== 106 /* SyntaxKind.SuperKeyword */) {
return;
}
var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false);
@@ -136139,46 +138516,46 @@ var ts;
// and has the same static qualifier as the original 'super's owner.
return container && ts.isStatic(container) === !!staticFlag && container.parent.symbol === searchSpaceNode.symbol ? nodeEntry(node) : undefined;
});
- return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }];
+ return [{ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: searchSpaceNode.symbol }, references: references }];
}
function isParameterName(node) {
- return node.kind === 79 /* Identifier */ && node.parent.kind === 163 /* Parameter */ && node.parent.name === node;
+ return node.kind === 79 /* SyntaxKind.Identifier */ && node.parent.kind === 164 /* SyntaxKind.Parameter */ && node.parent.name === node;
}
function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) {
var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false);
// Whether 'this' occurs in a static context within a class.
- var staticFlag = 32 /* Static */;
+ var staticFlag = 32 /* ModifierFlags.Static */;
switch (searchSpaceNode.kind) {
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
if (ts.isObjectLiteralMethod(searchSpaceNode)) {
staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode);
searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning object literals
break;
}
// falls through
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
- case 170 /* Constructor */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode);
searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class
break;
- case 303 /* SourceFile */:
+ case 305 /* SyntaxKind.SourceFile */:
if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) {
return undefined;
}
// falls through
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
break;
// Computed properties in classes are not handled here because references to this are illegal,
// so there is no point finding references to them.
default:
return undefined;
}
- var references = ts.flatMap(searchSpaceNode.kind === 303 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) {
+ var references = ts.flatMap(searchSpaceNode.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) {
cancellationToken.throwIfCancellationRequested();
return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) {
if (!ts.isThis(node)) {
@@ -136186,26 +138563,26 @@ var ts;
}
var container = ts.getThisContainer(node, /* includeArrowFunctions */ false);
switch (searchSpaceNode.kind) {
- case 212 /* FunctionExpression */:
- case 255 /* FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
return searchSpaceNode.symbol === container.symbol;
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol;
- case 225 /* ClassExpression */:
- case 256 /* ClassDeclaration */:
- case 204 /* ObjectLiteralExpression */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
// Make sure the container belongs to the same class/object literals
// and has the appropriate static modifier from the original container.
return container.parent && searchSpaceNode.symbol === container.parent.symbol && ts.isStatic(container) === !!staticFlag;
- case 303 /* SourceFile */:
- return container.kind === 303 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node);
+ case 305 /* SyntaxKind.SourceFile */:
+ return container.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node);
}
});
}).map(function (n) { return nodeEntry(n); });
var thisParameter = ts.firstDefined(references, function (r) { return ts.isParameter(r.node.parent) ? r.node : undefined; });
return [{
- definition: { type: 3 /* This */, node: thisParameter || thisOrSuperKeyword },
+ definition: { type: 3 /* DefinitionKind.This */, node: thisParameter || thisOrSuperKeyword },
references: references
}];
}
@@ -136218,18 +138595,18 @@ var ts;
if (type) {
var refType = ts.getContextualTypeFromParentOrAncestorTypeNode(ref, checker);
if (type !== checker.getStringType() && type === refType) {
- return nodeEntry(ref, 2 /* StringLiteral */);
+ return nodeEntry(ref, 2 /* EntryKind.StringLiteral */);
}
}
else {
return ts.isNoSubstitutionTemplateLiteral(ref) && !ts.rangeIsOnSingleLine(ref, sourceFile) ? undefined :
- nodeEntry(ref, 2 /* StringLiteral */);
+ nodeEntry(ref, 2 /* EntryKind.StringLiteral */);
}
}
});
});
return [{
- definition: { type: 4 /* String */, node: node },
+ definition: { type: 4 /* DefinitionKind.String */, node: node },
references: references
}];
}
@@ -136274,30 +138651,30 @@ var ts;
var shorthandValueSymbol = checker.getShorthandAssignmentValueSymbol(location.parent); // gets the local symbol
if (shorthandValueSymbol && isForRenamePopulateSearchSymbolSet) {
// When renaming 'x' in `const o = { x }`, just rename the local variable, not the property.
- return cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* SearchedLocalFoundProperty */);
+ return cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* EntryKind.SearchedLocalFoundProperty */);
}
// If the location is in a context sensitive location (i.e. in an object literal) try
// to get a contextual type for it, and add the property symbol from the contextual
// type to the search set
var contextualType = checker.getContextualType(containingObjectLiteralElement.parent);
- var res_1 = contextualType && ts.firstDefined(ts.getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker, contextualType, /*unionSymbolOk*/ true), function (sym) { return fromRoot(sym, 4 /* SearchedPropertyFoundLocal */); });
+ var res_1 = contextualType && ts.firstDefined(ts.getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker, contextualType, /*unionSymbolOk*/ true), function (sym) { return fromRoot(sym, 4 /* EntryKind.SearchedPropertyFoundLocal */); });
if (res_1)
return res_1;
// If the location is name of property symbol from object literal destructuring pattern
// Search the property symbol
// for ( { property: p2 } of elems) { }
var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, checker);
- var res1 = propertySymbol && cbSymbol(propertySymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 4 /* SearchedPropertyFoundLocal */);
+ var res1 = propertySymbol && cbSymbol(propertySymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 4 /* EntryKind.SearchedPropertyFoundLocal */);
if (res1)
return res1;
- var res2 = shorthandValueSymbol && cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* SearchedLocalFoundProperty */);
+ var res2 = shorthandValueSymbol && cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* EntryKind.SearchedLocalFoundProperty */);
if (res2)
return res2;
}
var aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(location, symbol, checker);
if (aliasedSymbol) {
// In case of UMD module and global merging, search for global as well
- var res_2 = cbSymbol(aliasedSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */);
+ var res_2 = cbSymbol(aliasedSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* EntryKind.Node */);
if (res_2)
return res_2;
}
@@ -136307,14 +138684,14 @@ var ts;
if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) {
// For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property).
var paramProps = checker.getSymbolsOfParameterPropertyDeclaration(ts.cast(symbol.valueDeclaration, ts.isParameter), symbol.name);
- ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property]
- return fromRoot(symbol.flags & 1 /* FunctionScopedVariable */ ? paramProps[1] : paramProps[0]);
+ ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* SymbolFlags.FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* SymbolFlags.Property */)); // is [parameter, property]
+ return fromRoot(symbol.flags & 1 /* SymbolFlags.FunctionScopedVariable */ ? paramProps[1] : paramProps[0]);
}
- var exportSpecifier = ts.getDeclarationOfKind(symbol, 274 /* ExportSpecifier */);
+ var exportSpecifier = ts.getDeclarationOfKind(symbol, 275 /* SyntaxKind.ExportSpecifier */);
if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) {
var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier);
if (localSymbol) {
- var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */);
+ var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* EntryKind.Node */);
if (res_3)
return res_3;
}
@@ -136329,7 +138706,7 @@ var ts;
else {
bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker);
}
- return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* SearchedPropertyFoundLocal */);
+ return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* EntryKind.SearchedPropertyFoundLocal */);
}
ts.Debug.assert(isForRenamePopulateSearchSymbolSet);
// due to the above assert and the arguments at the uses of this function,
@@ -136337,7 +138714,7 @@ var ts;
var includeOriginalSymbolOfBindingElement = onlyIncludeBindingElementAtReferenceLocation;
if (includeOriginalSymbolOfBindingElement) {
var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker);
- return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* SearchedPropertyFoundLocal */);
+ return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* EntryKind.SearchedPropertyFoundLocal */);
}
function fromRoot(sym, kind) {
// If this is a union property:
@@ -136349,13 +138726,13 @@ var ts;
return ts.firstDefined(checker.getRootSymbols(sym), function (rootSymbol) {
return cbSymbol(sym, rootSymbol, /*baseSymbol*/ undefined, kind)
// Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions
- || (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */) && allowBaseTypes(rootSymbol)
+ || (rootSymbol.parent && rootSymbol.parent.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */) && allowBaseTypes(rootSymbol)
? getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, checker, function (base) { return cbSymbol(sym, rootSymbol, base, kind); })
: undefined);
});
}
function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) {
- var bindingElement = ts.getDeclarationOfKind(symbol, 202 /* BindingElement */);
+ var bindingElement = ts.getDeclarationOfKind(symbol, 203 /* SyntaxKind.BindingElement */);
if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) {
return ts.getPropertySymbolFromBindingElement(checker, bindingElement);
}
@@ -136377,7 +138754,7 @@ var ts;
// interface C extends C {
// /*findRef*/propName: string;
// }
- if (!(symbol.flags & (32 /* Class */ | 64 /* Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol)))
+ if (!(symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol)))
return;
return ts.firstDefined(symbol.declarations, function (declaration) { return ts.firstDefined(ts.getAllSuperTypeNodes(declaration), function (typeReference) {
var type = checker.getTypeAtLocation(typeReference);
@@ -136391,12 +138768,12 @@ var ts;
if (!symbol.valueDeclaration)
return false;
var modifierFlags = ts.getEffectiveModifierFlags(symbol.valueDeclaration);
- return !!(modifierFlags & 32 /* Static */);
+ return !!(modifierFlags & 32 /* ModifierFlags.Static */);
}
function getRelatedSymbol(search, referenceSymbol, referenceLocation, state) {
var checker = state.checker;
return forEachRelatedSymbol(referenceSymbol, referenceLocation, checker, /*isForRenamePopulateSearchSymbolSet*/ false,
- /*onlyIncludeBindingElementAtReferenceLocation*/ state.options.use !== 2 /* Rename */ || !!state.options.providePrefixAndSuffixTextForRename, function (sym, rootSymbol, baseSymbol, kind) {
+ /*onlyIncludeBindingElementAtReferenceLocation*/ state.options.use !== 2 /* FindReferencesUse.Rename */ || !!state.options.providePrefixAndSuffixTextForRename, function (sym, rootSymbol, baseSymbol, kind) {
// check whether the symbol used to search itself is just the searched one.
if (baseSymbol) {
// static method/property and instance method/property might have the same name. Only check static or only check instance.
@@ -136406,7 +138783,7 @@ var ts;
}
return search.includes(baseSymbol || rootSymbol || sym)
// For a base type, use the symbol for the derived type. For a synthetic (e.g. union) property, use the union symbol.
- ? { symbol: rootSymbol && !(ts.getCheckFlags(sym) & 6 /* Synthetic */) ? rootSymbol : sym, kind: kind }
+ ? { symbol: rootSymbol && !(ts.getCheckFlags(sym) & 6 /* CheckFlags.Synthetic */) ? rootSymbol : sym, kind: kind }
: undefined;
},
/*allowBaseTypes*/ function (rootSymbol) {
@@ -136446,7 +138823,7 @@ var ts;
}
Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations;
function isImplementation(node) {
- return !!(node.flags & 8388608 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) :
+ return !!(node.flags & 16777216 /* NodeFlags.Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) :
(ts.isVariableLike(node) ? ts.hasInitializer(node) :
ts.isFunctionLikeDeclaration(node) ? !!node.body :
ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node));
@@ -136457,7 +138834,7 @@ var ts;
if (shorthandSymbol) {
for (var _i = 0, _a = shorthandSymbol.getDeclarations(); _i < _a.length; _i++) {
var declaration = _a[_i];
- if (ts.getMeaningFromDeclaration(declaration) & 1 /* Value */) {
+ if (ts.getMeaningFromDeclaration(declaration) & 1 /* SemanticMeaning.Value */) {
addReference(declaration);
}
}
@@ -136486,12 +138863,12 @@ var ts;
var propertyAccessExpression = ts.isRightSideOfPropertyAccess(location) ? location.parent : undefined;
var lhsType = propertyAccessExpression && checker.getTypeAtLocation(propertyAccessExpression.expression);
var res = ts.mapDefined(lhsType && (lhsType.isUnionOrIntersection() ? lhsType.types : lhsType.symbol === symbol.parent ? undefined : [lhsType]), function (t) {
- return t.symbol && t.symbol.flags & (32 /* Class */ | 64 /* Interface */) ? t.symbol : undefined;
+ return t.symbol && t.symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */) ? t.symbol : undefined;
});
return res.length === 0 ? undefined : res;
}
function isForRenameWithPrefixAndSuffixText(options) {
- return options.use === 2 /* Rename */ && options.providePrefixAndSuffixTextForRename;
+ return options.use === 2 /* FindReferencesUse.Rename */ && options.providePrefixAndSuffixTextForRename;
}
})(Core = FindAllReferences.Core || (FindAllReferences.Core = {}));
})(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {}));
@@ -136511,7 +138888,7 @@ var ts;
&& ts.isVariableDeclaration(node.parent)
&& node === node.parent.initializer
&& ts.isIdentifier(node.parent.name)
- && !!(ts.getCombinedNodeFlags(node.parent) & 2 /* Const */);
+ && !!(ts.getCombinedNodeFlags(node.parent) & 2 /* NodeFlags.Const */);
}
/**
* Indicates whether a node could possibly be a call hierarchy declaration.
@@ -136560,7 +138937,7 @@ var ts;
return ts.Debug.checkDefined(node.modifiers && ts.find(node.modifiers, isDefaultModifier));
}
function isDefaultModifier(node) {
- return node.kind === 88 /* DefaultKeyword */;
+ return node.kind === 88 /* SyntaxKind.DefaultKeyword */;
}
/** Gets the symbol for a call hierarchy declaration. */
function getSymbolOfCallHierarchyDeclaration(typeChecker, node) {
@@ -136605,7 +138982,7 @@ var ts;
if (text === undefined) {
// get the text from printing the node on a single line without comments...
var printer_1 = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
- text = ts.usingSingleLineStringWriter(function (writer) { return printer_1.writeNode(4 /* Unspecified */, node, node.getSourceFile(), writer); });
+ text = ts.usingSingleLineStringWriter(function (writer) { return printer_1.writeNode(4 /* EmitHint.Unspecified */, node, node.getSourceFile(), writer); });
}
return { text: text, pos: declName.getStart(), end: declName.getEnd() };
}
@@ -136618,16 +138995,16 @@ var ts;
return;
}
switch (node.kind) {
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 168 /* MethodDeclaration */:
- if (node.parent.kind === 204 /* ObjectLiteralExpression */) {
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) {
return (_a = ts.getAssignedName(node.parent)) === null || _a === void 0 ? void 0 : _a.getText();
}
return (_b = ts.getNameOfDeclaration(node.parent)) === null || _b === void 0 ? void 0 : _b.getText();
- case 255 /* FunctionDeclaration */:
- case 256 /* ClassDeclaration */:
- case 260 /* ModuleDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
if (ts.isModuleBlock(node.parent) && ts.isIdentifier(node.parent.parent.name)) {
return node.parent.parent.name.getText();
}
@@ -136725,7 +139102,7 @@ var ts;
}
return undefined;
}
- if (location.kind === 124 /* StaticKeyword */ && ts.isClassStaticBlockDeclaration(location.parent)) {
+ if (location.kind === 124 /* SyntaxKind.StaticKeyword */ && ts.isClassStaticBlockDeclaration(location.parent)) {
location = location.parent;
continue;
}
@@ -136736,7 +139113,7 @@ var ts;
if (!followingSymbol) {
var symbol = typeChecker.getSymbolAtLocation(location);
if (symbol) {
- if (symbol.flags & 2097152 /* Alias */) {
+ if (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
symbol = typeChecker.getAliasedSymbol(symbol);
}
if (symbol.valueDeclaration) {
@@ -136766,7 +139143,7 @@ var ts;
return x !== undefined;
}
function convertEntryToCallSite(entry) {
- if (entry.kind === 1 /* Node */) {
+ if (entry.kind === 1 /* FindAllReferences.EntryKind.Node */) {
var node = entry.node;
if (ts.isCallOrNewExpressionTarget(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true)
|| ts.isTaggedTemplateTag(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true)
@@ -136796,7 +139173,7 @@ var ts;
return [];
}
var location = getCallHierarchyDeclarationReferenceNode(declaration);
- var calls = ts.filter(ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, program.getSourceFiles(), location, /*position*/ 0, { use: 1 /* References */ }, convertEntryToCallSite), isDefined);
+ var calls = ts.filter(ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, program.getSourceFiles(), location, /*position*/ 0, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }, convertEntryToCallSite), isDefined);
return calls ? ts.group(calls, getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToIncomingCall(program, entries); }) : [];
}
CallHierarchy.getIncomingCalls = getIncomingCalls;
@@ -136824,7 +139201,7 @@ var ts;
function collect(node) {
if (!node)
return;
- if (node.flags & 8388608 /* Ambient */) {
+ if (node.flags & 16777216 /* NodeFlags.Ambient */) {
// do not descend into ambient nodes.
return;
}
@@ -136841,59 +139218,59 @@ var ts;
return;
}
switch (node.kind) {
- case 79 /* Identifier */:
- case 264 /* ImportEqualsDeclaration */:
- case 265 /* ImportDeclaration */:
- case 271 /* ExportDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 258 /* TypeAliasDeclaration */:
+ case 79 /* SyntaxKind.Identifier */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
// do not descend into nodes that cannot contain callable nodes
return;
- case 169 /* ClassStaticBlockDeclaration */:
+ case 170 /* SyntaxKind.ClassStaticBlockDeclaration */:
recordCallSite(node);
return;
- case 210 /* TypeAssertionExpression */:
- case 228 /* AsExpression */:
+ case 211 /* SyntaxKind.TypeAssertionExpression */:
+ case 229 /* SyntaxKind.AsExpression */:
// do not descend into the type side of an assertion
collect(node.expression);
return;
- case 253 /* VariableDeclaration */:
- case 163 /* Parameter */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
+ case 164 /* SyntaxKind.Parameter */:
// do not descend into the type of a variable or parameter declaration
collect(node.name);
collect(node.initializer);
return;
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
// do not descend into the type arguments of a call expression
recordCallSite(node);
collect(node.expression);
ts.forEach(node.arguments, collect);
return;
- case 208 /* NewExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
// do not descend into the type arguments of a new expression
recordCallSite(node);
collect(node.expression);
ts.forEach(node.arguments, collect);
return;
- case 209 /* TaggedTemplateExpression */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
// do not descend into the type arguments of a tagged template expression
recordCallSite(node);
collect(node.tag);
collect(node.template);
return;
- case 279 /* JsxOpeningElement */:
- case 278 /* JsxSelfClosingElement */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
// do not descend into the type arguments of a JsxOpeningLikeElement
recordCallSite(node);
collect(node.tagName);
collect(node.attributes);
return;
- case 164 /* Decorator */:
+ case 165 /* SyntaxKind.Decorator */:
recordCallSite(node);
collect(node.expression);
return;
- case 205 /* PropertyAccessExpression */:
- case 206 /* ElementAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
recordCallSite(node);
ts.forEachChild(node, collect);
break;
@@ -136910,7 +139287,7 @@ var ts;
ts.forEach(node.statements, collect);
}
function collectCallSitesOfModuleDeclaration(node, collect) {
- if (!ts.hasSyntacticModifier(node, 2 /* Ambient */) && node.body && ts.isModuleBlock(node.body)) {
+ if (!ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */) && node.body && ts.isModuleBlock(node.body)) {
ts.forEach(node.body.statements, collect);
}
}
@@ -136949,25 +139326,25 @@ var ts;
var callSites = [];
var collect = createCallSiteCollector(program, callSites);
switch (node.kind) {
- case 303 /* SourceFile */:
+ case 305 /* SyntaxKind.SourceFile */:
collectCallSitesOfSourceFile(node, collect);
break;
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
collectCallSitesOfModuleDeclaration(node, collect);
break;
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
collectCallSitesOfFunctionLikeDeclaration(program.getTypeChecker(), node, collect);
break;
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
collectCallSitesOfClassLikeDeclaration(node, collect);
break;
- case 169 /* ClassStaticBlockDeclaration */:
+ case 170 /* SyntaxKind.ClassStaticBlockDeclaration */:
collectCallSitesOfClassStaticBlockDeclaration(node, collect);
break;
default:
@@ -136983,7 +139360,7 @@ var ts;
}
/** Gets the call sites that call out of the provided call hierarchy declaration. */
function getOutgoingCalls(program, declaration) {
- if (declaration.flags & 8388608 /* Ambient */ || ts.isMethodSignature(declaration)) {
+ if (declaration.flags & 16777216 /* NodeFlags.Ambient */ || ts.isMethodSignature(declaration)) {
return [];
}
return ts.group(collectCallSites(program, declaration), getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToOutgoingCall(program, entries); });
@@ -137223,7 +139600,9 @@ var ts;
(function (ts) {
var GoToDefinition;
(function (GoToDefinition) {
- function getDefinitionAtPosition(program, sourceFile, position) {
+ function getDefinitionAtPosition(program, sourceFile, position, searchOtherFilesOnly, stopAtAlias) {
+ var _a;
+ var _b;
var resolvedRef = getReferenceAtPosition(sourceFile, position, program);
var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray;
if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) {
@@ -137236,45 +139615,75 @@ var ts;
}
var parent = node.parent;
var typeChecker = program.getTypeChecker();
- if (node.kind === 158 /* OverrideKeyword */ || (ts.isJSDocOverrideTag(node) && ts.rangeContainsPosition(node.tagName, position))) {
+ if (node.kind === 159 /* SyntaxKind.OverrideKeyword */ || (ts.isJSDocOverrideTag(node) && ts.rangeContainsPosition(node.tagName, position))) {
return getDefinitionFromOverriddenMember(typeChecker, node) || ts.emptyArray;
}
// Labels
if (ts.isJumpStatementTarget(node)) {
var label = ts.getTargetLabel(node.parent, node.text);
- return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217
+ return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* ScriptElementKind.label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217
}
if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
var classDecl = node.parent.parent;
- var symbol_1 = getSymbol(classDecl, typeChecker);
+ var _c = getSymbol(classDecl, typeChecker, stopAtAlias), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution;
var staticBlocks = ts.filter(classDecl.members, ts.isClassStaticBlockDeclaration);
var containerName_1 = symbol_1 ? typeChecker.symbolToString(symbol_1, classDecl) : "";
var sourceFile_1 = node.getSourceFile();
return ts.map(staticBlocks, function (staticBlock) {
var pos = ts.moveRangePastModifiers(staticBlock).pos;
pos = ts.skipTrivia(sourceFile_1.text, pos);
- return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, { start: pos, length: "static".length });
+ return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* ScriptElementKind.constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length });
});
}
- var symbol = getSymbol(node, typeChecker);
+ var _d = getSymbol(node, typeChecker, stopAtAlias), symbol = _d.symbol, failedAliasResolution = _d.failedAliasResolution;
+ var fallbackNode = node;
+ if (searchOtherFilesOnly && failedAliasResolution) {
+ // We couldn't resolve the specific import, try on the module specifier.
+ var importDeclaration = ts.forEach(__spreadArray([node], (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray, true), function (n) { return ts.findAncestor(n, ts.isAnyImportOrBareOrAccessedRequire); });
+ var moduleSpecifier = importDeclaration && ts.tryGetModuleSpecifierFromDeclaration(importDeclaration);
+ if (moduleSpecifier) {
+ (_a = getSymbol(moduleSpecifier, typeChecker, stopAtAlias), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution);
+ fallbackNode = moduleSpecifier;
+ }
+ }
+ if (!symbol && ts.isModuleSpecifierLike(fallbackNode)) {
+ // We couldn't resolve the module specifier as an external module, but it could
+ // be that module resolution succeeded but the target was not a module.
+ var ref = (_b = sourceFile.resolvedModules) === null || _b === void 0 ? void 0 : _b.get(fallbackNode.text, ts.getModeForUsageLocation(sourceFile, fallbackNode));
+ if (ref) {
+ return [{
+ name: fallbackNode.text,
+ fileName: ref.resolvedFileName,
+ containerName: undefined,
+ containerKind: undefined,
+ kind: "script" /* ScriptElementKind.scriptElement */,
+ textSpan: ts.createTextSpan(0, 0),
+ failedAliasResolution: failedAliasResolution,
+ isAmbient: ts.isDeclarationFileName(ref.resolvedFileName),
+ unverified: fallbackNode !== node,
+ }];
+ }
+ }
// Could not find a symbol e.g. node is string or number keyword,
// or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
if (!symbol) {
return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker));
}
+ if (searchOtherFilesOnly && ts.every(symbol.declarations, function (d) { return d.getSourceFile().fileName === sourceFile.fileName; }))
+ return undefined;
var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node);
// Don't go to the component constructor definition for a JSX element, just go to the component definition.
if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && isConstructorLike(calledDeclaration))) {
- var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration);
+ var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration, failedAliasResolution);
// For a function, if this is the original function definition, return just sigInfo.
// If this is the original constructor definition, parent is the class.
if (typeChecker.getRootSymbols(symbol).some(function (s) { return symbolMatchesSignature(s, calledDeclaration); })) {
return [sigInfo];
}
else {
- var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray;
+ var defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || ts.emptyArray;
// For a 'super()' call, put the signature first, else put the variable first.
- return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false);
+ return node.kind === 106 /* SyntaxKind.SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false);
}
}
// Because name in short-hand property assignment has two different meanings: property name and property value,
@@ -137282,9 +139691,9 @@ var ts;
// go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition
// is performed at the location of property access, we would like to go to definition of the property in the short-hand
// assignment. This case and others are handled by the following code.
- if (node.parent.kind === 295 /* ShorthandPropertyAssignment */) {
+ if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) {
var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
- var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : ts.emptyArray;
+ var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node, /*unverified*/ false, failedAliasResolution); }) : ts.emptyArray;
return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray);
}
// If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the
@@ -137307,7 +139716,7 @@ var ts;
return prop && getDefinitionFromSymbol(typeChecker, prop, node);
});
}
- return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node));
+ return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution));
}
GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition;
/**
@@ -137369,7 +139778,7 @@ var ts;
}
var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position);
if (typeReferenceDirective) {
- var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName);
+ var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName, typeReferenceDirective.resolutionMode || sourceFile.impliedNodeFormat);
var file = reference && program.getSourceFile(reference.resolvedFileName); // TODO:GH#18217
return file && { reference: typeReferenceDirective, fileName: file.fileName, file: file, unverified: false };
}
@@ -137404,22 +139813,25 @@ var ts;
if (node === sourceFile) {
return undefined;
}
- var symbol = getSymbol(node, typeChecker);
+ if (ts.isImportMeta(node.parent) && node.parent.name === node) {
+ return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*failedAliasResolution*/ false);
+ }
+ var _a = getSymbol(node, typeChecker, /*stopAtAlias*/ false), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution;
if (!symbol)
return undefined;
var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker);
- var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node);
+ var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node, failedAliasResolution);
// If a function returns 'void' or some other type with no definition, just return the function definition.
- var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
+ var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution);
return typeDefinitions.length ? typeDefinitions
- : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node)
+ : !(symbol.flags & 111551 /* SymbolFlags.Value */) && symbol.flags & 788968 /* SymbolFlags.Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution)
: undefined;
}
GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition;
- function definitionFromType(type, checker, node) {
- return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) {
- return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node);
+ function definitionFromType(type, checker, node, failedAliasResolution) {
+ return ts.flatMap(type.isUnion() && !(type.flags & 32 /* TypeFlags.Enum */) ? type.types : [type], function (t) {
+ return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution);
});
}
function tryGetReturnTypeOfFunction(symbol, type, checker) {
@@ -137455,19 +139867,23 @@ var ts;
function getDefinitionInfoForIndexSignatures(node, checker) {
return ts.mapDefined(checker.getIndexInfosAtLocation(node), function (info) { return info.declaration && createDefinitionFromSignatureDeclaration(checker, info.declaration); });
}
- function getSymbol(node, checker) {
+ function getSymbol(node, checker, stopAtAlias) {
var symbol = checker.getSymbolAtLocation(node);
// If this is an alias, and the request came at the declaration location
// get the aliased symbol instead. This allows for goto def on an import e.g.
// import {A, B} from "mod";
// to jump to the implementation directly.
- if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) {
+ var failedAliasResolution = false;
+ if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* SymbolFlags.Alias */ && !stopAtAlias && shouldSkipAlias(node, symbol.declarations[0])) {
var aliased = checker.getAliasedSymbol(symbol);
if (aliased.declarations) {
- return aliased;
+ return { symbol: aliased };
+ }
+ else {
+ failedAliasResolution = true;
}
}
- return symbol;
+ return { symbol: symbol, failedAliasResolution: failedAliasResolution };
}
// Go to the original declaration for cases:
//
@@ -137475,36 +139891,55 @@ var ts;
// (2) when the aliased symbol is originating from an import.
//
function shouldSkipAlias(node, declaration) {
- if (node.kind !== 79 /* Identifier */) {
+ if (node.kind !== 79 /* SyntaxKind.Identifier */) {
return false;
}
if (node.parent === declaration) {
return true;
}
- switch (declaration.kind) {
- case 266 /* ImportClause */:
- case 264 /* ImportEqualsDeclaration */:
- return true;
- case 269 /* ImportSpecifier */:
- return declaration.parent.kind === 268 /* NamedImports */;
- case 202 /* BindingElement */:
- case 253 /* VariableDeclaration */:
- return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration);
- default:
- return false;
+ if (declaration.kind === 268 /* SyntaxKind.NamespaceImport */) {
+ return false;
}
+ return true;
}
- function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) {
- // There are cases when you extend a function by adding properties to it afterwards,
- // we want to strip those extra properties.
- // For deduping purposes, we also want to exclude any declarationNodes if provided.
- var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); })
- || undefined;
- return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); });
+ /**
+ * ```ts
+ * function f() {}
+ * f.foo = 0;
+ * ```
+ *
+ * Here, `f` has two declarations: the function declaration, and the identifier in the next line.
+ * The latter is a declaration for `f` because it gives `f` the `SymbolFlags.Namespace` meaning so
+ * it can contain `foo`. However, that declaration is pretty uninteresting and not intuitively a
+ * "definition" for `f`. Ideally, the question we'd like to answer is "what SymbolFlags does this
+ * declaration contribute to the symbol for `f`?" If the answer is just `Namespace` and the
+ * declaration looks like an assignment, that declaration is in no sense a definition for `f`.
+ * But that information is totally lost during binding and/or symbol merging, so we need to do
+ * our best to reconstruct it or use other heuristics. This function (and the logic around its
+ * calling) covers our tests but feels like a hack, and it would be great if someone could come
+ * up with a more precise definition of what counts as a definition.
+ */
+ function isExpandoDeclaration(node) {
+ if (!ts.isAssignmentDeclaration(node))
+ return false;
+ var containingAssignment = ts.findAncestor(node, function (p) {
+ if (ts.isAssignmentExpression(p))
+ return true;
+ if (!ts.isAssignmentDeclaration(p))
+ return "quit";
+ return false;
+ });
+ return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* AssignmentDeclarationKind.Property */;
+ }
+ function getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, excludeDeclaration) {
+ var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; });
+ var withoutExpandos = ts.filter(filteredDeclarations, function (d) { return !isExpandoDeclaration(d); });
+ var results = ts.some(withoutExpandos) ? withoutExpandos : filteredDeclarations;
+ return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(results, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution); });
function getConstructSignatureDefinition() {
// Applicable only if we are in a new expression, or we are on a constructor declaration
// and in either case the symbol has a construct signature definition, i.e. class
- if (symbol.flags & 32 /* Class */ && !(symbol.flags & (16 /* Function */ | 3 /* Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 134 /* ConstructorKeyword */)) {
+ if (symbol.flags & 32 /* SymbolFlags.Class */ && !(symbol.flags & (16 /* SymbolFlags.Function */ | 3 /* SymbolFlags.Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 134 /* SyntaxKind.ConstructorKeyword */)) {
var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration");
return getSignatureDefinition(cls.members, /*selectConstructors*/ true);
}
@@ -137524,26 +139959,27 @@ var ts;
return declarations.length
? declarationsWithBody.length !== 0
? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); })
- : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)]
+ : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution)]
: undefined;
}
}
/** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */
- function createDefinitionInfo(declaration, checker, symbol, node) {
+ function createDefinitionInfo(declaration, checker, symbol, node, unverified, failedAliasResolution) {
var symbolName = checker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
var symbolKind = ts.SymbolDisplay.getSymbolKind(checker, symbol, node);
var containerName = symbol.parent ? checker.symbolToString(symbol.parent, node) : "";
- return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName);
+ return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution);
}
+ GoToDefinition.createDefinitionInfo = createDefinitionInfo;
/** Creates a DefinitionInfo directly from the name of a declaration. */
- function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, textSpan) {
+ function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution, textSpan) {
var sourceFile = declaration.getSourceFile();
if (!textSpan) {
var name = ts.getNameOfDeclaration(declaration) || declaration;
textSpan = ts.createTextSpanFromNode(name, sourceFile);
}
return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217
- containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) });
+ containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 16777216 /* NodeFlags.Ambient */), unverified: unverified, failedAliasResolution: failedAliasResolution });
}
function isDefinitionVisible(checker, declaration) {
if (checker.isDeclarationVisible(declaration))
@@ -137555,29 +139991,29 @@ var ts;
return isDefinitionVisible(checker, declaration.parent);
// Handle some exceptions here like arrow function, members of class and object literal expression which are technically not visible but we want the definition to be determined by its parent
switch (declaration.kind) {
- case 166 /* PropertyDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 168 /* MethodDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
// Private/protected properties/methods are not visible
- if (ts.hasEffectiveModifier(declaration, 8 /* Private */))
+ if (ts.hasEffectiveModifier(declaration, 8 /* ModifierFlags.Private */))
return false;
// Public properties/methods are visible if its parents are visible, so:
// falls through
- case 170 /* Constructor */:
- case 294 /* PropertyAssignment */:
- case 295 /* ShorthandPropertyAssignment */:
- case 204 /* ObjectLiteralExpression */:
- case 225 /* ClassExpression */:
- case 213 /* ArrowFunction */:
- case 212 /* FunctionExpression */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 213 /* SyntaxKind.FunctionExpression */:
return isDefinitionVisible(checker, declaration.parent);
default:
return false;
}
}
- function createDefinitionFromSignatureDeclaration(typeChecker, decl) {
- return createDefinitionInfo(decl, typeChecker, decl.symbol, decl);
+ function createDefinitionFromSignatureDeclaration(typeChecker, decl, failedAliasResolution) {
+ return createDefinitionInfo(decl, typeChecker, decl.symbol, decl, /*unverified*/ false, failedAliasResolution);
}
function findReferenceInPosition(refs, pos) {
return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); });
@@ -137587,7 +140023,7 @@ var ts;
return {
fileName: targetFileName,
textSpan: ts.createTextSpanFromBounds(0, 0),
- kind: "script" /* scriptElement */,
+ kind: "script" /* ScriptElementKind.scriptElement */,
name: name,
containerName: undefined,
containerKind: undefined,
@@ -137608,9 +140044,9 @@ var ts;
}
function isConstructorLike(node) {
switch (node.kind) {
- case 170 /* Constructor */:
- case 179 /* ConstructorType */:
- case 174 /* ConstructSignature */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 180 /* SyntaxKind.ConstructorType */:
+ case 175 /* SyntaxKind.ConstructSignature */:
return true;
default:
return false;
@@ -137722,10 +140158,10 @@ var ts;
// - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation
if (jsdoc.comment === undefined
|| ts.isJSDoc(jsdoc)
- && declaration.kind !== 343 /* JSDocTypedefTag */ && declaration.kind !== 336 /* JSDocCallbackTag */
+ && declaration.kind !== 345 /* SyntaxKind.JSDocTypedefTag */ && declaration.kind !== 338 /* SyntaxKind.JSDocCallbackTag */
&& jsdoc.tags
- && jsdoc.tags.some(function (t) { return t.kind === 343 /* JSDocTypedefTag */ || t.kind === 336 /* JSDocCallbackTag */; })
- && !jsdoc.tags.some(function (t) { return t.kind === 338 /* JSDocParameterTag */ || t.kind === 339 /* JSDocReturnTag */; })) {
+ && jsdoc.tags.some(function (t) { return t.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 338 /* SyntaxKind.JSDocCallbackTag */; })
+ && !jsdoc.tags.some(function (t) { return t.kind === 340 /* SyntaxKind.JSDocParameterTag */ || t.kind === 341 /* SyntaxKind.JSDocReturnTag */; })) {
continue;
}
var newparts = getDisplayPartsFromComment(jsdoc.comment, checker);
@@ -137742,11 +140178,11 @@ var ts;
}
function getCommentHavingNodes(declaration) {
switch (declaration.kind) {
- case 338 /* JSDocParameterTag */:
- case 345 /* JSDocPropertyTag */:
+ case 340 /* SyntaxKind.JSDocParameterTag */:
+ case 347 /* SyntaxKind.JSDocPropertyTag */:
return [declaration];
- case 336 /* JSDocCallbackTag */:
- case 343 /* JSDocTypedefTag */:
+ case 338 /* SyntaxKind.JSDocCallbackTag */:
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
return [declaration, declaration.parent];
default:
return ts.getJSDocCommentsAndTags(declaration);
@@ -137760,8 +140196,8 @@ var ts;
// skip comments containing @typedefs since they're not associated with particular declarations
// Exceptions:
// - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation
- if (tags.some(function (t) { return t.kind === 343 /* JSDocTypedefTag */ || t.kind === 336 /* JSDocCallbackTag */; })
- && !tags.some(function (t) { return t.kind === 338 /* JSDocParameterTag */ || t.kind === 339 /* JSDocReturnTag */; })) {
+ if (tags.some(function (t) { return t.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 338 /* SyntaxKind.JSDocCallbackTag */; })
+ && !tags.some(function (t) { return t.kind === 340 /* SyntaxKind.JSDocParameterTag */ || t.kind === 341 /* SyntaxKind.JSDocReturnTag */; })) {
return;
}
for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) {
@@ -137776,17 +140212,17 @@ var ts;
if (typeof comment === "string") {
return [ts.textPart(comment)];
}
- return ts.flatMap(comment, function (node) { return node.kind === 319 /* JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); });
+ return ts.flatMap(comment, function (node) { return node.kind === 321 /* SyntaxKind.JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); });
}
function getCommentDisplayParts(tag, checker) {
var comment = tag.comment, kind = tag.kind;
var namePart = getTagNameDisplayPart(kind);
switch (kind) {
- case 327 /* JSDocImplementsTag */:
+ case 329 /* SyntaxKind.JSDocImplementsTag */:
return withNode(tag.class);
- case 326 /* JSDocAugmentsTag */:
+ case 328 /* SyntaxKind.JSDocAugmentsTag */:
return withNode(tag.class);
- case 342 /* JSDocTemplateTag */:
+ case 344 /* SyntaxKind.JSDocTemplateTag */:
var templateTag = tag;
var displayParts_3 = [];
if (templateTag.constraint) {
@@ -137800,7 +140236,7 @@ var ts;
ts.forEach(templateTag.typeParameters, function (tp) {
displayParts_3.push(namePart(tp.getText()));
if (lastTypeParameter_1 !== tp) {
- displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]);
+ displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* SyntaxKind.CommaToken */), ts.spacePart()]);
}
});
}
@@ -137808,13 +140244,13 @@ var ts;
displayParts_3.push.apply(displayParts_3, __spreadArray([ts.spacePart()], getDisplayPartsFromComment(comment, checker), true));
}
return displayParts_3;
- case 341 /* JSDocTypeTag */:
+ case 343 /* SyntaxKind.JSDocTypeTag */:
return withNode(tag.typeExpression);
- case 343 /* JSDocTypedefTag */:
- case 336 /* JSDocCallbackTag */:
- case 345 /* JSDocPropertyTag */:
- case 338 /* JSDocParameterTag */:
- case 344 /* JSDocSeeTag */:
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
+ case 338 /* SyntaxKind.JSDocCallbackTag */:
+ case 347 /* SyntaxKind.JSDocPropertyTag */:
+ case 340 /* SyntaxKind.JSDocParameterTag */:
+ case 346 /* SyntaxKind.JSDocSeeTag */:
var name = tag.name;
return name ? withNode(name)
: comment === undefined ? undefined
@@ -137841,14 +140277,14 @@ var ts;
}
function getTagNameDisplayPart(kind) {
switch (kind) {
- case 338 /* JSDocParameterTag */:
+ case 340 /* SyntaxKind.JSDocParameterTag */:
return ts.parameterNamePart;
- case 345 /* JSDocPropertyTag */:
+ case 347 /* SyntaxKind.JSDocPropertyTag */:
return ts.propertyNamePart;
- case 342 /* JSDocTemplateTag */:
+ case 344 /* SyntaxKind.JSDocTemplateTag */:
return ts.typeParameterNamePart;
- case 343 /* JSDocTypedefTag */:
- case 336 /* JSDocCallbackTag */:
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
+ case 338 /* SyntaxKind.JSDocCallbackTag */:
return ts.typeAliasNamePart;
default:
return ts.textPart;
@@ -137858,7 +140294,7 @@ var ts;
return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, function (tagName) {
return {
name: tagName,
- kind: "keyword" /* keyword */,
+ kind: "keyword" /* ScriptElementKind.keyword */,
kindModifiers: "",
sortText: ts.Completions.SortText.LocationPriority,
};
@@ -137870,7 +140306,7 @@ var ts;
return jsDocTagCompletionEntries || (jsDocTagCompletionEntries = ts.map(jsDocTagNames, function (tagName) {
return {
name: "@".concat(tagName),
- kind: "keyword" /* keyword */,
+ kind: "keyword" /* ScriptElementKind.keyword */,
kindModifiers: "",
sortText: ts.Completions.SortText.LocationPriority
};
@@ -137880,7 +140316,7 @@ var ts;
function getJSDocTagCompletionDetails(name) {
return {
name: name,
- kind: "" /* unknown */,
+ kind: "" /* ScriptElementKind.unknown */,
kindModifiers: "",
displayParts: [ts.textPart(name)],
documentation: ts.emptyArray,
@@ -137906,14 +140342,14 @@ var ts;
|| nameThusFar !== undefined && !ts.startsWith(name, nameThusFar)) {
return undefined;
}
- return { name: name, kind: "parameter" /* parameterElement */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority };
+ return { name: name, kind: "parameter" /* ScriptElementKind.parameterElement */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority };
});
}
JsDoc.getJSDocParameterNameCompletions = getJSDocParameterNameCompletions;
function getJSDocParameterNameCompletionDetails(name) {
return {
name: name,
- kind: "parameter" /* parameterElement */,
+ kind: "parameter" /* ScriptElementKind.parameterElement */,
kindModifiers: "",
displayParts: [ts.textPart(name)],
documentation: ts.emptyArray,
@@ -137962,7 +140398,8 @@ var ts;
return undefined;
}
var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters, hasReturn = commentOwnerInfo.hasReturn;
- if (commentOwner.getStart(sourceFile) < position) {
+ var commentOwnerJSDoc = ts.hasJSDocNodes(commentOwner) && commentOwner.jsDoc ? ts.lastOrUndefined(commentOwner.jsDoc) : undefined;
+ if (commentOwner.getStart(sourceFile) < position || commentOwnerJSDoc && commentOwnerJSDoc !== existingDocComment) {
return undefined;
}
var indentationStr = getIndentationStringAtPosition(sourceFile, position);
@@ -137999,7 +140436,7 @@ var ts;
function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) {
return parameters.map(function (_a, i) {
var name = _a.name, dotDotDotToken = _a.dotDotDotToken;
- var paramName = name.kind === 79 /* Identifier */ ? name.text : "param" + i;
+ var paramName = name.kind === 79 /* SyntaxKind.Identifier */ ? name.text : "param" + i;
var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : "";
return "".concat(indentationStr, " * @param ").concat(type).concat(paramName).concat(newLine);
}).join("");
@@ -138012,24 +140449,24 @@ var ts;
}
function getCommentOwnerInfoWorker(commentOwner, options) {
switch (commentOwner.kind) {
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 168 /* MethodDeclaration */:
- case 170 /* Constructor */:
- case 167 /* MethodSignature */:
- case 213 /* ArrowFunction */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 214 /* SyntaxKind.ArrowFunction */:
var host = commentOwner;
return { commentOwner: commentOwner, parameters: host.parameters, hasReturn: hasReturn(host, options) };
- case 294 /* PropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
return getCommentOwnerInfoWorker(commentOwner.initializer, options);
- case 256 /* ClassDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 165 /* PropertySignature */:
- case 259 /* EnumDeclaration */:
- case 297 /* EnumMember */:
- case 258 /* TypeAliasDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 299 /* SyntaxKind.EnumMember */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
return { commentOwner: commentOwner };
- case 236 /* VariableStatement */: {
+ case 237 /* SyntaxKind.VariableStatement */: {
var varStatement = commentOwner;
var varDeclarations = varStatement.declarationList.declarations;
var host_1 = varDeclarations.length === 1 && varDeclarations[0].initializer
@@ -138039,25 +140476,25 @@ var ts;
? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1, options) }
: { commentOwner: commentOwner };
}
- case 303 /* SourceFile */:
+ case 305 /* SyntaxKind.SourceFile */:
return "quit";
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
// If in walking up the tree, we hit a a nested namespace declaration,
// then we must be somewhere within a dotted namespace name; however we don't
// want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'.
- return commentOwner.parent.kind === 260 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner };
- case 237 /* ExpressionStatement */:
+ return commentOwner.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? undefined : { commentOwner: commentOwner };
+ case 238 /* SyntaxKind.ExpressionStatement */:
return getCommentOwnerInfoWorker(commentOwner.expression, options);
- case 220 /* BinaryExpression */: {
+ case 221 /* SyntaxKind.BinaryExpression */: {
var be = commentOwner;
- if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) {
+ if (ts.getAssignmentDeclarationKind(be) === 0 /* AssignmentDeclarationKind.None */) {
return "quit";
}
return ts.isFunctionLike(be.right)
? { commentOwner: commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right, options) }
: { commentOwner: commentOwner };
}
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
var init = commentOwner.initializer;
if (init && (ts.isFunctionExpression(init) || ts.isArrowFunction(init))) {
return { commentOwner: commentOwner, parameters: init.parameters, hasReturn: hasReturn(init, options) };
@@ -138070,14 +140507,14 @@ var ts;
|| ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; }));
}
function getRightHandSideOfAssignment(rightHandSide) {
- while (rightHandSide.kind === 211 /* ParenthesizedExpression */) {
+ while (rightHandSide.kind === 212 /* SyntaxKind.ParenthesizedExpression */) {
rightHandSide = rightHandSide.expression;
}
switch (rightHandSide.kind) {
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
return rightHandSide;
- case 225 /* ClassExpression */:
+ case 226 /* SyntaxKind.ClassExpression */:
return ts.find(rightHandSide.members, ts.isConstructorDeclaration);
}
}
@@ -138136,9 +140573,9 @@ var ts;
}
function shouldKeepItem(declaration, checker) {
switch (declaration.kind) {
- case 266 /* ImportClause */:
- case 269 /* ImportSpecifier */:
- case 264 /* ImportEqualsDeclaration */:
+ case 267 /* SyntaxKind.ImportClause */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217
var imported = checker.getAliasedSymbol(importer);
return importer.escapedName !== imported.escapedName;
@@ -138148,7 +140585,7 @@ var ts;
}
function tryAddSingleDeclarationName(declaration, containers) {
var name = ts.getNameOfDeclaration(declaration);
- return !!name && (pushLiteral(name, containers) || name.kind === 161 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers));
+ return !!name && (pushLiteral(name, containers) || name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers));
}
// Only added the names of computed properties if they're simple dotted expressions, like:
//
@@ -138165,7 +140602,7 @@ var ts;
// First, if we started with a computed property name, then add all but the last
// portion into the container array.
var name = ts.getNameOfDeclaration(declaration);
- if (name && name.kind === 161 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) {
+ if (name && name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) {
return ts.emptyArray;
}
// Don't include the last portion.
@@ -138199,7 +140636,7 @@ var ts;
textSpan: ts.createTextSpanFromNode(declaration),
// TODO(jfreeman): What should be the containerName when the container has a computed name?
containerName: containerName ? containerName.text : "",
- containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */,
+ containerKind: containerName ? ts.getNodeKind(container) : "" /* ScriptElementKind.unknown */,
};
}
})(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {}));
@@ -138382,7 +140819,7 @@ var ts;
*/
function hasNavigationBarName(node) {
return !ts.hasDynamicName(node) ||
- (node.kind !== 220 /* BinaryExpression */ &&
+ (node.kind !== 221 /* SyntaxKind.BinaryExpression */ &&
ts.isPropertyAccessExpression(node.name.expression) &&
ts.isIdentifier(node.name.expression.expression) &&
ts.idText(node.name.expression.expression) === "Symbol");
@@ -138395,7 +140832,7 @@ var ts;
return;
}
switch (node.kind) {
- case 170 /* Constructor */:
+ case 171 /* SyntaxKind.Constructor */:
// Get parameter properties, and treat them as being on the *same* level as the constructor, not under it.
var ctr = node;
addNodeWithRecursiveChild(ctr, ctr.body);
@@ -138407,25 +140844,25 @@ var ts;
}
}
break;
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 167 /* MethodSignature */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 168 /* SyntaxKind.MethodSignature */:
if (hasNavigationBarName(node)) {
addNodeWithRecursiveChild(node, node.body);
}
break;
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
if (hasNavigationBarName(node)) {
addNodeWithRecursiveInitializer(node);
}
break;
- case 165 /* PropertySignature */:
+ case 166 /* SyntaxKind.PropertySignature */:
if (hasNavigationBarName(node)) {
addLeafNode(node);
}
break;
- case 266 /* ImportClause */:
+ case 267 /* SyntaxKind.ImportClause */:
var importClause = node;
// Handle default import case e.g.:
// import d from "mod";
@@ -138437,7 +140874,7 @@ var ts;
// import {a, b as B} from "mod";
var namedBindings = importClause.namedBindings;
if (namedBindings) {
- if (namedBindings.kind === 267 /* NamespaceImport */) {
+ if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) {
addLeafNode(namedBindings);
}
else {
@@ -138448,17 +140885,17 @@ var ts;
}
}
break;
- case 295 /* ShorthandPropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
addNodeWithRecursiveChild(node, node.name);
break;
- case 296 /* SpreadAssignment */:
+ case 298 /* SyntaxKind.SpreadAssignment */:
var expression = node.expression;
// Use the expression as the name of the SpreadAssignment, otherwise show as <unknown>.
ts.isIdentifier(expression) ? addLeafNode(node, expression) : addLeafNode(node);
break;
- case 202 /* BindingElement */:
- case 294 /* PropertyAssignment */:
- case 253 /* VariableDeclaration */: {
+ case 203 /* SyntaxKind.BindingElement */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
+ case 254 /* SyntaxKind.VariableDeclaration */: {
var child = node;
if (ts.isBindingPattern(child.name)) {
addChildrenRecursively(child.name);
@@ -138468,7 +140905,7 @@ var ts;
}
break;
}
- case 255 /* FunctionDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
var nameNode = node.name;
// If we see a function declaration track as a possible ES5 class
if (nameNode && ts.isIdentifier(nameNode)) {
@@ -138476,11 +140913,11 @@ var ts;
}
addNodeWithRecursiveChild(node, node.body);
break;
- case 213 /* ArrowFunction */:
- case 212 /* FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 213 /* SyntaxKind.FunctionExpression */:
addNodeWithRecursiveChild(node, node.body);
break;
- case 259 /* EnumDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
startNode(node);
for (var _e = 0, _f = node.members; _e < _f.length; _e++) {
var member = _f[_e];
@@ -138490,9 +140927,9 @@ var ts;
}
endNode();
break;
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- case 257 /* InterfaceDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
startNode(node);
for (var _g = 0, _h = node.members; _g < _h.length; _g++) {
var member = _h[_g];
@@ -138500,10 +140937,10 @@ var ts;
}
endNode();
break;
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
addNodeWithRecursiveChild(node, getInteriorModule(node).body);
break;
- case 270 /* ExportAssignment */: {
+ case 271 /* SyntaxKind.ExportAssignment */: {
var expression_1 = node.expression;
var child = ts.isObjectLiteralExpression(expression_1) || ts.isCallExpression(expression_1) ? expression_1 :
ts.isArrowFunction(expression_1) || ts.isFunctionExpression(expression_1) ? expression_1.body : undefined;
@@ -138517,27 +140954,27 @@ var ts;
}
break;
}
- case 274 /* ExportSpecifier */:
- case 264 /* ImportEqualsDeclaration */:
- case 175 /* IndexSignature */:
- case 173 /* CallSignature */:
- case 174 /* ConstructSignature */:
- case 258 /* TypeAliasDeclaration */:
+ case 275 /* SyntaxKind.ExportSpecifier */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 176 /* SyntaxKind.IndexSignature */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
addLeafNode(node);
break;
- case 207 /* CallExpression */:
- case 220 /* BinaryExpression */: {
+ case 208 /* SyntaxKind.CallExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */: {
var special = ts.getAssignmentDeclarationKind(node);
switch (special) {
- case 1 /* ExportsProperty */:
- case 2 /* ModuleExports */:
+ case 1 /* AssignmentDeclarationKind.ExportsProperty */:
+ case 2 /* AssignmentDeclarationKind.ModuleExports */:
addNodeWithRecursiveChild(node, node.right);
return;
- case 6 /* Prototype */:
- case 3 /* PrototypeProperty */: {
+ case 6 /* AssignmentDeclarationKind.Prototype */:
+ case 3 /* AssignmentDeclarationKind.PrototypeProperty */: {
var binaryExpression = node;
var assignmentTarget = binaryExpression.left;
- var prototypeAccess = special === 3 /* PrototypeProperty */ ?
+ var prototypeAccess = special === 3 /* AssignmentDeclarationKind.PrototypeProperty */ ?
assignmentTarget.expression :
assignmentTarget;
var depth = 0;
@@ -138551,7 +140988,7 @@ var ts;
else {
_a = startNestedNodes(binaryExpression, prototypeAccess.expression), depth = _a[0], className = _a[1];
}
- if (special === 6 /* Prototype */) {
+ if (special === 6 /* AssignmentDeclarationKind.Prototype */) {
if (ts.isObjectLiteralExpression(binaryExpression.right)) {
if (binaryExpression.right.properties.length > 0) {
startNode(binaryExpression, className);
@@ -138571,10 +141008,10 @@ var ts;
endNestedNodes(depth);
return;
}
- case 7 /* ObjectDefinePropertyValue */:
- case 9 /* ObjectDefinePrototypeProperty */: {
+ case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */:
+ case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: {
var defineCall = node;
- var className = special === 7 /* ObjectDefinePropertyValue */ ?
+ var className = special === 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */ ?
defineCall.arguments[0] :
defineCall.arguments[0].expression;
var memberName = defineCall.arguments[1];
@@ -138587,7 +141024,7 @@ var ts;
endNestedNodes(depth);
return;
}
- case 5 /* Property */: {
+ case 5 /* AssignmentDeclarationKind.Property */: {
var binaryExpression = node;
var assignmentTarget = binaryExpression.left;
var targetFunction = assignmentTarget.expression;
@@ -138605,9 +141042,9 @@ var ts;
}
break;
}
- case 4 /* ThisProperty */:
- case 0 /* None */:
- case 8 /* ObjectDefinePropertyExports */:
+ case 4 /* AssignmentDeclarationKind.ThisProperty */:
+ case 0 /* AssignmentDeclarationKind.None */:
+ case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */:
break;
default:
ts.Debug.assertNever(special);
@@ -138663,16 +141100,16 @@ var ts;
});
}
var isEs5ClassMember = (_a = {},
- _a[5 /* Property */] = true,
- _a[3 /* PrototypeProperty */] = true,
- _a[7 /* ObjectDefinePropertyValue */] = true,
- _a[9 /* ObjectDefinePrototypeProperty */] = true,
- _a[0 /* None */] = false,
- _a[1 /* ExportsProperty */] = false,
- _a[2 /* ModuleExports */] = false,
- _a[8 /* ObjectDefinePropertyExports */] = false,
- _a[6 /* Prototype */] = true,
- _a[4 /* ThisProperty */] = false,
+ _a[5 /* AssignmentDeclarationKind.Property */] = true,
+ _a[3 /* AssignmentDeclarationKind.PrototypeProperty */] = true,
+ _a[7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */] = true,
+ _a[9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */] = true,
+ _a[0 /* AssignmentDeclarationKind.None */] = false,
+ _a[1 /* AssignmentDeclarationKind.ExportsProperty */] = false,
+ _a[2 /* AssignmentDeclarationKind.ModuleExports */] = false,
+ _a[8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */] = false,
+ _a[6 /* AssignmentDeclarationKind.Prototype */] = true,
+ _a[4 /* AssignmentDeclarationKind.ThisProperty */] = false,
_a);
function tryMergeEs5Class(a, b, bIndex, parent) {
function isPossibleConstructor(node) {
@@ -138680,10 +141117,10 @@ var ts;
}
var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ?
ts.getAssignmentDeclarationKind(b.node) :
- 0 /* None */;
+ 0 /* AssignmentDeclarationKind.None */;
var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ?
ts.getAssignmentDeclarationKind(a.node) :
- 0 /* None */;
+ 0 /* AssignmentDeclarationKind.None */;
// We treat this as an es5 class and merge the nodes in in one of several cases
if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements
|| (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member
@@ -138749,7 +141186,7 @@ var ts;
}
return true;
}
- return bAssignmentDeclarationKind === 0 /* None */ ? false : true;
+ return bAssignmentDeclarationKind === 0 /* AssignmentDeclarationKind.None */ ? false : true;
}
function tryMerge(a, b, bIndex, parent) {
// const v = false as boolean;
@@ -138768,12 +141205,12 @@ var ts;
return false;
}
switch (a.kind) {
- case 166 /* PropertyDeclaration */:
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
return ts.isStatic(a) === ts.isStatic(b);
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
return areSameModule(a, b)
&& getFullyQualifiedModuleName(a) === getFullyQualifiedModuleName(b);
default:
@@ -138781,7 +141218,7 @@ var ts;
}
}
function isSynthesized(node) {
- return !!(node.flags & 8 /* Synthesized */);
+ return !!(node.flags & 8 /* NodeFlags.Synthesized */);
}
// We want to merge own children like `I` in in `module A { interface I {} } module A { interface I {} }`
// We don't want to merge unrelated children like `m` in `const o = { a: { m() {} }, b: { m() {} } };`
@@ -138795,7 +141232,7 @@ var ts;
if (!a.body || !b.body) {
return a.body === b.body;
}
- return a.body.kind === b.body.kind && (a.body.kind !== 260 /* ModuleDeclaration */ || areSameModule(a.body, b.body));
+ return a.body.kind === b.body.kind && (a.body.kind !== 261 /* SyntaxKind.ModuleDeclaration */ || areSameModule(a.body, b.body));
}
/** Merge source into target. Source should be thrown away after this is called. */
function merge(target, source) {
@@ -138825,7 +141262,7 @@ var ts;
* So `new()` can still come before an `aardvark` method.
*/
function tryGetName(node) {
- if (node.kind === 260 /* ModuleDeclaration */) {
+ if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) {
return getModuleName(node);
}
var declName = ts.getNameOfDeclaration(node);
@@ -138834,16 +141271,16 @@ var ts;
return propertyName && ts.unescapeLeadingUnderscores(propertyName);
}
switch (node.kind) {
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
- case 225 /* ClassExpression */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 226 /* SyntaxKind.ClassExpression */:
return getFunctionOrClassName(node);
default:
return undefined;
}
}
function getItemName(node, name) {
- if (node.kind === 260 /* ModuleDeclaration */) {
+ if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) {
return cleanText(getModuleName(node));
}
if (name) {
@@ -138855,32 +141292,32 @@ var ts;
}
}
switch (node.kind) {
- case 303 /* SourceFile */:
+ case 305 /* SyntaxKind.SourceFile */:
var sourceFile = node;
return ts.isExternalModule(sourceFile)
? "\"".concat(ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))), "\"")
: "<global>";
- case 270 /* ExportAssignment */:
- return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */;
- case 213 /* ArrowFunction */:
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) {
+ case 271 /* SyntaxKind.ExportAssignment */:
+ return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */;
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ if (ts.getSyntacticModifierFlags(node) & 512 /* ModifierFlags.Default */) {
return "default";
}
// We may get a string with newlines or other whitespace in the case of an object dereference
// (eg: "app\n.onactivated"), so we should remove the whitespace for readability in the
// navigation bar.
return getFunctionOrClassName(node);
- case 170 /* Constructor */:
+ case 171 /* SyntaxKind.Constructor */:
return "constructor";
- case 174 /* ConstructSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
return "new()";
- case 173 /* CallSignature */:
+ case 174 /* SyntaxKind.CallSignature */:
return "()";
- case 175 /* IndexSignature */:
+ case 176 /* SyntaxKind.IndexSignature */:
return "[]";
default:
return "<unknown>";
@@ -138913,19 +141350,19 @@ var ts;
}
// Some nodes are otherwise important enough to always include in the primary navigation menu.
switch (navigationBarNodeKind(item)) {
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- case 259 /* EnumDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 260 /* ModuleDeclaration */:
- case 303 /* SourceFile */:
- case 258 /* TypeAliasDeclaration */:
- case 343 /* JSDocTypedefTag */:
- case 336 /* JSDocCallbackTag */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 305 /* SyntaxKind.SourceFile */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
+ case 338 /* SyntaxKind.JSDocCallbackTag */:
return true;
- case 213 /* ArrowFunction */:
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
return isTopLevelFunctionDeclaration(item);
default:
return false;
@@ -138935,10 +141372,10 @@ var ts;
return false;
}
switch (navigationBarNodeKind(item.parent)) {
- case 261 /* ModuleBlock */:
- case 303 /* SourceFile */:
- case 168 /* MethodDeclaration */:
- case 170 /* Constructor */:
+ case 262 /* SyntaxKind.ModuleBlock */:
+ case 305 /* SyntaxKind.SourceFile */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 171 /* SyntaxKind.Constructor */:
return true;
default:
return false;
@@ -139000,7 +141437,7 @@ var ts;
function getFullyQualifiedModuleName(moduleDeclaration) {
// Otherwise, we need to aggregate each identifier to build up the qualified name.
var result = [ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)];
- while (moduleDeclaration.body && moduleDeclaration.body.kind === 260 /* ModuleDeclaration */) {
+ while (moduleDeclaration.body && moduleDeclaration.body.kind === 261 /* SyntaxKind.ModuleDeclaration */) {
moduleDeclaration = moduleDeclaration.body;
result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name));
}
@@ -139014,13 +141451,13 @@ var ts;
return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl;
}
function isComputedProperty(member) {
- return !member.name || member.name.kind === 161 /* ComputedPropertyName */;
+ return !member.name || member.name.kind === 162 /* SyntaxKind.ComputedPropertyName */;
}
function getNodeSpan(node) {
- return node.kind === 303 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile);
+ return node.kind === 305 /* SyntaxKind.SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile);
}
function getModifiers(node) {
- if (node.parent && node.parent.kind === 253 /* VariableDeclaration */) {
+ if (node.parent && node.parent.kind === 254 /* SyntaxKind.VariableDeclaration */) {
node = node.parent;
}
return ts.getNodeModifiers(node);
@@ -139035,7 +141472,7 @@ var ts;
return cleanText(ts.declarationNameToString(parent.name));
}
// See if it is of the form "<expr> = function(){...}". If so, use the text from the left-hand side.
- else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */) {
+ else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) {
return nodeText(parent.left).replace(whiteSpaceRegex, "");
}
// See if it is a property assignment, and if so use the property name
@@ -139043,7 +141480,7 @@ var ts;
return nodeText(parent.name);
}
// Default exports are named "default"
- else if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) {
+ else if (ts.getSyntacticModifierFlags(node) & 512 /* ModifierFlags.Default */) {
return "default";
}
else if (ts.isClassLike(node)) {
@@ -139078,9 +141515,9 @@ var ts;
}
function isFunctionOrClassExpression(node) {
switch (node.kind) {
- case 213 /* ArrowFunction */:
- case 212 /* FunctionExpression */:
- case 225 /* ClassExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 226 /* SyntaxKind.ClassExpression */:
return true;
default:
return false;
@@ -139113,8 +141550,8 @@ var ts;
var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences });
var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program, skipDestructiveCodeActions)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); };
// All of the old ImportDeclarations in the file, in syntactic order.
- var topLevelImportDecls = sourceFile.statements.filter(ts.isImportDeclaration);
- organizeImportsWorker(topLevelImportDecls, coalesceAndOrganizeImports);
+ var topLevelImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, sourceFile.statements.filter(ts.isImportDeclaration));
+ topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
// All of the old ExportDeclarations in the file, in syntactic order.
var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
organizeImportsWorker(topLevelExportDecls, coalesceExports);
@@ -139122,8 +141559,8 @@ var ts;
var ambientModule = _a[_i];
if (!ambientModule.body)
continue;
- var ambientModuleImportDecls = ambientModule.body.statements.filter(ts.isImportDeclaration);
- organizeImportsWorker(ambientModuleImportDecls, coalesceAndOrganizeImports);
+ var ambientModuleImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, ambientModule.body.statements.filter(ts.isImportDeclaration));
+ ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
}
@@ -139169,15 +141606,50 @@ var ts;
}
}
OrganizeImports.organizeImports = organizeImports;
+ function groupImportsByNewlineContiguous(sourceFile, importDecls) {
+ var scanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ false, sourceFile.languageVariant);
+ var groupImports = [];
+ var groupIndex = 0;
+ for (var _i = 0, importDecls_1 = importDecls; _i < importDecls_1.length; _i++) {
+ var topLevelImportDecl = importDecls_1[_i];
+ if (isNewGroup(sourceFile, topLevelImportDecl, scanner)) {
+ groupIndex++;
+ }
+ if (!groupImports[groupIndex]) {
+ groupImports[groupIndex] = [];
+ }
+ groupImports[groupIndex].push(topLevelImportDecl);
+ }
+ return groupImports;
+ }
+ // a new group is created if an import includes at least two new line
+ // new line from multi-line comment doesn't count
+ function isNewGroup(sourceFile, topLevelImportDecl, scanner) {
+ var startPos = topLevelImportDecl.getFullStart();
+ var endPos = topLevelImportDecl.getStart();
+ scanner.setText(sourceFile.text, startPos, endPos - startPos);
+ var numberOfNewLines = 0;
+ while (scanner.getTokenPos() < endPos) {
+ var tokenKind = scanner.scan();
+ if (tokenKind === 4 /* SyntaxKind.NewLineTrivia */) {
+ numberOfNewLines++;
+ if (numberOfNewLines >= 2) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
function removeUnusedImports(oldImports, sourceFile, program, skipDestructiveCodeActions) {
// As a precaution, consider unused import detection to be destructive (GH #43051)
if (skipDestructiveCodeActions) {
return oldImports;
}
var typeChecker = program.getTypeChecker();
+ var compilerOptions = program.getCompilerOptions();
var jsxNamespace = typeChecker.getJsxNamespace(sourceFile);
var jsxFragmentFactory = typeChecker.getJsxFragmentFactory(sourceFile);
- var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* ContainsJsx */);
+ var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* TransformFlags.ContainsJsx */);
var usedImports = [];
for (var _i = 0, oldImports_1 = oldImports; _i < oldImports_1.length; _i++) {
var importDecl = oldImports_1[_i];
@@ -139231,7 +141703,7 @@ var ts;
return usedImports;
function isDeclarationUsed(identifier) {
// The JSX factory symbol is always used if JSX elements are present - even if they are not allowed.
- return jsxElementsPresent && (identifier.text === jsxNamespace || jsxFragmentFactory && identifier.text === jsxFragmentFactory) ||
+ return jsxElementsPresent && (identifier.text === jsxNamespace || jsxFragmentFactory && identifier.text === jsxFragmentFactory) && ts.jsxModeNeedsExplicitImport(compilerOptions.jsx) ||
ts.FindAllReferences.Core.isSymbolReferencedInFile(identifier, typeChecker, sourceFile);
}
}
@@ -139446,11 +141918,11 @@ var ts;
function getModuleSpecifierExpression(declaration) {
var _a;
switch (declaration.kind) {
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return (_a = ts.tryCast(declaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression;
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
return declaration.moduleSpecifier;
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
return declaration.declarationList.declarations[0].initializer.arguments[0];
}
}
@@ -139489,19 +141961,19 @@ var ts;
function getImportKindOrder(s1) {
var _a;
switch (s1.kind) {
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
if (!s1.importClause)
return 0;
if (s1.importClause.isTypeOnly)
return 1;
- if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 267 /* NamespaceImport */)
+ if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* SyntaxKind.NamespaceImport */)
return 2;
if (s1.importClause.name)
return 3;
return 4;
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return 5;
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
return 6;
}
}
@@ -139554,7 +142026,7 @@ var ts;
}
var lastImport = current - 1;
if (lastImport !== firstImport) {
- out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */));
+ out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* SyntaxKind.ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* OutliningSpanKind.Imports */));
}
}
function visitNonImportNode(n) {
@@ -139562,7 +142034,7 @@ var ts;
if (depthRemaining === 0)
return;
cancellationToken.throwIfCancellationRequested();
- if (ts.isDeclaration(n) || ts.isVariableStatement(n) || ts.isReturnStatement(n) || ts.isCallOrNewExpression(n) || n.kind === 1 /* EndOfFileToken */) {
+ if (ts.isDeclaration(n) || ts.isVariableStatement(n) || ts.isReturnStatement(n) || ts.isCallOrNewExpression(n) || n.kind === 1 /* SyntaxKind.EndOfFileToken */) {
addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out);
}
if (ts.isFunctionLike(n) && ts.isBinaryExpression(n.parent) && ts.isPropertyAccessExpression(n.parent.left)) {
@@ -139612,7 +142084,7 @@ var ts;
}
if (!result[1]) {
var span = ts.createTextSpanFromBounds(sourceFile.text.indexOf("//", currentLineStart), lineEnd);
- regions.push(createOutliningSpan(span, "region" /* Region */, span, /*autoCollapse*/ false, result[2] || "#region"));
+ regions.push(createOutliningSpan(span, "region" /* OutliningSpanKind.Region */, span, /*autoCollapse*/ false, result[2] || "#region"));
}
else {
var region = regions.pop();
@@ -139647,7 +142119,7 @@ var ts;
var _a = comments_1[_i], kind = _a.kind, pos_1 = _a.pos, end = _a.end;
cancellationToken.throwIfCancellationRequested();
switch (kind) {
- case 2 /* SingleLineCommentTrivia */:
+ case 2 /* SyntaxKind.SingleLineCommentTrivia */:
// never fold region delimiters into single-line comment regions
var commentText = sourceText.slice(pos_1, end);
if (isRegionDelimiter(commentText)) {
@@ -139663,9 +142135,9 @@ var ts;
lastSingleLineCommentEnd = end;
singleLineCommentCount++;
break;
- case 3 /* MultiLineCommentTrivia */:
+ case 3 /* SyntaxKind.MultiLineCommentTrivia */:
combineAndAddMultipleSingleLineComments();
- out.push(createOutliningSpanFromBounds(pos_1, end, "comment" /* Comment */));
+ out.push(createOutliningSpanFromBounds(pos_1, end, "comment" /* OutliningSpanKind.Comment */));
singleLineCommentCount = 0;
break;
default:
@@ -139676,7 +142148,7 @@ var ts;
function combineAndAddMultipleSingleLineComments() {
// Only outline spans of two or more consecutive single line comments
if (singleLineCommentCount > 1) {
- out.push(createOutliningSpanFromBounds(firstSingleLineCommentStart, lastSingleLineCommentEnd, "comment" /* Comment */));
+ out.push(createOutliningSpanFromBounds(firstSingleLineCommentStart, lastSingleLineCommentEnd, "comment" /* OutliningSpanKind.Comment */));
}
}
}
@@ -139690,7 +142162,7 @@ var ts;
}
function getOutliningSpanForNode(n, sourceFile) {
switch (n.kind) {
- case 234 /* Block */:
+ case 235 /* SyntaxKind.Block */:
if (ts.isFunctionLike(n.parent)) {
return functionSpan(n.parent, n, sourceFile);
}
@@ -139698,23 +142170,23 @@ var ts;
// If the latter, we want to collapse the block, but consider its hint span
// to be the entire span of the parent.
switch (n.parent.kind) {
- case 239 /* DoStatement */:
- case 242 /* ForInStatement */:
- case 243 /* ForOfStatement */:
- case 241 /* ForStatement */:
- case 238 /* IfStatement */:
- case 240 /* WhileStatement */:
- case 247 /* WithStatement */:
- case 291 /* CatchClause */:
+ case 240 /* SyntaxKind.DoStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 239 /* SyntaxKind.IfStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
+ case 248 /* SyntaxKind.WithStatement */:
+ case 292 /* SyntaxKind.CatchClause */:
return spanForNode(n.parent);
- case 251 /* TryStatement */:
+ case 252 /* SyntaxKind.TryStatement */:
// Could be the try-block, or the finally-block.
var tryStatement = n.parent;
if (tryStatement.tryBlock === n) {
return spanForNode(n.parent);
}
else if (tryStatement.finallyBlock === n) {
- var node = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile);
+ var node = ts.findChildOfKind(tryStatement, 96 /* SyntaxKind.FinallyKeyword */, sourceFile);
if (node)
return spanForNode(node);
}
@@ -139722,87 +142194,89 @@ var ts;
default:
// Block was a standalone block. In this case we want to only collapse
// the span of the block, independent of any parent span.
- return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */);
+ return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* OutliningSpanKind.Code */);
}
- case 261 /* ModuleBlock */:
+ case 262 /* SyntaxKind.ModuleBlock */:
return spanForNode(n.parent);
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- case 257 /* InterfaceDeclaration */:
- case 259 /* EnumDeclaration */:
- case 262 /* CaseBlock */:
- case 181 /* TypeLiteral */:
- case 200 /* ObjectBindingPattern */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 263 /* SyntaxKind.CaseBlock */:
+ case 182 /* SyntaxKind.TypeLiteral */:
+ case 201 /* SyntaxKind.ObjectBindingPattern */:
return spanForNode(n);
- case 183 /* TupleType */:
- return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* OpenBracketToken */);
- case 288 /* CaseClause */:
- case 289 /* DefaultClause */:
+ case 184 /* SyntaxKind.TupleType */:
+ return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* SyntaxKind.OpenBracketToken */);
+ case 289 /* SyntaxKind.CaseClause */:
+ case 290 /* SyntaxKind.DefaultClause */:
return spanForNodeArray(n.statements);
- case 204 /* ObjectLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
return spanForObjectOrArrayLiteral(n);
- case 203 /* ArrayLiteralExpression */:
- return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */);
- case 277 /* JsxElement */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
+ return spanForObjectOrArrayLiteral(n, 22 /* SyntaxKind.OpenBracketToken */);
+ case 278 /* SyntaxKind.JsxElement */:
return spanForJSXElement(n);
- case 281 /* JsxFragment */:
+ case 282 /* SyntaxKind.JsxFragment */:
return spanForJSXFragment(n);
- case 278 /* JsxSelfClosingElement */:
- case 279 /* JsxOpeningElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
return spanForJSXAttributes(n.attributes);
- case 222 /* TemplateExpression */:
- case 14 /* NoSubstitutionTemplateLiteral */:
+ case 223 /* SyntaxKind.TemplateExpression */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
return spanForTemplateLiteral(n);
- case 201 /* ArrayBindingPattern */:
- return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* OpenBracketToken */);
- case 213 /* ArrowFunction */:
+ case 202 /* SyntaxKind.ArrayBindingPattern */:
+ return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* SyntaxKind.OpenBracketToken */);
+ case 214 /* SyntaxKind.ArrowFunction */:
return spanForArrowFunction(n);
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
return spanForCallExpression(n);
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
+ return spanForParenthesizedExpression(n);
}
function spanForCallExpression(node) {
if (!node.arguments.length) {
return undefined;
}
- var openToken = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile);
- var closeToken = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile);
+ var openToken = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile);
+ var closeToken = ts.findChildOfKind(node, 21 /* SyntaxKind.CloseParenToken */, sourceFile);
if (!openToken || !closeToken || ts.positionsAreOnSameLine(openToken.pos, closeToken.pos, sourceFile)) {
return undefined;
}
return spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ false, /*useFullStart*/ true);
}
function spanForArrowFunction(node) {
- if (ts.isBlock(node.body) || ts.positionsAreOnSameLine(node.body.getFullStart(), node.body.getEnd(), sourceFile)) {
+ if (ts.isBlock(node.body) || ts.isParenthesizedExpression(node.body) || ts.positionsAreOnSameLine(node.body.getFullStart(), node.body.getEnd(), sourceFile)) {
return undefined;
}
var textSpan = ts.createTextSpanFromBounds(node.body.getFullStart(), node.body.getEnd());
- return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(node));
+ return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(node));
}
function spanForJSXElement(node) {
var textSpan = ts.createTextSpanFromBounds(node.openingElement.getStart(sourceFile), node.closingElement.getEnd());
var tagName = node.openingElement.tagName.getText(sourceFile);
var bannerText = "<" + tagName + ">...</" + tagName + ">";
- return createOutliningSpan(textSpan, "code" /* Code */, textSpan, /*autoCollapse*/ false, bannerText);
+ return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, textSpan, /*autoCollapse*/ false, bannerText);
}
function spanForJSXFragment(node) {
var textSpan = ts.createTextSpanFromBounds(node.openingFragment.getStart(sourceFile), node.closingFragment.getEnd());
var bannerText = "<>...</>";
- return createOutliningSpan(textSpan, "code" /* Code */, textSpan, /*autoCollapse*/ false, bannerText);
+ return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, textSpan, /*autoCollapse*/ false, bannerText);
}
function spanForJSXAttributes(node) {
if (node.properties.length === 0) {
return undefined;
}
- return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */);
+ return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* OutliningSpanKind.Code */);
}
function spanForTemplateLiteral(node) {
- if (node.kind === 14 /* NoSubstitutionTemplateLiteral */ && node.text.length === 0) {
+ if (node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ && node.text.length === 0) {
return undefined;
}
- return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */);
+ return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* OutliningSpanKind.Code */);
}
function spanForObjectOrArrayLiteral(node, open) {
- if (open === void 0) { open = 18 /* OpenBraceToken */; }
+ if (open === void 0) { open = 18 /* SyntaxKind.OpenBraceToken */; }
// If the block has no leading keywords and is inside an array literal or call expression,
// we only want to collapse the span of the block.
// Otherwise, the collapsed section will include the end of the previous line.
@@ -139811,26 +142285,32 @@ var ts;
function spanForNode(hintSpanNode, autoCollapse, useFullStart, open, close) {
if (autoCollapse === void 0) { autoCollapse = false; }
if (useFullStart === void 0) { useFullStart = true; }
- if (open === void 0) { open = 18 /* OpenBraceToken */; }
- if (close === void 0) { close = open === 18 /* OpenBraceToken */ ? 19 /* CloseBraceToken */ : 23 /* CloseBracketToken */; }
+ if (open === void 0) { open = 18 /* SyntaxKind.OpenBraceToken */; }
+ if (close === void 0) { close = open === 18 /* SyntaxKind.OpenBraceToken */ ? 19 /* SyntaxKind.CloseBraceToken */ : 23 /* SyntaxKind.CloseBracketToken */; }
var openToken = ts.findChildOfKind(n, open, sourceFile);
var closeToken = ts.findChildOfKind(n, close, sourceFile);
return openToken && closeToken && spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart);
}
function spanForNodeArray(nodeArray) {
- return nodeArray.length ? createOutliningSpan(ts.createTextSpanFromRange(nodeArray), "code" /* Code */) : undefined;
+ return nodeArray.length ? createOutliningSpan(ts.createTextSpanFromRange(nodeArray), "code" /* OutliningSpanKind.Code */) : undefined;
+ }
+ function spanForParenthesizedExpression(node) {
+ if (ts.positionsAreOnSameLine(node.getStart(), node.getEnd(), sourceFile))
+ return undefined;
+ var textSpan = ts.createTextSpanFromBounds(node.getStart(), node.getEnd());
+ return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(node));
}
}
function functionSpan(node, body, sourceFile) {
var openToken = tryGetFunctionOpenToken(node, body, sourceFile);
- var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile);
- return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 213 /* ArrowFunction */);
+ var closeToken = ts.findChildOfKind(body, 19 /* SyntaxKind.CloseBraceToken */, sourceFile);
+ return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 214 /* SyntaxKind.ArrowFunction */);
}
function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) {
if (autoCollapse === void 0) { autoCollapse = false; }
if (useFullStart === void 0) { useFullStart = true; }
var textSpan = ts.createTextSpanFromBounds(useFullStart ? openToken.getFullStart() : openToken.getStart(sourceFile), closeToken.getEnd());
- return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(hintSpanNode, sourceFile), autoCollapse);
+ return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(hintSpanNode, sourceFile), autoCollapse);
}
function createOutliningSpan(textSpan, kind, hintSpan, autoCollapse, bannerText) {
if (hintSpan === void 0) { hintSpan = textSpan; }
@@ -139840,12 +142320,12 @@ var ts;
}
function tryGetFunctionOpenToken(node, body, sourceFile) {
if (ts.isNodeArrayMultiLine(node.parameters, sourceFile)) {
- var openParenToken = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile);
+ var openParenToken = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile);
if (openParenToken) {
return openParenToken;
}
}
- return ts.findChildOfKind(body, 18 /* OpenBraceToken */, sourceFile);
+ return ts.findChildOfKind(body, 18 /* SyntaxKind.OpenBraceToken */, sourceFile);
}
})(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {}));
})(ts || (ts = {}));
@@ -139971,7 +142451,7 @@ var ts;
//
// Note: if the segment contains a space or an asterisk then we must assume that it's a
// multi-word segment.
- if (every(segment.totalTextChunk.text, function (ch) { return ch !== 32 /* space */ && ch !== 42 /* asterisk */; })) {
+ if (every(segment.totalTextChunk.text, function (ch) { return ch !== 32 /* CharacterCodes.space */ && ch !== 42 /* CharacterCodes.asterisk */; })) {
var match = matchTextChunk(candidate, segment.totalTextChunk, stringToWordSpans);
if (match)
return match;
@@ -140023,7 +142503,7 @@ var ts;
return ts.min(a, b, compareMatches);
}
function compareMatches(a, b) {
- return a === undefined ? 1 /* GreaterThan */ : b === undefined ? -1 /* LessThan */
+ return a === undefined ? 1 /* Comparison.GreaterThan */ : b === undefined ? -1 /* Comparison.LessThan */
: ts.compareValues(a.kind, b.kind) || ts.compareBooleans(!a.isCaseSensitive, !b.isCaseSensitive);
}
function partStartsWith(candidate, candidateSpan, pattern, ignoreCase, patternSpan) {
@@ -140100,10 +142580,10 @@ var ts;
}
function isUpperCaseLetter(ch) {
// Fast check for the ascii range.
- if (ch >= 65 /* A */ && ch <= 90 /* Z */) {
+ if (ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */) {
return true;
}
- if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* Latest */)) {
+ if (ch < 127 /* CharacterCodes.maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* ScriptTarget.Latest */)) {
return false;
}
// TODO: find a way to determine this for any unicode characters in a
@@ -140113,10 +142593,10 @@ var ts;
}
function isLowerCaseLetter(ch) {
// Fast check for the ascii range.
- if (ch >= 97 /* a */ && ch <= 122 /* z */) {
+ if (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) {
return true;
}
- if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* Latest */)) {
+ if (ch < 127 /* CharacterCodes.maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* ScriptTarget.Latest */)) {
return false;
}
// TODO: find a way to determine this for any unicode characters in a
@@ -140141,10 +142621,10 @@ var ts;
}
function toLowerCase(ch) {
// Fast convert for the ascii range.
- if (ch >= 65 /* A */ && ch <= 90 /* Z */) {
- return 97 /* a */ + (ch - 65 /* A */);
+ if (ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */) {
+ return 97 /* CharacterCodes.a */ + (ch - 65 /* CharacterCodes.A */);
}
- if (ch < 127 /* maxAsciiCharacter */) {
+ if (ch < 127 /* CharacterCodes.maxAsciiCharacter */) {
return ch;
}
// TODO: find a way to compute this for any unicode characters in a
@@ -140153,10 +142633,10 @@ var ts;
}
function isDigit(ch) {
// TODO(cyrusn): Find a way to support this for unicode digits.
- return ch >= 48 /* _0 */ && ch <= 57 /* _9 */;
+ return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */;
}
function isWordChar(ch) {
- return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* _ */ || ch === 36 /* $ */;
+ return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* CharacterCodes._ */ || ch === 36 /* CharacterCodes.$ */;
}
function breakPatternIntoTextChunks(pattern) {
var result = [];
@@ -140225,35 +142705,35 @@ var ts;
}
function charIsPunctuation(ch) {
switch (ch) {
- case 33 /* exclamation */:
- case 34 /* doubleQuote */:
- case 35 /* hash */:
- case 37 /* percent */:
- case 38 /* ampersand */:
- case 39 /* singleQuote */:
- case 40 /* openParen */:
- case 41 /* closeParen */:
- case 42 /* asterisk */:
- case 44 /* comma */:
- case 45 /* minus */:
- case 46 /* dot */:
- case 47 /* slash */:
- case 58 /* colon */:
- case 59 /* semicolon */:
- case 63 /* question */:
- case 64 /* at */:
- case 91 /* openBracket */:
- case 92 /* backslash */:
- case 93 /* closeBracket */:
- case 95 /* _ */:
- case 123 /* openBrace */:
- case 125 /* closeBrace */:
+ case 33 /* CharacterCodes.exclamation */:
+ case 34 /* CharacterCodes.doubleQuote */:
+ case 35 /* CharacterCodes.hash */:
+ case 37 /* CharacterCodes.percent */:
+ case 38 /* CharacterCodes.ampersand */:
+ case 39 /* CharacterCodes.singleQuote */:
+ case 40 /* CharacterCodes.openParen */:
+ case 41 /* CharacterCodes.closeParen */:
+ case 42 /* CharacterCodes.asterisk */:
+ case 44 /* CharacterCodes.comma */:
+ case 45 /* CharacterCodes.minus */:
+ case 46 /* CharacterCodes.dot */:
+ case 47 /* CharacterCodes.slash */:
+ case 58 /* CharacterCodes.colon */:
+ case 59 /* CharacterCodes.semicolon */:
+ case 63 /* CharacterCodes.question */:
+ case 64 /* CharacterCodes.at */:
+ case 91 /* CharacterCodes.openBracket */:
+ case 92 /* CharacterCodes.backslash */:
+ case 93 /* CharacterCodes.closeBracket */:
+ case 95 /* CharacterCodes._ */:
+ case 123 /* CharacterCodes.openBrace */:
+ case 125 /* CharacterCodes.closeBrace */:
return true;
}
return false;
}
function isAllPunctuation(identifier, start, end) {
- return every(identifier, function (ch) { return charIsPunctuation(ch) && ch !== 95 /* _ */; }, start, end);
+ return every(identifier, function (ch) { return charIsPunctuation(ch) && ch !== 95 /* CharacterCodes._ */; }, start, end);
}
function transitionFromUpperToLower(identifier, index, wordStart) {
// Cases this supports:
@@ -140314,7 +142794,7 @@ var ts;
if (readImportFiles === void 0) { readImportFiles = true; }
if (detectJavaScriptImports === void 0) { detectJavaScriptImports = false; }
var pragmaContext = {
- languageVersion: 1 /* ES5 */,
+ languageVersion: 1 /* ScriptTarget.ES5 */,
pragmas: undefined,
checkJsDirective: undefined,
referencedFiles: [],
@@ -140335,10 +142815,10 @@ var ts;
function nextToken() {
lastToken = currentToken;
currentToken = ts.scanner.scan();
- if (currentToken === 18 /* OpenBraceToken */) {
+ if (currentToken === 18 /* SyntaxKind.OpenBraceToken */) {
braceNesting++;
}
- else if (currentToken === 19 /* CloseBraceToken */) {
+ else if (currentToken === 19 /* SyntaxKind.CloseBraceToken */) {
braceNesting--;
}
return currentToken;
@@ -140368,12 +142848,12 @@ var ts;
*/
function tryConsumeDeclare() {
var token = ts.scanner.getToken();
- if (token === 135 /* DeclareKeyword */) {
+ if (token === 135 /* SyntaxKind.DeclareKeyword */) {
// declare module "mod"
token = nextToken();
- if (token === 141 /* ModuleKeyword */) {
+ if (token === 141 /* SyntaxKind.ModuleKeyword */) {
token = nextToken();
- if (token === 10 /* StringLiteral */) {
+ if (token === 10 /* SyntaxKind.StringLiteral */) {
recordAmbientExternalModule();
}
}
@@ -140385,54 +142865,54 @@ var ts;
* Returns true if at least one token was consumed from the stream
*/
function tryConsumeImport() {
- if (lastToken === 24 /* DotToken */) {
+ if (lastToken === 24 /* SyntaxKind.DotToken */) {
return false;
}
var token = ts.scanner.getToken();
- if (token === 100 /* ImportKeyword */) {
+ if (token === 100 /* SyntaxKind.ImportKeyword */) {
token = nextToken();
- if (token === 20 /* OpenParenToken */) {
+ if (token === 20 /* SyntaxKind.OpenParenToken */) {
token = nextToken();
- if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) {
+ if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) {
// import("mod");
recordModuleName();
return true;
}
}
- else if (token === 10 /* StringLiteral */) {
+ else if (token === 10 /* SyntaxKind.StringLiteral */) {
// import "mod";
recordModuleName();
return true;
}
else {
- if (token === 151 /* TypeKeyword */) {
+ if (token === 152 /* SyntaxKind.TypeKeyword */) {
var skipTypeKeyword = ts.scanner.lookAhead(function () {
var token = ts.scanner.scan();
- return token !== 155 /* FromKeyword */ && (token === 41 /* AsteriskToken */ ||
- token === 18 /* OpenBraceToken */ ||
- token === 79 /* Identifier */ ||
+ return token !== 156 /* SyntaxKind.FromKeyword */ && (token === 41 /* SyntaxKind.AsteriskToken */ ||
+ token === 18 /* SyntaxKind.OpenBraceToken */ ||
+ token === 79 /* SyntaxKind.Identifier */ ||
ts.isKeyword(token));
});
if (skipTypeKeyword) {
token = nextToken();
}
}
- if (token === 79 /* Identifier */ || ts.isKeyword(token)) {
+ if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) {
token = nextToken();
- if (token === 155 /* FromKeyword */) {
+ if (token === 156 /* SyntaxKind.FromKeyword */) {
token = nextToken();
- if (token === 10 /* StringLiteral */) {
+ if (token === 10 /* SyntaxKind.StringLiteral */) {
// import d from "mod";
recordModuleName();
return true;
}
}
- else if (token === 63 /* EqualsToken */) {
+ else if (token === 63 /* SyntaxKind.EqualsToken */) {
if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) {
return true;
}
}
- else if (token === 27 /* CommaToken */) {
+ else if (token === 27 /* SyntaxKind.CommaToken */) {
// consume comma and keep going
token = nextToken();
}
@@ -140441,18 +142921,18 @@ var ts;
return true;
}
}
- if (token === 18 /* OpenBraceToken */) {
+ if (token === 18 /* SyntaxKind.OpenBraceToken */) {
token = nextToken();
// consume "{ a as B, c, d as D}" clauses
// make sure that it stops on EOF
- while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) {
+ while (token !== 19 /* SyntaxKind.CloseBraceToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) {
token = nextToken();
}
- if (token === 19 /* CloseBraceToken */) {
+ if (token === 19 /* SyntaxKind.CloseBraceToken */) {
token = nextToken();
- if (token === 155 /* FromKeyword */) {
+ if (token === 156 /* SyntaxKind.FromKeyword */) {
token = nextToken();
- if (token === 10 /* StringLiteral */) {
+ if (token === 10 /* SyntaxKind.StringLiteral */) {
// import {a as A} from "mod";
// import d, {a, b as B} from "mod"
recordModuleName();
@@ -140460,15 +142940,15 @@ var ts;
}
}
}
- else if (token === 41 /* AsteriskToken */) {
+ else if (token === 41 /* SyntaxKind.AsteriskToken */) {
token = nextToken();
- if (token === 127 /* AsKeyword */) {
+ if (token === 127 /* SyntaxKind.AsKeyword */) {
token = nextToken();
- if (token === 79 /* Identifier */ || ts.isKeyword(token)) {
+ if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) {
token = nextToken();
- if (token === 155 /* FromKeyword */) {
+ if (token === 156 /* SyntaxKind.FromKeyword */) {
token = nextToken();
- if (token === 10 /* StringLiteral */) {
+ if (token === 10 /* SyntaxKind.StringLiteral */) {
// import * as NS from "mod"
// import d, * as NS from "mod"
recordModuleName();
@@ -140484,31 +142964,31 @@ var ts;
}
function tryConsumeExport() {
var token = ts.scanner.getToken();
- if (token === 93 /* ExportKeyword */) {
+ if (token === 93 /* SyntaxKind.ExportKeyword */) {
markAsExternalModuleIfTopLevel();
token = nextToken();
- if (token === 151 /* TypeKeyword */) {
+ if (token === 152 /* SyntaxKind.TypeKeyword */) {
var skipTypeKeyword = ts.scanner.lookAhead(function () {
var token = ts.scanner.scan();
- return token === 41 /* AsteriskToken */ ||
- token === 18 /* OpenBraceToken */;
+ return token === 41 /* SyntaxKind.AsteriskToken */ ||
+ token === 18 /* SyntaxKind.OpenBraceToken */;
});
if (skipTypeKeyword) {
token = nextToken();
}
}
- if (token === 18 /* OpenBraceToken */) {
+ if (token === 18 /* SyntaxKind.OpenBraceToken */) {
token = nextToken();
// consume "{ a as B, c, d as D}" clauses
// make sure it stops on EOF
- while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) {
+ while (token !== 19 /* SyntaxKind.CloseBraceToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) {
token = nextToken();
}
- if (token === 19 /* CloseBraceToken */) {
+ if (token === 19 /* SyntaxKind.CloseBraceToken */) {
token = nextToken();
- if (token === 155 /* FromKeyword */) {
+ if (token === 156 /* SyntaxKind.FromKeyword */) {
token = nextToken();
- if (token === 10 /* StringLiteral */) {
+ if (token === 10 /* SyntaxKind.StringLiteral */) {
// export {a as A} from "mod";
// export {a, b as B} from "mod"
recordModuleName();
@@ -140516,31 +142996,31 @@ var ts;
}
}
}
- else if (token === 41 /* AsteriskToken */) {
+ else if (token === 41 /* SyntaxKind.AsteriskToken */) {
token = nextToken();
- if (token === 155 /* FromKeyword */) {
+ if (token === 156 /* SyntaxKind.FromKeyword */) {
token = nextToken();
- if (token === 10 /* StringLiteral */) {
+ if (token === 10 /* SyntaxKind.StringLiteral */) {
// export * from "mod"
recordModuleName();
}
}
}
- else if (token === 100 /* ImportKeyword */) {
+ else if (token === 100 /* SyntaxKind.ImportKeyword */) {
token = nextToken();
- if (token === 151 /* TypeKeyword */) {
+ if (token === 152 /* SyntaxKind.TypeKeyword */) {
var skipTypeKeyword = ts.scanner.lookAhead(function () {
var token = ts.scanner.scan();
- return token === 79 /* Identifier */ ||
+ return token === 79 /* SyntaxKind.Identifier */ ||
ts.isKeyword(token);
});
if (skipTypeKeyword) {
token = nextToken();
}
}
- if (token === 79 /* Identifier */ || ts.isKeyword(token)) {
+ if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) {
token = nextToken();
- if (token === 63 /* EqualsToken */) {
+ if (token === 63 /* SyntaxKind.EqualsToken */) {
if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) {
return true;
}
@@ -140554,12 +143034,12 @@ var ts;
function tryConsumeRequireCall(skipCurrentToken, allowTemplateLiterals) {
if (allowTemplateLiterals === void 0) { allowTemplateLiterals = false; }
var token = skipCurrentToken ? nextToken() : ts.scanner.getToken();
- if (token === 145 /* RequireKeyword */) {
+ if (token === 146 /* SyntaxKind.RequireKeyword */) {
token = nextToken();
- if (token === 20 /* OpenParenToken */) {
+ if (token === 20 /* SyntaxKind.OpenParenToken */) {
token = nextToken();
- if (token === 10 /* StringLiteral */ ||
- allowTemplateLiterals && token === 14 /* NoSubstitutionTemplateLiteral */) {
+ if (token === 10 /* SyntaxKind.StringLiteral */ ||
+ allowTemplateLiterals && token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) {
// require("mod");
recordModuleName();
}
@@ -140570,16 +143050,16 @@ var ts;
}
function tryConsumeDefine() {
var token = ts.scanner.getToken();
- if (token === 79 /* Identifier */ && ts.scanner.getTokenValue() === "define") {
+ if (token === 79 /* SyntaxKind.Identifier */ && ts.scanner.getTokenValue() === "define") {
token = nextToken();
- if (token !== 20 /* OpenParenToken */) {
+ if (token !== 20 /* SyntaxKind.OpenParenToken */) {
return true;
}
token = nextToken();
- if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) {
+ if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) {
// looks like define ("modname", ... - skip string literal and comma
token = nextToken();
- if (token === 27 /* CommaToken */) {
+ if (token === 27 /* SyntaxKind.CommaToken */) {
token = nextToken();
}
else {
@@ -140588,15 +143068,15 @@ var ts;
}
}
// should be start of dependency list
- if (token !== 22 /* OpenBracketToken */) {
+ if (token !== 22 /* SyntaxKind.OpenBracketToken */) {
return true;
}
// skip open bracket
token = nextToken();
// scan until ']' or EOF
- while (token !== 23 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) {
+ while (token !== 23 /* SyntaxKind.CloseBracketToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) {
// record string literals as module names
- if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) {
+ if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) {
recordModuleName();
}
token = nextToken();
@@ -140624,9 +143104,44 @@ var ts;
// AnySymbol.import("mod")
// AnySymbol.nested.import("mod")
while (true) {
- if (ts.scanner.getToken() === 1 /* EndOfFileToken */) {
+ if (ts.scanner.getToken() === 1 /* SyntaxKind.EndOfFileToken */) {
break;
}
+ if (ts.scanner.getToken() === 15 /* SyntaxKind.TemplateHead */) {
+ var stack = [ts.scanner.getToken()];
+ var token = ts.scanner.scan();
+ loop: while (ts.length(stack)) {
+ switch (token) {
+ case 1 /* SyntaxKind.EndOfFileToken */:
+ break loop;
+ case 100 /* SyntaxKind.ImportKeyword */:
+ tryConsumeImport();
+ break;
+ case 15 /* SyntaxKind.TemplateHead */:
+ stack.push(token);
+ break;
+ case 18 /* SyntaxKind.OpenBraceToken */:
+ if (ts.length(stack)) {
+ stack.push(token);
+ }
+ break;
+ case 19 /* SyntaxKind.CloseBraceToken */:
+ if (ts.length(stack)) {
+ if (ts.lastOrUndefined(stack) === 15 /* SyntaxKind.TemplateHead */) {
+ if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* SyntaxKind.TemplateTail */) {
+ stack.pop();
+ }
+ }
+ else {
+ stack.pop();
+ }
+ }
+ break;
+ }
+ token = ts.scanner.scan();
+ }
+ nextToken();
+ }
// check if at least one of alternative have moved scanner forward
if (tryConsumeDeclare() ||
tryConsumeImport() ||
@@ -140700,13 +143215,13 @@ var ts;
if (!symbol) {
if (ts.isStringLiteralLike(node)) {
var type = ts.getContextualTypeFromParentOrAncestorTypeNode(node, typeChecker);
- if (type && ((type.flags & 128 /* StringLiteral */) || ((type.flags & 1048576 /* Union */) && ts.every(type.types, function (type) { return !!(type.flags & 128 /* StringLiteral */); })))) {
- return getRenameInfoSuccess(node.text, node.text, "string" /* string */, "", node, sourceFile);
+ if (type && ((type.flags & 128 /* TypeFlags.StringLiteral */) || ((type.flags & 1048576 /* TypeFlags.Union */) && ts.every(type.types, function (type) { return !!(type.flags & 128 /* TypeFlags.StringLiteral */); })))) {
+ return getRenameInfoSuccess(node.text, node.text, "string" /* ScriptElementKind.string */, "", node, sourceFile);
}
}
else if (ts.isLabelName(node)) {
var name = ts.getTextOfNode(node);
- return getRenameInfoSuccess(name, name, "label" /* label */, "" /* none */, node, sourceFile);
+ return getRenameInfoSuccess(name, name, "label" /* ScriptElementKind.label */, "" /* ScriptElementKindModifier.none */, node, sourceFile);
}
return undefined;
}
@@ -140719,14 +143234,14 @@ var ts;
return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library);
}
// Cannot rename `default` as in `import { default as foo } from "./someModule";
- if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* Module */) {
+ if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* SymbolFlags.Module */) {
return undefined;
}
if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) {
return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined;
}
var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node);
- var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 161 /* ComputedPropertyName */)
+ var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */)
? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node))
: undefined;
var displayName = specifierName || typeChecker.symbolToString(symbol);
@@ -140735,7 +143250,7 @@ var ts;
}
function isDefinedInLibraryFile(program, declaration) {
var sourceFile = declaration.getSourceFile();
- return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */);
+ return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Extension.Dts */);
}
function getRenameInfoForModule(node, sourceFile, moduleSymbol) {
if (!ts.isExternalModuleNameRelative(node.text)) {
@@ -140746,7 +143261,7 @@ var ts;
return undefined;
var withoutIndex = ts.endsWith(node.text, "/index") || ts.endsWith(node.text, "/index.js") ? undefined : ts.tryRemoveSuffix(ts.removeFileExtension(moduleSourceFile.fileName), "/index");
var name = withoutIndex === undefined ? moduleSourceFile.fileName : withoutIndex;
- var kind = withoutIndex === undefined ? "module" /* moduleElement */ : "directory" /* directory */;
+ var kind = withoutIndex === undefined ? "module" /* ScriptElementKind.moduleElement */ : "directory" /* ScriptElementKind.directory */;
var indexAfterLastSlash = node.text.lastIndexOf("/") + 1;
// Span should only be the last component of the path. + 1 to account for the quote character.
var triggerSpan = ts.createTextSpan(node.getStart(sourceFile) + 1 + indexAfterLastSlash, node.text.length - indexAfterLastSlash);
@@ -140756,7 +143271,7 @@ var ts;
kind: kind,
displayName: name,
fullDisplayName: name,
- kindModifiers: "" /* none */,
+ kindModifiers: "" /* ScriptElementKindModifier.none */,
triggerSpan: triggerSpan,
};
}
@@ -140786,13 +143301,13 @@ var ts;
}
function nodeIsEligibleForRename(node) {
switch (node.kind) {
- case 79 /* Identifier */:
- case 80 /* PrivateIdentifier */:
- case 10 /* StringLiteral */:
- case 14 /* NoSubstitutionTemplateLiteral */:
- case 108 /* ThisKeyword */:
+ case 79 /* SyntaxKind.Identifier */:
+ case 80 /* SyntaxKind.PrivateIdentifier */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
+ case 108 /* SyntaxKind.ThisKeyword */:
return true;
- case 8 /* NumericLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node);
default:
return false;
@@ -140824,7 +143339,7 @@ var ts;
break outer;
}
var comment = ts.singleOrUndefined(ts.getTrailingCommentRanges(sourceFile.text, node.end));
- if (comment && comment.kind === 2 /* SingleLineCommentTrivia */) {
+ if (comment && comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) {
pushSelectionCommentRange(comment.pos, comment.end);
}
if (positionShouldSnapToNode(sourceFile, pos, node)) {
@@ -140892,7 +143407,7 @@ var ts;
function pushSelectionCommentRange(start, end) {
pushSelectionRange(start, end);
var pos = start;
- while (sourceFile.text.charCodeAt(pos) === 47 /* slash */) {
+ while (sourceFile.text.charCodeAt(pos) === 47 /* CharacterCodes.slash */) {
pos++;
}
pushSelectionRange(pos, end);
@@ -140949,26 +143464,26 @@ var ts;
if (ts.isMappedTypeNode(node)) {
var _a = node.getChildren(), openBraceToken = _a[0], children = _a.slice(1);
var closeBraceToken = ts.Debug.checkDefined(children.pop());
- ts.Debug.assertEqual(openBraceToken.kind, 18 /* OpenBraceToken */);
- ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */);
+ ts.Debug.assertEqual(openBraceToken.kind, 18 /* SyntaxKind.OpenBraceToken */);
+ ts.Debug.assertEqual(closeBraceToken.kind, 19 /* SyntaxKind.CloseBraceToken */);
// Group `-/+readonly` and `-/+?`
var groupedWithPlusMinusTokens = groupChildren(children, function (child) {
- return child === node.readonlyToken || child.kind === 144 /* ReadonlyKeyword */ ||
- child === node.questionToken || child.kind === 57 /* QuestionToken */;
+ return child === node.readonlyToken || child.kind === 145 /* SyntaxKind.ReadonlyKeyword */ ||
+ child === node.questionToken || child.kind === 57 /* SyntaxKind.QuestionToken */;
});
// Group type parameter with surrounding brackets
var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) {
var kind = _a.kind;
- return kind === 22 /* OpenBracketToken */ ||
- kind === 162 /* TypeParameter */ ||
- kind === 23 /* CloseBracketToken */;
+ return kind === 22 /* SyntaxKind.OpenBracketToken */ ||
+ kind === 163 /* SyntaxKind.TypeParameter */ ||
+ kind === 23 /* SyntaxKind.CloseBracketToken */;
});
return [
openBraceToken,
// Pivot on `:`
createSyntaxList(splitChildren(groupedWithBrackets, function (_a) {
var kind = _a.kind;
- return kind === 58 /* ColonToken */;
+ return kind === 58 /* SyntaxKind.ColonToken */;
})),
closeBraceToken,
];
@@ -140980,7 +143495,7 @@ var ts;
});
return splitChildren(children, function (_a) {
var kind = _a.kind;
- return kind === 58 /* ColonToken */;
+ return kind === 58 /* SyntaxKind.ColonToken */;
});
}
// Group the parameter name with its `...`, then that group with its `?`, then pivot on `=`.
@@ -140993,14 +143508,14 @@ var ts;
});
return splitChildren(groupedWithQuestionToken, function (_a) {
var kind = _a.kind;
- return kind === 63 /* EqualsToken */;
+ return kind === 63 /* SyntaxKind.EqualsToken */;
});
}
// Pivot on '='
if (ts.isBindingElement(node)) {
return splitChildren(node.getChildren(), function (_a) {
var kind = _a.kind;
- return kind === 63 /* EqualsToken */;
+ return kind === 63 /* SyntaxKind.EqualsToken */;
});
}
return node.getChildren();
@@ -141056,7 +143571,7 @@ var ts;
var leftChildren = children.slice(0, splitTokenIndex);
var splitToken = children[splitTokenIndex];
var lastToken = ts.last(children);
- var separateLastToken = separateTrailingSemicolon && lastToken.kind === 26 /* SemicolonToken */;
+ var separateLastToken = separateTrailingSemicolon && lastToken.kind === 26 /* SyntaxKind.SemicolonToken */;
var rightChildren = children.slice(splitTokenIndex + 1, separateLastToken ? children.length - 1 : undefined);
var result = ts.compact([
leftChildren.length ? createSyntaxList(leftChildren) : undefined,
@@ -141071,25 +143586,25 @@ var ts;
}
function isListOpener(token) {
var kind = token && token.kind;
- return kind === 18 /* OpenBraceToken */
- || kind === 22 /* OpenBracketToken */
- || kind === 20 /* OpenParenToken */
- || kind === 279 /* JsxOpeningElement */;
+ return kind === 18 /* SyntaxKind.OpenBraceToken */
+ || kind === 22 /* SyntaxKind.OpenBracketToken */
+ || kind === 20 /* SyntaxKind.OpenParenToken */
+ || kind === 280 /* SyntaxKind.JsxOpeningElement */;
}
function isListCloser(token) {
var kind = token && token.kind;
- return kind === 19 /* CloseBraceToken */
- || kind === 23 /* CloseBracketToken */
- || kind === 21 /* CloseParenToken */
- || kind === 280 /* JsxClosingElement */;
+ return kind === 19 /* SyntaxKind.CloseBraceToken */
+ || kind === 23 /* SyntaxKind.CloseBracketToken */
+ || kind === 21 /* SyntaxKind.CloseParenToken */
+ || kind === 281 /* SyntaxKind.JsxClosingElement */;
}
function getEndPos(sourceFile, node) {
switch (node.kind) {
- case 338 /* JSDocParameterTag */:
- case 336 /* JSDocCallbackTag */:
- case 345 /* JSDocPropertyTag */:
- case 343 /* JSDocTypedefTag */:
- case 340 /* JSDocThisTag */:
+ case 340 /* SyntaxKind.JSDocParameterTag */:
+ case 338 /* SyntaxKind.JSDocCallbackTag */:
+ case 347 /* SyntaxKind.JSDocPropertyTag */:
+ case 345 /* SyntaxKind.JSDocTypedefTag */:
+ case 342 /* SyntaxKind.JSDocThisTag */:
return sourceFile.getLineEndOfPosition(node.getStart());
default:
return node.getEnd();
@@ -141136,7 +143651,7 @@ var ts;
return ts.isSourceFileJS(sourceFile) ? createJSSignatureHelpItems(argumentInfo, program, cancellationToken) : undefined;
}
return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) {
- return candidateInfo.kind === 0 /* Candidate */
+ return candidateInfo.kind === 0 /* CandidateOrTypeKind.Candidate */
? createSignatureHelpItems(candidateInfo.candidates, candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker)
: createTypeHelpItems(candidateInfo.symbol, argumentInfo, sourceFile, typeChecker);
});
@@ -141150,27 +143665,27 @@ var ts;
function getCandidateOrTypeInfo(_a, checker, sourceFile, startingToken, onlyUseSyntacticOwners) {
var invocation = _a.invocation, argumentCount = _a.argumentCount;
switch (invocation.kind) {
- case 0 /* Call */: {
+ case 0 /* InvocationKind.Call */: {
if (onlyUseSyntacticOwners && !isSyntacticOwner(startingToken, invocation.node, sourceFile)) {
return undefined;
}
var candidates = [];
var resolvedSignature = checker.getResolvedSignatureForSignatureHelp(invocation.node, candidates, argumentCount); // TODO: GH#18217
- return candidates.length === 0 ? undefined : { kind: 0 /* Candidate */, candidates: candidates, resolvedSignature: resolvedSignature };
+ return candidates.length === 0 ? undefined : { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: candidates, resolvedSignature: resolvedSignature };
}
- case 1 /* TypeArgs */: {
+ case 1 /* InvocationKind.TypeArgs */: {
var called = invocation.called;
if (onlyUseSyntacticOwners && !containsPrecedingToken(startingToken, sourceFile, ts.isIdentifier(called) ? called.parent : called)) {
return undefined;
}
var candidates = ts.getPossibleGenericSignatures(called, argumentCount, checker);
if (candidates.length !== 0)
- return { kind: 0 /* Candidate */, candidates: candidates, resolvedSignature: ts.first(candidates) };
+ return { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: candidates, resolvedSignature: ts.first(candidates) };
var symbol = checker.getSymbolAtLocation(called);
- return symbol && { kind: 1 /* Type */, symbol: symbol };
+ return symbol && { kind: 1 /* CandidateOrTypeKind.Type */, symbol: symbol };
}
- case 2 /* Contextual */:
- return { kind: 0 /* Candidate */, candidates: [invocation.signature], resolvedSignature: invocation.signature };
+ case 2 /* InvocationKind.Contextual */:
+ return { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: [invocation.signature], resolvedSignature: invocation.signature };
default:
return ts.Debug.assertNever(invocation);
}
@@ -141180,20 +143695,20 @@ var ts;
return false;
var invocationChildren = node.getChildren(sourceFile);
switch (startingToken.kind) {
- case 20 /* OpenParenToken */:
+ case 20 /* SyntaxKind.OpenParenToken */:
return ts.contains(invocationChildren, startingToken);
- case 27 /* CommaToken */: {
+ case 27 /* SyntaxKind.CommaToken */: {
var containingList = ts.findContainingList(startingToken);
return !!containingList && ts.contains(invocationChildren, containingList);
}
- case 29 /* LessThanToken */:
+ case 29 /* SyntaxKind.LessThanToken */:
return containsPrecedingToken(startingToken, sourceFile, node.expression);
default:
return false;
}
}
function createJSSignatureHelpItems(argumentInfo, program, cancellationToken) {
- if (argumentInfo.invocation.kind === 2 /* Contextual */)
+ if (argumentInfo.invocation.kind === 2 /* InvocationKind.Contextual */)
return undefined;
// See if we can find some symbol with the call expression name that has call signatures.
var expression = getExpressionFromInvocation(argumentInfo.invocation);
@@ -141229,7 +143744,7 @@ var ts;
}
function getArgumentInfoForCompletions(node, position, sourceFile) {
var info = getImmediatelyContainingArgumentInfo(node, position, sourceFile);
- return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* Call */ ? undefined
+ return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* InvocationKind.Call */ ? undefined
: { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex };
}
SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions;
@@ -141246,7 +143761,7 @@ var ts;
return { list: list, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan };
}
function getArgumentOrParameterListAndIndex(node, sourceFile) {
- if (node.kind === 29 /* LessThanToken */ || node.kind === 20 /* OpenParenToken */) {
+ if (node.kind === 29 /* SyntaxKind.LessThanToken */ || node.kind === 20 /* SyntaxKind.OpenParenToken */) {
// Find the list that starts right *after* the < or ( token.
// If the user has just opened a list, consider this item 0.
return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 };
@@ -141289,7 +143804,7 @@ var ts;
return undefined;
var list = info.list, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
var isTypeParameterList = !!parent.typeArguments && parent.typeArguments.pos === list.pos;
- return { isTypeParameterList: isTypeParameterList, invocation: { kind: 0 /* Call */, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount };
+ return { isTypeParameterList: isTypeParameterList, invocation: { kind: 0 /* InvocationKind.Call */, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount };
}
else if (ts.isNoSubstitutionTemplateLiteral(node) && ts.isTaggedTemplateExpression(parent)) {
// Check if we're actually inside the template;
@@ -141299,10 +143814,10 @@ var ts;
}
return undefined;
}
- else if (ts.isTemplateHead(node) && parent.parent.kind === 209 /* TaggedTemplateExpression */) {
+ else if (ts.isTemplateHead(node) && parent.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) {
var templateExpression = parent;
var tagExpression = templateExpression.parent;
- ts.Debug.assert(templateExpression.kind === 222 /* TemplateExpression */);
+ ts.Debug.assert(templateExpression.kind === 223 /* SyntaxKind.TemplateExpression */);
var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1;
return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile);
}
@@ -141327,7 +143842,7 @@ var ts;
var attributeSpanEnd = ts.skipTrivia(sourceFile.text, parent.attributes.end, /*stopAfterLineBreak*/ false);
return {
isTypeParameterList: false,
- invocation: { kind: 0 /* Call */, node: parent },
+ invocation: { kind: 0 /* InvocationKind.Call */, node: parent },
argumentsSpan: ts.createTextSpan(attributeSpanStart, attributeSpanEnd - attributeSpanStart),
argumentIndex: 0,
argumentCount: 1
@@ -141337,7 +143852,7 @@ var ts;
var typeArgInfo = ts.getPossibleTypeArgumentsInfo(node, sourceFile);
if (typeArgInfo) {
var called = typeArgInfo.called, nTypeArguments = typeArgInfo.nTypeArguments;
- var invocation = { kind: 1 /* TypeArgs */, called: called };
+ var invocation = { kind: 1 /* InvocationKind.TypeArgs */, called: called };
var argumentsSpan = ts.createTextSpanFromBounds(called.getStart(sourceFile), node.end);
return { isTypeParameterList: true, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: nTypeArguments, argumentCount: nTypeArguments + 1 };
}
@@ -141360,31 +143875,34 @@ var ts;
var contextualType = info.contextualType, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
// for optional function condition.
var nonNullableContextualType = contextualType.getNonNullableType();
- var signatures = nonNullableContextualType.getCallSignatures();
- if (signatures.length !== 1)
+ var symbol = nonNullableContextualType.symbol;
+ if (symbol === undefined)
+ return undefined;
+ var signature = ts.lastOrUndefined(nonNullableContextualType.getCallSignatures());
+ if (signature === undefined)
return undefined;
- var invocation = { kind: 2 /* Contextual */, signature: ts.first(signatures), node: startingToken, symbol: chooseBetterSymbol(nonNullableContextualType.symbol) };
+ var invocation = { kind: 2 /* InvocationKind.Contextual */, signature: signature, node: startingToken, symbol: chooseBetterSymbol(symbol) };
return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount };
}
function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) {
- if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */)
+ if (startingToken.kind !== 20 /* SyntaxKind.OpenParenToken */ && startingToken.kind !== 27 /* SyntaxKind.CommaToken */)
return undefined;
var parent = startingToken.parent;
switch (parent.kind) {
- case 211 /* ParenthesizedExpression */:
- case 168 /* MethodDeclaration */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
var info = getArgumentOrParameterListInfo(startingToken, position, sourceFile);
if (!info)
return undefined;
var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
var contextualType = ts.isMethodDeclaration(parent) ? checker.getContextualTypeForObjectLiteralElement(parent) : checker.getContextualType(parent);
return contextualType && { contextualType: contextualType, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan };
- case 220 /* BinaryExpression */: {
+ case 221 /* SyntaxKind.BinaryExpression */: {
var highestBinary = getHighestBinary(parent);
var contextualType_1 = checker.getContextualType(highestBinary);
- var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1;
+ var argumentIndex_1 = startingToken.kind === 20 /* SyntaxKind.OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1;
var argumentCount_1 = countBinaryExpressionParameters(highestBinary);
return contextualType_1 && { contextualType: contextualType_1, argumentIndex: argumentIndex_1, argumentCount: argumentCount_1, argumentsSpan: ts.createTextSpanFromNode(parent) };
}
@@ -141394,7 +143912,7 @@ var ts;
}
// The type of a function type node has a symbol at that node, but it's better to use the symbol for a parameter or type alias.
function chooseBetterSymbol(s) {
- return s.name === "__type" /* Type */
+ return s.name === "__type" /* InternalSymbolName.Type */
? ts.firstDefined(s.declarations, function (d) { return ts.isFunctionTypeNode(d) ? d.parent.symbol : undefined; }) || s
: s;
}
@@ -141416,7 +143934,7 @@ var ts;
if (child === node) {
break;
}
- if (child.kind !== 27 /* CommaToken */) {
+ if (child.kind !== 27 /* SyntaxKind.CommaToken */) {
argumentIndex++;
}
}
@@ -141435,8 +143953,8 @@ var ts;
// That will give us 2 non-commas. We then add one for the last comma, giving us an
// arg count of 3.
var listChildren = argumentsList.getChildren();
- var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; });
- if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) {
+ var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* SyntaxKind.CommaToken */; });
+ if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* SyntaxKind.CommaToken */) {
argumentCount++;
}
return argumentCount;
@@ -141474,7 +143992,7 @@ var ts;
}
return {
isTypeParameterList: false,
- invocation: { kind: 0 /* Call */, node: tagExpression },
+ invocation: { kind: 0 /* InvocationKind.Call */, node: tagExpression },
argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression, sourceFile),
argumentIndex: argumentIndex,
argumentCount: argumentCount
@@ -141505,7 +144023,7 @@ var ts;
// | |
// This is because a Missing node has no width. However, what we actually want is to include trivia
// leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail.
- if (template.kind === 222 /* TemplateExpression */) {
+ if (template.kind === 223 /* SyntaxKind.TemplateExpression */) {
var lastSpan = ts.last(template.templateSpans);
if (lastSpan.literal.getFullWidth() === 0) {
applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false);
@@ -141537,17 +144055,17 @@ var ts;
return children[indexOfOpenerToken + 1];
}
function getExpressionFromInvocation(invocation) {
- return invocation.kind === 0 /* Call */ ? ts.getInvokedExpression(invocation.node) : invocation.called;
+ return invocation.kind === 0 /* InvocationKind.Call */ ? ts.getInvokedExpression(invocation.node) : invocation.called;
}
function getEnclosingDeclarationFromInvocation(invocation) {
- return invocation.kind === 0 /* Call */ ? invocation.node : invocation.kind === 1 /* TypeArgs */ ? invocation.called : invocation.node;
+ return invocation.kind === 0 /* InvocationKind.Call */ ? invocation.node : invocation.kind === 1 /* InvocationKind.TypeArgs */ ? invocation.called : invocation.node;
}
- var signatureHelpNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 70221824 /* IgnoreErrors */ | 16384 /* UseAliasDefinedOutsideCurrentScope */;
+ var signatureHelpNodeBuilderFlags = 8192 /* NodeBuilderFlags.OmitParameterModifiers */ | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */;
function createSignatureHelpItems(candidates, resolvedSignature, _a, sourceFile, typeChecker, useFullPrefix) {
var _b;
var isTypeParameterList = _a.isTypeParameterList, argumentCount = _a.argumentCount, applicableSpan = _a.argumentsSpan, invocation = _a.invocation, argumentIndex = _a.argumentIndex;
var enclosingDeclaration = getEnclosingDeclarationFromInvocation(invocation);
- var callTargetSymbol = invocation.kind === 2 /* Contextual */ ? invocation.symbol : (typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)) || useFullPrefix && ((_b = resolvedSignature.declaration) === null || _b === void 0 ? void 0 : _b.symbol));
+ var callTargetSymbol = invocation.kind === 2 /* InvocationKind.Contextual */ ? invocation.symbol : (typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)) || useFullPrefix && ((_b = resolvedSignature.declaration) === null || _b === void 0 ? void 0 : _b.symbol));
var callTargetDisplayParts = callTargetSymbol ? ts.symbolToDisplayParts(typeChecker, callTargetSymbol, useFullPrefix ? sourceFile : undefined, /*meaning*/ undefined) : ts.emptyArray;
var items = ts.map(candidates, function (candidateSignature) { return getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, typeChecker, enclosingDeclaration, sourceFile); });
if (argumentIndex !== 0) {
@@ -141604,10 +144122,10 @@ var ts;
var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); });
var documentation = symbol.getDocumentationComment(checker);
var tags = symbol.getJsDocTags(checker);
- var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay, true), [ts.punctuationPart(29 /* LessThanToken */)], false);
- return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags };
+ var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay, true), [ts.punctuationPart(29 /* SyntaxKind.LessThanToken */)], false);
+ return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* SyntaxKind.GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags };
}
- var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()];
+ var separatorDisplayParts = [ts.punctuationPart(27 /* SyntaxKind.CommaToken */), ts.spacePart()];
function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) {
var infos = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile);
return ts.map(infos, function (_a) {
@@ -141640,9 +144158,9 @@ var ts;
return checker.getExpandedParameters(candidateSignature).map(function (paramList) {
var params = ts.factory.createNodeArray(__spreadArray(__spreadArray([], thisParameter, true), ts.map(paramList, function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }), true));
var parameterParts = ts.mapToDisplayParts(function (writer) {
- printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer);
+ printer.writeList(2576 /* ListFormat.CallExpressionArguments */, params, sourceFile, writer);
});
- return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* LessThanToken */)], suffix: __spreadArray([ts.punctuationPart(31 /* GreaterThanToken */)], parameterParts, true) };
+ return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* SyntaxKind.LessThanToken */)], suffix: __spreadArray([ts.punctuationPart(31 /* SyntaxKind.GreaterThanToken */)], parameterParts, true) };
});
}
function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) {
@@ -141650,33 +144168,33 @@ var ts;
var typeParameterParts = ts.mapToDisplayParts(function (writer) {
if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) {
var args = ts.factory.createNodeArray(candidateSignature.typeParameters.map(function (p) { return checker.typeParameterToDeclaration(p, enclosingDeclaration, signatureHelpNodeBuilderFlags); }));
- printer.writeList(53776 /* TypeParameters */, args, sourceFile, writer);
+ printer.writeList(53776 /* ListFormat.TypeParameters */, args, sourceFile, writer);
}
});
var lists = checker.getExpandedParameters(candidateSignature);
var isVariadic = !checker.hasEffectiveRestParameter(candidateSignature) ? function (_) { return false; }
: lists.length === 1 ? function (_) { return true; }
- : function (pList) { return !!(pList.length && pList[pList.length - 1].checkFlags & 32768 /* RestParameter */); };
+ : function (pList) { return !!(pList.length && pList[pList.length - 1].checkFlags & 32768 /* CheckFlags.RestParameter */); };
return lists.map(function (parameterList) { return ({
isVariadic: isVariadic(parameterList),
parameters: parameterList.map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }),
- prefix: __spreadArray(__spreadArray([], typeParameterParts, true), [ts.punctuationPart(20 /* OpenParenToken */)], false),
- suffix: [ts.punctuationPart(21 /* CloseParenToken */)]
+ prefix: __spreadArray(__spreadArray([], typeParameterParts, true), [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)], false),
+ suffix: [ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)]
}); });
}
function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) {
var displayParts = ts.mapToDisplayParts(function (writer) {
var param = checker.symbolToParameterDeclaration(parameter, enclosingDeclaration, signatureHelpNodeBuilderFlags);
- printer.writeNode(4 /* Unspecified */, param, sourceFile, writer);
+ printer.writeNode(4 /* EmitHint.Unspecified */, param, sourceFile, writer);
});
var isOptional = checker.isOptionalParameter(parameter.valueDeclaration);
- var isRest = !!(parameter.checkFlags & 32768 /* RestParameter */);
+ var isRest = !!(parameter.checkFlags & 32768 /* CheckFlags.RestParameter */);
return { name: parameter.name, documentation: parameter.getDocumentationComment(checker), displayParts: displayParts, isOptional: isOptional, isRest: isRest };
}
function createSignatureHelpParameterForTypeParameter(typeParameter, checker, enclosingDeclaration, sourceFile, printer) {
var displayParts = ts.mapToDisplayParts(function (writer) {
var param = checker.typeParameterToDeclaration(typeParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags);
- printer.writeNode(4 /* Unspecified */, param, sourceFile, writer);
+ printer.writeNode(4 /* EmitHint.Unspecified */, param, sourceFile, writer);
});
return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts: displayParts, isOptional: false, isRest: false };
}
@@ -141710,14 +144228,14 @@ var ts;
return;
}
switch (node.kind) {
- case 260 /* ModuleDeclaration */:
- case 256 /* ClassDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 255 /* FunctionDeclaration */:
- case 225 /* ClassExpression */:
- case 212 /* FunctionExpression */:
- case 168 /* MethodDeclaration */:
- case 213 /* ArrowFunction */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 214 /* SyntaxKind.ArrowFunction */:
cancellationToken.throwIfCancellationRequested();
}
if (!ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth())) {
@@ -141755,7 +144273,7 @@ var ts;
result.push({
text: "".concat(isFirstVariadicArgument ? "..." : "").concat(truncation(text, maxHintsLength), ":"),
position: position,
- kind: "Parameter" /* Parameter */,
+ kind: "Parameter" /* InlayHintKind.Parameter */,
whitespaceAfter: true,
});
}
@@ -141763,7 +144281,7 @@ var ts;
result.push({
text: ": ".concat(truncation(text, maxHintsLength)),
position: position,
- kind: "Type" /* Type */,
+ kind: "Type" /* InlayHintKind.Type */,
whitespaceBefore: true,
});
}
@@ -141771,7 +144289,7 @@ var ts;
result.push({
text: "= ".concat(truncation(text, maxHintsLength)),
position: position,
- kind: "Enum" /* Enum */,
+ kind: "Enum" /* InlayHintKind.Enum */,
whitespaceBefore: true,
});
}
@@ -141785,7 +144303,7 @@ var ts;
}
}
function isModuleReferenceType(type) {
- return type.symbol && (type.symbol.flags & 1536 /* Module */);
+ return type.symbol && (type.symbol.flags & 1536 /* SymbolFlags.Module */);
}
function visitVariableLikeDeclaration(decl) {
if (!decl.initializer || ts.isBindingPattern(decl.name)) {
@@ -141857,17 +144375,17 @@ var ts;
}
function isHintableLiteral(node) {
switch (node.kind) {
- case 218 /* PrefixUnaryExpression */: {
+ case 219 /* SyntaxKind.PrefixUnaryExpression */: {
var operand = node.operand;
return ts.isLiteralExpression(operand) || ts.isIdentifier(operand) && ts.isInfinityOrNaNString(operand.escapedText);
}
- case 110 /* TrueKeyword */:
- case 95 /* FalseKeyword */:
- case 104 /* NullKeyword */:
- case 14 /* NoSubstitutionTemplateLiteral */:
- case 222 /* TemplateExpression */:
+ case 110 /* SyntaxKind.TrueKeyword */:
+ case 95 /* SyntaxKind.FalseKeyword */:
+ case 104 /* SyntaxKind.NullKeyword */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
+ case 223 /* SyntaxKind.TemplateExpression */:
return true;
- case 79 /* Identifier */: {
+ case 79 /* SyntaxKind.Identifier */: {
var name = node.escapedText;
return isUndefined(name) || ts.isInfinityOrNaNString(name);
}
@@ -141876,7 +144394,7 @@ var ts;
}
function visitFunctionDeclarationLikeForReturnType(decl) {
if (ts.isArrowFunction(decl)) {
- if (!ts.findChildOfKind(decl, 20 /* OpenParenToken */, file)) {
+ if (!ts.findChildOfKind(decl, 20 /* SyntaxKind.OpenParenToken */, file)) {
return;
}
}
@@ -141899,7 +144417,7 @@ var ts;
addTypeHints(typeDisplayString, getTypeAnnotationPosition(decl));
}
function getTypeAnnotationPosition(decl) {
- var closeParenToken = ts.findChildOfKind(decl, 21 /* CloseParenToken */, file);
+ var closeParenToken = ts.findChildOfKind(decl, 21 /* SyntaxKind.CloseParenToken */, file);
if (closeParenToken) {
return closeParenToken.end;
}
@@ -141920,7 +144438,7 @@ var ts;
if (!typeDisplayString) {
continue;
}
- addTypeHints(typeDisplayString, param.name.end);
+ addTypeHints(typeDisplayString, param.questionToken ? param.questionToken.end : param.name.end);
}
}
function getParameterDeclarationTypeDisplayString(symbol) {
@@ -141941,13 +144459,13 @@ var ts;
return text;
}
function printTypeInSingleLine(type) {
- var flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */;
+ var flags = 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 1048576 /* TypeFormatFlags.AllowUniqueESSymbolType */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */;
var options = { removeComments: true };
var printer = ts.createPrinter(options);
return ts.usingSingleLineStringWriter(function (writer) {
var typeNode = checker.typeToTypeNode(type, /*enclosingDeclaration*/ undefined, flags, writer);
ts.Debug.assertIsDefined(typeNode, "should always get typenode");
- printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ file, writer);
+ printer.writeNode(4 /* EmitHint.Unspecified */, typeNode, /*sourceFile*/ file, writer);
});
}
function isUndefined(name) {
@@ -142009,7 +144527,7 @@ var ts;
var options = program.getCompilerOptions();
var outPath = ts.outFile(options);
var declarationPath = outPath ?
- ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ :
+ ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */ :
ts.getDeclarationEmitOutputFilePathWorker(info.fileName, program.getCompilerOptions(), currentDirectory, program.getCommonSourceDirectory(), getCanonicalFileName);
if (declarationPath === undefined)
return undefined;
@@ -142118,7 +144636,7 @@ var ts;
program.getSemanticDiagnostics(sourceFile, cancellationToken);
var diags = [];
var checker = program.getTypeChecker();
- var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]);
+ var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]);
if (!isCommonJSFile &&
sourceFile.commonJsModuleIndicator &&
(ts.programContainsEsModules(program) || ts.compilerOptionsIndicateEsModules(program.getCompilerOptions())) &&
@@ -142137,7 +144655,7 @@ var ts;
continue;
var module_1 = ts.getResolvedModule(sourceFile, moduleSpecifier.text, ts.getModeForUsageLocation(sourceFile, moduleSpecifier));
var resolvedFile = module_1 && program.getSourceFile(module_1.resolvedFileName);
- if (resolvedFile && resolvedFile.externalModuleIndicator && ts.isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) {
+ if (resolvedFile && resolvedFile.externalModuleIndicator && resolvedFile.externalModuleIndicator !== true && ts.isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) {
diags.push(ts.createDiagnosticForNode(name, ts.Diagnostics.Import_may_be_converted_to_a_default_import));
}
}
@@ -142154,7 +144672,7 @@ var ts;
else {
if (ts.isVariableStatement(node) &&
node.parent === sourceFile &&
- node.declarationList.flags & 2 /* Const */ &&
+ node.declarationList.flags & 2 /* NodeFlags.Const */ &&
node.declarationList.declarations.length === 1) {
var init = node.declarationList.declarations[0].initializer;
if (init && ts.isRequireCall(init, /*checkArgumentIsStringLiteralLike*/ true)) {
@@ -142176,16 +144694,16 @@ var ts;
function containsTopLevelCommonjs(sourceFile) {
return sourceFile.statements.some(function (statement) {
switch (statement.kind) {
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
return statement.declarationList.declarations.some(function (decl) {
return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true);
});
- case 237 /* ExpressionStatement */: {
+ case 238 /* SyntaxKind.ExpressionStatement */: {
var expression = statement.expression;
if (!ts.isBinaryExpression(expression))
return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true);
var kind = ts.getAssignmentDeclarationKind(expression);
- return kind === 1 /* ExportsProperty */ || kind === 2 /* ModuleExports */;
+ return kind === 1 /* AssignmentDeclarationKind.ExportsProperty */ || kind === 2 /* AssignmentDeclarationKind.ModuleExports */;
}
default:
return false;
@@ -142197,12 +144715,12 @@ var ts;
}
function importNameForConvertToDefaultImport(node) {
switch (node.kind) {
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier;
- return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 267 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier)
+ return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ && ts.isStringLiteral(moduleSpecifier)
? importClause.namedBindings.name
: undefined;
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return node.name;
default:
return undefined;
@@ -142272,26 +144790,26 @@ var ts;
if (node.arguments.length < maxArguments)
return true;
return maxArguments === 1 || ts.some(node.arguments, function (arg) {
- return arg.kind === 104 /* NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined";
+ return arg.kind === 104 /* SyntaxKind.NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined";
});
}
// should be kept up to date with getTransformationBody in convertToAsyncFunction.ts
function isFixablePromiseArgument(arg, checker) {
switch (arg.kind) {
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
var functionFlags = ts.getFunctionFlags(arg);
- if (functionFlags & 1 /* Generator */) {
+ if (functionFlags & 1 /* FunctionFlags.Generator */) {
return false;
}
// falls through
- case 213 /* ArrowFunction */:
+ case 214 /* SyntaxKind.ArrowFunction */:
visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true);
// falls through
- case 104 /* NullKeyword */:
+ case 104 /* SyntaxKind.NullKeyword */:
return true;
- case 79 /* Identifier */:
- case 205 /* PropertyAccessExpression */: {
+ case 79 /* SyntaxKind.Identifier */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */: {
var symbol = checker.getSymbolAtLocation(arg);
if (!symbol) {
return false;
@@ -142308,24 +144826,24 @@ var ts;
}
function canBeConvertedToClass(node, checker) {
var _a, _b, _c, _d;
- if (node.kind === 212 /* FunctionExpression */) {
+ if (node.kind === 213 /* SyntaxKind.FunctionExpression */) {
if (ts.isVariableDeclaration(node.parent) && ((_a = node.symbol.members) === null || _a === void 0 ? void 0 : _a.size)) {
return true;
}
var symbol = checker.getSymbolOfExpando(node, /*allowDeclaration*/ false);
return !!(symbol && (((_b = symbol.exports) === null || _b === void 0 ? void 0 : _b.size) || ((_c = symbol.members) === null || _c === void 0 ? void 0 : _c.size)));
}
- if (node.kind === 255 /* FunctionDeclaration */) {
+ if (node.kind === 256 /* SyntaxKind.FunctionDeclaration */) {
return !!((_d = node.symbol.members) === null || _d === void 0 ? void 0 : _d.size);
}
return false;
}
function canBeConvertedToAsync(node) {
switch (node.kind) {
- case 255 /* FunctionDeclaration */:
- case 168 /* MethodDeclaration */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
return true;
default:
return false;
@@ -142338,32 +144856,32 @@ var ts;
(function (ts) {
var SymbolDisplay;
(function (SymbolDisplay) {
- var symbolDisplayNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 70221824 /* IgnoreErrors */ | 16384 /* UseAliasDefinedOutsideCurrentScope */;
+ var symbolDisplayNodeBuilderFlags = 8192 /* NodeBuilderFlags.OmitParameterModifiers */ | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */;
// TODO(drosen): use contextual SemanticMeaning.
function getSymbolKind(typeChecker, symbol, location) {
var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location);
- if (result !== "" /* unknown */) {
+ if (result !== "" /* ScriptElementKind.unknown */) {
return result;
}
var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol);
- if (flags & 32 /* Class */) {
- return ts.getDeclarationOfKind(symbol, 225 /* ClassExpression */) ?
- "local class" /* localClassElement */ : "class" /* classElement */;
- }
- if (flags & 384 /* Enum */)
- return "enum" /* enumElement */;
- if (flags & 524288 /* TypeAlias */)
- return "type" /* typeElement */;
- if (flags & 64 /* Interface */)
- return "interface" /* interfaceElement */;
- if (flags & 262144 /* TypeParameter */)
- return "type parameter" /* typeParameterElement */;
- if (flags & 8 /* EnumMember */)
- return "enum member" /* enumMemberElement */;
- if (flags & 2097152 /* Alias */)
- return "alias" /* alias */;
- if (flags & 1536 /* Module */)
- return "module" /* moduleElement */;
+ if (flags & 32 /* SymbolFlags.Class */) {
+ return ts.getDeclarationOfKind(symbol, 226 /* SyntaxKind.ClassExpression */) ?
+ "local class" /* ScriptElementKind.localClassElement */ : "class" /* ScriptElementKind.classElement */;
+ }
+ if (flags & 384 /* SymbolFlags.Enum */)
+ return "enum" /* ScriptElementKind.enumElement */;
+ if (flags & 524288 /* SymbolFlags.TypeAlias */)
+ return "type" /* ScriptElementKind.typeElement */;
+ if (flags & 64 /* SymbolFlags.Interface */)
+ return "interface" /* ScriptElementKind.interfaceElement */;
+ if (flags & 262144 /* SymbolFlags.TypeParameter */)
+ return "type parameter" /* ScriptElementKind.typeParameterElement */;
+ if (flags & 8 /* SymbolFlags.EnumMember */)
+ return "enum member" /* ScriptElementKind.enumMemberElement */;
+ if (flags & 2097152 /* SymbolFlags.Alias */)
+ return "alias" /* ScriptElementKind.alias */;
+ if (flags & 1536 /* SymbolFlags.Module */)
+ return "module" /* ScriptElementKind.moduleElement */;
return result;
}
SymbolDisplay.getSymbolKind = getSymbolKind;
@@ -142371,52 +144889,52 @@ var ts;
var roots = typeChecker.getRootSymbols(symbol);
// If this is a method from a mapped type, leave as a method so long as it still has a call signature.
if (roots.length === 1
- && ts.first(roots).flags & 8192 /* Method */
+ && ts.first(roots).flags & 8192 /* SymbolFlags.Method */
// Ensure the mapped version is still a method, as opposed to `{ [K in keyof I]: number }`.
&& typeChecker.getTypeOfSymbolAtLocation(symbol, location).getNonNullableType().getCallSignatures().length !== 0) {
- return "method" /* memberFunctionElement */;
+ return "method" /* ScriptElementKind.memberFunctionElement */;
}
if (typeChecker.isUndefinedSymbol(symbol)) {
- return "var" /* variableElement */;
+ return "var" /* ScriptElementKind.variableElement */;
}
if (typeChecker.isArgumentsSymbol(symbol)) {
- return "local var" /* localVariableElement */;
+ return "local var" /* ScriptElementKind.localVariableElement */;
}
- if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) {
- return "parameter" /* parameterElement */;
+ if (location.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) {
+ return "parameter" /* ScriptElementKind.parameterElement */;
}
var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol);
- if (flags & 3 /* Variable */) {
+ if (flags & 3 /* SymbolFlags.Variable */) {
if (ts.isFirstDeclarationOfSymbolParameter(symbol)) {
- return "parameter" /* parameterElement */;
+ return "parameter" /* ScriptElementKind.parameterElement */;
}
else if (symbol.valueDeclaration && ts.isVarConst(symbol.valueDeclaration)) {
- return "const" /* constElement */;
+ return "const" /* ScriptElementKind.constElement */;
}
else if (ts.forEach(symbol.declarations, ts.isLet)) {
- return "let" /* letElement */;
+ return "let" /* ScriptElementKind.letElement */;
}
- return isLocalVariableOrFunction(symbol) ? "local var" /* localVariableElement */ : "var" /* variableElement */;
+ return isLocalVariableOrFunction(symbol) ? "local var" /* ScriptElementKind.localVariableElement */ : "var" /* ScriptElementKind.variableElement */;
}
- if (flags & 16 /* Function */)
- return isLocalVariableOrFunction(symbol) ? "local function" /* localFunctionElement */ : "function" /* functionElement */;
+ if (flags & 16 /* SymbolFlags.Function */)
+ return isLocalVariableOrFunction(symbol) ? "local function" /* ScriptElementKind.localFunctionElement */ : "function" /* ScriptElementKind.functionElement */;
// FIXME: getter and setter use the same symbol. And it is rare to use only setter without getter, so in most cases the symbol always has getter flag.
// So, even when the location is just on the declaration of setter, this function returns getter.
- if (flags & 32768 /* GetAccessor */)
- return "getter" /* memberGetAccessorElement */;
- if (flags & 65536 /* SetAccessor */)
- return "setter" /* memberSetAccessorElement */;
- if (flags & 8192 /* Method */)
- return "method" /* memberFunctionElement */;
- if (flags & 16384 /* Constructor */)
- return "constructor" /* constructorImplementationElement */;
- if (flags & 4 /* Property */) {
- if (flags & 33554432 /* Transient */ && symbol.checkFlags & 6 /* Synthetic */) {
+ if (flags & 32768 /* SymbolFlags.GetAccessor */)
+ return "getter" /* ScriptElementKind.memberGetAccessorElement */;
+ if (flags & 65536 /* SymbolFlags.SetAccessor */)
+ return "setter" /* ScriptElementKind.memberSetAccessorElement */;
+ if (flags & 8192 /* SymbolFlags.Method */)
+ return "method" /* ScriptElementKind.memberFunctionElement */;
+ if (flags & 16384 /* SymbolFlags.Constructor */)
+ return "constructor" /* ScriptElementKind.constructorImplementationElement */;
+ if (flags & 4 /* SymbolFlags.Property */) {
+ if (flags & 33554432 /* SymbolFlags.Transient */ && symbol.checkFlags & 6 /* CheckFlags.Synthetic */) {
// If union property is result of union of non method (property/accessors/variables), it is labeled as property
var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) {
var rootSymbolFlags = rootSymbol.getFlags();
- if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) {
- return "property" /* memberVariableElement */;
+ if (rootSymbolFlags & (98308 /* SymbolFlags.PropertyOrAccessor */ | 3 /* SymbolFlags.Variable */)) {
+ return "property" /* ScriptElementKind.memberVariableElement */;
}
});
if (!unionPropertyKind) {
@@ -142424,23 +144942,23 @@ var ts;
// make sure it has call signatures before we can label it as method
var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
if (typeOfUnionProperty.getCallSignatures().length) {
- return "method" /* memberFunctionElement */;
+ return "method" /* ScriptElementKind.memberFunctionElement */;
}
- return "property" /* memberVariableElement */;
+ return "property" /* ScriptElementKind.memberVariableElement */;
}
return unionPropertyKind;
}
- return "property" /* memberVariableElement */;
+ return "property" /* ScriptElementKind.memberVariableElement */;
}
- return "" /* unknown */;
+ return "" /* ScriptElementKind.unknown */;
}
function getNormalizedSymbolModifiers(symbol) {
if (symbol.declarations && symbol.declarations.length) {
var _a = symbol.declarations, declaration = _a[0], declarations = _a.slice(1);
// omit deprecated flag if some declarations are not deprecated
var excludeFlags = ts.length(declarations) && ts.isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !ts.isDeprecatedDeclaration(d); })
- ? 8192 /* Deprecated */
- : 0 /* None */;
+ ? 8192 /* ModifierFlags.Deprecated */
+ : 0 /* ModifierFlags.None */;
var modifiers = ts.getNodeModifiers(declaration, excludeFlags);
if (modifiers) {
return modifiers.split(",");
@@ -142450,10 +144968,10 @@ var ts;
}
function getSymbolModifiers(typeChecker, symbol) {
if (!symbol) {
- return "" /* none */;
+ return "" /* ScriptElementKindModifier.none */;
}
var modifiers = new ts.Set(getNormalizedSymbolModifiers(symbol));
- if (symbol.flags & 2097152 /* Alias */) {
+ if (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
var resolvedSymbol = typeChecker.getAliasedSymbol(symbol);
if (resolvedSymbol !== symbol) {
ts.forEach(getNormalizedSymbolModifiers(resolvedSymbol), function (modifier) {
@@ -142461,10 +144979,10 @@ var ts;
});
}
}
- if (symbol.flags & 16777216 /* Optional */) {
- modifiers.add("optional" /* optionalModifier */);
+ if (symbol.flags & 16777216 /* SymbolFlags.Optional */) {
+ modifiers.add("optional" /* ScriptElementKindModifier.optionalModifier */);
}
- return modifiers.size > 0 ? ts.arrayFrom(modifiers.values()).join(",") : "" /* none */;
+ return modifiers.size > 0 ? ts.arrayFrom(modifiers.values()).join(",") : "" /* ScriptElementKindModifier.none */;
}
SymbolDisplay.getSymbolModifiers = getSymbolModifiers;
// TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location
@@ -142475,41 +144993,41 @@ var ts;
var documentation = [];
var tags = [];
var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol);
- var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */;
+ var symbolKind = semanticMeaning & 1 /* SemanticMeaning.Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* ScriptElementKind.unknown */;
var hasAddedSymbolInfo = false;
- var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location);
+ var isThisExpression = location.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location);
var type;
var printer;
var documentationFromAlias;
var tagsFromAlias;
var hasMultipleSignatures = false;
- if (location.kind === 108 /* ThisKeyword */ && !isThisExpression) {
- return { displayParts: [ts.keywordPart(108 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined };
+ if (location.kind === 108 /* SyntaxKind.ThisKeyword */ && !isThisExpression) {
+ return { displayParts: [ts.keywordPart(108 /* SyntaxKind.ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* ScriptElementKind.primitiveType */, tags: undefined };
}
// Class at constructor site need to be shown as constructor apart from property,method, vars
- if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 2097152 /* Alias */) {
+ if (symbolKind !== "" /* ScriptElementKind.unknown */ || symbolFlags & 32 /* SymbolFlags.Class */ || symbolFlags & 2097152 /* SymbolFlags.Alias */) {
// If symbol is accessor, they are allowed only if location is at declaration identifier of the accessor
- if (symbolKind === "getter" /* memberGetAccessorElement */ || symbolKind === "setter" /* memberSetAccessorElement */) {
+ if (symbolKind === "getter" /* ScriptElementKind.memberGetAccessorElement */ || symbolKind === "setter" /* ScriptElementKind.memberSetAccessorElement */) {
var declaration = ts.find(symbol.declarations, function (declaration) { return declaration.name === location; });
if (declaration) {
switch (declaration.kind) {
- case 171 /* GetAccessor */:
- symbolKind = "getter" /* memberGetAccessorElement */;
+ case 172 /* SyntaxKind.GetAccessor */:
+ symbolKind = "getter" /* ScriptElementKind.memberGetAccessorElement */;
break;
- case 172 /* SetAccessor */:
- symbolKind = "setter" /* memberSetAccessorElement */;
+ case 173 /* SyntaxKind.SetAccessor */:
+ symbolKind = "setter" /* ScriptElementKind.memberSetAccessorElement */;
break;
default:
ts.Debug.assertNever(declaration);
}
}
else {
- symbolKind = "property" /* memberVariableElement */;
+ symbolKind = "property" /* ScriptElementKind.memberVariableElement */;
}
}
var signature = void 0;
type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location);
- if (location.parent && location.parent.kind === 205 /* PropertyAccessExpression */) {
+ if (location.parent && location.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) {
var right = location.parent.name;
// Either the location is on the right of a property access, or on the left and the right is missing
if (right === location || (right && right.getFullWidth() === 0)) {
@@ -142529,7 +145047,7 @@ var ts;
}
if (callExpressionLike) {
signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217
- var useConstructSignatures = callExpressionLike.kind === 208 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SuperKeyword */);
+ var useConstructSignatures = callExpressionLike.kind === 209 /* SyntaxKind.NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SyntaxKind.SuperKeyword */);
var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures();
if (signature && !ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) {
// Get the first signature if there is one -- allSignatures may contain
@@ -142537,21 +145055,21 @@ var ts;
signature = allSignatures.length ? allSignatures[0] : undefined;
}
if (signature) {
- if (useConstructSignatures && (symbolFlags & 32 /* Class */)) {
+ if (useConstructSignatures && (symbolFlags & 32 /* SymbolFlags.Class */)) {
// Constructor
- symbolKind = "constructor" /* constructorImplementationElement */;
+ symbolKind = "constructor" /* ScriptElementKind.constructorImplementationElement */;
addPrefixForAnyFunctionOrVar(type.symbol, symbolKind);
}
- else if (symbolFlags & 2097152 /* Alias */) {
- symbolKind = "alias" /* alias */;
+ else if (symbolFlags & 2097152 /* SymbolFlags.Alias */) {
+ symbolKind = "alias" /* ScriptElementKind.alias */;
pushSymbolKind(symbolKind);
displayParts.push(ts.spacePart());
if (useConstructSignatures) {
- if (signature.flags & 4 /* Abstract */) {
- displayParts.push(ts.keywordPart(126 /* AbstractKeyword */));
+ if (signature.flags & 4 /* SignatureFlags.Abstract */) {
+ displayParts.push(ts.keywordPart(126 /* SyntaxKind.AbstractKeyword */));
displayParts.push(ts.spacePart());
}
- displayParts.push(ts.keywordPart(103 /* NewKeyword */));
+ displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */));
displayParts.push(ts.spacePart());
}
addFullSymbolName(symbol);
@@ -142560,29 +145078,29 @@ var ts;
addPrefixForAnyFunctionOrVar(symbol, symbolKind);
}
switch (symbolKind) {
- case "JSX attribute" /* jsxAttribute */:
- case "property" /* memberVariableElement */:
- case "var" /* variableElement */:
- case "const" /* constElement */:
- case "let" /* letElement */:
- case "parameter" /* parameterElement */:
- case "local var" /* localVariableElement */:
+ case "JSX attribute" /* ScriptElementKind.jsxAttribute */:
+ case "property" /* ScriptElementKind.memberVariableElement */:
+ case "var" /* ScriptElementKind.variableElement */:
+ case "const" /* ScriptElementKind.constElement */:
+ case "let" /* ScriptElementKind.letElement */:
+ case "parameter" /* ScriptElementKind.parameterElement */:
+ case "local var" /* ScriptElementKind.localVariableElement */:
// If it is call or construct signature of lambda's write type name
- displayParts.push(ts.punctuationPart(58 /* ColonToken */));
+ displayParts.push(ts.punctuationPart(58 /* SyntaxKind.ColonToken */));
displayParts.push(ts.spacePart());
- if (!(ts.getObjectFlags(type) & 16 /* Anonymous */) && type.symbol) {
- ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* AllowAnyNodeKind */ | 1 /* WriteTypeParametersOrArguments */));
+ if (!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) && type.symbol) {
+ ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* SymbolFormatFlags.AllowAnyNodeKind */ | 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */));
displayParts.push(ts.lineBreakPart());
}
if (useConstructSignatures) {
- if (signature.flags & 4 /* Abstract */) {
- displayParts.push(ts.keywordPart(126 /* AbstractKeyword */));
+ if (signature.flags & 4 /* SignatureFlags.Abstract */) {
+ displayParts.push(ts.keywordPart(126 /* SyntaxKind.AbstractKeyword */));
displayParts.push(ts.spacePart());
}
- displayParts.push(ts.keywordPart(103 /* NewKeyword */));
+ displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */));
displayParts.push(ts.spacePart());
}
- addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */);
+ addSignatureDisplayParts(signature, allSignatures, 262144 /* TypeFormatFlags.WriteArrowStyleSignature */);
break;
default:
// Just signature
@@ -142592,31 +145110,31 @@ var ts;
hasMultipleSignatures = allSignatures.length > 1;
}
}
- else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration
- (location.kind === 134 /* ConstructorKeyword */ && location.parent.kind === 170 /* Constructor */)) { // At constructor keyword of constructor declaration
+ else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* SymbolFlags.Accessor */)) || // name of function declaration
+ (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ && location.parent.kind === 171 /* SyntaxKind.Constructor */)) { // At constructor keyword of constructor declaration
// get the signature from the declaration and write it
var functionDeclaration_1 = location.parent;
// Use function declaration to write the signatures only if the symbol corresponding to this declaration
var locationIsSymbolDeclaration = symbol.declarations && ts.find(symbol.declarations, function (declaration) {
- return declaration === (location.kind === 134 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1);
+ return declaration === (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1);
});
if (locationIsSymbolDeclaration) {
- var allSignatures = functionDeclaration_1.kind === 170 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures();
+ var allSignatures = functionDeclaration_1.kind === 171 /* SyntaxKind.Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures();
if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) {
signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); // TODO: GH#18217
}
else {
signature = allSignatures[0];
}
- if (functionDeclaration_1.kind === 170 /* Constructor */) {
+ if (functionDeclaration_1.kind === 171 /* SyntaxKind.Constructor */) {
// show (constructor) Type(...) signature
- symbolKind = "constructor" /* constructorImplementationElement */;
+ symbolKind = "constructor" /* ScriptElementKind.constructorImplementationElement */;
addPrefixForAnyFunctionOrVar(type.symbol, symbolKind);
}
else {
// (function/method) symbol(..signature)
- addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 173 /* CallSignature */ &&
- !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind);
+ addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 174 /* SyntaxKind.CallSignature */ &&
+ !(type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ || type.symbol.flags & 4096 /* SymbolFlags.ObjectLiteral */) ? type.symbol : symbol, symbolKind);
}
if (signature) {
addSignatureDisplayParts(signature, allSignatures);
@@ -142626,63 +145144,63 @@ var ts;
}
}
}
- if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) {
+ if (symbolFlags & 32 /* SymbolFlags.Class */ && !hasAddedSymbolInfo && !isThisExpression) {
addAliasPrefixIfNecessary();
- if (ts.getDeclarationOfKind(symbol, 225 /* ClassExpression */)) {
+ if (ts.getDeclarationOfKind(symbol, 226 /* SyntaxKind.ClassExpression */)) {
// Special case for class expressions because we would like to indicate that
// the class name is local to the class body (similar to function expression)
// (local class) class <className>
- pushSymbolKind("local class" /* localClassElement */);
+ pushSymbolKind("local class" /* ScriptElementKind.localClassElement */);
}
else {
// Class declaration has name which is not local.
- displayParts.push(ts.keywordPart(84 /* ClassKeyword */));
+ displayParts.push(ts.keywordPart(84 /* SyntaxKind.ClassKeyword */));
}
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
writeTypeParametersOfSymbol(symbol, sourceFile);
}
- if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) {
+ if ((symbolFlags & 64 /* SymbolFlags.Interface */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) {
prefixNextMeaning();
- displayParts.push(ts.keywordPart(118 /* InterfaceKeyword */));
+ displayParts.push(ts.keywordPart(118 /* SyntaxKind.InterfaceKeyword */));
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
writeTypeParametersOfSymbol(symbol, sourceFile);
}
- if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) {
+ if ((symbolFlags & 524288 /* SymbolFlags.TypeAlias */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) {
prefixNextMeaning();
- displayParts.push(ts.keywordPart(151 /* TypeKeyword */));
+ displayParts.push(ts.keywordPart(152 /* SyntaxKind.TypeKeyword */));
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
writeTypeParametersOfSymbol(symbol, sourceFile);
displayParts.push(ts.spacePart());
- displayParts.push(ts.operatorPart(63 /* EqualsToken */));
+ displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */));
displayParts.push(ts.spacePart());
- ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, ts.isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */));
+ ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, ts.isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* TypeFormatFlags.InTypeAlias */));
}
- if (symbolFlags & 384 /* Enum */) {
+ if (symbolFlags & 384 /* SymbolFlags.Enum */) {
prefixNextMeaning();
if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) {
- displayParts.push(ts.keywordPart(85 /* ConstKeyword */));
+ displayParts.push(ts.keywordPart(85 /* SyntaxKind.ConstKeyword */));
displayParts.push(ts.spacePart());
}
- displayParts.push(ts.keywordPart(92 /* EnumKeyword */));
+ displayParts.push(ts.keywordPart(92 /* SyntaxKind.EnumKeyword */));
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
}
- if (symbolFlags & 1536 /* Module */ && !isThisExpression) {
+ if (symbolFlags & 1536 /* SymbolFlags.Module */ && !isThisExpression) {
prefixNextMeaning();
- var declaration = ts.getDeclarationOfKind(symbol, 260 /* ModuleDeclaration */);
- var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* Identifier */;
- displayParts.push(ts.keywordPart(isNamespace ? 142 /* NamespaceKeyword */ : 141 /* ModuleKeyword */));
+ var declaration = ts.getDeclarationOfKind(symbol, 261 /* SyntaxKind.ModuleDeclaration */);
+ var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* SyntaxKind.Identifier */;
+ displayParts.push(ts.keywordPart(isNamespace ? 142 /* SyntaxKind.NamespaceKeyword */ : 141 /* SyntaxKind.ModuleKeyword */));
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
}
- if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) {
+ if ((symbolFlags & 262144 /* SymbolFlags.TypeParameter */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) {
prefixNextMeaning();
- displayParts.push(ts.punctuationPart(20 /* OpenParenToken */));
+ displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */));
displayParts.push(ts.textPart("type parameter"));
- displayParts.push(ts.punctuationPart(21 /* CloseParenToken */));
+ displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */));
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
if (symbol.parent) {
@@ -142693,7 +145211,7 @@ var ts;
}
else {
// Method/function type parameter
- var decl = ts.getDeclarationOfKind(symbol, 162 /* TypeParameter */);
+ var decl = ts.getDeclarationOfKind(symbol, 163 /* SyntaxKind.TypeParameter */);
if (decl === undefined)
return ts.Debug.fail();
var declaration = decl.parent;
@@ -142701,21 +145219,21 @@ var ts;
if (ts.isFunctionLikeKind(declaration.kind)) {
addInPrefix();
var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217
- if (declaration.kind === 174 /* ConstructSignature */) {
- displayParts.push(ts.keywordPart(103 /* NewKeyword */));
+ if (declaration.kind === 175 /* SyntaxKind.ConstructSignature */) {
+ displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */));
displayParts.push(ts.spacePart());
}
- else if (declaration.kind !== 173 /* CallSignature */ && declaration.name) {
+ else if (declaration.kind !== 174 /* SyntaxKind.CallSignature */ && declaration.name) {
addFullSymbolName(declaration.symbol);
}
- ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */));
+ ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */));
}
- else if (declaration.kind === 258 /* TypeAliasDeclaration */) {
+ else if (declaration.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) {
// Type alias type parameter
// For example
// type list<T> = T[]; // Both T will go through same code path
addInPrefix();
- displayParts.push(ts.keywordPart(151 /* TypeKeyword */));
+ displayParts.push(ts.keywordPart(152 /* SyntaxKind.TypeKeyword */));
displayParts.push(ts.spacePart());
addFullSymbolName(declaration.symbol);
writeTypeParametersOfSymbol(declaration.symbol, sourceFile);
@@ -142723,22 +145241,22 @@ var ts;
}
}
}
- if (symbolFlags & 8 /* EnumMember */) {
- symbolKind = "enum member" /* enumMemberElement */;
+ if (symbolFlags & 8 /* SymbolFlags.EnumMember */) {
+ symbolKind = "enum member" /* ScriptElementKind.enumMemberElement */;
addPrefixForAnyFunctionOrVar(symbol, "enum member");
var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0];
- if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 297 /* EnumMember */) {
+ if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 299 /* SyntaxKind.EnumMember */) {
var constantValue = typeChecker.getConstantValue(declaration);
if (constantValue !== undefined) {
displayParts.push(ts.spacePart());
- displayParts.push(ts.operatorPart(63 /* EqualsToken */));
+ displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */));
displayParts.push(ts.spacePart());
displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral));
}
}
}
// don't use symbolFlags since getAliasedSymbol requires the flag on the symbol itself
- if (symbol.flags & 2097152 /* Alias */) {
+ if (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
prefixNextMeaning();
if (!hasAddedSymbolInfo) {
var resolvedSymbol = typeChecker.getAliasedSymbol(symbol);
@@ -142747,7 +145265,7 @@ var ts;
var declarationName = ts.getNameOfDeclaration(resolvedNode);
if (declarationName) {
var isExternalModuleDeclaration = ts.isModuleWithStringLiteralName(resolvedNode) &&
- ts.hasSyntacticModifier(resolvedNode, 2 /* Ambient */);
+ ts.hasSyntacticModifier(resolvedNode, 2 /* ModifierFlags.Ambient */);
var shouldUseAliasName = symbol.name !== "default" && !isExternalModuleDeclaration;
var resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, resolvedSymbol, ts.getSourceFileOfNode(resolvedNode), resolvedNode, declarationName, semanticMeaning, shouldUseAliasName ? symbol : resolvedSymbol);
displayParts.push.apply(displayParts, resolvedInfo.displayParts);
@@ -142763,42 +145281,42 @@ var ts;
}
if (symbol.declarations) {
switch (symbol.declarations[0].kind) {
- case 263 /* NamespaceExportDeclaration */:
- displayParts.push(ts.keywordPart(93 /* ExportKeyword */));
+ case 264 /* SyntaxKind.NamespaceExportDeclaration */:
+ displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */));
displayParts.push(ts.spacePart());
- displayParts.push(ts.keywordPart(142 /* NamespaceKeyword */));
+ displayParts.push(ts.keywordPart(142 /* SyntaxKind.NamespaceKeyword */));
break;
- case 270 /* ExportAssignment */:
- displayParts.push(ts.keywordPart(93 /* ExportKeyword */));
+ case 271 /* SyntaxKind.ExportAssignment */:
+ displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */));
displayParts.push(ts.spacePart());
- displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* EqualsToken */ : 88 /* DefaultKeyword */));
+ displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* SyntaxKind.EqualsToken */ : 88 /* SyntaxKind.DefaultKeyword */));
break;
- case 274 /* ExportSpecifier */:
- displayParts.push(ts.keywordPart(93 /* ExportKeyword */));
+ case 275 /* SyntaxKind.ExportSpecifier */:
+ displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */));
break;
default:
- displayParts.push(ts.keywordPart(100 /* ImportKeyword */));
+ displayParts.push(ts.keywordPart(100 /* SyntaxKind.ImportKeyword */));
}
}
displayParts.push(ts.spacePart());
addFullSymbolName(symbol);
ts.forEach(symbol.declarations, function (declaration) {
- if (declaration.kind === 264 /* ImportEqualsDeclaration */) {
+ if (declaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
var importEqualsDeclaration = declaration;
if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) {
displayParts.push(ts.spacePart());
- displayParts.push(ts.operatorPart(63 /* EqualsToken */));
+ displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */));
displayParts.push(ts.spacePart());
- displayParts.push(ts.keywordPart(145 /* RequireKeyword */));
- displayParts.push(ts.punctuationPart(20 /* OpenParenToken */));
+ displayParts.push(ts.keywordPart(146 /* SyntaxKind.RequireKeyword */));
+ displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */));
displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral));
- displayParts.push(ts.punctuationPart(21 /* CloseParenToken */));
+ displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */));
}
else {
var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference);
if (internalAliasSymbol) {
displayParts.push(ts.spacePart());
- displayParts.push(ts.operatorPart(63 /* EqualsToken */));
+ displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */));
displayParts.push(ts.spacePart());
addFullSymbolName(internalAliasSymbol, enclosingDeclaration);
}
@@ -142808,30 +145326,30 @@ var ts;
});
}
if (!hasAddedSymbolInfo) {
- if (symbolKind !== "" /* unknown */) {
+ if (symbolKind !== "" /* ScriptElementKind.unknown */) {
if (type) {
if (isThisExpression) {
prefixNextMeaning();
- displayParts.push(ts.keywordPart(108 /* ThisKeyword */));
+ displayParts.push(ts.keywordPart(108 /* SyntaxKind.ThisKeyword */));
}
else {
addPrefixForAnyFunctionOrVar(symbol, symbolKind);
}
// For properties, variables and local vars: show the type
- if (symbolKind === "property" /* memberVariableElement */ ||
- symbolKind === "getter" /* memberGetAccessorElement */ ||
- symbolKind === "setter" /* memberSetAccessorElement */ ||
- symbolKind === "JSX attribute" /* jsxAttribute */ ||
- symbolFlags & 3 /* Variable */ ||
- symbolKind === "local var" /* localVariableElement */ ||
+ if (symbolKind === "property" /* ScriptElementKind.memberVariableElement */ ||
+ symbolKind === "getter" /* ScriptElementKind.memberGetAccessorElement */ ||
+ symbolKind === "setter" /* ScriptElementKind.memberSetAccessorElement */ ||
+ symbolKind === "JSX attribute" /* ScriptElementKind.jsxAttribute */ ||
+ symbolFlags & 3 /* SymbolFlags.Variable */ ||
+ symbolKind === "local var" /* ScriptElementKind.localVariableElement */ ||
isThisExpression) {
- displayParts.push(ts.punctuationPart(58 /* ColonToken */));
+ displayParts.push(ts.punctuationPart(58 /* SyntaxKind.ColonToken */));
displayParts.push(ts.spacePart());
// If the type is type parameter, format it specially
- if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) {
+ if (type.symbol && type.symbol.flags & 262144 /* SymbolFlags.TypeParameter */) {
var typeParameterParts = ts.mapToDisplayParts(function (writer) {
var param = typeChecker.typeParameterToDeclaration(type, enclosingDeclaration, symbolDisplayNodeBuilderFlags);
- getPrinter().writeNode(4 /* Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer);
+ getPrinter().writeNode(4 /* EmitHint.Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer);
});
ts.addRange(displayParts, typeParameterParts);
}
@@ -142842,17 +145360,17 @@ var ts;
var labelDecl = symbol.target.tupleLabelDeclaration;
ts.Debug.assertNode(labelDecl.name, ts.isIdentifier);
displayParts.push(ts.spacePart());
- displayParts.push(ts.punctuationPart(20 /* OpenParenToken */));
+ displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */));
displayParts.push(ts.textPart(ts.idText(labelDecl.name)));
- displayParts.push(ts.punctuationPart(21 /* CloseParenToken */));
+ displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */));
}
}
- else if (symbolFlags & 16 /* Function */ ||
- symbolFlags & 8192 /* Method */ ||
- symbolFlags & 16384 /* Constructor */ ||
- symbolFlags & 131072 /* Signature */ ||
- symbolFlags & 98304 /* Accessor */ ||
- symbolKind === "method" /* memberFunctionElement */) {
+ else if (symbolFlags & 16 /* SymbolFlags.Function */ ||
+ symbolFlags & 8192 /* SymbolFlags.Method */ ||
+ symbolFlags & 16384 /* SymbolFlags.Constructor */ ||
+ symbolFlags & 131072 /* SymbolFlags.Signature */ ||
+ symbolFlags & 98304 /* SymbolFlags.Accessor */ ||
+ symbolKind === "method" /* ScriptElementKind.memberFunctionElement */) {
var allSignatures = type.getNonNullableType().getCallSignatures();
if (allSignatures.length) {
addSignatureDisplayParts(allSignatures[0], allSignatures);
@@ -142868,14 +145386,14 @@ var ts;
if (documentation.length === 0 && !hasMultipleSignatures) {
documentation = symbol.getContextualDocumentationComment(enclosingDeclaration, typeChecker);
}
- if (documentation.length === 0 && symbolFlags & 4 /* Property */) {
+ if (documentation.length === 0 && symbolFlags & 4 /* SymbolFlags.Property */) {
// For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo`
// there documentation comments might be attached to the right hand side symbol of their declarations.
// The pattern of such special property access is that the parent symbol is the symbol of the file.
- if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 303 /* SourceFile */; })) {
+ if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 305 /* SyntaxKind.SourceFile */; })) {
for (var _i = 0, _b = symbol.declarations; _i < _b.length; _i++) {
var declaration = _b[_i];
- if (!declaration.parent || declaration.parent.kind !== 220 /* BinaryExpression */) {
+ if (!declaration.parent || declaration.parent.kind !== 221 /* SyntaxKind.BinaryExpression */) {
continue;
}
var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right);
@@ -142926,23 +145444,23 @@ var ts;
}
function addAliasPrefixIfNecessary() {
if (alias) {
- pushSymbolKind("alias" /* alias */);
+ pushSymbolKind("alias" /* ScriptElementKind.alias */);
displayParts.push(ts.spacePart());
}
}
function addInPrefix() {
displayParts.push(ts.spacePart());
- displayParts.push(ts.keywordPart(101 /* InKeyword */));
+ displayParts.push(ts.keywordPart(101 /* SyntaxKind.InKeyword */));
displayParts.push(ts.spacePart());
}
function addFullSymbolName(symbolToDisplay, enclosingDeclaration) {
if (alias && symbolToDisplay === symbol) {
symbolToDisplay = alias;
}
- var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */ | 4 /* AllowAnyNodeKind */);
+ var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */ | 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */);
ts.addRange(displayParts, fullSymbolDisplayParts);
- if (symbol.flags & 16777216 /* Optional */) {
- displayParts.push(ts.punctuationPart(57 /* QuestionToken */));
+ if (symbol.flags & 16777216 /* SymbolFlags.Optional */) {
+ displayParts.push(ts.punctuationPart(57 /* SyntaxKind.QuestionToken */));
}
}
function addPrefixForAnyFunctionOrVar(symbol, symbolKind) {
@@ -142957,31 +145475,31 @@ var ts;
}
function pushSymbolKind(symbolKind) {
switch (symbolKind) {
- case "var" /* variableElement */:
- case "function" /* functionElement */:
- case "let" /* letElement */:
- case "const" /* constElement */:
- case "constructor" /* constructorImplementationElement */:
+ case "var" /* ScriptElementKind.variableElement */:
+ case "function" /* ScriptElementKind.functionElement */:
+ case "let" /* ScriptElementKind.letElement */:
+ case "const" /* ScriptElementKind.constElement */:
+ case "constructor" /* ScriptElementKind.constructorImplementationElement */:
displayParts.push(ts.textOrKeywordPart(symbolKind));
return;
default:
- displayParts.push(ts.punctuationPart(20 /* OpenParenToken */));
+ displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */));
displayParts.push(ts.textOrKeywordPart(symbolKind));
- displayParts.push(ts.punctuationPart(21 /* CloseParenToken */));
+ displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */));
return;
}
}
function addSignatureDisplayParts(signature, allSignatures, flags) {
- if (flags === void 0) { flags = 0 /* None */; }
- ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */));
+ if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; }
+ ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */));
if (allSignatures.length > 1) {
displayParts.push(ts.spacePart());
- displayParts.push(ts.punctuationPart(20 /* OpenParenToken */));
- displayParts.push(ts.operatorPart(39 /* PlusToken */));
+ displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */));
+ displayParts.push(ts.operatorPart(39 /* SyntaxKind.PlusToken */));
displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral));
displayParts.push(ts.spacePart());
displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads"));
- displayParts.push(ts.punctuationPart(21 /* CloseParenToken */));
+ displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */));
}
documentation = signature.getDocumentationComment(typeChecker);
tags = signature.getJsDocTags();
@@ -142993,7 +145511,7 @@ var ts;
function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) {
var typeParameterParts = ts.mapToDisplayParts(function (writer) {
var params = typeChecker.symbolToTypeParameterDeclarations(symbol, enclosingDeclaration, symbolDisplayNodeBuilderFlags);
- getPrinter().writeList(53776 /* TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer);
+ getPrinter().writeList(53776 /* ListFormat.TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer);
});
ts.addRange(displayParts, typeParameterParts);
}
@@ -143005,16 +145523,16 @@ var ts;
}
return ts.forEach(symbol.declarations, function (declaration) {
// Function expressions are local
- if (declaration.kind === 212 /* FunctionExpression */) {
+ if (declaration.kind === 213 /* SyntaxKind.FunctionExpression */) {
return true;
}
- if (declaration.kind !== 253 /* VariableDeclaration */ && declaration.kind !== 255 /* FunctionDeclaration */) {
+ if (declaration.kind !== 254 /* SyntaxKind.VariableDeclaration */ && declaration.kind !== 256 /* SyntaxKind.FunctionDeclaration */) {
return false;
}
// If the parent is not sourceFile or module block it is local variable
for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) {
// Reached source file or module block
- if (parent.kind === 303 /* SourceFile */ || parent.kind === 261 /* ModuleBlock */) {
+ if (parent.kind === 305 /* SyntaxKind.SourceFile */ || parent.kind === 262 /* SyntaxKind.ModuleBlock */) {
return false;
}
}
@@ -143053,19 +145571,7 @@ var ts;
options.suppressOutputPathCheck = true;
// Filename can be non-ts file.
options.allowNonTsExtensions = true;
- // if jsx is specified then treat file as .tsx
- var inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts");
- var sourceFile = ts.createSourceFile(inputFileName, input, ts.getEmitScriptTarget(options));
- if (transpileOptions.moduleName) {
- sourceFile.moduleName = transpileOptions.moduleName;
- }
- if (transpileOptions.renamedDependencies) {
- sourceFile.renamedDependencies = new ts.Map(ts.getEntries(transpileOptions.renamedDependencies));
- }
var newLine = ts.getNewLineCharacter(options);
- // Output
- var outputText;
- var sourceMapText;
// Create a compilerHost object to allow the compiler to read and write files
var compilerHost = {
getSourceFile: function (fileName) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; },
@@ -143089,6 +145595,22 @@ var ts;
directoryExists: function () { return true; },
getDirectories: function () { return []; }
};
+ // if jsx is specified then treat file as .tsx
+ var inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts");
+ var sourceFile = ts.createSourceFile(inputFileName, input, {
+ languageVersion: ts.getEmitScriptTarget(options),
+ impliedNodeFormat: ts.getImpliedNodeFormatForFile(ts.toPath(inputFileName, "", compilerHost.getCanonicalFileName), /*cache*/ undefined, compilerHost, options),
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(options)
+ });
+ if (transpileOptions.moduleName) {
+ sourceFile.moduleName = transpileOptions.moduleName;
+ }
+ if (transpileOptions.renamedDependencies) {
+ sourceFile.renamedDependencies = new ts.Map(ts.getEntries(transpileOptions.renamedDependencies));
+ }
+ // Output
+ var outputText;
+ var sourceMapText;
var program = ts.createProgram([inputFileName], options, compilerHost);
if (transpileOptions.reportDiagnostics) {
ts.addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile));
@@ -143215,8 +145737,8 @@ var ts;
return startLine === endLine;
};
FormattingContext.prototype.BlockIsOnOneLine = function (node) {
- var openBrace = ts.findChildOfKind(node, 18 /* OpenBraceToken */, this.sourceFile);
- var closeBrace = ts.findChildOfKind(node, 19 /* CloseBraceToken */, this.sourceFile);
+ var openBrace = ts.findChildOfKind(node, 18 /* SyntaxKind.OpenBraceToken */, this.sourceFile);
+ var closeBrace = ts.findChildOfKind(node, 19 /* SyntaxKind.CloseBraceToken */, this.sourceFile);
if (openBrace && closeBrace) {
var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line;
var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line;
@@ -143234,8 +145756,8 @@ var ts;
(function (ts) {
var formatting;
(function (formatting) {
- var standardScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */);
- var jsxScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */);
+ var standardScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 0 /* LanguageVariant.Standard */);
+ var jsxScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 1 /* LanguageVariant.JSX */);
var ScanAction;
(function (ScanAction) {
ScanAction[ScanAction["Scan"] = 0] = "Scan";
@@ -143247,7 +145769,7 @@ var ts;
ScanAction[ScanAction["RescanJsxAttributeValue"] = 6] = "RescanJsxAttributeValue";
})(ScanAction || (ScanAction = {}));
function getFormattingScanner(text, languageVariant, startPos, endPos, cb) {
- var scanner = languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner;
+ var scanner = languageVariant === 1 /* LanguageVariant.JSX */ ? jsxScanner : standardScanner;
scanner.setText(text);
scanner.setTextPos(startPos);
var wasNewLine = true;
@@ -143275,7 +145797,7 @@ var ts;
lastTokenInfo = undefined;
var isStarted = scanner.getStartPos() !== startPos;
if (isStarted) {
- wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4 /* NewLineTrivia */;
+ wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4 /* SyntaxKind.NewLineTrivia */;
}
else {
scanner.scan();
@@ -143303,11 +145825,11 @@ var ts;
}
function shouldRescanGreaterThanToken(node) {
switch (node.kind) {
- case 33 /* GreaterThanEqualsToken */:
- case 71 /* GreaterThanGreaterThanEqualsToken */:
- case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
- case 49 /* GreaterThanGreaterThanGreaterThanToken */:
- case 48 /* GreaterThanGreaterThanToken */:
+ case 33 /* SyntaxKind.GreaterThanEqualsToken */:
+ case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */:
+ case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */:
+ case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */:
+ case 48 /* SyntaxKind.GreaterThanGreaterThanToken */:
return true;
}
return false;
@@ -143315,12 +145837,12 @@ var ts;
function shouldRescanJsxIdentifier(node) {
if (node.parent) {
switch (node.parent.kind) {
- case 284 /* JsxAttribute */:
- case 279 /* JsxOpeningElement */:
- case 280 /* JsxClosingElement */:
- case 278 /* JsxSelfClosingElement */:
+ case 285 /* SyntaxKind.JsxAttribute */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
+ case 281 /* SyntaxKind.JsxClosingElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
// May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier.
- return ts.isKeyword(node.kind) || node.kind === 79 /* Identifier */;
+ return ts.isKeyword(node.kind) || node.kind === 79 /* SyntaxKind.Identifier */;
}
}
return false;
@@ -143329,29 +145851,29 @@ var ts;
return ts.isJsxText(node);
}
function shouldRescanSlashToken(container) {
- return container.kind === 13 /* RegularExpressionLiteral */;
+ return container.kind === 13 /* SyntaxKind.RegularExpressionLiteral */;
}
function shouldRescanTemplateToken(container) {
- return container.kind === 16 /* TemplateMiddle */ ||
- container.kind === 17 /* TemplateTail */;
+ return container.kind === 16 /* SyntaxKind.TemplateMiddle */ ||
+ container.kind === 17 /* SyntaxKind.TemplateTail */;
}
function shouldRescanJsxAttributeValue(node) {
return node.parent && ts.isJsxAttribute(node.parent) && node.parent.initializer === node;
}
function startsWithSlashToken(t) {
- return t === 43 /* SlashToken */ || t === 68 /* SlashEqualsToken */;
+ return t === 43 /* SyntaxKind.SlashToken */ || t === 68 /* SyntaxKind.SlashEqualsToken */;
}
function readTokenInfo(n) {
ts.Debug.assert(isOnToken());
// normally scanner returns the smallest available token
// check the kind of context node to determine if scanner should have more greedy behavior and consume more text.
- var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ :
- shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ :
- shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ :
- shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ :
- shouldRescanJsxText(n) ? 5 /* RescanJsxText */ :
- shouldRescanJsxAttributeValue(n) ? 6 /* RescanJsxAttributeValue */ :
- 0 /* Scan */;
+ var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* ScanAction.RescanGreaterThanToken */ :
+ shouldRescanSlashToken(n) ? 2 /* ScanAction.RescanSlashToken */ :
+ shouldRescanTemplateToken(n) ? 3 /* ScanAction.RescanTemplateToken */ :
+ shouldRescanJsxIdentifier(n) ? 4 /* ScanAction.RescanJsxIdentifier */ :
+ shouldRescanJsxText(n) ? 5 /* ScanAction.RescanJsxText */ :
+ shouldRescanJsxAttributeValue(n) ? 6 /* ScanAction.RescanJsxAttributeValue */ :
+ 0 /* ScanAction.Scan */;
if (lastTokenInfo && expectedScanAction === lastScanAction) {
// readTokenInfo was called before with the same expected scan action.
// No need to re-scan text, return existing 'lastTokenInfo'
@@ -143383,7 +145905,7 @@ var ts;
trailingTrivia = [];
}
trailingTrivia.push(trivia);
- if (currentToken === 4 /* NewLineTrivia */) {
+ if (currentToken === 4 /* SyntaxKind.NewLineTrivia */) {
// move past new line
scanner.scan();
break;
@@ -143394,40 +145916,40 @@ var ts;
}
function getNextToken(n, expectedScanAction) {
var token = scanner.getToken();
- lastScanAction = 0 /* Scan */;
+ lastScanAction = 0 /* ScanAction.Scan */;
switch (expectedScanAction) {
- case 1 /* RescanGreaterThanToken */:
- if (token === 31 /* GreaterThanToken */) {
- lastScanAction = 1 /* RescanGreaterThanToken */;
+ case 1 /* ScanAction.RescanGreaterThanToken */:
+ if (token === 31 /* SyntaxKind.GreaterThanToken */) {
+ lastScanAction = 1 /* ScanAction.RescanGreaterThanToken */;
var newToken = scanner.reScanGreaterToken();
ts.Debug.assert(n.kind === newToken);
return newToken;
}
break;
- case 2 /* RescanSlashToken */:
+ case 2 /* ScanAction.RescanSlashToken */:
if (startsWithSlashToken(token)) {
- lastScanAction = 2 /* RescanSlashToken */;
+ lastScanAction = 2 /* ScanAction.RescanSlashToken */;
var newToken = scanner.reScanSlashToken();
ts.Debug.assert(n.kind === newToken);
return newToken;
}
break;
- case 3 /* RescanTemplateToken */:
- if (token === 19 /* CloseBraceToken */) {
- lastScanAction = 3 /* RescanTemplateToken */;
+ case 3 /* ScanAction.RescanTemplateToken */:
+ if (token === 19 /* SyntaxKind.CloseBraceToken */) {
+ lastScanAction = 3 /* ScanAction.RescanTemplateToken */;
return scanner.reScanTemplateToken(/* isTaggedTemplate */ false);
}
break;
- case 4 /* RescanJsxIdentifier */:
- lastScanAction = 4 /* RescanJsxIdentifier */;
+ case 4 /* ScanAction.RescanJsxIdentifier */:
+ lastScanAction = 4 /* ScanAction.RescanJsxIdentifier */;
return scanner.scanJsxIdentifier();
- case 5 /* RescanJsxText */:
- lastScanAction = 5 /* RescanJsxText */;
+ case 5 /* ScanAction.RescanJsxText */:
+ lastScanAction = 5 /* ScanAction.RescanJsxText */;
return scanner.reScanJsxToken(/* allowMultilineJsxText */ false);
- case 6 /* RescanJsxAttributeValue */:
- lastScanAction = 6 /* RescanJsxAttributeValue */;
+ case 6 /* ScanAction.RescanJsxAttributeValue */:
+ lastScanAction = 6 /* ScanAction.RescanJsxAttributeValue */;
return scanner.reScanJsxAttributeValue();
- case 0 /* Scan */:
+ case 0 /* ScanAction.Scan */:
break;
default:
ts.Debug.assertNever(expectedScanAction);
@@ -143436,15 +145958,15 @@ var ts;
}
function readEOFTokenRange() {
ts.Debug.assert(isOnEOF());
- return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* EndOfFileToken */);
+ return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* SyntaxKind.EndOfFileToken */);
}
function isOnToken() {
var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken();
- return current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current);
+ return current !== 1 /* SyntaxKind.EndOfFileToken */ && !ts.isTrivia(current);
}
function isOnEOF() {
var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken();
- return current === 1 /* EndOfFileToken */;
+ return current === 1 /* SyntaxKind.EndOfFileToken */;
}
// when containing node in the tree is token
// but its kind differs from the kind that was returned by the scanner,
@@ -143511,8 +146033,8 @@ var ts;
(function (formatting) {
function getAllRules() {
var allTokens = [];
- for (var token = 0 /* FirstToken */; token <= 159 /* LastToken */; token++) {
- if (token !== 1 /* EndOfFileToken */) {
+ for (var token = 0 /* SyntaxKind.FirstToken */; token <= 160 /* SyntaxKind.LastToken */; token++) {
+ if (token !== 1 /* SyntaxKind.EndOfFileToken */) {
allTokens.push(token);
}
}
@@ -143524,263 +146046,263 @@ var ts;
return { tokens: allTokens.filter(function (t) { return !tokens.some(function (t2) { return t2 === t; }); }), isSpecific: false };
}
var anyToken = { tokens: allTokens, isSpecific: false };
- var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [3 /* MultiLineCommentTrivia */], false));
- var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [1 /* EndOfFileToken */], false));
- var keywords = tokenRangeFromRange(81 /* FirstKeyword */, 159 /* LastKeyword */);
- var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 78 /* LastBinaryOperator */);
- var binaryKeywordOperators = [101 /* InKeyword */, 102 /* InstanceOfKeyword */, 159 /* OfKeyword */, 127 /* AsKeyword */, 139 /* IsKeyword */];
- var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */];
+ var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [3 /* SyntaxKind.MultiLineCommentTrivia */], false));
+ var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [1 /* SyntaxKind.EndOfFileToken */], false));
+ var keywords = tokenRangeFromRange(81 /* SyntaxKind.FirstKeyword */, 160 /* SyntaxKind.LastKeyword */);
+ var binaryOperators = tokenRangeFromRange(29 /* SyntaxKind.FirstBinaryOperator */, 78 /* SyntaxKind.LastBinaryOperator */);
+ var binaryKeywordOperators = [101 /* SyntaxKind.InKeyword */, 102 /* SyntaxKind.InstanceOfKeyword */, 160 /* SyntaxKind.OfKeyword */, 127 /* SyntaxKind.AsKeyword */, 139 /* SyntaxKind.IsKeyword */];
+ var unaryPrefixOperators = [45 /* SyntaxKind.PlusPlusToken */, 46 /* SyntaxKind.MinusMinusToken */, 54 /* SyntaxKind.TildeToken */, 53 /* SyntaxKind.ExclamationToken */];
var unaryPrefixExpressions = [
- 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 79 /* Identifier */, 20 /* OpenParenToken */,
- 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */
+ 8 /* SyntaxKind.NumericLiteral */, 9 /* SyntaxKind.BigIntLiteral */, 79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */,
+ 22 /* SyntaxKind.OpenBracketToken */, 18 /* SyntaxKind.OpenBraceToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */
];
- var unaryPreincrementExpressions = [79 /* Identifier */, 20 /* OpenParenToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */];
- var unaryPostincrementExpressions = [79 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 103 /* NewKeyword */];
- var unaryPredecrementExpressions = [79 /* Identifier */, 20 /* OpenParenToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */];
- var unaryPostdecrementExpressions = [79 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 103 /* NewKeyword */];
- var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */];
- var typeNames = __spreadArray([79 /* Identifier */], ts.typeKeywords, true);
+ var unaryPreincrementExpressions = [79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */];
+ var unaryPostincrementExpressions = [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */, 23 /* SyntaxKind.CloseBracketToken */, 103 /* SyntaxKind.NewKeyword */];
+ var unaryPredecrementExpressions = [79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */];
+ var unaryPostdecrementExpressions = [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */, 23 /* SyntaxKind.CloseBracketToken */, 103 /* SyntaxKind.NewKeyword */];
+ var comments = [2 /* SyntaxKind.SingleLineCommentTrivia */, 3 /* SyntaxKind.MultiLineCommentTrivia */];
+ var typeNames = __spreadArray([79 /* SyntaxKind.Identifier */], ts.typeKeywords, true);
// Place a space before open brace in a function declaration
// TypeScript: Function can have return types, which can be made of tons of different token kinds
var functionOpenBraceLeftTokenRange = anyTokenIncludingMultilineComments;
// Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc)
- var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* Identifier */, 3 /* MultiLineCommentTrivia */, 84 /* ClassKeyword */, 93 /* ExportKeyword */, 100 /* ImportKeyword */]);
+ var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* SyntaxKind.Identifier */, 3 /* SyntaxKind.MultiLineCommentTrivia */, 84 /* SyntaxKind.ClassKeyword */, 93 /* SyntaxKind.ExportKeyword */, 100 /* SyntaxKind.ImportKeyword */]);
// Place a space before open brace in a control flow construct
- var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 90 /* DoKeyword */, 111 /* TryKeyword */, 96 /* FinallyKeyword */, 91 /* ElseKeyword */]);
+ var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* SyntaxKind.CloseParenToken */, 3 /* SyntaxKind.MultiLineCommentTrivia */, 90 /* SyntaxKind.DoKeyword */, 111 /* SyntaxKind.TryKeyword */, 96 /* SyntaxKind.FinallyKeyword */, 91 /* SyntaxKind.ElseKeyword */]);
// These rules are higher in priority than user-configurable
var highPriorityCommonRules = [
// Leave comments alone
- rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* StopProcessingSpaceActions */),
- rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* StopProcessingSpaceActions */),
- rule("NotSpaceBeforeColon", anyToken, 58 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */),
- rule("SpaceAfterColon", 58 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* InsertSpace */),
- rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */),
+ rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* RuleAction.StopProcessingSpaceActions */),
+ rule("IgnoreAfterLineComment", 2 /* SyntaxKind.SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* RuleAction.StopProcessingSpaceActions */),
+ rule("NotSpaceBeforeColon", anyToken, 58 /* SyntaxKind.ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */),
+ rule("SpaceAfterColon", 58 /* SyntaxKind.ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* SyntaxKind.QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */),
// insert space after '?' only when it is used in conditional operator
- rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* InsertSpace */),
+ rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* SyntaxKind.QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* RuleAction.InsertSpace */),
// in other cases there should be no space between '?' and next token
- rule("NoSpaceAfterQuestionMark", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
- rule("NoSpaceBeforeDot", anyToken, [24 /* DotToken */, 28 /* QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
- rule("NoSpaceAfterDot", [24 /* DotToken */, 28 /* QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
- rule("NoSpaceBetweenImportParenInImportType", 100 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */),
+ rule("NoSpaceAfterQuestionMark", 57 /* SyntaxKind.QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceBeforeDot", anyToken, [24 /* SyntaxKind.DotToken */, 28 /* SyntaxKind.QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceAfterDot", [24 /* SyntaxKind.DotToken */, 28 /* SyntaxKind.QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceBetweenImportParenInImportType", 100 /* SyntaxKind.ImportKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* RuleAction.DeleteSpace */),
// Special handling of unary operators.
// Prefix operators generally shouldn't have a space between
// them and their target unary expression.
- rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */),
- rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
- rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
- rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* DeleteSpace */),
- rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* DeleteSpace */),
+ rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* SyntaxKind.PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* SyntaxKind.MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* SyntaxKind.PlusPlusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* SyntaxKind.MinusMinusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* RuleAction.DeleteSpace */),
// More unary operator special-casing.
// DevDiv 181814: Be careful when removing leading whitespace
// around unary operators. Examples:
// 1 - -2 --X--> 1--2
// a + ++b --X--> a+++b
- rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* PlusPlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */),
- rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* PlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */),
- rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* PlusToken */, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */),
- rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* MinusMinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */),
- rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* MinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */),
- rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* MinusToken */, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */),
- rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
+ rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* SyntaxKind.PlusPlusToken */, 39 /* SyntaxKind.PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* SyntaxKind.PlusToken */, 39 /* SyntaxKind.PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* SyntaxKind.PlusToken */, 45 /* SyntaxKind.PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* SyntaxKind.MinusMinusToken */, 40 /* SyntaxKind.MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* SyntaxKind.MinusToken */, 40 /* SyntaxKind.MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* SyntaxKind.MinusToken */, 46 /* SyntaxKind.MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceAfterCloseBrace", 19 /* SyntaxKind.CloseBraceToken */, [27 /* SyntaxKind.CommaToken */, 26 /* SyntaxKind.SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
// For functions and control block place } on a new line [multi-line rule]
- rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 8 /* InsertNewLine */),
+ rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* SyntaxKind.CloseBraceToken */, [isMultilineBlockContext], 8 /* RuleAction.InsertNewLine */),
// Space/new line after }.
- rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* InsertSpace */),
+ rule("SpaceAfterCloseBrace", 19 /* SyntaxKind.CloseBraceToken */, anyTokenExcept(21 /* SyntaxKind.CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* RuleAction.InsertSpace */),
// Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied
// Also should not apply to })
- rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 91 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
- rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 115 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
- rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */),
+ rule("SpaceBetweenCloseBraceAndElse", 19 /* SyntaxKind.CloseBraceToken */, 91 /* SyntaxKind.ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceBetweenCloseBraceAndWhile", 19 /* SyntaxKind.CloseBraceToken */, 115 /* SyntaxKind.WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* RuleAction.DeleteSpace */),
// Add a space after control dec context if the next character is an open bracket ex: 'if (false)[a, b] = [1, 2];' -> 'if (false) [a, b] = [1, 2];'
- rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 4 /* InsertSpace */),
- rule("NoSpaceBetweenFunctionKeywordAndStar", 98 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */),
- rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 79 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */),
- rule("SpaceAfterFunctionInFuncDecl", 98 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* InsertSpace */),
+ rule("SpaceAfterConditionalClosingParen", 21 /* SyntaxKind.CloseParenToken */, 22 /* SyntaxKind.OpenBracketToken */, [isControlDeclContext], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceBetweenFunctionKeywordAndStar", 98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* RuleAction.DeleteSpace */),
+ rule("SpaceAfterStarInGeneratorDeclaration", 41 /* SyntaxKind.AsteriskToken */, 79 /* SyntaxKind.Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceAfterFunctionInFuncDecl", 98 /* SyntaxKind.FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* RuleAction.InsertSpace */),
// Insert new line after { and before } in multi-line contexts.
- rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* InsertNewLine */),
+ rule("NewLineAfterOpenBraceInBlockContext", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* RuleAction.InsertNewLine */),
// For get/set members, we check for (identifier,identifier) since get/set don't have tokens and they are represented as just an identifier token.
// Though, we do extra check on the context to make sure we are dealing with get/set node. Example:
// get x() {}
// set x(val) {}
- rule("SpaceAfterGetSetInMember", [136 /* GetKeyword */, 148 /* SetKeyword */], 79 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */),
- rule("NoSpaceBetweenYieldKeywordAndStar", 125 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */),
- rule("SpaceBetweenYieldOrYieldStarAndOperand", [125 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */),
- rule("NoSpaceBetweenReturnAndSemicolon", 105 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
- rule("SpaceAfterCertainKeywords", [113 /* VarKeyword */, 109 /* ThrowKeyword */, 103 /* NewKeyword */, 89 /* DeleteKeyword */, 105 /* ReturnKeyword */, 112 /* TypeOfKeyword */, 132 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
- rule("SpaceAfterLetConstInVariableDeclaration", [119 /* LetKeyword */, 85 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */),
- rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* DeleteSpace */),
+ rule("SpaceAfterGetSetInMember", [136 /* SyntaxKind.GetKeyword */, 149 /* SyntaxKind.SetKeyword */], 79 /* SyntaxKind.Identifier */, [isFunctionDeclContext], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceBetweenYieldKeywordAndStar", 125 /* SyntaxKind.YieldKeyword */, 41 /* SyntaxKind.AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* RuleAction.DeleteSpace */),
+ rule("SpaceBetweenYieldOrYieldStarAndOperand", [125 /* SyntaxKind.YieldKeyword */, 41 /* SyntaxKind.AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceBetweenReturnAndSemicolon", 105 /* SyntaxKind.ReturnKeyword */, 26 /* SyntaxKind.SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
+ rule("SpaceAfterCertainKeywords", [113 /* SyntaxKind.VarKeyword */, 109 /* SyntaxKind.ThrowKeyword */, 103 /* SyntaxKind.NewKeyword */, 89 /* SyntaxKind.DeleteKeyword */, 105 /* SyntaxKind.ReturnKeyword */, 112 /* SyntaxKind.TypeOfKeyword */, 132 /* SyntaxKind.AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceAfterLetConstInVariableDeclaration", [119 /* SyntaxKind.LetKeyword */, 85 /* SyntaxKind.ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* RuleAction.DeleteSpace */),
// Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options.
- rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */),
- rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */),
- rule("SpaceAfterVoidOperator", 114 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */),
+ rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceAfterVoidOperator", 114 /* SyntaxKind.VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* RuleAction.InsertSpace */),
// Async-await
- rule("SpaceBetweenAsyncAndOpenParen", 131 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
- rule("SpaceBetweenAsyncAndFunctionKeyword", 131 /* AsyncKeyword */, [98 /* FunctionKeyword */, 79 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
+ rule("SpaceBetweenAsyncAndOpenParen", 131 /* SyntaxKind.AsyncKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceBetweenAsyncAndFunctionKeyword", 131 /* SyntaxKind.AsyncKeyword */, [98 /* SyntaxKind.FunctionKeyword */, 79 /* SyntaxKind.Identifier */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
// Template string
- rule("NoSpaceBetweenTagAndTemplateString", [79 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
+ rule("NoSpaceBetweenTagAndTemplateString", [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */], [14 /* SyntaxKind.NoSubstitutionTemplateLiteral */, 15 /* SyntaxKind.TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
// JSX opening elements
- rule("SpaceBeforeJsxAttribute", anyToken, 79 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
- rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
- rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SlashToken */, 31 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
- rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
- rule("NoSpaceAfterEqualInJsxAttribute", 63 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
+ rule("SpaceBeforeJsxAttribute", anyToken, 79 /* SyntaxKind.Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SyntaxKind.SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SyntaxKind.SlashToken */, 31 /* SyntaxKind.GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* SyntaxKind.EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceAfterEqualInJsxAttribute", 63 /* SyntaxKind.EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
// TypeScript-specific rules
// Use of module as a function call. e.g.: import m2 = module("m2");
- rule("NoSpaceAfterModuleImport", [141 /* ModuleKeyword */, 145 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
+ rule("NoSpaceAfterModuleImport", [141 /* SyntaxKind.ModuleKeyword */, 146 /* SyntaxKind.RequireKeyword */], 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
// Add a space around certain TypeScript keywords
rule("SpaceAfterCertainTypeScriptKeywords", [
- 126 /* AbstractKeyword */,
- 84 /* ClassKeyword */,
- 135 /* DeclareKeyword */,
- 88 /* DefaultKeyword */,
- 92 /* EnumKeyword */,
- 93 /* ExportKeyword */,
- 94 /* ExtendsKeyword */,
- 136 /* GetKeyword */,
- 117 /* ImplementsKeyword */,
- 100 /* ImportKeyword */,
- 118 /* InterfaceKeyword */,
- 141 /* ModuleKeyword */,
- 142 /* NamespaceKeyword */,
- 121 /* PrivateKeyword */,
- 123 /* PublicKeyword */,
- 122 /* ProtectedKeyword */,
- 144 /* ReadonlyKeyword */,
- 148 /* SetKeyword */,
- 124 /* StaticKeyword */,
- 151 /* TypeKeyword */,
- 155 /* FromKeyword */,
- 140 /* KeyOfKeyword */,
- 137 /* InferKeyword */,
- ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
- rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* ExtendsKeyword */, 117 /* ImplementsKeyword */, 155 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
+ 126 /* SyntaxKind.AbstractKeyword */,
+ 84 /* SyntaxKind.ClassKeyword */,
+ 135 /* SyntaxKind.DeclareKeyword */,
+ 88 /* SyntaxKind.DefaultKeyword */,
+ 92 /* SyntaxKind.EnumKeyword */,
+ 93 /* SyntaxKind.ExportKeyword */,
+ 94 /* SyntaxKind.ExtendsKeyword */,
+ 136 /* SyntaxKind.GetKeyword */,
+ 117 /* SyntaxKind.ImplementsKeyword */,
+ 100 /* SyntaxKind.ImportKeyword */,
+ 118 /* SyntaxKind.InterfaceKeyword */,
+ 141 /* SyntaxKind.ModuleKeyword */,
+ 142 /* SyntaxKind.NamespaceKeyword */,
+ 121 /* SyntaxKind.PrivateKeyword */,
+ 123 /* SyntaxKind.PublicKeyword */,
+ 122 /* SyntaxKind.ProtectedKeyword */,
+ 145 /* SyntaxKind.ReadonlyKeyword */,
+ 149 /* SyntaxKind.SetKeyword */,
+ 124 /* SyntaxKind.StaticKeyword */,
+ 152 /* SyntaxKind.TypeKeyword */,
+ 156 /* SyntaxKind.FromKeyword */,
+ 140 /* SyntaxKind.KeyOfKeyword */,
+ 137 /* SyntaxKind.InferKeyword */,
+ ], anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* SyntaxKind.ExtendsKeyword */, 117 /* SyntaxKind.ImplementsKeyword */, 156 /* SyntaxKind.FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
// Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" {
- rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 4 /* InsertSpace */),
+ rule("SpaceAfterModuleName", 10 /* SyntaxKind.StringLiteral */, 18 /* SyntaxKind.OpenBraceToken */, [isModuleDeclContext], 4 /* RuleAction.InsertSpace */),
// Lambda expressions
- rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
- rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
+ rule("SpaceBeforeArrow", anyToken, 38 /* SyntaxKind.EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceAfterArrow", 38 /* SyntaxKind.EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
// Optional parameters and let args
- rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 79 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
- rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */),
+ rule("NoSpaceAfterEllipsis", 25 /* SyntaxKind.DotDotDotToken */, 79 /* SyntaxKind.Identifier */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceAfterOptionalParameters", 57 /* SyntaxKind.QuestionToken */, [21 /* SyntaxKind.CloseParenToken */, 27 /* SyntaxKind.CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* RuleAction.DeleteSpace */),
// Remove spaces in empty interface literals. e.g.: x: {}
- rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */),
+ rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* RuleAction.DeleteSpace */),
// generics and type assertions
- rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */),
- rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */),
- rule("NoSpaceAfterOpenAngularBracket", 29 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */),
- rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */),
- rule("NoSpaceAfterCloseAngularBracket", 31 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 31 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* DeleteSpace */),
+ rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* SyntaxKind.CloseParenToken */, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceAfterOpenAngularBracket", 29 /* SyntaxKind.LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* SyntaxKind.GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceAfterCloseAngularBracket", 31 /* SyntaxKind.GreaterThanToken */, [20 /* SyntaxKind.OpenParenToken */, 22 /* SyntaxKind.OpenBracketToken */, 31 /* SyntaxKind.GreaterThanToken */, 27 /* SyntaxKind.CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* RuleAction.DeleteSpace */),
// decorators
- rule("SpaceBeforeAt", [21 /* CloseParenToken */, 79 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
- rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
+ rule("SpaceBeforeAt", [21 /* SyntaxKind.CloseParenToken */, 79 /* SyntaxKind.Identifier */], 59 /* SyntaxKind.AtToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceAfterAt", 59 /* SyntaxKind.AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
// Insert space after @ in decorator
rule("SpaceAfterDecorator", anyToken, [
- 126 /* AbstractKeyword */,
- 79 /* Identifier */,
- 93 /* ExportKeyword */,
- 88 /* DefaultKeyword */,
- 84 /* ClassKeyword */,
- 124 /* StaticKeyword */,
- 123 /* PublicKeyword */,
- 121 /* PrivateKeyword */,
- 122 /* ProtectedKeyword */,
- 136 /* GetKeyword */,
- 148 /* SetKeyword */,
- 22 /* OpenBracketToken */,
- 41 /* AsteriskToken */,
- ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */),
- rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */),
- rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */),
- rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
+ 126 /* SyntaxKind.AbstractKeyword */,
+ 79 /* SyntaxKind.Identifier */,
+ 93 /* SyntaxKind.ExportKeyword */,
+ 88 /* SyntaxKind.DefaultKeyword */,
+ 84 /* SyntaxKind.ClassKeyword */,
+ 124 /* SyntaxKind.StaticKeyword */,
+ 123 /* SyntaxKind.PublicKeyword */,
+ 121 /* SyntaxKind.PrivateKeyword */,
+ 122 /* SyntaxKind.ProtectedKeyword */,
+ 136 /* SyntaxKind.GetKeyword */,
+ 149 /* SyntaxKind.SetKeyword */,
+ 22 /* SyntaxKind.OpenBracketToken */,
+ 41 /* SyntaxKind.AsteriskToken */,
+ ], [isEndOfDecoratorContextOnSameLine], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* SyntaxKind.ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* SyntaxKind.NewKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* RuleAction.DeleteSpace */),
+ rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* SyntaxKind.LessThanToken */, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
];
// These rules are applied after high priority
var userConfigurableRules = [
// Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses
- rule("SpaceAfterConstructor", 134 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
- rule("NoSpaceAfterConstructor", 134 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
- rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* InsertSpace */),
- rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* DeleteSpace */),
+ rule("SpaceAfterConstructor", 134 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceAfterConstructor", 134 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
+ rule("SpaceAfterComma", 27 /* SyntaxKind.CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceAfterComma", 27 /* SyntaxKind.CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* RuleAction.DeleteSpace */),
// Insert space after function keyword for anonymous functions
- rule("SpaceAfterAnonymousFunctionKeyword", [98 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */),
- rule("NoSpaceAfterAnonymousFunctionKeyword", [98 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */),
+ rule("SpaceAfterAnonymousFunctionKeyword", [98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */], 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceAfterAnonymousFunctionKeyword", [98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */], 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* RuleAction.DeleteSpace */),
// Insert space after keywords in control flow statements
- rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* InsertSpace */),
- rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* DeleteSpace */),
+ rule("SpaceAfterKeywordInControl", keywords, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceAfterKeywordInControl", keywords, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* RuleAction.DeleteSpace */),
// Insert space after opening and before closing nonempty parenthesis
- rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
- rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
- rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
- rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
- rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
- rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
+ rule("SpaceAfterOpenParen", 20 /* SyntaxKind.OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceBeforeCloseParen", anyToken, 21 /* SyntaxKind.CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceBetweenOpenParens", 20 /* SyntaxKind.OpenParenToken */, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceBetweenParens", 20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceAfterOpenParen", 20 /* SyntaxKind.OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceBeforeCloseParen", anyToken, 21 /* SyntaxKind.CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
// Insert space after opening and before closing nonempty brackets
- rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
- rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
- rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
- rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
- rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
+ rule("SpaceAfterOpenBracket", 22 /* SyntaxKind.OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceBeforeCloseBracket", anyToken, 23 /* SyntaxKind.CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceBetweenBrackets", 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceAfterOpenBracket", 22 /* SyntaxKind.OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* SyntaxKind.CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
// Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}.
- rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */),
- rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */),
- rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */),
- rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
- rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
+ rule("SpaceAfterOpenBrace", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceBeforeCloseBrace", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceAfterOpenBrace", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
// Insert a space after opening and before closing empty brace brackets
- rule("SpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces")], 4 /* InsertSpace */),
- rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
+ rule("SpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces")], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
// Insert space after opening and before closing template string braces
- rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */),
- rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
- rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 16 /* DeleteSpace */, 1 /* CanDeleteNewLines */),
- rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
+ rule("SpaceAfterTemplateHeadAndMiddle", [15 /* SyntaxKind.TemplateHead */, 16 /* SyntaxKind.TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */),
+ rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* SyntaxKind.TemplateMiddle */, 17 /* SyntaxKind.TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* SyntaxKind.TemplateHead */, 16 /* SyntaxKind.TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 16 /* RuleAction.DeleteSpace */, 1 /* RuleFlags.CanDeleteNewLines */),
+ rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* SyntaxKind.TemplateMiddle */, 17 /* SyntaxKind.TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
// No space after { and before } in JSX expression
- rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */),
- rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */),
- rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */),
- rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */),
+ rule("SpaceAfterOpenBraceInJsxExpression", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* RuleAction.DeleteSpace */),
// Insert space after semicolon in for statement
- rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* InsertSpace */),
- rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* DeleteSpace */),
+ rule("SpaceAfterSemicolonInFor", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceAfterSemicolonInFor", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* RuleAction.DeleteSpace */),
// Insert space before and after binary operators
- rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */),
- rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */),
- rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */),
- rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */),
- rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* InsertSpace */),
- rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* DeleteSpace */),
+ rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */),
+ rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* RuleAction.DeleteSpace */),
+ rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* RuleAction.DeleteSpace */),
// Open Brace braces after control block
- rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */),
+ rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */),
// Open Brace braces after function
// TypeScript: Function can have return types, which can be made of tons of different token kinds
- rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */),
+ rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */),
// Open Brace braces after TypeScript module/class/interface
- rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */),
- rule("SpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* InsertSpace */),
- rule("NoSpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* DeleteSpace */),
- rule("SpaceBeforeTypeAnnotation", anyToken, [57 /* QuestionToken */, 58 /* ColonToken */], [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* InsertSpace */),
- rule("NoSpaceBeforeTypeAnnotation", anyToken, [57 /* QuestionToken */, 58 /* ColonToken */], [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* DeleteSpace */),
- rule("NoOptionalSemicolon", 26 /* SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* DeleteToken */),
- rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* InsertTrailingSemicolon */),
+ rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */),
+ rule("SpaceAfterTypeAssertion", 31 /* SyntaxKind.GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceAfterTypeAssertion", 31 /* SyntaxKind.GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* RuleAction.DeleteSpace */),
+ rule("SpaceBeforeTypeAnnotation", anyToken, [57 /* SyntaxKind.QuestionToken */, 58 /* SyntaxKind.ColonToken */], [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* RuleAction.InsertSpace */),
+ rule("NoSpaceBeforeTypeAnnotation", anyToken, [57 /* SyntaxKind.QuestionToken */, 58 /* SyntaxKind.ColonToken */], [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoOptionalSemicolon", 26 /* SyntaxKind.SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* RuleAction.DeleteToken */),
+ rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* RuleAction.InsertTrailingSemicolon */),
];
// These rules are lower in priority than user-configurable. Rules earlier in this list have priority over rules later in the list.
var lowPriorityCommonRules = [
// Space after keyword but not before ; or : or ?
- rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
- rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */),
- rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */),
- rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */),
- rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
+ rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SyntaxKind.SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
+ rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */),
+ rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */),
+ rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */),
+ rule("NoSpaceBeforeComma", anyToken, 27 /* SyntaxKind.CommaToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
// No space before and after indexer `x[]`
- rule("NoSpaceBeforeOpenBracket", anyTokenExcept(131 /* AsyncKeyword */, 82 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
- rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* DeleteSpace */),
- rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
+ rule("NoSpaceBeforeOpenBracket", anyTokenExcept(131 /* SyntaxKind.AsyncKeyword */, 82 /* SyntaxKind.CaseKeyword */), 22 /* SyntaxKind.OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */),
+ rule("NoSpaceAfterCloseBracket", 23 /* SyntaxKind.CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* RuleAction.DeleteSpace */),
+ rule("SpaceAfterSemicolon", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
// Remove extra space between for and await
- rule("SpaceBetweenForAndAwaitKeyword", 97 /* ForKeyword */, 132 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
+ rule("SpaceBetweenForAndAwaitKeyword", 97 /* SyntaxKind.ForKeyword */, 132 /* SyntaxKind.AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
// Add a space between statements. All keywords except (do,else,case) has open/close parens after them.
// So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any]
- rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 90 /* DoKeyword */, 91 /* ElseKeyword */, 82 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */),
+ rule("SpaceBetweenStatements", [21 /* SyntaxKind.CloseParenToken */, 90 /* SyntaxKind.DoKeyword */, 91 /* SyntaxKind.ElseKeyword */, 82 /* SyntaxKind.CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* RuleAction.InsertSpace */),
// This low-pri rule takes care of "try {", "catch {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter.
- rule("SpaceAfterTryCatchFinally", [111 /* TryKeyword */, 83 /* CatchKeyword */, 96 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
+ rule("SpaceAfterTryCatchFinally", [111 /* SyntaxKind.TryKeyword */, 83 /* SyntaxKind.CatchKeyword */, 96 /* SyntaxKind.FinallyKeyword */], 18 /* SyntaxKind.OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */),
];
return __spreadArray(__spreadArray(__spreadArray([], highPriorityCommonRules, true), userConfigurableRules, true), lowPriorityCommonRules, true);
}
@@ -143798,7 +146320,7 @@ var ts;
* @param flags whether the rule deletes a line or not, defaults to no-op
*/
function rule(debugName, left, right, context, action, flags) {
- if (flags === void 0) { flags = 0 /* None */; }
+ if (flags === void 0) { flags = 0 /* RuleFlags.None */; }
return { leftTokenRange: toTokenRange(left), rightTokenRange: toTokenRange(right), rule: { debugName: debugName, context: context, action: action, flags: flags } };
}
function tokenRangeFrom(tokens) {
@@ -143839,54 +146361,54 @@ var ts;
return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; };
}
function isForContext(context) {
- return context.contextNode.kind === 241 /* ForStatement */;
+ return context.contextNode.kind === 242 /* SyntaxKind.ForStatement */;
}
function isNotForContext(context) {
return !isForContext(context);
}
function isBinaryOpContext(context) {
switch (context.contextNode.kind) {
- case 220 /* BinaryExpression */:
- return context.contextNode.operatorToken.kind !== 27 /* CommaToken */;
- case 221 /* ConditionalExpression */:
- case 188 /* ConditionalType */:
- case 228 /* AsExpression */:
- case 274 /* ExportSpecifier */:
- case 269 /* ImportSpecifier */:
- case 176 /* TypePredicate */:
- case 186 /* UnionType */:
- case 187 /* IntersectionType */:
+ case 221 /* SyntaxKind.BinaryExpression */:
+ return context.contextNode.operatorToken.kind !== 27 /* SyntaxKind.CommaToken */;
+ case 222 /* SyntaxKind.ConditionalExpression */:
+ case 189 /* SyntaxKind.ConditionalType */:
+ case 229 /* SyntaxKind.AsExpression */:
+ case 275 /* SyntaxKind.ExportSpecifier */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
+ case 177 /* SyntaxKind.TypePredicate */:
+ case 187 /* SyntaxKind.UnionType */:
+ case 188 /* SyntaxKind.IntersectionType */:
return true;
// equals in binding elements: function foo([[x, y] = [1, 2]])
- case 202 /* BindingElement */:
+ case 203 /* SyntaxKind.BindingElement */:
// equals in type X = ...
// falls through
- case 258 /* TypeAliasDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
// equal in import a = module('a');
// falls through
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
// equal in export = 1
// falls through
- case 270 /* ExportAssignment */:
+ case 271 /* SyntaxKind.ExportAssignment */:
// equal in let a = 0
// falls through
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
// equal in p = 0
// falls through
- case 163 /* Parameter */:
- case 297 /* EnumMember */:
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
- return context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */;
+ case 164 /* SyntaxKind.Parameter */:
+ case 299 /* SyntaxKind.EnumMember */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ return context.currentTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */ || context.nextTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */;
// "in" keyword in for (let x in []) { }
- case 242 /* ForInStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
// "in" keyword in [P in keyof T]: T[P]
// falls through
- case 162 /* TypeParameter */:
- return context.currentTokenSpan.kind === 101 /* InKeyword */ || context.nextTokenSpan.kind === 101 /* InKeyword */ || context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */;
+ case 163 /* SyntaxKind.TypeParameter */:
+ return context.currentTokenSpan.kind === 101 /* SyntaxKind.InKeyword */ || context.nextTokenSpan.kind === 101 /* SyntaxKind.InKeyword */ || context.currentTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */ || context.nextTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */;
// Technically, "of" is not a binary operator, but format it the same way as "in"
- case 243 /* ForOfStatement */:
- return context.currentTokenSpan.kind === 159 /* OfKeyword */ || context.nextTokenSpan.kind === 159 /* OfKeyword */;
+ case 244 /* SyntaxKind.ForOfStatement */:
+ return context.currentTokenSpan.kind === 160 /* SyntaxKind.OfKeyword */ || context.nextTokenSpan.kind === 160 /* SyntaxKind.OfKeyword */;
}
return false;
}
@@ -143898,22 +146420,22 @@ var ts;
}
function isTypeAnnotationContext(context) {
var contextKind = context.contextNode.kind;
- return contextKind === 166 /* PropertyDeclaration */ ||
- contextKind === 165 /* PropertySignature */ ||
- contextKind === 163 /* Parameter */ ||
- contextKind === 253 /* VariableDeclaration */ ||
+ return contextKind === 167 /* SyntaxKind.PropertyDeclaration */ ||
+ contextKind === 166 /* SyntaxKind.PropertySignature */ ||
+ contextKind === 164 /* SyntaxKind.Parameter */ ||
+ contextKind === 254 /* SyntaxKind.VariableDeclaration */ ||
ts.isFunctionLikeKind(contextKind);
}
function isConditionalOperatorContext(context) {
- return context.contextNode.kind === 221 /* ConditionalExpression */ ||
- context.contextNode.kind === 188 /* ConditionalType */;
+ return context.contextNode.kind === 222 /* SyntaxKind.ConditionalExpression */ ||
+ context.contextNode.kind === 189 /* SyntaxKind.ConditionalType */;
}
function isSameLineTokenOrBeforeBlockContext(context) {
return context.TokensAreOnSameLine() || isBeforeBlockContext(context);
}
function isBraceWrappedContext(context) {
- return context.contextNode.kind === 200 /* ObjectBindingPattern */ ||
- context.contextNode.kind === 194 /* MappedType */ ||
+ return context.contextNode.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ||
+ context.contextNode.kind === 195 /* SyntaxKind.MappedType */ ||
isSingleLineBlockContext(context);
}
// This check is done before an open brace in a control construct, a function, or a typescript block declaration
@@ -143939,34 +146461,34 @@ var ts;
return true;
}
switch (node.kind) {
- case 234 /* Block */:
- case 262 /* CaseBlock */:
- case 204 /* ObjectLiteralExpression */:
- case 261 /* ModuleBlock */:
+ case 235 /* SyntaxKind.Block */:
+ case 263 /* SyntaxKind.CaseBlock */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
+ case 262 /* SyntaxKind.ModuleBlock */:
return true;
}
return false;
}
function isFunctionDeclContext(context) {
switch (context.contextNode.kind) {
- case 255 /* FunctionDeclaration */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
// case SyntaxKind.MemberFunctionDeclaration:
// falls through
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
// case SyntaxKind.MethodSignature:
// falls through
- case 173 /* CallSignature */:
- case 212 /* FunctionExpression */:
- case 170 /* Constructor */:
- case 213 /* ArrowFunction */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 214 /* SyntaxKind.ArrowFunction */:
// case SyntaxKind.ConstructorDeclaration:
// case SyntaxKind.SimpleArrowFunctionExpression:
// case SyntaxKind.ParenthesizedArrowFunctionExpression:
// falls through
- case 257 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one
+ case 258 /* SyntaxKind.InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one
return true;
}
return false;
@@ -143975,40 +146497,40 @@ var ts;
return !isFunctionDeclContext(context);
}
function isFunctionDeclarationOrFunctionExpressionContext(context) {
- return context.contextNode.kind === 255 /* FunctionDeclaration */ || context.contextNode.kind === 212 /* FunctionExpression */;
+ return context.contextNode.kind === 256 /* SyntaxKind.FunctionDeclaration */ || context.contextNode.kind === 213 /* SyntaxKind.FunctionExpression */;
}
function isTypeScriptDeclWithBlockContext(context) {
return nodeIsTypeScriptDeclWithBlockContext(context.contextNode);
}
function nodeIsTypeScriptDeclWithBlockContext(node) {
switch (node.kind) {
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- case 257 /* InterfaceDeclaration */:
- case 259 /* EnumDeclaration */:
- case 181 /* TypeLiteral */:
- case 260 /* ModuleDeclaration */:
- case 271 /* ExportDeclaration */:
- case 272 /* NamedExports */:
- case 265 /* ImportDeclaration */:
- case 268 /* NamedImports */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 182 /* SyntaxKind.TypeLiteral */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
+ case 273 /* SyntaxKind.NamedExports */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
+ case 269 /* SyntaxKind.NamedImports */:
return true;
}
return false;
}
function isAfterCodeBlockContext(context) {
switch (context.currentTokenParent.kind) {
- case 256 /* ClassDeclaration */:
- case 260 /* ModuleDeclaration */:
- case 259 /* EnumDeclaration */:
- case 291 /* CatchClause */:
- case 261 /* ModuleBlock */:
- case 248 /* SwitchStatement */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 292 /* SyntaxKind.CatchClause */:
+ case 262 /* SyntaxKind.ModuleBlock */:
+ case 249 /* SyntaxKind.SwitchStatement */:
return true;
- case 234 /* Block */: {
+ case 235 /* SyntaxKind.Block */: {
var blockParent = context.currentTokenParent.parent;
// In a codefix scenario, we can't rely on parents being set. So just always return true.
- if (!blockParent || blockParent.kind !== 213 /* ArrowFunction */ && blockParent.kind !== 212 /* FunctionExpression */) {
+ if (!blockParent || blockParent.kind !== 214 /* SyntaxKind.ArrowFunction */ && blockParent.kind !== 213 /* SyntaxKind.FunctionExpression */) {
return true;
}
}
@@ -144017,71 +146539,71 @@ var ts;
}
function isControlDeclContext(context) {
switch (context.contextNode.kind) {
- case 238 /* IfStatement */:
- case 248 /* SwitchStatement */:
- case 241 /* ForStatement */:
- case 242 /* ForInStatement */:
- case 243 /* ForOfStatement */:
- case 240 /* WhileStatement */:
- case 251 /* TryStatement */:
- case 239 /* DoStatement */:
- case 247 /* WithStatement */:
+ case 239 /* SyntaxKind.IfStatement */:
+ case 249 /* SyntaxKind.SwitchStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
+ case 252 /* SyntaxKind.TryStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
+ case 248 /* SyntaxKind.WithStatement */:
// TODO
// case SyntaxKind.ElseClause:
// falls through
- case 291 /* CatchClause */:
+ case 292 /* SyntaxKind.CatchClause */:
return true;
default:
return false;
}
}
function isObjectContext(context) {
- return context.contextNode.kind === 204 /* ObjectLiteralExpression */;
+ return context.contextNode.kind === 205 /* SyntaxKind.ObjectLiteralExpression */;
}
function isFunctionCallContext(context) {
- return context.contextNode.kind === 207 /* CallExpression */;
+ return context.contextNode.kind === 208 /* SyntaxKind.CallExpression */;
}
function isNewContext(context) {
- return context.contextNode.kind === 208 /* NewExpression */;
+ return context.contextNode.kind === 209 /* SyntaxKind.NewExpression */;
}
function isFunctionCallOrNewContext(context) {
return isFunctionCallContext(context) || isNewContext(context);
}
function isPreviousTokenNotComma(context) {
- return context.currentTokenSpan.kind !== 27 /* CommaToken */;
+ return context.currentTokenSpan.kind !== 27 /* SyntaxKind.CommaToken */;
}
function isNextTokenNotCloseBracket(context) {
- return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */;
+ return context.nextTokenSpan.kind !== 23 /* SyntaxKind.CloseBracketToken */;
}
function isNextTokenNotCloseParen(context) {
- return context.nextTokenSpan.kind !== 21 /* CloseParenToken */;
+ return context.nextTokenSpan.kind !== 21 /* SyntaxKind.CloseParenToken */;
}
function isArrowFunctionContext(context) {
- return context.contextNode.kind === 213 /* ArrowFunction */;
+ return context.contextNode.kind === 214 /* SyntaxKind.ArrowFunction */;
}
function isImportTypeContext(context) {
- return context.contextNode.kind === 199 /* ImportType */;
+ return context.contextNode.kind === 200 /* SyntaxKind.ImportType */;
}
function isNonJsxSameLineTokenContext(context) {
- return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */;
+ return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* SyntaxKind.JsxText */;
}
function isNonJsxTextContext(context) {
- return context.contextNode.kind !== 11 /* JsxText */;
+ return context.contextNode.kind !== 11 /* SyntaxKind.JsxText */;
}
function isNonJsxElementOrFragmentContext(context) {
- return context.contextNode.kind !== 277 /* JsxElement */ && context.contextNode.kind !== 281 /* JsxFragment */;
+ return context.contextNode.kind !== 278 /* SyntaxKind.JsxElement */ && context.contextNode.kind !== 282 /* SyntaxKind.JsxFragment */;
}
function isJsxExpressionContext(context) {
- return context.contextNode.kind === 287 /* JsxExpression */ || context.contextNode.kind === 286 /* JsxSpreadAttribute */;
+ return context.contextNode.kind === 288 /* SyntaxKind.JsxExpression */ || context.contextNode.kind === 287 /* SyntaxKind.JsxSpreadAttribute */;
}
function isNextTokenParentJsxAttribute(context) {
- return context.nextTokenParent.kind === 284 /* JsxAttribute */;
+ return context.nextTokenParent.kind === 285 /* SyntaxKind.JsxAttribute */;
}
function isJsxAttributeContext(context) {
- return context.contextNode.kind === 284 /* JsxAttribute */;
+ return context.contextNode.kind === 285 /* SyntaxKind.JsxAttribute */;
}
function isJsxSelfClosingElementContext(context) {
- return context.contextNode.kind === 278 /* JsxSelfClosingElement */;
+ return context.contextNode.kind === 279 /* SyntaxKind.JsxSelfClosingElement */;
}
function isNotBeforeBlockInFunctionDeclarationContext(context) {
return !isFunctionDeclContext(context) && !isBeforeBlockContext(context);
@@ -144096,45 +146618,45 @@ var ts;
while (ts.isExpressionNode(node)) {
node = node.parent;
}
- return node.kind === 164 /* Decorator */;
+ return node.kind === 165 /* SyntaxKind.Decorator */;
}
function isStartOfVariableDeclarationList(context) {
- return context.currentTokenParent.kind === 254 /* VariableDeclarationList */ &&
+ return context.currentTokenParent.kind === 255 /* SyntaxKind.VariableDeclarationList */ &&
context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos;
}
function isNotFormatOnEnter(context) {
- return context.formattingRequestKind !== 2 /* FormatOnEnter */;
+ return context.formattingRequestKind !== 2 /* FormattingRequestKind.FormatOnEnter */;
}
function isModuleDeclContext(context) {
- return context.contextNode.kind === 260 /* ModuleDeclaration */;
+ return context.contextNode.kind === 261 /* SyntaxKind.ModuleDeclaration */;
}
function isObjectTypeContext(context) {
- return context.contextNode.kind === 181 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration;
+ return context.contextNode.kind === 182 /* SyntaxKind.TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration;
}
function isConstructorSignatureContext(context) {
- return context.contextNode.kind === 174 /* ConstructSignature */;
+ return context.contextNode.kind === 175 /* SyntaxKind.ConstructSignature */;
}
function isTypeArgumentOrParameterOrAssertion(token, parent) {
- if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) {
+ if (token.kind !== 29 /* SyntaxKind.LessThanToken */ && token.kind !== 31 /* SyntaxKind.GreaterThanToken */) {
return false;
}
switch (parent.kind) {
- case 177 /* TypeReference */:
- case 210 /* TypeAssertionExpression */:
- case 258 /* TypeAliasDeclaration */:
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- case 257 /* InterfaceDeclaration */:
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 173 /* CallSignature */:
- case 174 /* ConstructSignature */:
- case 207 /* CallExpression */:
- case 208 /* NewExpression */:
- case 227 /* ExpressionWithTypeArguments */:
+ case 178 /* SyntaxKind.TypeReference */:
+ case 211 /* SyntaxKind.TypeAssertionExpression */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 208 /* SyntaxKind.CallExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
return true;
default:
return false;
@@ -144145,28 +146667,28 @@ var ts;
isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent);
}
function isTypeAssertionContext(context) {
- return context.contextNode.kind === 210 /* TypeAssertionExpression */;
+ return context.contextNode.kind === 211 /* SyntaxKind.TypeAssertionExpression */;
}
function isVoidOpContext(context) {
- return context.currentTokenSpan.kind === 114 /* VoidKeyword */ && context.currentTokenParent.kind === 216 /* VoidExpression */;
+ return context.currentTokenSpan.kind === 114 /* SyntaxKind.VoidKeyword */ && context.currentTokenParent.kind === 217 /* SyntaxKind.VoidExpression */;
}
function isYieldOrYieldStarWithOperand(context) {
- return context.contextNode.kind === 223 /* YieldExpression */ && context.contextNode.expression !== undefined;
+ return context.contextNode.kind === 224 /* SyntaxKind.YieldExpression */ && context.contextNode.expression !== undefined;
}
function isNonNullAssertionContext(context) {
- return context.contextNode.kind === 229 /* NonNullExpression */;
+ return context.contextNode.kind === 230 /* SyntaxKind.NonNullExpression */;
}
function isNotStatementConditionContext(context) {
return !isStatementConditionContext(context);
}
function isStatementConditionContext(context) {
switch (context.contextNode.kind) {
- case 238 /* IfStatement */:
- case 241 /* ForStatement */:
- case 242 /* ForInStatement */:
- case 243 /* ForOfStatement */:
- case 239 /* DoStatement */:
- case 240 /* WhileStatement */:
+ case 239 /* SyntaxKind.IfStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
return true;
default:
return false;
@@ -144188,15 +146710,15 @@ var ts;
var startLine = context.sourceFile.getLineAndCharacterOfPosition(context.currentTokenSpan.pos).line;
var endLine = context.sourceFile.getLineAndCharacterOfPosition(nextTokenStart).line;
if (startLine === endLine) {
- return nextTokenKind === 19 /* CloseBraceToken */
- || nextTokenKind === 1 /* EndOfFileToken */;
+ return nextTokenKind === 19 /* SyntaxKind.CloseBraceToken */
+ || nextTokenKind === 1 /* SyntaxKind.EndOfFileToken */;
}
- if (nextTokenKind === 233 /* SemicolonClassElement */ ||
- nextTokenKind === 26 /* SemicolonToken */) {
+ if (nextTokenKind === 234 /* SyntaxKind.SemicolonClassElement */ ||
+ nextTokenKind === 26 /* SyntaxKind.SemicolonToken */) {
return false;
}
- if (context.contextNode.kind === 257 /* InterfaceDeclaration */ ||
- context.contextNode.kind === 258 /* TypeAliasDeclaration */) {
+ if (context.contextNode.kind === 258 /* SyntaxKind.InterfaceDeclaration */ ||
+ context.contextNode.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) {
// Can’t remove semicolon after `foo`; it would parse as a method declaration:
//
// interface I {
@@ -144205,25 +146727,25 @@ var ts;
// }
return !ts.isPropertySignature(context.currentTokenParent)
|| !!context.currentTokenParent.type
- || nextTokenKind !== 20 /* OpenParenToken */;
+ || nextTokenKind !== 20 /* SyntaxKind.OpenParenToken */;
}
if (ts.isPropertyDeclaration(context.currentTokenParent)) {
return !context.currentTokenParent.initializer;
}
- return context.currentTokenParent.kind !== 241 /* ForStatement */
- && context.currentTokenParent.kind !== 235 /* EmptyStatement */
- && context.currentTokenParent.kind !== 233 /* SemicolonClassElement */
- && nextTokenKind !== 22 /* OpenBracketToken */
- && nextTokenKind !== 20 /* OpenParenToken */
- && nextTokenKind !== 39 /* PlusToken */
- && nextTokenKind !== 40 /* MinusToken */
- && nextTokenKind !== 43 /* SlashToken */
- && nextTokenKind !== 13 /* RegularExpressionLiteral */
- && nextTokenKind !== 27 /* CommaToken */
- && nextTokenKind !== 222 /* TemplateExpression */
- && nextTokenKind !== 15 /* TemplateHead */
- && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */
- && nextTokenKind !== 24 /* DotToken */;
+ return context.currentTokenParent.kind !== 242 /* SyntaxKind.ForStatement */
+ && context.currentTokenParent.kind !== 236 /* SyntaxKind.EmptyStatement */
+ && context.currentTokenParent.kind !== 234 /* SyntaxKind.SemicolonClassElement */
+ && nextTokenKind !== 22 /* SyntaxKind.OpenBracketToken */
+ && nextTokenKind !== 20 /* SyntaxKind.OpenParenToken */
+ && nextTokenKind !== 39 /* SyntaxKind.PlusToken */
+ && nextTokenKind !== 40 /* SyntaxKind.MinusToken */
+ && nextTokenKind !== 43 /* SyntaxKind.SlashToken */
+ && nextTokenKind !== 13 /* SyntaxKind.RegularExpressionLiteral */
+ && nextTokenKind !== 27 /* SyntaxKind.CommaToken */
+ && nextTokenKind !== 223 /* SyntaxKind.TemplateExpression */
+ && nextTokenKind !== 15 /* SyntaxKind.TemplateHead */
+ && nextTokenKind !== 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */
+ && nextTokenKind !== 24 /* SyntaxKind.DotToken */;
}
function isSemicolonInsertionContext(context) {
return ts.positionIsASICandidate(context.currentTokenSpan.end, context.currentTokenParent, context.sourceFile);
@@ -144252,17 +146774,17 @@ var ts;
*/
function getRuleActionExclusion(ruleAction) {
var mask = 0;
- if (ruleAction & 1 /* StopProcessingSpaceActions */) {
- mask |= 28 /* ModifySpaceAction */;
+ if (ruleAction & 1 /* RuleAction.StopProcessingSpaceActions */) {
+ mask |= 28 /* RuleAction.ModifySpaceAction */;
}
- if (ruleAction & 2 /* StopProcessingTokenActions */) {
- mask |= 96 /* ModifyTokenAction */;
+ if (ruleAction & 2 /* RuleAction.StopProcessingTokenActions */) {
+ mask |= 96 /* RuleAction.ModifyTokenAction */;
}
- if (ruleAction & 28 /* ModifySpaceAction */) {
- mask |= 28 /* ModifySpaceAction */;
+ if (ruleAction & 28 /* RuleAction.ModifySpaceAction */) {
+ mask |= 28 /* RuleAction.ModifySpaceAction */;
}
- if (ruleAction & 96 /* ModifyTokenAction */) {
- mask |= 96 /* ModifyTokenAction */;
+ if (ruleAction & 96 /* RuleAction.ModifyTokenAction */) {
+ mask |= 96 /* RuleAction.ModifyTokenAction */;
}
return mask;
}
@@ -144311,12 +146833,12 @@ var ts;
return map;
}
function getRuleBucketIndex(row, column) {
- ts.Debug.assert(row <= 159 /* LastKeyword */ && column <= 159 /* LastKeyword */, "Must compute formatting context from tokens");
+ ts.Debug.assert(row <= 160 /* SyntaxKind.LastKeyword */ && column <= 160 /* SyntaxKind.LastKeyword */, "Must compute formatting context from tokens");
return (row * mapRowLength) + column;
}
var maskBitSize = 5;
var mask = 31; // MaskBitSize bits
- var mapRowLength = 159 /* LastToken */ + 1;
+ var mapRowLength = 160 /* SyntaxKind.LastToken */ + 1;
var RulesPosition;
(function (RulesPosition) {
RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific";
@@ -144342,7 +146864,7 @@ var ts;
// In order to insert a rule to the end of sub-bucket (3), we get the index by adding
// the values in the bitmap segments 3rd, 2nd, and 1st.
function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) {
- var position = rule.action & 3 /* StopAction */ ?
+ var position = rule.action & 3 /* RuleAction.StopAction */ ?
specificTokens ? RulesPosition.StopRulesSpecific : RulesPosition.StopRulesAny :
rule.context !== formatting.anyContext ?
specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny :
@@ -144411,16 +146933,16 @@ var ts;
// end value is exclusive so add 1 to the result
end: endOfFormatSpan + 1
};
- return formatSpan(span, sourceFile, formatContext, 2 /* FormatOnEnter */);
+ return formatSpan(span, sourceFile, formatContext, 2 /* FormattingRequestKind.FormatOnEnter */);
}
formatting.formatOnEnter = formatOnEnter;
function formatOnSemicolon(position, sourceFile, formatContext) {
- var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SemicolonToken */, sourceFile);
- return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormatOnSemicolon */);
+ var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SyntaxKind.SemicolonToken */, sourceFile);
+ return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormattingRequestKind.FormatOnSemicolon */);
}
formatting.formatOnSemicolon = formatOnSemicolon;
function formatOnOpeningCurly(position, sourceFile, formatContext) {
- var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* OpenBraceToken */, sourceFile);
+ var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* SyntaxKind.OpenBraceToken */, sourceFile);
if (!openingCurly) {
return [];
}
@@ -144442,12 +146964,12 @@ var ts;
pos: ts.getLineStartPositionForPosition(outermostNode.getStart(sourceFile), sourceFile),
end: position
};
- return formatSpan(textRange, sourceFile, formatContext, 4 /* FormatOnOpeningCurlyBrace */);
+ return formatSpan(textRange, sourceFile, formatContext, 4 /* FormattingRequestKind.FormatOnOpeningCurlyBrace */);
}
formatting.formatOnOpeningCurly = formatOnOpeningCurly;
function formatOnClosingCurly(position, sourceFile, formatContext) {
- var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* CloseBraceToken */, sourceFile);
- return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormatOnClosingCurlyBrace */);
+ var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* SyntaxKind.CloseBraceToken */, sourceFile);
+ return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormattingRequestKind.FormatOnClosingCurlyBrace */);
}
formatting.formatOnClosingCurly = formatOnClosingCurly;
function formatDocument(sourceFile, formatContext) {
@@ -144455,7 +146977,7 @@ var ts;
pos: 0,
end: sourceFile.text.length
};
- return formatSpan(span, sourceFile, formatContext, 0 /* FormatDocument */);
+ return formatSpan(span, sourceFile, formatContext, 0 /* FormattingRequestKind.FormatDocument */);
}
formatting.formatDocument = formatDocument;
function formatSelection(start, end, sourceFile, formatContext) {
@@ -144464,7 +146986,7 @@ var ts;
pos: ts.getLineStartPositionForPosition(start, sourceFile),
end: end,
};
- return formatSpan(span, sourceFile, formatContext, 1 /* FormatSelection */);
+ return formatSpan(span, sourceFile, formatContext, 1 /* FormattingRequestKind.FormatSelection */);
}
formatting.formatSelection = formatSelection;
/**
@@ -144504,17 +147026,17 @@ var ts;
// i.e. parent is class declaration with the list of members and node is one of members.
function isListElement(parent, node) {
switch (parent.kind) {
- case 256 /* ClassDeclaration */:
- case 257 /* InterfaceDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
return ts.rangeContainsRange(parent.members, node);
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
var body = parent.body;
- return !!body && body.kind === 261 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node);
- case 303 /* SourceFile */:
- case 234 /* Block */:
- case 261 /* ModuleBlock */:
+ return !!body && body.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.rangeContainsRange(body.statements, node);
+ case 305 /* SyntaxKind.SourceFile */:
+ case 235 /* SyntaxKind.Block */:
+ case 262 /* SyntaxKind.ModuleBlock */:
return ts.rangeContainsRange(parent.statements, node);
- case 291 /* CatchClause */:
+ case 292 /* SyntaxKind.CatchClause */:
return ts.rangeContainsRange(parent.block.statements, node);
}
return false;
@@ -144611,11 +147133,11 @@ var ts;
* to the initial indentation.
*/
function getOwnOrInheritedDelta(n, options, sourceFile) {
- var previousLine = -1 /* Unknown */;
+ var previousLine = -1 /* Constants.Unknown */;
var child;
while (n) {
var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line;
- if (previousLine !== -1 /* Unknown */ && line !== previousLine) {
+ if (previousLine !== -1 /* Constants.Unknown */ && line !== previousLine) {
break;
}
if (formatting.SmartIndenter.shouldIndentChildNode(options, n, child, sourceFile)) {
@@ -144629,7 +147151,7 @@ var ts;
}
function formatNodeGivenIndentation(node, sourceFileLike, languageVariant, initialIndentation, delta, formatContext) {
var range = { pos: node.pos, end: node.end };
- return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, formatContext, 1 /* FormatSelection */, function (_) { return false; }, // assume that node does not have any errors
+ return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, formatContext, 1 /* FormattingRequestKind.FormatSelection */, function (_) { return false; }, // assume that node does not have any errors
sourceFileLike); });
}
formatting.formatNodeGivenIndentation = formatNodeGivenIndentation;
@@ -144649,6 +147171,7 @@ var ts;
return formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end, function (scanner) { return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, formatContext.options), getOwnOrInheritedDelta(enclosingNode, formatContext.options, sourceFile), scanner, formatContext, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); });
}
function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, _a, requestKind, rangeContainsError, sourceFile) {
+ var _b;
var options = _a.options, getRules = _a.getRules, host = _a.host;
// formatting context is used by rules provider
var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options);
@@ -144656,7 +147179,7 @@ var ts;
var previousParent;
var previousRangeStartLine;
var lastIndentedLine;
- var indentationOnLastIndentedLine = -1 /* Unknown */;
+ var indentationOnLastIndentedLine = -1 /* Constants.Unknown */;
var edits = [];
formattingScanner.advance();
if (formattingScanner.isOnToken()) {
@@ -144680,11 +147203,12 @@ var ts;
}
}
if (previousRange && formattingScanner.getStartPos() >= originalRange.end) {
- var token = formattingScanner.isOnEOF() ? formattingScanner.readEOFTokenRange() :
+ var tokenInfo = formattingScanner.isOnEOF() ? formattingScanner.readEOFTokenRange() :
formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(enclosingNode).token :
undefined;
- if (token) {
- processPair(token, sourceFile.getLineAndCharacterOfPosition(token.pos).line, enclosingNode, previousRange, previousRangeStartLine, previousParent, enclosingNode,
+ if (tokenInfo) {
+ var parent = ((_b = ts.findPrecedingToken(tokenInfo.end, sourceFile, enclosingNode)) === null || _b === void 0 ? void 0 : _b.parent) || previousParent;
+ processPair(tokenInfo, sourceFile.getLineAndCharacterOfPosition(tokenInfo.pos).line, parent, previousRange, previousRangeStartLine, previousParent, parent,
/*dynamicIndentation*/ undefined);
}
}
@@ -144700,7 +147224,7 @@ var ts;
function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) {
if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos) ||
ts.rangeContainsStartEnd(range, startPos, endPos) /* Not to miss zero-range nodes e.g. JsxText */) {
- if (inheritedIndentation !== -1 /* Unknown */) {
+ if (inheritedIndentation !== -1 /* Constants.Unknown */) {
return inheritedIndentation;
}
}
@@ -144715,7 +147239,7 @@ var ts;
return baseIndentSize > column ? baseIndentSize : column;
}
}
- return -1 /* Unknown */;
+ return -1 /* Constants.Unknown */;
}
function computeIndentation(node, startLine, inheritedIndentation, parent, parentDynamicIndentation, effectiveParentStartLine) {
var delta = formatting.SmartIndenter.shouldIndentChildNode(options, node) ? options.indentSize : 0;
@@ -144728,8 +147252,8 @@ var ts;
delta: Math.min(options.indentSize, parentDynamicIndentation.getDelta(node) + delta)
};
}
- else if (inheritedIndentation === -1 /* Unknown */) {
- if (node.kind === 20 /* OpenParenToken */ && startLine === lastIndentedLine) {
+ else if (inheritedIndentation === -1 /* Constants.Unknown */) {
+ if (node.kind === 20 /* SyntaxKind.OpenParenToken */ && startLine === lastIndentedLine) {
// the is used for chaining methods formatting
// - we need to get the indentation on last line and the delta of parent
return { indentation: indentationOnLastIndentedLine, delta: parentDynamicIndentation.getDelta(node) };
@@ -144752,19 +147276,19 @@ var ts;
return node.modifiers[0].kind;
}
switch (node.kind) {
- case 256 /* ClassDeclaration */: return 84 /* ClassKeyword */;
- case 257 /* InterfaceDeclaration */: return 118 /* InterfaceKeyword */;
- case 255 /* FunctionDeclaration */: return 98 /* FunctionKeyword */;
- case 259 /* EnumDeclaration */: return 259 /* EnumDeclaration */;
- case 171 /* GetAccessor */: return 136 /* GetKeyword */;
- case 172 /* SetAccessor */: return 148 /* SetKeyword */;
- case 168 /* MethodDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */: return 84 /* SyntaxKind.ClassKeyword */;
+ case 258 /* SyntaxKind.InterfaceDeclaration */: return 118 /* SyntaxKind.InterfaceKeyword */;
+ case 256 /* SyntaxKind.FunctionDeclaration */: return 98 /* SyntaxKind.FunctionKeyword */;
+ case 260 /* SyntaxKind.EnumDeclaration */: return 260 /* SyntaxKind.EnumDeclaration */;
+ case 172 /* SyntaxKind.GetAccessor */: return 136 /* SyntaxKind.GetKeyword */;
+ case 173 /* SyntaxKind.SetAccessor */: return 149 /* SyntaxKind.SetKeyword */;
+ case 169 /* SyntaxKind.MethodDeclaration */:
if (node.asteriskToken) {
- return 41 /* AsteriskToken */;
+ return 41 /* SyntaxKind.AsteriskToken */;
}
// falls through
- case 166 /* PropertyDeclaration */:
- case 163 /* Parameter */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 164 /* SyntaxKind.Parameter */:
var name = ts.getNameOfDeclaration(node);
if (name) {
return name.kind;
@@ -144779,12 +147303,12 @@ var ts;
// .. {
// // comment
// }
- case 19 /* CloseBraceToken */:
- case 23 /* CloseBracketToken */:
- case 21 /* CloseParenToken */:
+ case 19 /* SyntaxKind.CloseBraceToken */:
+ case 23 /* SyntaxKind.CloseBracketToken */:
+ case 21 /* SyntaxKind.CloseParenToken */:
return indentation + getDelta(container);
}
- return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation;
+ return tokenIndentation !== -1 /* Constants.Unknown */ ? tokenIndentation : indentation;
},
// if list end token is LessThanToken '>' then its delta should be explicitly suppressed
// so that LessThanToken as a binary operator can still be indented.
@@ -144811,26 +147335,26 @@ var ts;
function shouldAddDelta(line, kind, container) {
switch (kind) {
// open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent
- case 18 /* OpenBraceToken */:
- case 19 /* CloseBraceToken */:
- case 21 /* CloseParenToken */:
- case 91 /* ElseKeyword */:
- case 115 /* WhileKeyword */:
- case 59 /* AtToken */:
+ case 18 /* SyntaxKind.OpenBraceToken */:
+ case 19 /* SyntaxKind.CloseBraceToken */:
+ case 21 /* SyntaxKind.CloseParenToken */:
+ case 91 /* SyntaxKind.ElseKeyword */:
+ case 115 /* SyntaxKind.WhileKeyword */:
+ case 59 /* SyntaxKind.AtToken */:
return false;
- case 43 /* SlashToken */:
- case 31 /* GreaterThanToken */:
+ case 43 /* SyntaxKind.SlashToken */:
+ case 31 /* SyntaxKind.GreaterThanToken */:
switch (container.kind) {
- case 279 /* JsxOpeningElement */:
- case 280 /* JsxClosingElement */:
- case 278 /* JsxSelfClosingElement */:
- case 227 /* ExpressionWithTypeArguments */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
+ case 281 /* SyntaxKind.JsxClosingElement */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
return false;
}
break;
- case 22 /* OpenBracketToken */:
- case 23 /* CloseBracketToken */:
- if (container.kind !== 194 /* MappedType */) {
+ case 22 /* SyntaxKind.OpenBracketToken */:
+ case 23 /* SyntaxKind.CloseBracketToken */:
+ if (container.kind !== 195 /* SyntaxKind.MappedType */) {
return false;
}
break;
@@ -144865,7 +147389,7 @@ var ts;
// if there are any tokens that logically belong to node and interleave child nodes
// such tokens will be consumed in processChildNode for the child that follows them
ts.forEachChild(node, function (child) {
- processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false);
+ processChildNode(child, /*inheritedIndentation*/ -1 /* Constants.Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false);
}, function (nodes) {
processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation);
});
@@ -144878,6 +147402,9 @@ var ts;
consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node);
}
function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) {
+ if (ts.nodeIsMissing(child)) {
+ return inheritedIndentation;
+ }
var childStartPos = child.getStart(sourceFile);
var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line;
var undecoratedChildStartLine = childStartLine;
@@ -144885,10 +147412,10 @@ var ts;
undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(child, sourceFile)).line;
}
// if child is a list item - try to get its indentation, only if parent is within the original range.
- var childIndentationAmount = -1 /* Unknown */;
+ var childIndentationAmount = -1 /* Constants.Unknown */;
if (isListItem && ts.rangeContainsRange(originalRange, parent)) {
childIndentationAmount = tryComputeIndentationForListItem(childStartPos, child.end, parentStartLine, originalRange, inheritedIndentation);
- if (childIndentationAmount !== -1 /* Unknown */) {
+ if (childIndentationAmount !== -1 /* Constants.Unknown */) {
inheritedIndentation = childIndentationAmount;
}
}
@@ -144924,17 +147451,17 @@ var ts;
// if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules
var tokenInfo = formattingScanner.readTokenInfo(child);
// JSX text shouldn't affect indenting
- if (child.kind !== 11 /* JsxText */) {
+ if (child.kind !== 11 /* SyntaxKind.JsxText */) {
ts.Debug.assert(tokenInfo.token.end === child.end, "Token end is child end");
consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child);
return inheritedIndentation;
}
}
- var effectiveParentStartLine = child.kind === 164 /* Decorator */ ? childStartLine : undecoratedParentStartLine;
+ var effectiveParentStartLine = child.kind === 165 /* SyntaxKind.Decorator */ ? childStartLine : undecoratedParentStartLine;
var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine);
processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta);
childContextNode = node;
- if (isFirstListItem && parent.kind === 203 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) {
+ if (isFirstListItem && parent.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && inheritedIndentation === -1 /* Constants.Unknown */) {
inheritedIndentation = childIndentation.indentation;
}
return inheritedIndentation;
@@ -144944,7 +147471,14 @@ var ts;
var listStartToken = getOpenTokenForList(parent, nodes);
var listDynamicIndentation = parentDynamicIndentation;
var startLine = parentStartLine;
- if (listStartToken !== 0 /* Unknown */) {
+ // node range is outside the target range - do not dive inside
+ if (!ts.rangeOverlapsWithStartEnd(originalRange, nodes.pos, nodes.end)) {
+ if (nodes.end < originalRange.pos) {
+ formattingScanner.skipToEndOf(nodes);
+ }
+ return;
+ }
+ if (listStartToken !== 0 /* SyntaxKind.Unknown */) {
// introduce a new indentation scope for lists (including list start and end tokens)
while (formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) {
var tokenInfo = formattingScanner.readTokenInfo(parent);
@@ -144957,7 +147491,7 @@ var ts;
startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line;
consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent);
var indentationOnListStartToken = void 0;
- if (indentationOnLastIndentedLine !== -1 /* Unknown */) {
+ if (indentationOnLastIndentedLine !== -1 /* Constants.Unknown */) {
// scanner just processed list start token so consider last indentation as list indentation
// function foo(): { // last indentation was 0, list item will be indented based on this value
// foo: number;
@@ -144976,15 +147510,15 @@ var ts;
}
}
}
- var inheritedIndentation = -1 /* Unknown */;
+ var inheritedIndentation = -1 /* Constants.Unknown */;
for (var i = 0; i < nodes.length; i++) {
var child = nodes[i];
inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListItem*/ true, /*isFirstListItem*/ i === 0);
}
var listEndToken = getCloseTokenForOpenToken(listStartToken);
- if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) {
+ if (listEndToken !== 0 /* SyntaxKind.Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) {
var tokenInfo = formattingScanner.readTokenInfo(parent);
- if (tokenInfo.token.kind === 27 /* CommaToken */ && ts.isCallLikeExpression(parent)) {
+ if (tokenInfo.token.kind === 27 /* SyntaxKind.CommaToken */ && ts.isCallLikeExpression(parent)) {
var commaTokenLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line;
if (startLine !== commaTokenLine) {
formattingScanner.advance();
@@ -145008,7 +147542,7 @@ var ts;
if (currentTokenInfo.leadingTrivia) {
processTrivia(currentTokenInfo.leadingTrivia, parent, childContextNode, dynamicIndentation);
}
- var lineAction = 0 /* None */;
+ var lineAction = 0 /* LineAction.None */;
var isTokenInRange = ts.rangeContainsRange(originalRange, currentTokenInfo.token);
var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos);
if (isTokenInRange) {
@@ -145018,13 +147552,13 @@ var ts;
lineAction = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation);
// do not indent comments\token if token range overlaps with some error
if (!rangeHasError) {
- if (lineAction === 0 /* None */) {
+ if (lineAction === 0 /* LineAction.None */) {
// indent token only if end line of previous range does not match start line of the token
var prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line;
indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine;
}
else {
- indentToken = lineAction === 1 /* LineAdded */;
+ indentToken = lineAction === 1 /* LineAction.LineAdded */;
}
}
}
@@ -145034,15 +147568,15 @@ var ts;
if (indentToken) {
var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ?
dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container, !!isListEndToken) :
- -1 /* Unknown */;
+ -1 /* Constants.Unknown */;
var indentNextTokenOrTrivia = true;
if (currentTokenInfo.leadingTrivia) {
var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container);
indentNextTokenOrTrivia = indentTriviaItems(currentTokenInfo.leadingTrivia, commentIndentation_1, indentNextTokenOrTrivia, function (item) { return insertIndentation(item.pos, commentIndentation_1, /*lineAdded*/ false); });
}
// indent token only if is it is in target range and does not overlap with any error ranges
- if (tokenIndentation !== -1 /* Unknown */ && indentNextTokenOrTrivia) {
- insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAction === 1 /* LineAdded */);
+ if (tokenIndentation !== -1 /* Constants.Unknown */ && indentNextTokenOrTrivia) {
+ insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAction === 1 /* LineAction.LineAdded */);
lastIndentedLine = tokenStart.line;
indentationOnLastIndentedLine = tokenIndentation;
}
@@ -145056,19 +147590,19 @@ var ts;
var triviaItem = trivia_1[_i];
var triviaInRange = ts.rangeContainsRange(originalRange, triviaItem);
switch (triviaItem.kind) {
- case 3 /* MultiLineCommentTrivia */:
+ case 3 /* SyntaxKind.MultiLineCommentTrivia */:
if (triviaInRange) {
indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia);
}
indentNextTokenOrTrivia = false;
break;
- case 2 /* SingleLineCommentTrivia */:
+ case 2 /* SyntaxKind.SingleLineCommentTrivia */:
if (indentNextTokenOrTrivia && triviaInRange) {
indentSingleLine(triviaItem);
}
indentNextTokenOrTrivia = false;
break;
- case 4 /* NewLineTrivia */:
+ case 4 /* SyntaxKind.NewLineTrivia */:
indentNextTokenOrTrivia = true;
break;
}
@@ -145086,7 +147620,7 @@ var ts;
}
function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) {
var rangeHasError = rangeContainsError(range);
- var lineAction = 0 /* None */;
+ var lineAction = 0 /* LineAction.None */;
if (!rangeHasError) {
if (!previousRange) {
// trim whitespaces starting from the beginning of the span up to the current line
@@ -145107,7 +147641,7 @@ var ts;
formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode);
var rules = getRules(formattingContext);
var trimTrailingWhitespaces = formattingContext.options.trimTrailingWhitespace !== false;
- var lineAction = 0 /* None */;
+ var lineAction = 0 /* LineAction.None */;
if (rules) {
// Apply rules in reverse order so that higher priority rules (which are first in the array)
// win in a conflict with lower priority rules.
@@ -145115,14 +147649,14 @@ var ts;
lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine);
if (dynamicIndentation) {
switch (lineAction) {
- case 2 /* LineRemoved */:
+ case 2 /* LineAction.LineRemoved */:
// Handle the case where the next line is moved to be the end of this line.
// In this case we don't indent the next line in the next pass.
if (currentParent.getStart(sourceFile) === currentItem.pos) {
dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false, contextNode);
}
break;
- case 1 /* LineAdded */:
+ case 1 /* LineAction.LineAdded */:
// Handle the case where token2 is moved to the new line.
// In this case we indent token2 in the next pass but we set
// sameLineIndent flag to notify the indenter that the indentation is within the line.
@@ -145131,15 +147665,15 @@ var ts;
}
break;
default:
- ts.Debug.assert(lineAction === 0 /* None */);
+ ts.Debug.assert(lineAction === 0 /* LineAction.None */);
}
}
// We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line
- trimTrailingWhitespaces = trimTrailingWhitespaces && !(rule.action & 16 /* DeleteSpace */) && rule.flags !== 1 /* CanDeleteNewLines */;
+ trimTrailingWhitespaces = trimTrailingWhitespaces && !(rule.action & 16 /* RuleAction.DeleteSpace */) && rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */;
});
}
else {
- trimTrailingWhitespaces = trimTrailingWhitespaces && currentItem.kind !== 1 /* EndOfFileToken */;
+ trimTrailingWhitespaces = trimTrailingWhitespaces && currentItem.kind !== 1 /* SyntaxKind.EndOfFileToken */;
}
if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) {
// We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line
@@ -145165,7 +147699,7 @@ var ts;
function characterToColumn(startLinePosition, characterInLine) {
var column = 0;
for (var i = 0; i < characterInLine; i++) {
- if (sourceFile.text.charCodeAt(startLinePosition + i) === 9 /* tab */) {
+ if (sourceFile.text.charCodeAt(startLinePosition + i) === 9 /* CharacterCodes.tab */) {
column += options.tabSize - column % options.tabSize;
}
else {
@@ -145296,48 +147830,48 @@ var ts;
function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) {
var onLaterLine = currentStartLine !== previousStartLine;
switch (rule.action) {
- case 1 /* StopProcessingSpaceActions */:
+ case 1 /* RuleAction.StopProcessingSpaceActions */:
// no action required
- return 0 /* None */;
- case 16 /* DeleteSpace */:
+ return 0 /* LineAction.None */;
+ case 16 /* RuleAction.DeleteSpace */:
if (previousRange.end !== currentRange.pos) {
// delete characters starting from t1.end up to t2.pos exclusive
recordDelete(previousRange.end, currentRange.pos - previousRange.end);
- return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */;
+ return onLaterLine ? 2 /* LineAction.LineRemoved */ : 0 /* LineAction.None */;
}
break;
- case 32 /* DeleteToken */:
+ case 32 /* RuleAction.DeleteToken */:
recordDelete(previousRange.pos, previousRange.end - previousRange.pos);
break;
- case 8 /* InsertNewLine */:
+ case 8 /* RuleAction.InsertNewLine */:
// exit early if we on different lines and rule cannot change number of newlines
// if line1 and line2 are on subsequent lines then no edits are required - ok to exit
// if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines
- if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) {
- return 0 /* None */;
+ if (rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */ && previousStartLine !== currentStartLine) {
+ return 0 /* LineAction.None */;
}
// edit should not be applied if we have one line feed between elements
var lineDelta = currentStartLine - previousStartLine;
if (lineDelta !== 1) {
recordReplace(previousRange.end, currentRange.pos - previousRange.end, ts.getNewLineOrDefaultFromHost(host, options));
- return onLaterLine ? 0 /* None */ : 1 /* LineAdded */;
+ return onLaterLine ? 0 /* LineAction.None */ : 1 /* LineAction.LineAdded */;
}
break;
- case 4 /* InsertSpace */:
+ case 4 /* RuleAction.InsertSpace */:
// exit early if we on different lines and rule cannot change number of newlines
- if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) {
- return 0 /* None */;
+ if (rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */ && previousStartLine !== currentStartLine) {
+ return 0 /* LineAction.None */;
}
var posDelta = currentRange.pos - previousRange.end;
- if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* space */) {
+ if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* CharacterCodes.space */) {
recordReplace(previousRange.end, currentRange.pos - previousRange.end, " ");
- return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */;
+ return onLaterLine ? 2 /* LineAction.LineRemoved */ : 0 /* LineAction.None */;
}
break;
- case 64 /* InsertTrailingSemicolon */:
+ case 64 /* RuleAction.InsertTrailingSemicolon */:
recordInsert(previousRange.end, ";");
}
- return 0 /* None */;
+ return 0 /* LineAction.None */;
}
}
var LineAction;
@@ -145379,53 +147913,53 @@ var ts;
//
// Internally, we represent the end of the comment at the newline and closing '/', respectively.
//
- position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); });
+ position === range.end && (range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); });
}
formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment;
function getOpenTokenForList(node, list) {
switch (node.kind) {
- case 170 /* Constructor */:
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 213 /* ArrowFunction */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 214 /* SyntaxKind.ArrowFunction */:
if (node.typeParameters === list) {
- return 29 /* LessThanToken */;
+ return 29 /* SyntaxKind.LessThanToken */;
}
else if (node.parameters === list) {
- return 20 /* OpenParenToken */;
+ return 20 /* SyntaxKind.OpenParenToken */;
}
break;
- case 207 /* CallExpression */:
- case 208 /* NewExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
if (node.typeArguments === list) {
- return 29 /* LessThanToken */;
+ return 29 /* SyntaxKind.LessThanToken */;
}
else if (node.arguments === list) {
- return 20 /* OpenParenToken */;
+ return 20 /* SyntaxKind.OpenParenToken */;
}
break;
- case 177 /* TypeReference */:
+ case 178 /* SyntaxKind.TypeReference */:
if (node.typeArguments === list) {
- return 29 /* LessThanToken */;
+ return 29 /* SyntaxKind.LessThanToken */;
}
break;
- case 181 /* TypeLiteral */:
- return 18 /* OpenBraceToken */;
+ case 182 /* SyntaxKind.TypeLiteral */:
+ return 18 /* SyntaxKind.OpenBraceToken */;
}
- return 0 /* Unknown */;
+ return 0 /* SyntaxKind.Unknown */;
}
function getCloseTokenForOpenToken(kind) {
switch (kind) {
- case 20 /* OpenParenToken */:
- return 21 /* CloseParenToken */;
- case 29 /* LessThanToken */:
- return 31 /* GreaterThanToken */;
- case 18 /* OpenBraceToken */:
- return 19 /* CloseBraceToken */;
+ case 20 /* SyntaxKind.OpenParenToken */:
+ return 21 /* SyntaxKind.CloseParenToken */;
+ case 29 /* SyntaxKind.LessThanToken */:
+ return 31 /* SyntaxKind.GreaterThanToken */;
+ case 18 /* SyntaxKind.OpenBraceToken */:
+ return 19 /* SyntaxKind.CloseBraceToken */;
}
- return 0 /* Unknown */;
+ return 0 /* SyntaxKind.Unknown */;
}
var internedSizes;
var internedTabsIndentation;
@@ -145511,7 +148045,7 @@ var ts;
var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true);
// eslint-disable-next-line no-null/no-null
var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null);
- if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) {
+ if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) {
return getCommentIndent(sourceFile, position, options, enclosingCommentRange);
}
if (!precedingToken) {
@@ -145526,20 +148060,44 @@ var ts;
// indentation is first non-whitespace character in a previous line
// for block indentation, we should look for a line which contains something that's not
// whitespace.
- if (options.indentStyle === ts.IndentStyle.Block) {
+ var currentToken = ts.getTokenAtPosition(sourceFile, position);
+ // For object literals, we want indentation to work just like with blocks.
+ // If the `{` starts in any position (even in the middle of a line), then
+ // the following indentation should treat `{` as the start of that line (including leading whitespace).
+ // ```
+ // const a: { x: undefined, y: undefined } = {} // leading 4 whitespaces and { starts in the middle of line
+ // ->
+ // const a: { x: undefined, y: undefined } = {
+ // x: undefined,
+ // y: undefined,
+ // }
+ // ---------------------
+ // const a: {x : undefined, y: undefined } =
+ // {}
+ // ->
+ // const a: { x: undefined, y: undefined } =
+ // { // leading 5 whitespaces and { starts at 6 column
+ // x: undefined,
+ // y: undefined,
+ // }
+ // ```
+ var isObjectLiteral = currentToken.kind === 18 /* SyntaxKind.OpenBraceToken */ && currentToken.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */;
+ if (options.indentStyle === ts.IndentStyle.Block || isObjectLiteral) {
return getBlockIndent(sourceFile, position, options);
}
- if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 220 /* BinaryExpression */) {
+ if (precedingToken.kind === 27 /* SyntaxKind.CommaToken */ && precedingToken.parent.kind !== 221 /* SyntaxKind.BinaryExpression */) {
// previous token is comma that separates items in list - find the previous item and try to derive indentation from it
var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options);
- if (actualIndentation !== -1 /* Unknown */) {
+ if (actualIndentation !== -1 /* Value.Unknown */) {
return actualIndentation;
}
}
var containerList = getListByPosition(position, precedingToken.parent, sourceFile);
// use list position if the preceding token is before any list items
if (containerList && !ts.rangeContainsRange(containerList, precedingToken)) {
- return getActualIndentationForListStartLine(containerList, sourceFile, options) + options.indentSize; // TODO: GH#18217
+ var useTheSameBaseIndentation = [213 /* SyntaxKind.FunctionExpression */, 214 /* SyntaxKind.ArrowFunction */].indexOf(currentToken.parent.kind) !== -1;
+ var indentSize = useTheSameBaseIndentation ? 0 : options.indentSize;
+ return getActualIndentationForListStartLine(containerList, sourceFile, options) + indentSize; // TODO: GH#18217
}
return getSmartIndent(sourceFile, position, precedingToken, lineAtPosition, assumeNewLineBeforeCloseBrace, options);
}
@@ -145557,7 +148115,7 @@ var ts;
return column;
}
var firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPositionOfLine + character);
- return firstNonWhitespaceCharacterCode === 42 /* asterisk */ ? column - 1 : column;
+ return firstNonWhitespaceCharacterCode === 42 /* CharacterCodes.asterisk */ ? column - 1 : column;
}
function getBlockIndent(sourceFile, position, options) {
// move backwards until we find a line with a non-whitespace character,
@@ -145582,9 +148140,9 @@ var ts;
if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(options, current, previous, sourceFile, /*isNextChild*/ true)) {
var currentStart = getStartLineAndCharacterForNode(current, sourceFile);
var nextTokenKind = nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile);
- var indentationDelta = nextTokenKind !== 0 /* Unknown */
+ var indentationDelta = nextTokenKind !== 0 /* NextTokenKind.Unknown */
// handle cases when codefix is about to be inserted before the close brace
- ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* CloseBrace */ ? options.indentSize : 0
+ ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* NextTokenKind.CloseBrace */ ? options.indentSize : 0
: lineAtPosition !== currentStart.line ? options.indentSize : 0;
return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); // TODO: GH#18217
}
@@ -145593,7 +148151,7 @@ var ts;
// function foo(a
// | preceding node 'a' does share line with its parent but indentation is expected
var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, /*listIndentsChild*/ true);
- if (actualIndentation !== -1 /* Unknown */) {
+ if (actualIndentation !== -1 /* Value.Unknown */) {
return actualIndentation;
}
previous = current;
@@ -145647,12 +148205,12 @@ var ts;
// }) looking at the relationship between the list and *first* list item.
var listIndentsChild = !!firstListChild && getStartLineAndCharacterForNode(firstListChild, sourceFile).line > containingListOrParentStart.line;
var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, listIndentsChild);
- if (actualIndentation !== -1 /* Unknown */) {
+ if (actualIndentation !== -1 /* Value.Unknown */) {
return actualIndentation + indentationDelta;
}
// try to fetch actual indentation for current node from source text
actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options);
- if (actualIndentation !== -1 /* Unknown */) {
+ if (actualIndentation !== -1 /* Value.Unknown */) {
return actualIndentation + indentationDelta;
}
}
@@ -145691,7 +148249,7 @@ var ts;
}
else {
// handle broken code gracefully
- return -1 /* Unknown */;
+ return -1 /* Value.Unknown */;
}
}
/*
@@ -145702,9 +148260,9 @@ var ts;
// - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually
// - parent and child are not on the same line
var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) &&
- (parent.kind === 303 /* SourceFile */ || !parentAndChildShareLine);
+ (parent.kind === 305 /* SyntaxKind.SourceFile */ || !parentAndChildShareLine);
if (!useActualIndentation) {
- return -1 /* Unknown */;
+ return -1 /* Value.Unknown */;
}
return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options);
}
@@ -145717,13 +148275,13 @@ var ts;
function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) {
var nextToken = ts.findNextToken(precedingToken, current, sourceFile);
if (!nextToken) {
- return 0 /* Unknown */;
+ return 0 /* NextTokenKind.Unknown */;
}
- if (nextToken.kind === 18 /* OpenBraceToken */) {
+ if (nextToken.kind === 18 /* SyntaxKind.OpenBraceToken */) {
// open braces are always indented at the parent level
- return 1 /* OpenBrace */;
+ return 1 /* NextTokenKind.OpenBrace */;
}
- else if (nextToken.kind === 19 /* CloseBraceToken */) {
+ else if (nextToken.kind === 19 /* SyntaxKind.CloseBraceToken */) {
// close braces are indented at the parent level if they are located on the same line with cursor
// this means that if new line will be added at $ position, this case will be indented
// class A {
@@ -145733,9 +148291,9 @@ var ts;
// class A {
// $}
var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line;
- return lineAtPosition === nextTokenStartLine ? 2 /* CloseBrace */ : 0 /* Unknown */;
+ return lineAtPosition === nextTokenStartLine ? 2 /* NextTokenKind.CloseBrace */ : 0 /* NextTokenKind.Unknown */;
}
- return 0 /* Unknown */;
+ return 0 /* NextTokenKind.Unknown */;
}
function getStartLineAndCharacterForNode(n, sourceFile) {
return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile));
@@ -145750,8 +148308,8 @@ var ts;
}
SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled;
function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) {
- if (parent.kind === 238 /* IfStatement */ && parent.elseStatement === child) {
- var elseKeyword = ts.findChildOfKind(parent, 91 /* ElseKeyword */, sourceFile);
+ if (parent.kind === 239 /* SyntaxKind.IfStatement */ && parent.elseStatement === child) {
+ var elseKeyword = ts.findChildOfKind(parent, 91 /* SyntaxKind.ElseKeyword */, sourceFile);
ts.Debug.assert(elseKeyword !== undefined);
var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line;
return elseKeywordStartLine === childStartLine;
@@ -145831,42 +148389,42 @@ var ts;
}
function getListByRange(start, end, node, sourceFile) {
switch (node.kind) {
- case 177 /* TypeReference */:
+ case 178 /* SyntaxKind.TypeReference */:
return getList(node.typeArguments);
- case 204 /* ObjectLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
return getList(node.properties);
- case 203 /* ArrayLiteralExpression */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
return getList(node.elements);
- case 181 /* TypeLiteral */:
+ case 182 /* SyntaxKind.TypeLiteral */:
return getList(node.members);
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 173 /* CallSignature */:
- case 170 /* Constructor */:
- case 179 /* ConstructorType */:
- case 174 /* ConstructSignature */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 180 /* SyntaxKind.ConstructorType */:
+ case 175 /* SyntaxKind.ConstructSignature */:
return getList(node.typeParameters) || getList(node.parameters);
- case 171 /* GetAccessor */:
+ case 172 /* SyntaxKind.GetAccessor */:
return getList(node.parameters);
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- case 257 /* InterfaceDeclaration */:
- case 258 /* TypeAliasDeclaration */:
- case 342 /* JSDocTemplateTag */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 344 /* SyntaxKind.JSDocTemplateTag */:
return getList(node.typeParameters);
- case 208 /* NewExpression */:
- case 207 /* CallExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
return getList(node.typeArguments) || getList(node.arguments);
- case 254 /* VariableDeclarationList */:
+ case 255 /* SyntaxKind.VariableDeclarationList */:
return getList(node.declarations);
- case 268 /* NamedImports */:
- case 272 /* NamedExports */:
+ case 269 /* SyntaxKind.NamedImports */:
+ case 273 /* SyntaxKind.NamedExports */:
return getList(node.elements);
- case 200 /* ObjectBindingPattern */:
- case 201 /* ArrayBindingPattern */:
+ case 201 /* SyntaxKind.ObjectBindingPattern */:
+ case 202 /* SyntaxKind.ArrayBindingPattern */:
return getList(node.elements);
}
function getList(list) {
@@ -145884,27 +148442,27 @@ var ts;
}
function getActualIndentationForListStartLine(list, sourceFile, options) {
if (!list) {
- return -1 /* Unknown */;
+ return -1 /* Value.Unknown */;
}
return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options);
}
function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) {
- if (node.parent && node.parent.kind === 254 /* VariableDeclarationList */) {
+ if (node.parent && node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */) {
// VariableDeclarationList has no wrapping tokens
- return -1 /* Unknown */;
+ return -1 /* Value.Unknown */;
}
var containingList = getContainingList(node, sourceFile);
if (containingList) {
var index = containingList.indexOf(node);
if (index !== -1) {
var result = deriveActualIndentationFromList(containingList, index, sourceFile, options);
- if (result !== -1 /* Unknown */) {
+ if (result !== -1 /* Value.Unknown */) {
return result;
}
}
return getActualIndentationForListStartLine(containingList, sourceFile, options) + (listIndentsChild ? options.indentSize : 0); // TODO: GH#18217
}
- return -1 /* Unknown */;
+ return -1 /* Value.Unknown */;
}
function deriveActualIndentationFromList(list, index, sourceFile, options) {
ts.Debug.assert(index >= 0 && index < list.length);
@@ -145913,7 +148471,7 @@ var ts;
// if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i]
var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile);
for (var i = index - 1; i >= 0; i--) {
- if (list[i].kind === 27 /* CommaToken */) {
+ if (list[i].kind === 27 /* SyntaxKind.CommaToken */) {
continue;
}
// skip list items that ends on the same line with the current list element
@@ -145923,7 +148481,7 @@ var ts;
}
lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile);
}
- return -1 /* Unknown */;
+ return -1 /* Value.Unknown */;
}
function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) {
var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0);
@@ -145944,7 +148502,7 @@ var ts;
if (!ts.isWhiteSpaceSingleLine(ch)) {
break;
}
- if (ch === 9 /* tab */) {
+ if (ch === 9 /* CharacterCodes.tab */) {
column += options.tabSize + (column % options.tabSize);
}
else {
@@ -145960,98 +148518,98 @@ var ts;
}
SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn;
function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) {
- var childKind = child ? child.kind : 0 /* Unknown */;
+ var childKind = child ? child.kind : 0 /* SyntaxKind.Unknown */;
switch (parent.kind) {
- case 237 /* ExpressionStatement */:
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- case 257 /* InterfaceDeclaration */:
- case 259 /* EnumDeclaration */:
- case 258 /* TypeAliasDeclaration */:
- case 203 /* ArrayLiteralExpression */:
- case 234 /* Block */:
- case 261 /* ModuleBlock */:
- case 204 /* ObjectLiteralExpression */:
- case 181 /* TypeLiteral */:
- case 194 /* MappedType */:
- case 183 /* TupleType */:
- case 262 /* CaseBlock */:
- case 289 /* DefaultClause */:
- case 288 /* CaseClause */:
- case 211 /* ParenthesizedExpression */:
- case 205 /* PropertyAccessExpression */:
- case 207 /* CallExpression */:
- case 208 /* NewExpression */:
- case 236 /* VariableStatement */:
- case 270 /* ExportAssignment */:
- case 246 /* ReturnStatement */:
- case 221 /* ConditionalExpression */:
- case 201 /* ArrayBindingPattern */:
- case 200 /* ObjectBindingPattern */:
- case 279 /* JsxOpeningElement */:
- case 282 /* JsxOpeningFragment */:
- case 278 /* JsxSelfClosingElement */:
- case 287 /* JsxExpression */:
- case 167 /* MethodSignature */:
- case 173 /* CallSignature */:
- case 174 /* ConstructSignature */:
- case 163 /* Parameter */:
- case 178 /* FunctionType */:
- case 179 /* ConstructorType */:
- case 190 /* ParenthesizedType */:
- case 209 /* TaggedTemplateExpression */:
- case 217 /* AwaitExpression */:
- case 272 /* NamedExports */:
- case 268 /* NamedImports */:
- case 274 /* ExportSpecifier */:
- case 269 /* ImportSpecifier */:
- case 166 /* PropertyDeclaration */:
+ case 238 /* SyntaxKind.ExpressionStatement */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
+ case 235 /* SyntaxKind.Block */:
+ case 262 /* SyntaxKind.ModuleBlock */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
+ case 182 /* SyntaxKind.TypeLiteral */:
+ case 195 /* SyntaxKind.MappedType */:
+ case 184 /* SyntaxKind.TupleType */:
+ case 263 /* SyntaxKind.CaseBlock */:
+ case 290 /* SyntaxKind.DefaultClause */:
+ case 289 /* SyntaxKind.CaseClause */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
+ case 237 /* SyntaxKind.VariableStatement */:
+ case 271 /* SyntaxKind.ExportAssignment */:
+ case 247 /* SyntaxKind.ReturnStatement */:
+ case 222 /* SyntaxKind.ConditionalExpression */:
+ case 202 /* SyntaxKind.ArrayBindingPattern */:
+ case 201 /* SyntaxKind.ObjectBindingPattern */:
+ case 280 /* SyntaxKind.JsxOpeningElement */:
+ case 283 /* SyntaxKind.JsxOpeningFragment */:
+ case 279 /* SyntaxKind.JsxSelfClosingElement */:
+ case 288 /* SyntaxKind.JsxExpression */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 164 /* SyntaxKind.Parameter */:
+ case 179 /* SyntaxKind.FunctionType */:
+ case 180 /* SyntaxKind.ConstructorType */:
+ case 191 /* SyntaxKind.ParenthesizedType */:
+ case 210 /* SyntaxKind.TaggedTemplateExpression */:
+ case 218 /* SyntaxKind.AwaitExpression */:
+ case 273 /* SyntaxKind.NamedExports */:
+ case 269 /* SyntaxKind.NamedImports */:
+ case 275 /* SyntaxKind.ExportSpecifier */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
return true;
- case 253 /* VariableDeclaration */:
- case 294 /* PropertyAssignment */:
- case 220 /* BinaryExpression */:
- if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 204 /* ObjectLiteralExpression */) { // TODO: GH#18217
+ case 254 /* SyntaxKind.VariableDeclaration */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
+ case 221 /* SyntaxKind.BinaryExpression */:
+ if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // TODO: GH#18217
return rangeIsOnOneLine(sourceFile, child);
}
- if (parent.kind === 220 /* BinaryExpression */ && sourceFile && child && childKind === 277 /* JsxElement */) {
+ if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ && sourceFile && child && childKind === 278 /* SyntaxKind.JsxElement */) {
var parentStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, parent.pos)).line;
var childStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, child.pos)).line;
return parentStartLine !== childStartLine;
}
- if (parent.kind !== 220 /* BinaryExpression */) {
+ if (parent.kind !== 221 /* SyntaxKind.BinaryExpression */) {
return true;
}
break;
- case 239 /* DoStatement */:
- case 240 /* WhileStatement */:
- case 242 /* ForInStatement */:
- case 243 /* ForOfStatement */:
- case 241 /* ForStatement */:
- case 238 /* IfStatement */:
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 168 /* MethodDeclaration */:
- case 170 /* Constructor */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- return childKind !== 234 /* Block */;
- case 213 /* ArrowFunction */:
- if (sourceFile && childKind === 211 /* ParenthesizedExpression */) {
+ case 240 /* SyntaxKind.DoStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 239 /* SyntaxKind.IfStatement */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ return childKind !== 235 /* SyntaxKind.Block */;
+ case 214 /* SyntaxKind.ArrowFunction */:
+ if (sourceFile && childKind === 212 /* SyntaxKind.ParenthesizedExpression */) {
return rangeIsOnOneLine(sourceFile, child);
}
- return childKind !== 234 /* Block */;
- case 271 /* ExportDeclaration */:
- return childKind !== 272 /* NamedExports */;
- case 265 /* ImportDeclaration */:
- return childKind !== 266 /* ImportClause */ ||
- (!!child.namedBindings && child.namedBindings.kind !== 268 /* NamedImports */);
- case 277 /* JsxElement */:
- return childKind !== 280 /* JsxClosingElement */;
- case 281 /* JsxFragment */:
- return childKind !== 283 /* JsxClosingFragment */;
- case 187 /* IntersectionType */:
- case 186 /* UnionType */:
- if (childKind === 181 /* TypeLiteral */ || childKind === 183 /* TupleType */) {
+ return childKind !== 235 /* SyntaxKind.Block */;
+ case 272 /* SyntaxKind.ExportDeclaration */:
+ return childKind !== 273 /* SyntaxKind.NamedExports */;
+ case 266 /* SyntaxKind.ImportDeclaration */:
+ return childKind !== 267 /* SyntaxKind.ImportClause */ ||
+ (!!child.namedBindings && child.namedBindings.kind !== 269 /* SyntaxKind.NamedImports */);
+ case 278 /* SyntaxKind.JsxElement */:
+ return childKind !== 281 /* SyntaxKind.JsxClosingElement */;
+ case 282 /* SyntaxKind.JsxFragment */:
+ return childKind !== 284 /* SyntaxKind.JsxClosingFragment */;
+ case 188 /* SyntaxKind.IntersectionType */:
+ case 187 /* SyntaxKind.UnionType */:
+ if (childKind === 182 /* SyntaxKind.TypeLiteral */ || childKind === 184 /* SyntaxKind.TupleType */) {
return false;
}
break;
@@ -146062,11 +148620,11 @@ var ts;
SmartIndenter.nodeWillIndentChild = nodeWillIndentChild;
function isControlFlowEndingStatement(kind, parent) {
switch (kind) {
- case 246 /* ReturnStatement */:
- case 250 /* ThrowStatement */:
- case 244 /* ContinueStatement */:
- case 245 /* BreakStatement */:
- return parent.kind !== 234 /* Block */;
+ case 247 /* SyntaxKind.ReturnStatement */:
+ case 251 /* SyntaxKind.ThrowStatement */:
+ case 245 /* SyntaxKind.ContinueStatement */:
+ case 246 /* SyntaxKind.BreakStatement */:
+ return parent.kind !== 235 /* SyntaxKind.Block */;
default:
return false;
}
@@ -146156,7 +148714,7 @@ var ts;
i++;
continue;
}
- return ch === 47 /* slash */;
+ return ch === 47 /* CharacterCodes.slash */;
}
return false;
}
@@ -146240,7 +148798,7 @@ var ts;
var comment = comments_2[_i];
// Single line can break the loop as trivia will only be this line.
// Comments on subsequest lines are also ignored.
- if (comment.kind === 2 /* SingleLineCommentTrivia */ || ts.getLineOfLocalPosition(sourceFile, comment.pos) > nodeEndLine) {
+ if (comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || ts.getLineOfLocalPosition(sourceFile, comment.pos) > nodeEndLine) {
break;
}
// Get the end line of the comment and compare against the end line of the node.
@@ -146283,7 +148841,7 @@ var ts;
* Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element
*/
function isSeparator(node, candidate) {
- return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 204 /* ObjectLiteralExpression */));
+ return !!candidate && !!node.parent && (candidate.kind === 27 /* SyntaxKind.CommaToken */ || (candidate.kind === 26 /* SyntaxKind.SemicolonToken */ && node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */));
}
function isThisTypeAnnotatable(containingFunction) {
return ts.isFunctionExpression(containingFunction) || ts.isFunctionDeclaration(containingFunction);
@@ -146389,7 +148947,7 @@ var ts;
};
ChangeTracker.prototype.nextCommaToken = function (sourceFile, node) {
var next = ts.findNextToken(node, node.parent, sourceFile);
- return next && next.kind === 27 /* CommaToken */ ? next : undefined;
+ return next && next.kind === 27 /* SyntaxKind.CommaToken */ ? next : undefined;
};
ChangeTracker.prototype.replacePropertyAssignment = function (sourceFile, oldNode, newNode) {
var suffix = this.nextCommaToken(sourceFile, oldNode) ? "" : ("," + this.newLineCharacter);
@@ -146469,7 +149027,7 @@ var ts;
}
var startPosition = ts.getPrecedingNonSpaceCharacterPosition(sourceFile.text, fnStart - 1);
var indent = sourceFile.text.slice(startPosition, fnStart);
- this.insertNodeAt(sourceFile, fnStart, tag, { preserveLeadingWhitespace: false, suffix: this.newLineCharacter + indent });
+ this.insertNodeAt(sourceFile, fnStart, tag, { suffix: this.newLineCharacter + indent });
};
ChangeTracker.prototype.createJSDocText = function (sourceFile, node) {
var comments = ts.flatMap(node.jsDoc, function (jsDoc) {
@@ -146506,7 +149064,7 @@ var ts;
var _a;
var endNode;
if (ts.isFunctionLike(node)) {
- endNode = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile);
+ endNode = ts.findChildOfKind(node, 21 /* SyntaxKind.CloseParenToken */, sourceFile);
if (!endNode) {
if (!ts.isArrowFunction(node))
return false; // Function missing parentheses, give up
@@ -146515,19 +149073,19 @@ var ts;
}
}
else {
- endNode = (_a = (node.kind === 253 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name;
+ endNode = (_a = (node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name;
}
this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " });
return true;
};
ChangeTracker.prototype.tryInsertThisTypeAnnotation = function (sourceFile, node, type) {
- var start = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile).getStart(sourceFile) + 1;
+ var start = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile).getStart(sourceFile) + 1;
var suffix = node.parameters.length ? ", " : "";
this.insertNodeAt(sourceFile, start, type, { prefix: "this: ", suffix: suffix });
};
ChangeTracker.prototype.insertTypeParameters = function (sourceFile, node, typeParameters) {
// If no `(`, is an arrow function `x => x`, so use the pos of the first parameter
- var start = (ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile);
+ var start = (ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile);
this.insertNodesAt(sourceFile, start, typeParameters, { prefix: "<", suffix: ">", joiner: ", " });
};
ChangeTracker.prototype.getOptionsForInsertNodeBefore = function (before, inserted, blankLineBetween) {
@@ -146585,25 +149143,25 @@ var ts;
suffix: this.newLineCharacter
});
};
- ChangeTracker.prototype.insertNodeAtClassStart = function (sourceFile, cls, newElement) {
- this.insertNodeAtStartWorker(sourceFile, cls, newElement);
+ ChangeTracker.prototype.insertMemberAtStart = function (sourceFile, node, newElement) {
+ this.insertNodeAtStartWorker(sourceFile, node, newElement);
};
ChangeTracker.prototype.insertNodeAtObjectStart = function (sourceFile, obj, newElement) {
this.insertNodeAtStartWorker(sourceFile, obj, newElement);
};
- ChangeTracker.prototype.insertNodeAtStartWorker = function (sourceFile, cls, newElement) {
+ ChangeTracker.prototype.insertNodeAtStartWorker = function (sourceFile, node, newElement) {
var _a;
- var indentation = (_a = this.guessIndentationFromExistingMembers(sourceFile, cls)) !== null && _a !== void 0 ? _a : this.computeIndentationForNewMember(sourceFile, cls);
- this.insertNodeAt(sourceFile, getMembersOrProperties(cls).pos, newElement, this.getInsertNodeAtStartInsertOptions(sourceFile, cls, indentation));
+ var indentation = (_a = this.guessIndentationFromExistingMembers(sourceFile, node)) !== null && _a !== void 0 ? _a : this.computeIndentationForNewMember(sourceFile, node);
+ this.insertNodeAt(sourceFile, getMembersOrProperties(node).pos, newElement, this.getInsertNodeAtStartInsertOptions(sourceFile, node, indentation));
};
/**
* Tries to guess the indentation from the existing members of a class/interface/object. All members must be on
* new lines and must share the same indentation.
*/
- ChangeTracker.prototype.guessIndentationFromExistingMembers = function (sourceFile, cls) {
+ ChangeTracker.prototype.guessIndentationFromExistingMembers = function (sourceFile, node) {
var indentation;
- var lastRange = cls;
- for (var _i = 0, _a = getMembersOrProperties(cls); _i < _a.length; _i++) {
+ var lastRange = node;
+ for (var _i = 0, _a = getMembersOrProperties(node); _i < _a.length; _i++) {
var member = _a[_i];
if (ts.rangeStartPositionsAreOnSameLine(lastRange, member, sourceFile)) {
// each indented member must be on a new line
@@ -146622,13 +149180,13 @@ var ts;
}
return indentation;
};
- ChangeTracker.prototype.computeIndentationForNewMember = function (sourceFile, cls) {
+ ChangeTracker.prototype.computeIndentationForNewMember = function (sourceFile, node) {
var _a;
- var clsStart = cls.getStart(sourceFile);
- return ts.formatting.SmartIndenter.findFirstNonWhitespaceColumn(ts.getLineStartPositionForPosition(clsStart, sourceFile), clsStart, sourceFile, this.formatContext.options)
+ var nodeStart = node.getStart(sourceFile);
+ return ts.formatting.SmartIndenter.findFirstNonWhitespaceColumn(ts.getLineStartPositionForPosition(nodeStart, sourceFile), nodeStart, sourceFile, this.formatContext.options)
+ ((_a = this.formatContext.options.indentSize) !== null && _a !== void 0 ? _a : 4);
};
- ChangeTracker.prototype.getInsertNodeAtStartInsertOptions = function (sourceFile, cls, indentation) {
+ ChangeTracker.prototype.getInsertNodeAtStartInsertOptions = function (sourceFile, node, indentation) {
// Rules:
// - Always insert leading newline.
// - For object literals:
@@ -146638,11 +149196,11 @@ var ts;
// and the node is empty (because we didn't add a trailing comma per the previous rule).
// - Only insert a trailing newline if body is single-line and there are no other insertions for the node.
// NOTE: This is handled in `finishClassesWithNodesInsertedAtStart`.
- var members = getMembersOrProperties(cls);
+ var members = getMembersOrProperties(node);
var isEmpty = members.length === 0;
- var isFirstInsertion = ts.addToSeen(this.classesWithNodesInsertedAtStart, ts.getNodeId(cls), { node: cls, sourceFile: sourceFile });
- var insertTrailingComma = ts.isObjectLiteralExpression(cls) && (!ts.isJsonSourceFile(sourceFile) || !isEmpty);
- var insertLeadingComma = ts.isObjectLiteralExpression(cls) && ts.isJsonSourceFile(sourceFile) && isEmpty && !isFirstInsertion;
+ var isFirstInsertion = ts.addToSeen(this.classesWithNodesInsertedAtStart, ts.getNodeId(node), { node: node, sourceFile: sourceFile });
+ var insertTrailingComma = ts.isObjectLiteralExpression(node) && (!ts.isJsonSourceFile(sourceFile) || !isEmpty);
+ var insertLeadingComma = ts.isObjectLiteralExpression(node) && ts.isJsonSourceFile(sourceFile) && isEmpty && !isFirstInsertion;
return {
indentation: indentation,
prefix: (insertLeadingComma ? "," : "") + this.newLineCharacter,
@@ -146668,8 +149226,8 @@ var ts;
if (needSemicolonBetween(after, newNode)) {
// check if previous statement ends with semicolon
// if not - insert semicolon to preserve the code from changing the meaning due to ASI
- if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* semicolon */) {
- this.replaceRange(sourceFile, ts.createRange(after.end), ts.factory.createToken(26 /* SemicolonToken */));
+ if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* CharacterCodes.semicolon */) {
+ this.replaceRange(sourceFile, ts.createRange(after.end), ts.factory.createToken(26 /* SyntaxKind.SemicolonToken */));
}
}
var endPosition = getAdjustedEndPosition(sourceFile, after, {});
@@ -146681,18 +149239,18 @@ var ts;
};
ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) {
switch (node.kind) {
- case 256 /* ClassDeclaration */:
- case 260 /* ModuleDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
return { prefix: this.newLineCharacter, suffix: this.newLineCharacter };
- case 253 /* VariableDeclaration */:
- case 10 /* StringLiteral */:
- case 79 /* Identifier */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 79 /* SyntaxKind.Identifier */:
return { prefix: ", " };
- case 294 /* PropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
return { suffix: "," + this.newLineCharacter };
- case 93 /* ExportKeyword */:
+ case 93 /* SyntaxKind.ExportKeyword */:
return { prefix: " " };
- case 163 /* Parameter */:
+ case 164 /* SyntaxKind.Parameter */:
return {};
default:
ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it
@@ -146701,28 +149259,28 @@ var ts;
};
ChangeTracker.prototype.insertName = function (sourceFile, node, name) {
ts.Debug.assert(!node.name);
- if (node.kind === 213 /* ArrowFunction */) {
- var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile);
- var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile);
+ if (node.kind === 214 /* SyntaxKind.ArrowFunction */) {
+ var arrow = ts.findChildOfKind(node, 38 /* SyntaxKind.EqualsGreaterThanToken */, sourceFile);
+ var lparen = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile);
if (lparen) {
// `() => {}` --> `function f() {}`
- this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " });
+ this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* SyntaxKind.FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " });
deleteNode(this, sourceFile, arrow);
}
else {
// `x => {}` -> `function f(x) {}`
this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function ".concat(name, "("));
// Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)`
- this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* CloseParenToken */));
+ this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */));
}
- if (node.body.kind !== 234 /* Block */) {
+ if (node.body.kind !== 235 /* SyntaxKind.Block */) {
// `() => 0` => `function f() { return 0; }`
- this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* OpenBraceToken */), ts.factory.createToken(105 /* ReturnKeyword */)], { joiner: " ", suffix: " " });
- this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SemicolonToken */), ts.factory.createToken(19 /* CloseBraceToken */)], { joiner: " " });
+ this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* SyntaxKind.OpenBraceToken */), ts.factory.createToken(105 /* SyntaxKind.ReturnKeyword */)], { joiner: " ", suffix: " " });
+ this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SyntaxKind.SemicolonToken */), ts.factory.createToken(19 /* SyntaxKind.CloseBraceToken */)], { joiner: " " });
}
}
else {
- var pos = ts.findChildOfKind(node, node.kind === 212 /* FunctionExpression */ ? 98 /* FunctionKeyword */ : 84 /* ClassKeyword */, sourceFile).end;
+ var pos = ts.findChildOfKind(node, node.kind === 213 /* SyntaxKind.FunctionExpression */ ? 98 /* SyntaxKind.FunctionKeyword */ : 84 /* SyntaxKind.ClassKeyword */, sourceFile).end;
this.insertNodeAt(sourceFile, pos, ts.factory.createIdentifier(name), { prefix: " " });
}
};
@@ -146794,12 +149352,12 @@ var ts;
// if list has only one element then we'll format is as multiline if node has comment in trailing trivia, or as singleline otherwise
// i.e. var x = 1 // this is x
// | new element will be inserted at this position
- separator = 27 /* CommaToken */;
+ separator = 27 /* SyntaxKind.CommaToken */;
}
else {
// element has more than one element, pick separator from the list
var tokenBeforeInsertPosition = ts.findPrecedingToken(after.pos, sourceFile);
- separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* CommaToken */;
+ separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* SyntaxKind.CommaToken */;
// determine if list is multiline by checking lines of after element and element that precedes it.
var afterMinusOneStartLinePosition = ts.getLineStartPositionForPosition(containingList[index - 1].getStart(sourceFile), sourceFile);
multilineList = afterMinusOneStartLinePosition !== afterStartLinePosition;
@@ -146899,10 +149457,10 @@ var ts;
}());
textChanges_3.ChangeTracker = ChangeTracker;
function updateJSDocHost(parent) {
- if (parent.kind !== 213 /* ArrowFunction */) {
+ if (parent.kind !== 214 /* SyntaxKind.ArrowFunction */) {
return parent;
}
- var jsDocNode = parent.parent.kind === 166 /* PropertyDeclaration */ ?
+ var jsDocNode = parent.parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ ?
parent.parent :
parent.parent.parent;
jsDocNode.jsDoc = parent.jsDoc;
@@ -146914,16 +149472,16 @@ var ts;
return undefined;
}
switch (oldTag.kind) {
- case 338 /* JSDocParameterTag */: {
+ case 340 /* SyntaxKind.JSDocParameterTag */: {
var oldParam = oldTag;
var newParam = newTag;
return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText
? ts.factory.createJSDocParameterTag(/*tagName*/ undefined, newParam.name, /*isBracketed*/ false, newParam.typeExpression, newParam.isNameFirst, oldParam.comment)
: undefined;
}
- case 339 /* JSDocReturnTag */:
+ case 341 /* SyntaxKind.JSDocReturnTag */:
return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
- case 341 /* JSDocTypeTag */:
+ case 343 /* SyntaxKind.JSDocTypeTag */:
return ts.factory.createJSDocTypeTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
}
}
@@ -146932,12 +149490,12 @@ var ts;
return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.IncludeAll }), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
}
function getClassOrObjectBraceEnds(cls, sourceFile) {
- var open = ts.findChildOfKind(cls, 18 /* OpenBraceToken */, sourceFile);
- var close = ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile);
+ var open = ts.findChildOfKind(cls, 18 /* SyntaxKind.OpenBraceToken */, sourceFile);
+ var close = ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile);
return [open === null || open === void 0 ? void 0 : open.end, close === null || close === void 0 ? void 0 : close.end];
}
- function getMembersOrProperties(cls) {
- return ts.isObjectLiteralExpression(cls) ? cls.properties : cls.members;
+ function getMembersOrProperties(node) {
+ return ts.isObjectLiteralExpression(node) ? node.properties : node.members;
}
function getNewFileText(statements, scriptKind, newLineCharacter, formatContext) {
return changesToText.newFileChangesWorker(/*oldFile*/ undefined, scriptKind, statements, newLineCharacter, formatContext);
@@ -146980,8 +149538,8 @@ var ts;
changesToText.newFileChanges = newFileChanges;
function newFileChangesWorker(oldFile, scriptKind, statements, newLineCharacter, formatContext) {
// TODO: this emits the file, parses it back, then formats it that -- may be a less roundabout way to do this
- var nonFormattedText = statements.map(function (s) { return s === 4 /* NewLineTrivia */ ? "" : getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter);
- var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 99 /* ESNext */, /*setParentNodes*/ true, scriptKind);
+ var nonFormattedText = statements.map(function (s) { return s === 4 /* SyntaxKind.NewLineTrivia */ ? "" : getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter);
+ var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 99 /* ScriptTarget.ESNext */, /*setParentNodes*/ true, scriptKind);
var changes = ts.formatting.formatDocument(sourceFile, formatContext);
return applyChanges(nonFormattedText, changes) + newLineCharacter;
}
@@ -147000,7 +149558,7 @@ var ts;
? change.nodes.map(function (n) { return ts.removeSuffix(format(n), newLineCharacter); }).join(((_a = change.options) === null || _a === void 0 ? void 0 : _a.joiner) || newLineCharacter)
: format(change.node);
// strip initial indentation (spaces or tabs) if text will be inserted in the middle of the line
- var noIndent = (options.preserveLeadingWhitespace || options.indentation !== undefined || ts.getLineStartPositionForPosition(pos, sourceFile) === pos) ? text : text.replace(/^\s+/, "");
+ var noIndent = (options.indentation !== undefined || ts.getLineStartPositionForPosition(pos, sourceFile) === pos) ? text : text.replace(/^\s+/, "");
return (options.prefix || "") + noIndent
+ ((!options.suffix || ts.endsWith(noIndent, options.suffix))
? "" : options.suffix);
@@ -147036,7 +149594,7 @@ var ts;
neverAsciiEscape: true,
preserveSourceNewlines: true,
terminateUnterminatedLiterals: true
- }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer);
+ }, writer).writeNode(4 /* EmitHint.Unspecified */, node, sourceFile, writer);
return { text: writer.getText(), node: assignPositionsToNode(node) };
}
changesToText.getNonformattedText = getNonformattedText;
@@ -147052,8 +149610,11 @@ var ts;
function isTrivia(s) {
return ts.skipTrivia(s, 0) === s.length;
}
+ // A transformation context that won't perform parenthesization, as some parenthesization rules
+ // are more aggressive than is strictly necessary.
+ var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NodeFactoryFlags.NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) });
function assignPositionsToNode(node) {
- var visited = ts.visitEachChild(node, assignPositionsToNode, ts.nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode);
+ var visited = ts.visitEachChild(node, assignPositionsToNode, textChangesTransformationContext, assignPositionsToNodeArray, assignPositionsToNode);
// create proxy node for non synthesized nodes
var newNode = ts.nodeIsSynthesized(visited) ? visited : Object.create(visited);
ts.setTextRangePosEnd(newNode, getPos(node), getEnd(node));
@@ -147262,7 +149823,7 @@ var ts;
var firstNodeLine;
for (var _b = 0, ranges_1 = ranges; _b < ranges_1.length; _b++) {
var range = ranges_1[_b];
- if (range.kind === 3 /* MultiLineCommentTrivia */) {
+ if (range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) {
if (ts.isPinnedComment(text, range.pos)) {
lastComment = { range: range, pinnedOrTripleSlash: true };
continue;
@@ -147302,7 +149863,7 @@ var ts;
var charCode = text.charCodeAt(position);
if (ts.isLineBreak(charCode)) {
position++;
- if (position < text.length && charCode === 13 /* carriageReturn */ && text.charCodeAt(position) === 10 /* lineFeed */) {
+ if (position < text.length && charCode === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(position) === 10 /* CharacterCodes.lineFeed */) {
position++;
}
}
@@ -147314,18 +149875,18 @@ var ts;
}
textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment;
function needSemicolonBetween(a, b) {
- return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 161 /* ComputedPropertyName */
+ return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 162 /* SyntaxKind.ComputedPropertyName */
|| ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[`
}
var deleteDeclaration;
(function (deleteDeclaration_1) {
function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) {
switch (node.kind) {
- case 163 /* Parameter */: {
+ case 164 /* SyntaxKind.Parameter */: {
var oldFunction = node.parent;
if (ts.isArrowFunction(oldFunction) &&
oldFunction.parameters.length === 1 &&
- !ts.findChildOfKind(oldFunction, 20 /* OpenParenToken */, sourceFile)) {
+ !ts.findChildOfKind(oldFunction, 20 /* SyntaxKind.OpenParenToken */, sourceFile)) {
// Lambdas with exactly one parameter are special because, after removal, there
// must be an empty parameter list (i.e. `()`) and this won't necessarily be the
// case if the parameter is simply removed (e.g. in `x => 1`).
@@ -147336,17 +149897,17 @@ var ts;
}
break;
}
- case 265 /* ImportDeclaration */:
- case 264 /* ImportEqualsDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
var isFirstImport = sourceFile.imports.length && node === ts.first(sourceFile.imports).parent || node === ts.find(sourceFile.statements, ts.isAnyImportSyntax);
// For first import, leave header comment in place, otherwise only delete JSDoc comments
deleteNode(changes, sourceFile, node, {
leadingTriviaOption: isFirstImport ? LeadingTriviaOption.Exclude : ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine,
});
break;
- case 202 /* BindingElement */:
+ case 203 /* SyntaxKind.BindingElement */:
var pattern = node.parent;
- var preserveComma = pattern.kind === 201 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements);
+ var preserveComma = pattern.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && node !== ts.last(pattern.elements);
if (preserveComma) {
deleteNode(changes, sourceFile, node);
}
@@ -147354,13 +149915,13 @@ var ts;
deleteNodeInList(changes, deletedNodesInLists, sourceFile, node);
}
break;
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node);
break;
- case 162 /* TypeParameter */:
+ case 163 /* SyntaxKind.TypeParameter */:
deleteNodeInList(changes, deletedNodesInLists, sourceFile, node);
break;
- case 269 /* ImportSpecifier */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
var namedImports = node.parent;
if (namedImports.elements.length === 1) {
deleteImportBinding(changes, sourceFile, namedImports);
@@ -147369,17 +149930,17 @@ var ts;
deleteNodeInList(changes, deletedNodesInLists, sourceFile, node);
}
break;
- case 267 /* NamespaceImport */:
+ case 268 /* SyntaxKind.NamespaceImport */:
deleteImportBinding(changes, sourceFile, node);
break;
- case 26 /* SemicolonToken */:
+ case 26 /* SyntaxKind.SemicolonToken */:
deleteNode(changes, sourceFile, node, { trailingTriviaOption: TrailingTriviaOption.Exclude });
break;
- case 98 /* FunctionKeyword */:
+ case 98 /* SyntaxKind.FunctionKeyword */:
deleteNode(changes, sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.Exclude });
break;
- case 256 /* ClassDeclaration */:
- case 255 /* FunctionDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
deleteNode(changes, sourceFile, node, { leadingTriviaOption: ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine });
break;
default:
@@ -147408,7 +149969,7 @@ var ts;
// import |d,| * as ns from './file'
var start = importClause.name.getStart(sourceFile);
var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end);
- if (nextToken && nextToken.kind === 27 /* CommaToken */) {
+ if (nextToken && nextToken.kind === 27 /* SyntaxKind.CommaToken */) {
// shift first non-whitespace position after comma to the start position of the node
var end = ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true);
changes.deleteRange(sourceFile, { pos: start, end: end });
@@ -147430,15 +149991,15 @@ var ts;
// Delete the entire import declaration
// |import * as ns from './file'|
// |import { a } from './file'|
- var importDecl = ts.getAncestor(node, 265 /* ImportDeclaration */);
+ var importDecl = ts.getAncestor(node, 266 /* SyntaxKind.ImportDeclaration */);
deleteNode(changes, sourceFile, importDecl);
}
}
function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) {
var parent = node.parent;
- if (parent.kind === 291 /* CatchClause */) {
+ if (parent.kind === 292 /* SyntaxKind.CatchClause */) {
// TODO: There's currently no unused diagnostic for this, could be a suggestion
- changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile));
+ changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* SyntaxKind.OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* SyntaxKind.CloseParenToken */, sourceFile));
return;
}
if (parent.declarations.length !== 1) {
@@ -147447,14 +150008,14 @@ var ts;
}
var gp = parent.parent;
switch (gp.kind) {
- case 243 /* ForOfStatement */:
- case 242 /* ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
changes.replaceNode(sourceFile, node, ts.factory.createObjectLiteralExpression());
break;
- case 241 /* ForStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
deleteNode(changes, sourceFile, parent);
break;
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
deleteNode(changes, sourceFile, gp, { leadingTriviaOption: ts.hasJSDocNodes(gp) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine });
break;
default:
@@ -147641,8 +150202,8 @@ var ts;
});
function makeChange(changeTracker, sourceFile, assertion) {
var replacement = ts.isAsExpression(assertion)
- ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */))
- : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */), assertion.expression);
+ ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */))
+ : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */), assertion.expression);
changeTracker.replaceNode(sourceFile, assertion.expression, replacement);
}
function getAssertion(sourceFile, pos) {
@@ -147693,7 +150254,7 @@ var ts;
errorCodes: errorCodes,
getCodeActions: function getCodeActionsToAddMissingAsync(context) {
var sourceFile = context.sourceFile, errorCode = context.errorCode, cancellationToken = context.cancellationToken, program = context.program, span = context.span;
- var diagnostic = ts.find(program.getDiagnosticsProducingTypeChecker().getDiagnostics(sourceFile, cancellationToken), getIsMatchingAsyncError(span, errorCode));
+ var diagnostic = ts.find(program.getTypeChecker().getDiagnostics(sourceFile, cancellationToken), getIsMatchingAsyncError(span, errorCode));
var directSpan = diagnostic && diagnostic.relatedInformation && ts.find(diagnostic.relatedInformation, function (r) { return r.code === ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async.code; });
var decl = getFixableErrorSpanDeclaration(sourceFile, directSpan);
if (!decl) {
@@ -147727,7 +150288,7 @@ var ts;
}
}
fixedDeclarations === null || fixedDeclarations === void 0 ? void 0 : fixedDeclarations.add(ts.getNodeId(insertionSite));
- var cloneWithModifier = ts.factory.updateModifiers(ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true), ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(ts.getSyntacticModifierFlags(insertionSite) | 256 /* Async */)));
+ var cloneWithModifier = ts.factory.updateModifiers(ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true), ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(ts.getSyntacticModifierFlags(insertionSite) | 256 /* ModifierFlags.Async */)));
changeTracker.replaceNode(sourceFile, insertionSite, cloneWithModifier);
}
function getFixableErrorSpanDeclaration(sourceFile, span) {
@@ -147777,7 +150338,7 @@ var ts;
ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined.code,
ts.Diagnostics.Type_0_is_not_an_array_type.code,
ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code,
- ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators.code,
+ ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher.code,
ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator.code,
ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator.code,
ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator.code,
@@ -147847,7 +150408,7 @@ var ts;
return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_await, fixId, ts.Diagnostics.Fix_all_expressions_possibly_missing_await);
}
function isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) {
- var checker = program.getDiagnosticsProducingTypeChecker();
+ var checker = program.getTypeChecker();
var diagnostics = checker.getDiagnostics(sourceFile, cancellationToken);
return ts.some(diagnostics, function (_a) {
var start = _a.start, length = _a.length, relatedInformation = _a.relatedInformation, code = _a.code;
@@ -147871,12 +150432,12 @@ var ts;
}
var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration);
var variableName = declaration && ts.tryCast(declaration.name, ts.isIdentifier);
- var variableStatement = ts.getAncestor(declaration, 236 /* VariableStatement */);
+ var variableStatement = ts.getAncestor(declaration, 237 /* SyntaxKind.VariableStatement */);
if (!declaration || !variableStatement ||
declaration.type ||
!declaration.initializer ||
variableStatement.getSourceFile() !== sourceFile ||
- ts.hasSyntacticModifier(variableStatement, 1 /* Export */) ||
+ ts.hasSyntacticModifier(variableStatement, 1 /* ModifierFlags.Export */) ||
!variableName ||
!isInsideAwaitableBody(declaration.initializer)) {
isCompleteFix = false;
@@ -147944,15 +150505,15 @@ var ts;
// Promise as an invalid operand. So if the whole binary expression is
// typed `any` as a result, there is a strong likelihood that this Promise
// is accidentally missing `await`.
- checker.getTypeAtLocation(errorNode).flags & 1 /* Any */;
+ checker.getTypeAtLocation(errorNode).flags & 1 /* TypeFlags.Any */;
}
function isInsideAwaitableBody(node) {
- return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) {
+ return node.kind & 32768 /* NodeFlags.AwaitContext */ || !!ts.findAncestor(node, function (ancestor) {
return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor ||
- ts.isBlock(ancestor) && (ancestor.parent.kind === 255 /* FunctionDeclaration */ ||
- ancestor.parent.kind === 212 /* FunctionExpression */ ||
- ancestor.parent.kind === 213 /* ArrowFunction */ ||
- ancestor.parent.kind === 168 /* MethodDeclaration */);
+ ts.isBlock(ancestor) && (ancestor.parent.kind === 256 /* SyntaxKind.FunctionDeclaration */ ||
+ ancestor.parent.kind === 213 /* SyntaxKind.FunctionExpression */ ||
+ ancestor.parent.kind === 214 /* SyntaxKind.ArrowFunction */ ||
+ ancestor.parent.kind === 169 /* SyntaxKind.MethodDeclaration */);
});
}
function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) {
@@ -148041,7 +150602,7 @@ var ts;
if (forInitializer)
return applyChange(changeTracker, forInitializer, sourceFile, fixedNodes);
var parent = token.parent;
- if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isExpressionStatement(parent.parent)) {
+ if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isExpressionStatement(parent.parent)) {
return applyChange(changeTracker, token, sourceFile, fixedNodes);
}
if (ts.isArrayLiteralExpression(parent)) {
@@ -148065,16 +150626,16 @@ var ts;
}
function applyChange(changeTracker, initializer, sourceFile, fixedNodes) {
if (!fixedNodes || ts.tryAddToSet(fixedNodes, initializer)) {
- changeTracker.insertModifierBefore(sourceFile, 85 /* ConstKeyword */, initializer);
+ changeTracker.insertModifierBefore(sourceFile, 85 /* SyntaxKind.ConstKeyword */, initializer);
}
}
function isPossiblyPartOfDestructuring(node) {
switch (node.kind) {
- case 79 /* Identifier */:
- case 203 /* ArrayLiteralExpression */:
- case 204 /* ObjectLiteralExpression */:
- case 294 /* PropertyAssignment */:
- case 295 /* ShorthandPropertyAssignment */:
+ case 79 /* SyntaxKind.Identifier */:
+ case 204 /* SyntaxKind.ArrayLiteralExpression */:
+ case 205 /* SyntaxKind.ObjectLiteralExpression */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
return true;
default:
return false;
@@ -148088,9 +150649,9 @@ var ts;
}
function isPossiblyPartOfCommaSeperatedInitializer(node) {
switch (node.kind) {
- case 79 /* Identifier */:
- case 220 /* BinaryExpression */:
- case 27 /* CommaToken */:
+ case 79 /* SyntaxKind.Identifier */:
+ case 221 /* SyntaxKind.BinaryExpression */:
+ case 27 /* SyntaxKind.CommaToken */:
return true;
default:
return false;
@@ -148100,10 +150661,10 @@ var ts;
if (!ts.isBinaryExpression(expression)) {
return false;
}
- if (expression.operatorToken.kind === 27 /* CommaToken */) {
+ if (expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) {
return ts.every([expression.left, expression.right], function (expression) { return expressionCouldBeVariableDeclaration(expression, checker); });
}
- return expression.operatorToken.kind === 63 /* EqualsToken */
+ return expression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */
&& ts.isIdentifier(expression.left)
&& !checker.getSymbolAtLocation(expression.left);
}
@@ -148138,9 +150699,9 @@ var ts;
return;
}
var declaration = token.parent;
- if (declaration.kind === 166 /* PropertyDeclaration */ &&
+ if (declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ &&
(!fixedNodes || ts.tryAddToSet(fixedNodes, declaration))) {
- changeTracker.insertModifierBefore(sourceFile, 135 /* DeclareKeyword */, declaration);
+ changeTracker.insertModifierBefore(sourceFile, 135 /* SyntaxKind.DeclareKeyword */, declaration);
}
}
})(codefix = ts.codefix || (ts.codefix = {}));
@@ -148255,7 +150816,7 @@ var ts;
if (!errorNode) {
return undefined;
}
- else if (ts.isBinaryExpression(errorNode.parent) && errorNode.parent.operatorToken.kind === 63 /* EqualsToken */) {
+ else if (ts.isBinaryExpression(errorNode.parent) && errorNode.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) {
return { source: errorNode.parent.right, target: errorNode.parent.left };
}
else if (ts.isVariableDeclaration(errorNode.parent) && errorNode.parent.initializer) {
@@ -148295,7 +150856,7 @@ var ts;
var add = toAdd_1[_i];
var d = add.valueDeclaration;
if (d && (ts.isPropertySignature(d) || ts.isPropertyDeclaration(d)) && d.type) {
- var t = ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], d.type.kind === 186 /* UnionType */ ? d.type.types : [d.type], true), [
+ var t = ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], d.type.kind === 187 /* SyntaxKind.UnionType */ ? d.type.types : [d.type], true), [
ts.factory.createTypeReferenceNode("undefined")
], false));
changes.replaceNode(d.getSourceFile(), d.type, t);
@@ -148348,9 +150909,9 @@ var ts;
if (typeParameters.length)
changes.insertTypeParameters(sourceFile, decl, typeParameters);
}
- var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* OpenParenToken */, sourceFile);
+ var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* SyntaxKind.OpenParenToken */, sourceFile);
if (needParens)
- changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.factory.createToken(20 /* OpenParenToken */));
+ changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */));
for (var _i = 0, _a = decl.parameters; _i < _a.length; _i++) {
var param = _a[_i];
if (!param.type) {
@@ -148360,7 +150921,7 @@ var ts;
}
}
if (needParens)
- changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.factory.createToken(21 /* CloseParenToken */));
+ changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */));
if (!decl.type) {
var returnType = ts.getJSDocReturnType(decl);
if (returnType)
@@ -148375,30 +150936,30 @@ var ts;
}
function isDeclarationWithType(node) {
return ts.isFunctionLikeDeclaration(node) ||
- node.kind === 253 /* VariableDeclaration */ ||
- node.kind === 165 /* PropertySignature */ ||
- node.kind === 166 /* PropertyDeclaration */;
+ node.kind === 254 /* SyntaxKind.VariableDeclaration */ ||
+ node.kind === 166 /* SyntaxKind.PropertySignature */ ||
+ node.kind === 167 /* SyntaxKind.PropertyDeclaration */;
}
function transformJSDocType(node) {
switch (node.kind) {
- case 310 /* JSDocAllType */:
- case 311 /* JSDocUnknownType */:
+ case 312 /* SyntaxKind.JSDocAllType */:
+ case 313 /* SyntaxKind.JSDocUnknownType */:
return ts.factory.createTypeReferenceNode("any", ts.emptyArray);
- case 314 /* JSDocOptionalType */:
+ case 316 /* SyntaxKind.JSDocOptionalType */:
return transformJSDocOptionalType(node);
- case 313 /* JSDocNonNullableType */:
+ case 315 /* SyntaxKind.JSDocNonNullableType */:
return transformJSDocType(node.type);
- case 312 /* JSDocNullableType */:
+ case 314 /* SyntaxKind.JSDocNullableType */:
return transformJSDocNullableType(node);
- case 316 /* JSDocVariadicType */:
+ case 318 /* SyntaxKind.JSDocVariadicType */:
return transformJSDocVariadicType(node);
- case 315 /* JSDocFunctionType */:
+ case 317 /* SyntaxKind.JSDocFunctionType */:
return transformJSDocFunctionType(node);
- case 177 /* TypeReference */:
+ case 178 /* SyntaxKind.TypeReference */:
return transformJSDocTypeReference(node);
default:
var visited = ts.visitEachChild(node, transformJSDocType, ts.nullTransformationContext);
- ts.setEmitFlags(visited, 1 /* SingleLine */);
+ ts.setEmitFlags(visited, 1 /* EmitFlags.SingleLine */);
return visited;
}
}
@@ -148415,13 +150976,13 @@ var ts;
var _a;
// TODO: This does not properly handle `function(new:C, string)` per https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System#the-javascript-type-language
// however we do handle it correctly in `serializeTypeForDeclaration` in checker.ts
- return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */));
+ return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */));
}
function transformJSDocParameter(node) {
var index = node.parent.parameters.indexOf(node);
- var isRest = node.type.kind === 316 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217
+ var isRest = node.type.kind === 318 /* SyntaxKind.JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217
var name = node.name || (isRest ? "rest" : "arg" + index);
- var dotdotdot = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken;
+ var dotdotdot = isRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : node.dotDotDotToken;
return ts.factory.createParameterDeclaration(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer);
}
function transformJSDocTypeReference(node) {
@@ -148459,11 +151020,11 @@ var ts;
var index = ts.factory.createParameterDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined,
- /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 146 /* NumberKeyword */ ? "n" : "s",
- /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 146 /* NumberKeyword */ ? "number" : "string", []),
+ /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */ ? "n" : "s",
+ /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */ ? "number" : "string", []),
/*initializer*/ undefined);
var indexSignature = ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]);
- ts.setEmitFlags(indexSignature, 1 /* SingleLine */);
+ ts.setEmitFlags(indexSignature, 1 /* EmitFlags.SingleLine */);
return indexSignature;
}
})(codefix = ts.codefix || (ts.codefix = {}));
@@ -148490,7 +151051,7 @@ var ts;
});
function doChange(changes, sourceFile, position, checker, preferences, compilerOptions) {
var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position));
- if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) {
+ if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* SymbolFlags.Function */ | 3 /* SymbolFlags.Variable */))) {
// Bad input
return undefined;
}
@@ -148514,20 +151075,6 @@ var ts;
}
function createClassElementsFromSymbol(symbol) {
var memberElements = [];
- // all instance members are stored in the "member" array of symbol
- if (symbol.members) {
- symbol.members.forEach(function (member, key) {
- if (key === "constructor" && member.valueDeclaration) {
- // fn.prototype.constructor = fn
- changes.delete(sourceFile, member.valueDeclaration.parent);
- return;
- }
- var memberElement = createClassElement(member, /*modifiers*/ undefined);
- if (memberElement) {
- memberElements.push.apply(memberElements, memberElement);
- }
- });
- }
// all static members are stored in the "exports" array of symbol
if (symbol.exports) {
symbol.exports.forEach(function (member) {
@@ -148537,21 +151084,34 @@ var ts;
if (member.declarations.length === 1 &&
ts.isPropertyAccessExpression(firstDeclaration) &&
ts.isBinaryExpression(firstDeclaration.parent) &&
- firstDeclaration.parent.operatorToken.kind === 63 /* EqualsToken */ &&
+ firstDeclaration.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ &&
ts.isObjectLiteralExpression(firstDeclaration.parent.right)) {
var prototypes = firstDeclaration.parent.right;
- var memberElement = createClassElement(prototypes.symbol, /** modifiers */ undefined);
- if (memberElement) {
- memberElements.push.apply(memberElements, memberElement);
- }
+ createClassElement(prototypes.symbol, /** modifiers */ undefined, memberElements);
}
}
else {
- var memberElement = createClassElement(member, [ts.factory.createToken(124 /* StaticKeyword */)]);
- if (memberElement) {
- memberElements.push.apply(memberElements, memberElement);
+ createClassElement(member, [ts.factory.createToken(124 /* SyntaxKind.StaticKeyword */)], memberElements);
+ }
+ });
+ }
+ // all instance members are stored in the "member" array of symbol (done last so instance members pulled from prototype assignments have priority)
+ if (symbol.members) {
+ symbol.members.forEach(function (member, key) {
+ var _a, _b, _c, _d;
+ if (key === "constructor" && member.valueDeclaration) {
+ var prototypeAssignment = (_d = (_c = (_b = (_a = symbol.exports) === null || _a === void 0 ? void 0 : _a.get("prototype")) === null || _b === void 0 ? void 0 : _b.declarations) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.parent;
+ if (prototypeAssignment && ts.isBinaryExpression(prototypeAssignment) && ts.isObjectLiteralExpression(prototypeAssignment.right) && ts.some(prototypeAssignment.right.properties, isConstructorAssignment)) {
+ // fn.prototype = { constructor: fn }
+ // Already deleted in `createClassElement` in first pass
+ }
+ else {
+ // fn.prototype.constructor = fn
+ changes.delete(sourceFile, member.valueDeclaration.parent);
}
+ return;
}
+ createClassElement(member, /*modifiers*/ undefined, memberElements);
});
}
return memberElements;
@@ -148579,63 +151139,72 @@ var ts;
});
}
}
- function createClassElement(symbol, modifiers) {
+ function createClassElement(symbol, modifiers, members) {
// Right now the only thing we can convert are function expressions, which are marked as methods
// or { x: y } type prototype assignments, which are marked as ObjectLiteral
- var members = [];
- if (!(symbol.flags & 8192 /* Method */) && !(symbol.flags & 4096 /* ObjectLiteral */)) {
- return members;
+ if (!(symbol.flags & 8192 /* SymbolFlags.Method */) && !(symbol.flags & 4096 /* SymbolFlags.ObjectLiteral */)) {
+ return;
}
var memberDeclaration = symbol.valueDeclaration;
var assignmentBinaryExpression = memberDeclaration.parent;
var assignmentExpr = assignmentBinaryExpression.right;
if (!shouldConvertDeclaration(memberDeclaration, assignmentExpr)) {
- return members;
+ return;
+ }
+ if (ts.some(members, function (m) {
+ var name = ts.getNameOfDeclaration(m);
+ if (name && ts.isIdentifier(name) && ts.idText(name) === ts.symbolName(symbol)) {
+ return true; // class member already made for this name
+ }
+ return false;
+ })) {
+ return;
}
// delete the entire statement if this expression is the sole expression to take care of the semicolon at the end
- var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 237 /* ExpressionStatement */
+ var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 238 /* SyntaxKind.ExpressionStatement */
? assignmentBinaryExpression.parent : assignmentBinaryExpression;
changes.delete(sourceFile, nodeToDelete);
if (!assignmentExpr) {
members.push(ts.factory.createPropertyDeclaration([], modifiers, symbol.name, /*questionToken*/ undefined,
/*type*/ undefined, /*initializer*/ undefined));
- return members;
+ return;
}
// f.x = expr
if (ts.isAccessExpression(memberDeclaration) && (ts.isFunctionExpression(assignmentExpr) || ts.isArrowFunction(assignmentExpr))) {
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
var name = tryGetPropertyName(memberDeclaration, compilerOptions, quotePreference);
if (name) {
- return createFunctionLikeExpressionMember(members, assignmentExpr, name);
+ createFunctionLikeExpressionMember(members, assignmentExpr, name);
}
- return members;
+ return;
}
// f.prototype = { ... }
else if (ts.isObjectLiteralExpression(assignmentExpr)) {
- return ts.flatMap(assignmentExpr.properties, function (property) {
+ ts.forEach(assignmentExpr.properties, function (property) {
if (ts.isMethodDeclaration(property) || ts.isGetOrSetAccessorDeclaration(property)) {
// MethodDeclaration and AccessorDeclaration can appear in a class directly
- return members.concat(property);
+ members.push(property);
}
if (ts.isPropertyAssignment(property) && ts.isFunctionExpression(property.initializer)) {
- return createFunctionLikeExpressionMember(members, property.initializer, property.name);
+ createFunctionLikeExpressionMember(members, property.initializer, property.name);
}
// Drop constructor assignments
if (isConstructorAssignment(property))
- return members;
- return [];
+ return;
+ return;
});
+ return;
}
else {
// Don't try to declare members in JavaScript files
if (ts.isSourceFileJS(sourceFile))
- return members;
+ return;
if (!ts.isPropertyAccessExpression(memberDeclaration))
- return members;
+ return;
var prop = ts.factory.createPropertyDeclaration(/*decorators*/ undefined, modifiers, memberDeclaration.name, /*questionToken*/ undefined, /*type*/ undefined, assignmentExpr);
ts.copyLeadingComments(assignmentBinaryExpression.parent, prop, sourceFile);
members.push(prop);
- return members;
+ return;
}
function createFunctionLikeExpressionMember(members, expression, name) {
if (ts.isFunctionExpression(expression))
@@ -148644,28 +151213,29 @@ var ts;
return createArrowFunctionExpressionMember(members, expression, name);
}
function createFunctionExpressionMember(members, functionExpression, name) {
- var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 131 /* AsyncKeyword */));
+ var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 131 /* SyntaxKind.AsyncKeyword */));
var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined,
/*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body);
ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile);
- return members.concat(method);
+ members.push(method);
+ return;
}
function createArrowFunctionExpressionMember(members, arrowFunction, name) {
var arrowFunctionBody = arrowFunction.body;
var bodyBlock;
// case 1: () => { return [1,2,3] }
- if (arrowFunctionBody.kind === 234 /* Block */) {
+ if (arrowFunctionBody.kind === 235 /* SyntaxKind.Block */) {
bodyBlock = arrowFunctionBody;
}
// case 2: () => [1,2,3]
else {
bodyBlock = ts.factory.createBlock([ts.factory.createReturnStatement(arrowFunctionBody)]);
}
- var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 131 /* AsyncKeyword */));
+ var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 131 /* SyntaxKind.AsyncKeyword */));
var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined,
/*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock);
ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile);
- return members.concat(method);
+ members.push(method);
}
}
}
@@ -148678,7 +151248,7 @@ var ts;
if (initializer.body) {
memberElements.unshift(ts.factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body));
}
- var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* ExportKeyword */);
+ var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* SyntaxKind.ExportKeyword */);
var cls = ts.factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name,
/*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements);
// Don't call copyComments here because we'll already leave them in place
@@ -148689,7 +151259,7 @@ var ts;
if (node.body) {
memberElements.unshift(ts.factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body));
}
- var modifiers = getModifierKindFromSource(node, 93 /* ExportKeyword */);
+ var modifiers = getModifierKindFromSource(node, 93 /* SyntaxKind.ExportKeyword */);
var cls = ts.factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name,
/*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements);
// Don't call copyComments here because we'll already leave them in place
@@ -148716,7 +151286,7 @@ var ts;
}
if (ts.isStringLiteralLike(propName)) {
return ts.isIdentifierText(propName.text, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(propName.text)
- : ts.isNoSubstitutionTemplateLiteral(propName) ? ts.factory.createStringLiteral(propName.text, quotePreference === 0 /* Single */)
+ : ts.isNoSubstitutionTemplateLiteral(propName) ? ts.factory.createStringLiteral(propName.text, quotePreference === 0 /* QuotePreference.Single */)
: propName;
}
return undefined;
@@ -148777,7 +151347,7 @@ var ts;
functionToConvert.decorators ? ts.skipTrivia(sourceFile.text, functionToConvert.decorators.end) :
functionToConvert.getStart(sourceFile);
var options = functionToConvert.modifiers ? { prefix: " " } : { suffix: " " };
- changes.insertModifierAt(sourceFile, pos, 131 /* AsyncKeyword */, options);
+ changes.insertModifierAt(sourceFile, pos, 131 /* SyntaxKind.AsyncKeyword */, options);
var _loop_14 = function (returnStatement) {
ts.forEachChild(returnStatement, function visit(node) {
if (ts.isCallExpression(node)) {
@@ -148852,7 +151422,7 @@ var ts;
// NOTE: this is a mostly copy of `isReferenceToType` from checker.ts. While this violates DRY, it keeps
// `isReferenceToType` in checker local to the checker to avoid the cost of a property lookup on `ts`.
function isReferenceToType(type, target) {
- return (ts.getObjectFlags(type) & 4 /* Reference */) !== 0
+ return (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) !== 0
&& type.target === target;
}
function getExplicitPromisedTypeOfPromiseReturningCallExpression(node, callback, checker) {
@@ -148915,7 +151485,7 @@ var ts;
var ident = (firstParameter === null || firstParameter === void 0 ? void 0 : firstParameter.valueDeclaration)
&& ts.isParameter(firstParameter.valueDeclaration)
&& ts.tryCast(firstParameter.valueDeclaration.name, ts.isIdentifier)
- || ts.factory.createUniqueName("result", 16 /* Optimistic */);
+ || ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */);
var synthName = getNewNameIfConflict(ident, collidingSymbolMap);
synthNamesMap.set(symbolIdString, synthName);
collidingSymbolMap.add(ident.text, symbol);
@@ -148996,7 +151566,7 @@ var ts;
}
function isNullOrUndefined(_a, node) {
var checker = _a.checker;
- if (node.kind === 104 /* NullKeyword */)
+ if (node.kind === 104 /* SyntaxKind.NullKeyword */)
return true;
if (ts.isIdentifier(node) && !ts.isGeneratedIdentifier(node) && ts.idText(node) === "undefined") {
var symbol = checker.getSymbolAtLocation(node);
@@ -149005,7 +151575,7 @@ var ts;
return false;
}
function createUniqueSynthName(prevArgName) {
- var renamedPrevArg = ts.factory.createUniqueName(prevArgName.identifier.text, 16 /* Optimistic */);
+ var renamedPrevArg = ts.factory.createUniqueName(prevArgName.identifier.text, 16 /* GeneratedIdentifierFlags.Optimistic */);
return createSynthIdentifier(renamedPrevArg);
}
function getPossibleNameForVarDecl(node, transformer, continuationArgName) {
@@ -149025,7 +151595,7 @@ var ts;
});
}
else {
- possibleNameForVarDecl = createSynthIdentifier(ts.factory.createUniqueName("result", 16 /* Optimistic */), continuationArgName.types);
+ possibleNameForVarDecl = createSynthIdentifier(ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */), continuationArgName.types);
}
// We are about to write a 'let' variable declaration, but `transformExpression` for both
// the try block and catch/finally block will assign to this name. Setting this flag indicates
@@ -149041,10 +151611,10 @@ var ts;
if (possibleNameForVarDecl && !shouldReturn(node, transformer)) {
varDeclIdentifier = ts.getSynthesizedDeepClone(declareSynthIdentifier(possibleNameForVarDecl));
var typeArray = possibleNameForVarDecl.types;
- var unionType = transformer.checker.getUnionType(typeArray, 2 /* Subtype */);
+ var unionType = transformer.checker.getUnionType(typeArray, 2 /* UnionReduction.Subtype */);
var unionTypeNode = transformer.isInJSFile ? undefined : transformer.checker.typeToTypeNode(unionType, /*enclosingDeclaration*/ undefined, /*flags*/ undefined);
var varDecl = [ts.factory.createVariableDeclaration(varDeclIdentifier, /*exclamationToken*/ undefined, unionTypeNode)];
- var varDeclList = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList(varDecl, 1 /* Let */));
+ var varDeclList = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList(varDecl, 1 /* NodeFlags.Let */));
statements.push(varDeclList);
}
statements.push(tryStatement);
@@ -149054,7 +151624,7 @@ var ts;
ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(declareSynthBindingPattern(continuationArgName)),
/*exclamationToken*/ undefined,
/*type*/ undefined, varDeclIdentifier)
- ], 2 /* Const */)));
+ ], 2 /* NodeFlags.Const */)));
}
return statements;
}
@@ -149159,12 +151729,12 @@ var ts;
/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([
ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(declareSynthBindingName(variableName)),
/*exclamationToken*/ undefined, typeAnnotation, rightHandSide)
- ], 2 /* Const */))
+ ], 2 /* NodeFlags.Const */))
];
}
function maybeAnnotateAndReturn(expressionToReturn, typeAnnotation) {
if (typeAnnotation && expressionToReturn) {
- var name = ts.factory.createUniqueName("result", 16 /* Optimistic */);
+ var name = ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */);
return __spreadArray(__spreadArray([], createVariableOrAssignmentOrExpressionStatement(createSynthIdentifier(name), expressionToReturn, typeAnnotation), true), [
ts.factory.createReturnStatement(name)
], false);
@@ -149180,11 +151750,11 @@ var ts;
function transformCallbackArgument(func, hasContinuation, continuationArgName, inputArgName, parent, transformer) {
var _a;
switch (func.kind) {
- case 104 /* NullKeyword */:
+ case 104 /* SyntaxKind.NullKeyword */:
// do not produce a transformed statement for a null argument
break;
- case 205 /* PropertyAccessExpression */:
- case 79 /* Identifier */: // identifier includes undefined
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 79 /* SyntaxKind.Identifier */: // identifier includes undefined
if (!inputArgName) {
// undefined was argument passed to promise handler
break;
@@ -149194,7 +151764,7 @@ var ts;
return maybeAnnotateAndReturn(synthCall, getExplicitPromisedTypeOfPromiseReturningCallExpression(parent, func, transformer.checker));
}
var type = transformer.checker.getTypeAtLocation(func);
- var callSignatures = transformer.checker.getSignaturesOfType(type, 0 /* Call */);
+ var callSignatures = transformer.checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */);
if (!callSignatures.length) {
// if identifier in handler has no call signatures, it's invalid
return silentFail();
@@ -149205,8 +151775,8 @@ var ts;
continuationArgName.types.push(transformer.checker.getAwaitedType(returnType) || returnType);
}
return varDeclOrAssignment;
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */: {
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */: {
var funcBody = func.body;
var returnType_1 = (_a = getLastCallSignature(transformer.checker.getTypeAtLocation(func), transformer.checker)) === null || _a === void 0 ? void 0 : _a.getReturnType();
// Arrow functions with block bodies { } will enter this control flow
@@ -149308,7 +151878,7 @@ var ts;
return !!checker.getPromisedTypeOfPromise(type) ? ts.factory.createAwaitExpression(rightHandSide) : rightHandSide;
}
function getLastCallSignature(type, checker) {
- var callSignatures = checker.getSignaturesOfType(type, 0 /* Call */);
+ var callSignatures = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */);
return ts.lastOrUndefined(callSignatures);
}
function removeReturns(stmts, prevArgName, transformer, seenReturnStatement) {
@@ -149325,7 +151895,7 @@ var ts;
ret.push(ts.factory.createExpressionStatement(ts.factory.createAssignment(referenceSynthIdentifier(prevArgName), possiblyAwaitedExpression)));
}
else {
- ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, possiblyAwaitedExpression)], 2 /* Const */))));
+ ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, possiblyAwaitedExpression)], 2 /* NodeFlags.Const */))));
}
}
}
@@ -149335,7 +151905,7 @@ var ts;
}
// if block has no return statement, need to define prevArgName as undefined to prevent undeclared variables
if (!seenReturnStatement && prevArgName !== undefined) {
- ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createIdentifier("undefined"))], 2 /* Const */))));
+ ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createIdentifier("undefined"))], 2 /* NodeFlags.Const */))));
}
return ret;
}
@@ -149417,12 +151987,12 @@ var ts;
}
function createSynthIdentifier(identifier, types) {
if (types === void 0) { types = []; }
- return { kind: 0 /* Identifier */, identifier: identifier, types: types, hasBeenDeclared: false, hasBeenReferenced: false };
+ return { kind: 0 /* SynthBindingNameKind.Identifier */, identifier: identifier, types: types, hasBeenDeclared: false, hasBeenReferenced: false };
}
function createSynthBindingPattern(bindingPattern, elements, types) {
if (elements === void 0) { elements = ts.emptyArray; }
if (types === void 0) { types = []; }
- return { kind: 1 /* BindingPattern */, bindingPattern: bindingPattern, elements: elements, types: types };
+ return { kind: 1 /* SynthBindingNameKind.BindingPattern */, bindingPattern: bindingPattern, elements: elements, types: types };
}
function referenceSynthIdentifier(synthId) {
synthId.hasBeenReferenced = true;
@@ -149443,10 +152013,10 @@ var ts;
return synthId.identifier;
}
function isSynthIdentifier(bindingName) {
- return bindingName.kind === 0 /* Identifier */;
+ return bindingName.kind === 0 /* SynthBindingNameKind.Identifier */;
}
function isSynthBindingPattern(bindingName) {
- return bindingName.kind === 1 /* BindingPattern */;
+ return bindingName.kind === 1 /* SynthBindingNameKind.BindingPattern */;
}
function shouldReturn(expression, transformer) {
return !!expression.original && transformer.setOfExpressionsToReturn.has(ts.getNodeId(expression.original));
@@ -149484,10 +152054,10 @@ var ts;
}
var importNode = ts.importFromModuleSpecifier(moduleSpecifier);
switch (importNode.kind) {
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference));
break;
- case 207 /* CallExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) {
changes.replaceNode(importingFile, importNode, ts.factory.createPropertyAccessExpression(ts.getSynthesizedDeepClone(importNode), "default"));
}
@@ -149527,7 +152097,7 @@ var ts;
forEachExportReference(sourceFile, function (node) {
var _a = node.name, text = _a.text, originalKeywordKind = _a.originalKeywordKind;
if (!res.has(text) && (originalKeywordKind !== undefined && ts.isNonContextualKeyword(originalKeywordKind)
- || checker.resolveName(text, node, 111551 /* Value */, /*excludeGlobals*/ true))) {
+ || checker.resolveName(text, node, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true))) {
// Unconditionally add an underscore in case `text` is a keyword.
res.set(text, makeUniqueName("_".concat(text), identifiers));
}
@@ -149547,29 +152117,29 @@ var ts;
sourceFile.forEachChild(function recur(node) {
if (ts.isPropertyAccessExpression(node) && ts.isExportsOrModuleExportsOrAlias(sourceFile, node.expression) && ts.isIdentifier(node.name)) {
var parent = node.parent;
- cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* EqualsToken */);
+ cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */);
}
node.forEachChild(recur);
});
}
function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, useSitesToUnqualify, quotePreference) {
switch (statement.kind) {
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference);
return false;
- case 237 /* ExpressionStatement */: {
+ case 238 /* SyntaxKind.ExpressionStatement */: {
var expression = statement.expression;
switch (expression.kind) {
- case 207 /* CallExpression */: {
+ case 208 /* SyntaxKind.CallExpression */: {
if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) {
// For side-effecting require() call, just make a side-effecting import.
changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference));
}
return false;
}
- case 220 /* BinaryExpression */: {
+ case 221 /* SyntaxKind.BinaryExpression */: {
var operatorToken = expression.operatorToken;
- return operatorToken.kind === 63 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify);
+ return operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify);
}
}
}
@@ -149616,8 +152186,8 @@ var ts;
/** Converts `const name = require("moduleSpecifier").propertyName` */
function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) {
switch (name.kind) {
- case 200 /* ObjectBindingPattern */:
- case 201 /* ArrayBindingPattern */: {
+ case 201 /* SyntaxKind.ObjectBindingPattern */:
+ case 202 /* SyntaxKind.ArrayBindingPattern */: {
// `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;`
var tmp = makeUniqueName(propertyName, identifiers);
return convertedImports([
@@ -149625,7 +152195,7 @@ var ts;
makeConst(/*modifiers*/ undefined, name, ts.factory.createIdentifier(tmp)),
]);
}
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
// `const a = require("b").c` --> `import { c as a } from "./b";
return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]);
default:
@@ -149668,17 +152238,17 @@ var ts;
function tryChangeModuleExportsObject(object, useSitesToUnqualify) {
var statements = ts.mapAllOrFail(object.properties, function (prop) {
switch (prop.kind) {
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
// TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`.
// falls through
- case 295 /* ShorthandPropertyAssignment */:
- case 296 /* SpreadAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
+ case 298 /* SyntaxKind.SpreadAssignment */:
return undefined;
- case 294 /* PropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer, useSitesToUnqualify);
- case 168 /* MethodDeclaration */:
- return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* ExportKeyword */)], prop, useSitesToUnqualify);
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */)], prop, useSitesToUnqualify);
default:
ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind ".concat(prop.kind));
}
@@ -149709,8 +152279,8 @@ var ts;
var moduleSpecifier = reExported.text;
var moduleSymbol = checker.getSymbolAtLocation(reExported);
var exports = moduleSymbol ? moduleSymbol.exports : ts.emptyMap;
- return exports.has("export=" /* ExportEquals */) ? [[reExportDefault(moduleSpecifier)], true] :
- !exports.has("default" /* Default */) ? [[reExportStar(moduleSpecifier)], false] :
+ return exports.has("export=" /* InternalSymbolName.ExportEquals */) ? [[reExportDefault(moduleSpecifier)], true] :
+ !exports.has("default" /* InternalSymbolName.Default */) ? [[reExportStar(moduleSpecifier)], false] :
// If there's some non-default export, must include both `export *` and `export default`.
exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true];
}
@@ -149725,23 +152295,23 @@ var ts;
var name = left.name.text;
if ((ts.isFunctionExpression(right) || ts.isArrowFunction(right) || ts.isClassExpression(right)) && (!right.name || right.name.text === name)) {
// `exports.f = function() {}` -> `export function f() {}` -- Replace `exports.f = ` with `export `, and insert the name after `function`.
- changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* ExportKeyword */), { suffix: " " });
+ changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */), { suffix: " " });
if (!right.name)
changes.insertName(sourceFile, right, name);
- var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile);
+ var semi = ts.findChildOfKind(parent, 26 /* SyntaxKind.SemicolonToken */, sourceFile);
if (semi)
changes.delete(sourceFile, semi);
}
else {
// `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const `
- changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.factory.createToken(93 /* ExportKeyword */), ts.factory.createToken(85 /* ConstKeyword */)], { joiner: " ", suffix: " " });
+ changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* SyntaxKind.DotToken */, sourceFile), [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */), ts.factory.createToken(85 /* SyntaxKind.ConstKeyword */)], { joiner: " ", suffix: " " });
}
}
// TODO: GH#22492 this will cause an error if a change has been made inside the body of the node.
function convertExportsDotXEquals_replaceNode(name, exported, useSitesToUnqualify) {
- var modifiers = [ts.factory.createToken(93 /* ExportKeyword */)];
+ var modifiers = [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */)];
switch (exported.kind) {
- case 212 /* FunctionExpression */: {
+ case 213 /* SyntaxKind.FunctionExpression */: {
var expressionName = exported.name;
if (expressionName && expressionName.text !== name) {
// `exports.f = function g() {}` -> `export const f = function g() {}`
@@ -149749,10 +152319,10 @@ var ts;
}
}
// falls through
- case 213 /* ArrowFunction */:
+ case 214 /* SyntaxKind.ArrowFunction */:
// `exports.f = function() {}` --> `export function f() {}`
return functionExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify);
- case 225 /* ClassExpression */:
+ case 226 /* SyntaxKind.ClassExpression */:
// `exports.C = class {}` --> `export class C {}`
return classExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify);
default:
@@ -149772,7 +152342,7 @@ var ts;
: ts.getSynthesizedDeepCloneWithReplacements(nodeOrNodes, /*includeTrivia*/ true, replaceNode);
function replaceNode(original) {
// We are replacing `mod.SomeExport` wih `SomeExport`, so we only need to look at PropertyAccessExpressions
- if (original.kind === 205 /* PropertyAccessExpression */) {
+ if (original.kind === 206 /* SyntaxKind.PropertyAccessExpression */) {
var replacement = useSitesToUnqualify.get(original);
// Remove entry from `useSitesToUnqualify` so the refactor knows it's taken care of by the parent statement we're replacing
useSitesToUnqualify.delete(original);
@@ -149787,7 +152357,7 @@ var ts;
*/
function convertSingleImport(name, moduleSpecifier, checker, identifiers, target, quotePreference) {
switch (name.kind) {
- case 200 /* ObjectBindingPattern */: {
+ case 201 /* SyntaxKind.ObjectBindingPattern */: {
var importSpecifiers = ts.mapAllOrFail(name.elements, function (e) {
return e.dotDotDotToken || e.initializer || e.propertyName && !ts.isIdentifier(e.propertyName) || !ts.isIdentifier(e.name)
? undefined
@@ -149798,7 +152368,7 @@ var ts;
}
}
// falls through -- object destructuring has an interesting pattern and must be a variable declaration
- case 201 /* ArrayBindingPattern */: {
+ case 202 /* SyntaxKind.ArrayBindingPattern */: {
/*
import x from "x";
const [a, b, c] = x;
@@ -149809,7 +152379,7 @@ var ts;
makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.factory.createIdentifier(tmp)),
]);
}
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference);
default:
return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind ".concat(name.kind));
@@ -149891,11 +152461,11 @@ var ts;
function isFreeIdentifier(node) {
var parent = node.parent;
switch (parent.kind) {
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
return parent.name !== node;
- case 202 /* BindingElement */:
+ case 203 /* SyntaxKind.BindingElement */:
return parent.propertyName !== node;
- case 269 /* ImportSpecifier */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
return parent.propertyName !== node;
default:
return true;
@@ -149919,7 +152489,7 @@ var ts;
return ts.factory.createImportSpecifier(/*isTypeOnly*/ false, propertyName !== undefined && propertyName !== name ? ts.factory.createIdentifier(propertyName) : undefined, ts.factory.createIdentifier(name));
}
function makeConst(modifiers, name, init) {
- return ts.factory.createVariableStatement(modifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, init)], 2 /* Const */));
+ return ts.factory.createVariableStatement(modifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, init)], 2 /* NodeFlags.Const */));
}
function makeExportDeclaration(exportSpecifiers, moduleSpecifier) {
return ts.factory.createExportDeclaration(
@@ -150009,7 +152579,7 @@ var ts;
var exportDeclaration = exportClause.parent;
var typeExportSpecifiers = getTypeExportSpecifiers(exportSpecifier, context);
if (typeExportSpecifiers.length === exportClause.elements.length) {
- changes.insertModifierBefore(context.sourceFile, 151 /* TypeKeyword */, exportClause);
+ changes.insertModifierBefore(context.sourceFile, 152 /* SyntaxKind.TypeKeyword */, exportClause);
}
else {
var valueExportDeclaration = ts.factory.updateExportDeclaration(exportDeclaration, exportDeclaration.decorators, exportDeclaration.modifiers,
@@ -150133,7 +152703,7 @@ var ts;
function doChange(changes, sourceFile, _a) {
var container = _a.container, typeNode = _a.typeNode, constraint = _a.constraint, name = _a.name;
changes.replaceNode(sourceFile, container, ts.factory.createMappedTypeNode(
- /*readonlyToken*/ undefined, ts.factory.createTypeParameterDeclaration(name, ts.factory.createTypeReferenceNode(constraint)),
+ /*readonlyToken*/ undefined, ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, ts.factory.createTypeReferenceNode(constraint)),
/*nameType*/ undefined,
/*questionToken*/ undefined, typeNode,
/*members*/ undefined));
@@ -150178,7 +152748,7 @@ var ts;
return ts.Debug.checkDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class");
}
function symbolPointsToNonPrivateMember(symbol) {
- return !symbol.valueDeclaration || !(ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 8 /* Private */);
+ return !symbol.valueDeclaration || !(ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 8 /* ModifierFlags.Private */);
}
function addMissingDeclarations(context, implementedTypeNode, sourceFile, classDeclaration, changeTracker, preferences) {
var checker = context.program.getTypeChecker();
@@ -150191,10 +152761,10 @@ var ts;
var classType = checker.getTypeAtLocation(classDeclaration);
var constructor = ts.find(classDeclaration.members, function (m) { return ts.isConstructorDeclaration(m); });
if (!classType.getNumberIndexType()) {
- createMissingIndexSignatureDeclaration(implementedType, 1 /* Number */);
+ createMissingIndexSignatureDeclaration(implementedType, 1 /* IndexKind.Number */);
}
if (!classType.getStringIndexType()) {
- createMissingIndexSignatureDeclaration(implementedType, 0 /* String */);
+ createMissingIndexSignatureDeclaration(implementedType, 0 /* IndexKind.String */);
}
var importAdder = codefix.createImportAdder(sourceFile, context.program, preferences, context.host);
codefix.createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, sourceFile, context, preferences, importAdder, function (member) { return insertInterfaceMemberNode(sourceFile, classDeclaration, member); });
@@ -150211,7 +152781,7 @@ var ts;
changeTracker.insertNodeAfter(sourceFile, constructor, newElement);
}
else {
- changeTracker.insertNodeAtClassStart(sourceFile, cls, newElement);
+ changeTracker.insertMemberAtStart(sourceFile, cls, newElement);
}
}
}
@@ -150290,7 +152860,7 @@ var ts;
var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
var exportInfo = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
var useRequire = shouldUseRequire(sourceFile, program);
- var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
+ var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, program, /*useNamespaceInfo*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
if (fix) {
addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
}
@@ -150300,20 +152870,20 @@ var ts;
var fixes = info.fixes, symbolName = info.symbolName;
var fix = ts.first(fixes);
switch (fix.kind) {
- case 0 /* UseNamespace */:
+ case 0 /* ImportFixKind.UseNamespace */:
addToNamespace.push(fix);
break;
- case 1 /* JsdocTypeImport */:
+ case 1 /* ImportFixKind.JsdocTypeImport */:
importType.push(fix);
break;
- case 2 /* AddToExisting */: {
+ case 2 /* ImportFixKind.AddToExisting */: {
var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly;
var key = String(ts.getNodeId(importClauseOrBindingPattern));
var entry = addToExisting.get(key);
if (!entry) {
addToExisting.set(key, entry = { importClauseOrBindingPattern: importClauseOrBindingPattern, defaultImport: undefined, namedImports: new ts.Map() });
}
- if (importKind === 0 /* Named */) {
+ if (importKind === 0 /* ImportKind.Named */) {
var prevValue = entry === null || entry === void 0 ? void 0 : entry.namedImports.get(symbolName);
entry.namedImports.set(symbolName, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly));
}
@@ -150326,28 +152896,28 @@ var ts;
}
break;
}
- case 3 /* AddNew */: {
+ case 3 /* ImportFixKind.AddNew */: {
var moduleSpecifier = fix.moduleSpecifier, importKind = fix.importKind, useRequire = fix.useRequire, addAsTypeOnly = fix.addAsTypeOnly;
var entry = getNewImportEntry(moduleSpecifier, importKind, useRequire, addAsTypeOnly);
ts.Debug.assert(entry.useRequire === useRequire, "(Add new) Tried to add an `import` and a `require` for the same module");
switch (importKind) {
- case 1 /* Default */:
+ case 1 /* ImportKind.Default */:
ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport.name === symbolName, "(Add new) Default import should be missing or match symbolName");
entry.defaultImport = { name: symbolName, addAsTypeOnly: reduceAddAsTypeOnlyValues((_b = entry.defaultImport) === null || _b === void 0 ? void 0 : _b.addAsTypeOnly, addAsTypeOnly) };
break;
- case 0 /* Named */:
+ case 0 /* ImportKind.Named */:
var prevValue = (entry.namedImports || (entry.namedImports = new ts.Map())).get(symbolName);
entry.namedImports.set(symbolName, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly));
break;
- case 3 /* CommonJS */:
- case 2 /* Namespace */:
+ case 3 /* ImportKind.CommonJS */:
+ case 2 /* ImportKind.Namespace */:
ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName");
entry.namespaceLikeImport = { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly };
break;
}
break;
}
- case 4 /* PromoteTypeOnly */:
+ case 4 /* ImportFixKind.PromoteTypeOnly */:
// Excluding from fix-all
break;
default:
@@ -150379,13 +152949,13 @@ var ts;
namespaceLikeImport: undefined,
useRequire: useRequire
};
- if (importKind === 1 /* Default */ && addAsTypeOnly === 2 /* Required */) {
+ if (importKind === 1 /* ImportKind.Default */ && addAsTypeOnly === 2 /* AddAsTypeOnly.Required */) {
if (typeOnlyEntry)
return typeOnlyEntry;
newImports.set(typeOnlyKey, newEntry);
return newEntry;
}
- if (addAsTypeOnly === 1 /* Allowed */ && (typeOnlyEntry || nonTypeOnlyEntry)) {
+ if (addAsTypeOnly === 1 /* AddAsTypeOnly.Allowed */ && (typeOnlyEntry || nonTypeOnlyEntry)) {
return (typeOnlyEntry || nonTypeOnlyEntry);
}
if (nonTypeOnlyEntry) {
@@ -150460,7 +153030,7 @@ var ts;
: getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, isJsxTagName, host, program, preferences, /*useAutoImportProvider*/ true);
var useRequire = shouldUseRequire(sourceFile, program);
var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position));
- var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences));
+ var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite, useRequire, host, preferences));
return {
moduleSpecifier: fix.moduleSpecifier,
codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix,
@@ -150473,13 +153043,13 @@ var ts;
var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions);
var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program);
var includeSymbolNameInDescription = symbolName !== symbolToken.text;
- return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions));
+ return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* QuotePreference.Double */, compilerOptions));
}
codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction;
- function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
+ function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, host, preferences) {
ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
- return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter, host);
+ return getBestFix(getImportFixes(exportInfos, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes, sourceFile, program, packageJsonImportFilter, host);
}
function codeFixActionToCodeAction(_a) {
var description = _a.description, changes = _a.changes, commands = _a.commands;
@@ -150501,7 +153071,7 @@ var ts;
}
var named = checker.tryGetMemberInModuleExportsAndProperties(symbol.name, moduleSymbol);
if (named && ts.skipAlias(named, checker) === symbol) {
- return { symbol: named, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson };
+ return { symbol: named, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: 0 /* ExportKind.Named */, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson };
}
}
}
@@ -150524,7 +153094,7 @@ var ts;
for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) {
var exported = _a[_i];
if (exported.name === symbolName && checker.getMergedSymbol(ts.skipAlias(exported, checker)) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
- result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson });
+ result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* ExportKind.Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson });
}
}
});
@@ -150534,25 +153104,32 @@ var ts;
return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host));
}
}
- function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
- var _a = getNewImportFixes(program, importingFile,
- /*position*/ undefined,
- /*isValidTypeOnlyUseSite*/ false,
- /*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
+ function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
+ var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite,
+ /*useRequire*/ false, program, importingFile, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host);
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
}
codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
- function getImportFixes(exportInfos, symbolName,
+ function getImportFixes(exportInfos, useNamespaceInfo,
/** undefined only for missing JSX namespace */
- position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences) {
+ isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, fromCacheOnly) {
var checker = program.getTypeChecker();
var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile, program.getCompilerOptions()); });
- var useNamespace = position === undefined ? undefined : tryUseExistingNamespaceImport(existingImports, symbolName, position, checker);
+ var useNamespace = useNamespaceInfo && tryUseExistingNamespaceImport(existingImports, useNamespaceInfo.symbolName, useNamespaceInfo.position, checker);
var addToExisting = tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, program.getCompilerOptions());
- // Don't bother providing an action to add a new import if we can add to an existing one.
- var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences);
- return __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), addImport, true);
+ if (addToExisting) {
+ // Don't bother providing an action to add a new import if we can add to an existing one.
+ return {
+ computedWithoutCacheCount: 0,
+ fixes: __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), [addToExisting], false),
+ };
+ }
+ var _a = getFixesForAddImport(exportInfos, existingImports, program, sourceFile, useNamespaceInfo === null || useNamespaceInfo === void 0 ? void 0 : useNamespaceInfo.position, isValidTypeOnlyUseSite, useRequire, host, preferences, fromCacheOnly), fixes = _a.fixes, _b = _a.computedWithoutCacheCount, computedWithoutCacheCount = _b === void 0 ? 0 : _b;
+ return {
+ computedWithoutCacheCount: computedWithoutCacheCount,
+ fixes: __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), fixes, true),
+ };
}
function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) {
// It is possible that multiple import statements with the same specifier exist in the file.
@@ -150568,13 +153145,14 @@ var ts;
// 2. add "member3" to the second import statement's import list
// and it is up to the user to decide which one fits best.
return ts.firstDefined(existingImports, function (_a) {
+ var _b;
var declaration = _a.declaration;
var namespacePrefix = getNamespaceLikeImportText(declaration);
- var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
+ var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
if (namespacePrefix && moduleSpecifier) {
var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker);
if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) {
- return { kind: 0 /* UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier };
+ return { kind: 0 /* ImportFixKind.UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier };
}
}
});
@@ -150582,11 +153160,11 @@ var ts;
function getTargetModuleFromNamespaceLikeImport(declaration, checker) {
var _a;
switch (declaration.kind) {
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return checker.resolveExternalModuleName(declaration.initializer.arguments[0]);
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return checker.getAliasedSymbol(declaration.symbol);
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
var namespaceImport = ts.tryCast((_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings, ts.isNamespaceImport);
return namespaceImport && checker.getAliasedSymbol(namespaceImport.symbol);
default:
@@ -150596,11 +153174,11 @@ var ts;
function getNamespaceLikeImportText(declaration) {
var _a, _b, _c;
switch (declaration.kind) {
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return (_a = ts.tryCast(declaration.name, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text;
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return declaration.name.text;
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
return (_c = ts.tryCast((_b = declaration.importClause) === null || _b === void 0 ? void 0 : _b.namedBindings, ts.isNamespaceImport)) === null || _c === void 0 ? void 0 : _c.name.text;
default:
return ts.Debug.assertNever(declaration);
@@ -150609,31 +153187,31 @@ var ts;
function getAddAsTypeOnly(isValidTypeOnlyUseSite, isForNewImportDeclaration, symbol, targetFlags, checker, compilerOptions) {
if (!isValidTypeOnlyUseSite) {
// Can't use a type-only import if the usage is an emitting position
- return 4 /* NotAllowed */;
+ return 4 /* AddAsTypeOnly.NotAllowed */;
}
- if (isForNewImportDeclaration && compilerOptions.importsNotUsedAsValues === 2 /* Error */) {
+ if (isForNewImportDeclaration && compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */) {
// Not writing a (top-level) type-only import here would create an error because the runtime dependency is unnecessary
- return 2 /* Required */;
+ return 2 /* AddAsTypeOnly.Required */;
}
if (compilerOptions.isolatedModules && compilerOptions.preserveValueImports &&
- (!(targetFlags & 111551 /* Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) {
+ (!(targetFlags & 111551 /* SymbolFlags.Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) {
// A type-only import is required for this symbol if under these settings if the symbol will
// be erased, which will happen if the target symbol is purely a type or if it was exported/imported
// as type-only already somewhere between this import and the target.
- return 2 /* Required */;
+ return 2 /* AddAsTypeOnly.Required */;
}
- return 1 /* Allowed */;
+ return 1 /* AddAsTypeOnly.Allowed */;
}
function tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, compilerOptions) {
return ts.firstDefined(existingImports, function (_a) {
var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags;
- if (importKind === 3 /* CommonJS */ || importKind === 2 /* Namespace */ || declaration.kind === 264 /* ImportEqualsDeclaration */) {
+ if (importKind === 3 /* ImportKind.CommonJS */ || importKind === 2 /* ImportKind.Namespace */ || declaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
// These kinds of imports are not combinable with anything
return undefined;
}
- if (declaration.kind === 253 /* VariableDeclaration */) {
- return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 200 /* ObjectBindingPattern */
- ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* NotAllowed */ }
+ if (declaration.kind === 254 /* SyntaxKind.VariableDeclaration */) {
+ return (importKind === 0 /* ImportKind.Named */ || importKind === 1 /* ImportKind.Default */) && declaration.name.kind === 201 /* SyntaxKind.ObjectBindingPattern */
+ ? { kind: 2 /* ImportFixKind.AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* AddAsTypeOnly.NotAllowed */ }
: undefined;
}
var importClause = declaration.importClause;
@@ -150642,22 +153220,22 @@ var ts;
var name = importClause.name, namedBindings = importClause.namedBindings;
// A type-only import may not have both a default and named imports, so the only way a name can
// be added to an existing type-only import is adding a named import to existing named bindings.
- if (importClause.isTypeOnly && !(importKind === 0 /* Named */ && namedBindings))
+ if (importClause.isTypeOnly && !(importKind === 0 /* ImportKind.Named */ && namedBindings))
return undefined;
// N.B. we don't have to figure out whether to use the main program checker
// or the AutoImportProvider checker because we're adding to an existing import; the existence of
// the import guarantees the symbol came from the main program.
var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ false, symbol, targetFlags, checker, compilerOptions);
- if (importKind === 1 /* Default */ && (name || // Cannot add a default import to a declaration that already has one
- addAsTypeOnly === 2 /* Required */ && namedBindings // Cannot add a default import as type-only if the import already has named bindings
+ if (importKind === 1 /* ImportKind.Default */ && (name || // Cannot add a default import to a declaration that already has one
+ addAsTypeOnly === 2 /* AddAsTypeOnly.Required */ && namedBindings // Cannot add a default import as type-only if the import already has named bindings
))
return undefined;
- if (importKind === 0 /* Named */ &&
- (namedBindings === null || namedBindings === void 0 ? void 0 : namedBindings.kind) === 267 /* NamespaceImport */ // Cannot add a named import to a declaration that has a namespace import
+ if (importKind === 0 /* ImportKind.Named */ &&
+ (namedBindings === null || namedBindings === void 0 ? void 0 : namedBindings.kind) === 268 /* SyntaxKind.NamespaceImport */ // Cannot add a named import to a declaration that has a namespace import
)
return undefined;
return {
- kind: 2 /* AddToExisting */,
+ kind: 2 /* ImportFixKind.AddToExisting */,
importClauseOrBindingPattern: importClause,
importKind: importKind,
moduleSpecifier: declaration.moduleSpecifier.text,
@@ -150668,7 +153246,7 @@ var ts;
function getExistingImportDeclarations(_a, checker, importingFile, compilerOptions) {
var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol;
// Can't use an es6 import for a type in JS.
- if (!(targetFlags & 111551 /* Value */) && ts.isSourceFileJS(importingFile))
+ if (!(targetFlags & 111551 /* SymbolFlags.Value */) && ts.isSourceFileJS(importingFile))
return ts.emptyArray;
var importKind = getImportKind(importingFile, exportKind, compilerOptions);
return ts.mapDefined(importingFile.imports, function (moduleSpecifier) {
@@ -150676,7 +153254,7 @@ var ts;
if (ts.isVariableDeclarationInitializedToRequire(i.parent)) {
return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined;
}
- if (i.kind === 265 /* ImportDeclaration */ || i.kind === 264 /* ImportEqualsDeclaration */) {
+ if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined;
}
});
@@ -150714,6 +153292,7 @@ var ts;
var compilerOptions = program.getCompilerOptions();
var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host);
var getChecker = ts.memoizeOne(function (isFromPackageJson) { return isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); });
+ var rejectNodeModulesRelativePaths = ts.moduleResolutionUsesNodeModules(ts.getEmitModuleResolutionKind(compilerOptions));
var getModuleSpecifiers = fromCacheOnly
? function (moduleSymbol) { return ({ moduleSpecifiers: ts.moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }); }
: function (moduleSymbol, checker) { return ts.moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); };
@@ -150721,38 +153300,39 @@ var ts;
var fixes = ts.flatMap(exportInfo, function (exportInfo, i) {
var checker = getChecker(exportInfo.isFromPackageJson);
var _a = getModuleSpecifiers(exportInfo.moduleSymbol, checker), computedWithoutCache = _a.computedWithoutCache, moduleSpecifiers = _a.moduleSpecifiers;
- var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */);
+ var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* SymbolFlags.Value */);
var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, exportInfo.symbol, exportInfo.targetFlags, checker, compilerOptions);
computedWithoutCacheCount += computedWithoutCache ? 1 : 0;
- return moduleSpecifiers === null || moduleSpecifiers === void 0 ? void 0 : moduleSpecifiers.map(function (moduleSpecifier) {
- // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types.
- return !importedSymbolHasValueMeaning && isJs && position !== undefined
- ? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 }
- : {
- kind: 3 /* AddNew */,
- moduleSpecifier: moduleSpecifier,
- importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions),
- useRequire: useRequire,
- addAsTypeOnly: addAsTypeOnly,
- exportInfo: exportInfo,
- isReExport: i > 0,
- };
+ return ts.mapDefined(moduleSpecifiers, function (moduleSpecifier) {
+ return rejectNodeModulesRelativePaths && ts.pathContainsNodeModules(moduleSpecifier) ? undefined :
+ // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types.
+ !importedSymbolHasValueMeaning && isJs && position !== undefined ? { kind: 1 /* ImportFixKind.JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } :
+ {
+ kind: 3 /* ImportFixKind.AddNew */,
+ moduleSpecifier: moduleSpecifier,
+ importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions),
+ useRequire: useRequire,
+ addAsTypeOnly: addAsTypeOnly,
+ exportInfo: exportInfo,
+ isReExport: i > 0,
+ };
});
});
return { computedWithoutCacheCount: computedWithoutCacheCount, fixes: fixes };
}
- function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
+ function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences, fromCacheOnly) {
var existingDeclaration = ts.firstDefined(existingImports, function (info) { return newImportInfoFromExistingSpecifier(info, isValidTypeOnlyUseSite, useRequire, program.getTypeChecker(), program.getCompilerOptions()); });
- return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes;
+ return existingDeclaration ? { fixes: [existingDeclaration] } : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences, fromCacheOnly);
}
function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) {
+ var _b;
var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags;
- var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
+ var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
if (moduleSpecifier) {
var addAsTypeOnly = useRequire
- ? 4 /* NotAllowed */
+ ? 4 /* AddAsTypeOnly.NotAllowed */
: getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, symbol, targetFlags, checker, compilerOptions);
- return { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire };
+ return { kind: 3 /* ImportFixKind.AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire };
}
}
function getFixesInfo(context, errorCode, pos, useAutoImportProvider) {
@@ -150783,23 +153363,23 @@ var ts;
if (!ts.some(fixes))
return;
// These will always be placed first if available, and are better than other kinds
- if (fixes[0].kind === 0 /* UseNamespace */ || fixes[0].kind === 2 /* AddToExisting */) {
+ if (fixes[0].kind === 0 /* ImportFixKind.UseNamespace */ || fixes[0].kind === 2 /* ImportFixKind.AddToExisting */) {
return fixes[0];
}
return fixes.reduce(function (best, fix) {
// Takes true branch of conditional if `fix` is better than `best`
- return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* LessThan */ ? fix : best;
+ return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* Comparison.LessThan */ ? fix : best;
});
}
/** @returns `Comparison.LessThan` if `a` is better than `b`. */
function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier, toPath) {
- if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) {
+ if (a.kind !== 0 /* ImportFixKind.UseNamespace */ && b.kind !== 0 /* ImportFixKind.UseNamespace */) {
return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier))
|| compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program)
|| ts.compareBooleans(isFixPossiblyReExportingImportingFile(a, importingFile, program.getCompilerOptions(), toPath), isFixPossiblyReExportingImportingFile(b, importingFile, program.getCompilerOptions(), toPath))
|| ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier);
}
- return 0 /* EqualTo */;
+ return 0 /* Comparison.EqualTo */;
}
// This is a simple heuristic to try to avoid creating an import cycle with a barrel re-export.
// E.g., do not `import { Foo } from ".."` when you could `import { Foo } from "../Foo"`.
@@ -150822,10 +153402,10 @@ var ts;
}
function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) {
if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:"))
- return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* LessThan */ : 1 /* GreaterThan */;
+ return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */;
if (ts.startsWith(b, "node:") && !ts.startsWith(a, "node:"))
- return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? 1 /* GreaterThan */ : -1 /* LessThan */;
- return 0 /* EqualTo */;
+ return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? 1 /* Comparison.GreaterThan */ : -1 /* Comparison.LessThan */;
+ return 0 /* Comparison.EqualTo */;
}
function getFixesInfoForUMDImport(_a, token) {
var _b;
@@ -150836,9 +153416,10 @@ var ts;
return undefined;
var symbol = checker.getAliasedSymbol(umdSymbol);
var symbolName = umdSymbol.name;
- var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
+ var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* ExportKind.UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
var useRequire = shouldUseRequire(sourceFile, program);
- var fixes = getImportFixes(exportInfo, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
+ var position = ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined;
+ var fixes = getImportFixes(exportInfo, position ? { position: position, symbolName: symbolName } : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences).fixes;
return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
}
function getUmdSymbol(token, checker) {
@@ -150849,7 +153430,7 @@ var ts;
// The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`.
var parent = token.parent;
return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent)
- ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol)
+ ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol)
: undefined;
}
/**
@@ -150858,10 +153439,10 @@ var ts;
*/
function getImportKind(importingFile, exportKind, compilerOptions, forceImportKeyword) {
switch (exportKind) {
- case 0 /* Named */: return 0 /* Named */;
- case 1 /* Default */: return 1 /* Default */;
- case 2 /* ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword);
- case 3 /* UMD */: return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword);
+ case 0 /* ExportKind.Named */: return 0 /* ImportKind.Named */;
+ case 1 /* ExportKind.Default */: return 1 /* ImportKind.Default */;
+ case 2 /* ExportKind.ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword);
+ case 3 /* ExportKind.UMD */: return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword);
default: return ts.Debug.assertNever(exportKind);
}
}
@@ -150869,7 +153450,7 @@ var ts;
function getUmdImportKind(importingFile, compilerOptions, forceImportKeyword) {
// Import a synthetic `default` if enabled.
if (ts.getAllowSyntheticDefaultImports(compilerOptions)) {
- return 1 /* Default */;
+ return 1 /* ImportKind.Default */;
}
// When a synthetic `default` is unavailable, use `import..require` if the module kind supports it.
var moduleKind = ts.getEmitModuleKind(compilerOptions);
@@ -150878,9 +153459,9 @@ var ts;
case ts.ModuleKind.CommonJS:
case ts.ModuleKind.UMD:
if (ts.isInJSFile(importingFile)) {
- return ts.isExternalModule(importingFile) || forceImportKeyword ? 2 /* Namespace */ : 3 /* CommonJS */;
+ return ts.isExternalModule(importingFile) || forceImportKeyword ? 2 /* ImportKind.Namespace */ : 3 /* ImportKind.CommonJS */;
}
- return 3 /* CommonJS */;
+ return 3 /* ImportKind.CommonJS */;
case ts.ModuleKind.System:
case ts.ModuleKind.ES2015:
case ts.ModuleKind.ES2020:
@@ -150888,10 +153469,10 @@ var ts;
case ts.ModuleKind.ESNext:
case ts.ModuleKind.None:
// Fall back to the `import * as ns` style import.
- return 2 /* Namespace */;
- case ts.ModuleKind.Node12:
+ return 2 /* ImportKind.Namespace */;
+ case ts.ModuleKind.Node16:
case ts.ModuleKind.NodeNext:
- return importingFile.impliedNodeFormat === ts.ModuleKind.ESNext ? 2 /* Namespace */ : 3 /* CommonJS */;
+ return importingFile.impliedNodeFormat === ts.ModuleKind.ESNext ? 2 /* ImportKind.Namespace */ : 3 /* ImportKind.CommonJS */;
default:
return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind ".concat(moduleKind));
}
@@ -150901,33 +153482,32 @@ var ts;
var checker = program.getTypeChecker();
var compilerOptions = program.getCompilerOptions();
var symbolName = getSymbolName(sourceFile, checker, symbolToken, compilerOptions);
- // "default" is a keyword and not a legal identifier for the import, so we don't expect it here
- ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here");
+ // "default" is a keyword and not a legal identifier for the import, but appears as an identifier.
+ if (symbolName === "default" /* InternalSymbolName.Default */) {
+ return undefined;
+ }
var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
var useRequire = shouldUseRequire(sourceFile, program);
var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) {
var _ = _a[0], exportInfos = _a[1];
- return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
+ return getImportFixes(exportInfos, { symbolName: symbolName, position: symbolToken.getStart(sourceFile) }, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes;
}));
return { fixes: fixes, symbolName: symbolName, errorIdentifierText: symbolToken.text };
}
function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) {
var checker = program.getTypeChecker();
- var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
+ var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true);
if (!symbol)
return undefined;
var typeOnlyAliasDeclaration = checker.getTypeOnlyAliasDeclaration(symbol);
if (!typeOnlyAliasDeclaration || ts.getSourceFileOfNode(typeOnlyAliasDeclaration) !== sourceFile)
return undefined;
- return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration };
- }
- function jsxModeNeedsExplicitImport(jsx) {
- return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
+ return { kind: 4 /* ImportFixKind.PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration };
}
function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) {
var parent = symbolToken.parent;
- if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
+ if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && ts.jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
var jsxNamespace = checker.getJsxNamespace(sourceFile);
if (needsJsxNamespaceFix(jsxNamespace, symbolToken, checker)) {
return jsxNamespace;
@@ -150938,8 +153518,8 @@ var ts;
function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) {
if (ts.isIntrinsicJsxName(symbolToken.text))
return true; // If we were triggered by a matching error code on an intrinsic, the error must have been about missing the JSX factory
- var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
- return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* Value */);
+ var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true);
+ return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* SymbolFlags.Value */);
}
// Returns a map from an exported symbol's ID to a list of every way it's (re-)exported.
function getExportInfos(symbolName, isJsxTagName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) {
@@ -150971,7 +153551,7 @@ var ts;
// check exports with the same name
var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol);
if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) {
- addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* Named */, program, isFromPackageJson);
+ addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* ExportKind.Named */, program, isFromPackageJson);
}
});
return originalSymbolToExportInfos;
@@ -150982,14 +153562,14 @@ var ts;
// 1. 'import =' will not work in es2015+ TS files, so the decision is between a default
// and a namespace import, based on allowSyntheticDefaultImports/esModuleInterop.
if (!isJS && ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) {
- return allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */;
+ return allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 2 /* ImportKind.Namespace */;
}
// 2. 'import =' will not work in JavaScript, so the decision is between a default import,
// a namespace import, and const/require.
if (isJS) {
return ts.isExternalModule(importingFile) || forceImportKeyword
- ? allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */
- : 3 /* CommonJS */;
+ ? allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 2 /* ImportKind.Namespace */
+ : 3 /* ImportKind.CommonJS */;
}
// 3. At this point the most correct choice is probably 'import =', but people
// really hate that, so look to see if the importing file has any precedent
@@ -150998,12 +153578,12 @@ var ts;
var statement = _a[_i];
// `import foo` parses as an ImportEqualsDeclaration even though it could be an ImportDeclaration
if (ts.isImportEqualsDeclaration(statement) && !ts.nodeIsMissing(statement.moduleReference)) {
- return 3 /* CommonJS */;
+ return 3 /* ImportKind.CommonJS */;
}
}
// 4. We have no precedent to go on, so just use a default import if
// allowSyntheticDefaultImports/esModuleInterop is enabled.
- return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */;
+ return allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 3 /* ImportKind.CommonJS */;
}
function codeActionForFix(context, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) {
var diag;
@@ -151014,35 +153594,35 @@ var ts;
}
function codeActionForFixWorker(changes, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) {
switch (fix.kind) {
- case 0 /* UseNamespace */:
+ case 0 /* ImportFixKind.UseNamespace */:
addNamespaceQualifier(changes, sourceFile, fix);
return [ts.Diagnostics.Change_0_to_1, symbolName, "".concat(fix.namespacePrefix, ".").concat(symbolName)];
- case 1 /* JsdocTypeImport */:
+ case 1 /* ImportFixKind.JsdocTypeImport */:
addImportType(changes, sourceFile, fix, quotePreference);
return [ts.Diagnostics.Change_0_to_1, symbolName, getImportTypePrefix(fix.moduleSpecifier, quotePreference) + symbolName];
- case 2 /* AddToExisting */: {
+ case 2 /* ImportFixKind.AddToExisting */: {
var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly, moduleSpecifier = fix.moduleSpecifier;
- doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions);
+ doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* ImportKind.Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* ImportKind.Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions);
var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier);
return includeSymbolNameInDescription
? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifierWithoutQuotes]
: [ts.Diagnostics.Update_import_from_0, moduleSpecifierWithoutQuotes];
}
- case 3 /* AddNew */: {
+ case 3 /* ImportFixKind.AddNew */: {
var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, addAsTypeOnly = fix.addAsTypeOnly, useRequire = fix.useRequire;
var getDeclarations = useRequire ? getNewRequires : getNewImports;
- var defaultImport = importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined;
- var namedImports = importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined;
- var namespaceLikeImport = importKind === 2 /* Namespace */ || importKind === 3 /* CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined;
+ var defaultImport = importKind === 1 /* ImportKind.Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined;
+ var namedImports = importKind === 0 /* ImportKind.Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined;
+ var namespaceLikeImport = importKind === 2 /* ImportKind.Namespace */ || importKind === 3 /* ImportKind.CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined;
ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true);
return includeSymbolNameInDescription
? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifier]
: [ts.Diagnostics.Add_import_from_0, moduleSpecifier];
}
- case 4 /* PromoteTypeOnly */: {
+ case 4 /* ImportFixKind.PromoteTypeOnly */: {
var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration;
var promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, compilerOptions, sourceFile);
- return promotedDeclaration.kind === 269 /* ImportSpecifier */
+ return promotedDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */
? [ts.Diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)]
: [ts.Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)];
}
@@ -151052,7 +153632,7 @@ var ts;
}
function getModuleSpecifierText(promotedDeclaration) {
var _a, _b;
- return promotedDeclaration.kind === 264 /* ImportEqualsDeclaration */
+ return promotedDeclaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */
? ((_b = ts.tryCast((_a = ts.tryCast(promotedDeclaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression, ts.isStringLiteralLike)) === null || _b === void 0 ? void 0 : _b.text) || promotedDeclaration.moduleReference.getText()
: ts.cast(promotedDeclaration.parent.moduleSpecifier, ts.isStringLiteral).text;
}
@@ -151060,7 +153640,7 @@ var ts;
// See comment in `doAddExistingFix` on constant with the same name.
var convertExistingToTypeOnly = compilerOptions.preserveValueImports && compilerOptions.isolatedModules;
switch (aliasDeclaration.kind) {
- case 269 /* ImportSpecifier */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
if (aliasDeclaration.isTypeOnly) {
if (aliasDeclaration.parent.elements.length > 1 && ts.OrganizeImports.importSpecifiersAreSorted(aliasDeclaration.parent.elements)) {
changes.delete(sourceFile, aliasDeclaration);
@@ -151078,13 +153658,13 @@ var ts;
promoteImportClause(aliasDeclaration.parent.parent);
return aliasDeclaration.parent.parent;
}
- case 266 /* ImportClause */:
+ case 267 /* SyntaxKind.ImportClause */:
promoteImportClause(aliasDeclaration);
return aliasDeclaration;
- case 267 /* NamespaceImport */:
+ case 268 /* SyntaxKind.NamespaceImport */:
promoteImportClause(aliasDeclaration.parent);
return aliasDeclaration.parent;
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
changes.deleteRange(sourceFile, aliasDeclaration.getChildAt(1));
return aliasDeclaration;
default:
@@ -151096,7 +153676,7 @@ var ts;
var namedImports = ts.tryCast(importClause.namedBindings, ts.isNamedImports);
if (namedImports && namedImports.elements.length > 1) {
if (ts.OrganizeImports.importSpecifiersAreSorted(namedImports.elements) &&
- aliasDeclaration.kind === 269 /* ImportSpecifier */ &&
+ aliasDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ &&
namedImports.elements.indexOf(aliasDeclaration) !== 0) {
// The import specifier being promoted will be the only non-type-only,
// import in the NamedImports, so it should be moved to the front.
@@ -151106,7 +153686,7 @@ var ts;
for (var _i = 0, _a = namedImports.elements; _i < _a.length; _i++) {
var element = _a[_i];
if (element !== aliasDeclaration && !element.isTypeOnly) {
- changes.insertModifierBefore(sourceFile, 151 /* TypeKeyword */, element);
+ changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, element);
}
}
}
@@ -151115,7 +153695,7 @@ var ts;
}
function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) {
var _a;
- if (clause.kind === 200 /* ObjectBindingPattern */) {
+ if (clause.kind === 201 /* SyntaxKind.ObjectBindingPattern */) {
if (defaultImport) {
addElementToBindingPattern(clause, defaultImport.name, "default");
}
@@ -151125,7 +153705,7 @@ var ts;
}
return;
}
- var promoteFromTypeOnly = clause.isTypeOnly && ts.some(__spreadArray([defaultImport], namedImports, true), function (i) { return (i === null || i === void 0 ? void 0 : i.addAsTypeOnly) === 4 /* NotAllowed */; });
+ var promoteFromTypeOnly = clause.isTypeOnly && ts.some(__spreadArray([defaultImport], namedImports, true), function (i) { return (i === null || i === void 0 ? void 0 : i.addAsTypeOnly) === 4 /* AddAsTypeOnly.NotAllowed */; });
var existingSpecifiers = clause.namedBindings && ((_a = ts.tryCast(clause.namedBindings, ts.isNamedImports)) === null || _a === void 0 ? void 0 : _a.elements);
// If we are promoting from a type-only import and `--isolatedModules` and `--preserveValueImports`
// are enabled, we need to make every existing import specifier type-only. It may be possible that
@@ -151176,7 +153756,7 @@ var ts;
if (convertExistingToTypeOnly && existingSpecifiers) {
for (var _d = 0, existingSpecifiers_1 = existingSpecifiers; _d < existingSpecifiers_1.length; _d++) {
var specifier = existingSpecifiers_1[_d];
- changes.insertModifierBefore(sourceFile, 151 /* TypeKeyword */, specifier);
+ changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, specifier);
}
}
}
@@ -151204,7 +153784,7 @@ var ts;
}
function needsTypeOnly(_a) {
var addAsTypeOnly = _a.addAsTypeOnly;
- return addAsTypeOnly === 2 /* Required */;
+ return addAsTypeOnly === 2 /* AddAsTypeOnly.Required */;
}
function getNewImports(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport) {
var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifier, quotePreference);
@@ -151213,12 +153793,12 @@ var ts;
var topLevelTypeOnly_1 = (!defaultImport || needsTypeOnly(defaultImport)) && ts.every(namedImports, needsTypeOnly);
statements = ts.combine(statements, ts.makeImport(defaultImport && ts.factory.createIdentifier(defaultImport.name), namedImports === null || namedImports === void 0 ? void 0 : namedImports.map(function (_a) {
var addAsTypeOnly = _a.addAsTypeOnly, name = _a.name;
- return ts.factory.createImportSpecifier(!topLevelTypeOnly_1 && addAsTypeOnly === 2 /* Required */,
+ return ts.factory.createImportSpecifier(!topLevelTypeOnly_1 && addAsTypeOnly === 2 /* AddAsTypeOnly.Required */,
/*propertyName*/ undefined, ts.factory.createIdentifier(name));
}), moduleSpecifier, quotePreference, topLevelTypeOnly_1));
}
if (namespaceLikeImport) {
- var declaration = namespaceLikeImport.importKind === 3 /* CommonJS */
+ var declaration = namespaceLikeImport.importKind === 3 /* ImportKind.CommonJS */
? ts.factory.createImportEqualsDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined, needsTypeOnly(namespaceLikeImport), ts.factory.createIdentifier(namespaceLikeImport.name), ts.factory.createExternalModuleReference(quotedModuleSpecifier))
@@ -151259,7 +153839,7 @@ var ts;
ts.factory.createVariableDeclaration(typeof name === "string" ? ts.factory.createIdentifier(name) : name,
/*exclamationToken*/ undefined,
/*type*/ undefined, ts.factory.createCallExpression(ts.factory.createIdentifier("require"), /*typeArguments*/ undefined, [quotedModuleSpecifier]))
- ], 2 /* Const */));
+ ], 2 /* NodeFlags.Const */));
}
function symbolHasMeaning(_a, meaning) {
var declarations = _a.declarations;
@@ -151430,7 +154010,7 @@ var ts;
accessibilityModifier ? accessibilityModifier.end :
classElement.decorators ? ts.skipTrivia(sourceFile.text, classElement.decorators.end) : classElement.getStart(sourceFile);
var options = accessibilityModifier || staticModifier || abstractModifier ? { prefix: " " } : { suffix: " " };
- changeTracker.insertModifierAt(sourceFile, modifierPos, 158 /* OverrideKeyword */, options);
+ changeTracker.insertModifierAt(sourceFile, modifierPos, 159 /* SyntaxKind.OverrideKeyword */, options);
}
function doRemoveOverrideModifierChange(changeTracker, sourceFile, pos) {
var classElement = findContainerClassElementLike(sourceFile, pos);
@@ -151438,19 +154018,19 @@ var ts;
changeTracker.filterJSDocTags(sourceFile, classElement, ts.not(ts.isJSDocOverrideTag));
return;
}
- var overrideModifier = classElement.modifiers && ts.find(classElement.modifiers, function (modifier) { return modifier.kind === 158 /* OverrideKeyword */; });
+ var overrideModifier = classElement.modifiers && ts.find(classElement.modifiers, function (modifier) { return modifier.kind === 159 /* SyntaxKind.OverrideKeyword */; });
ts.Debug.assertIsDefined(overrideModifier);
changeTracker.deleteModifier(sourceFile, overrideModifier);
}
function isClassElementLikeHasJSDoc(node) {
switch (node.kind) {
- case 170 /* Constructor */:
- case 166 /* PropertyDeclaration */:
- case 168 /* MethodDeclaration */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
return true;
- case 163 /* Parameter */:
+ case 164 /* SyntaxKind.Parameter */:
return ts.isParameterPropertyDeclaration(node, node.parent);
default:
return false;
@@ -151492,7 +154072,7 @@ var ts;
});
function doChange(changes, sourceFile, node, preferences) {
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
- var argumentsExpression = ts.factory.createStringLiteral(node.name.text, quotePreference === 0 /* Single */);
+ var argumentsExpression = ts.factory.createStringLiteral(node.name.text, quotePreference === 0 /* QuotePreference.Single */);
changes.replaceNode(sourceFile, node, ts.isPropertyAccessChain(node) ?
ts.factory.createElementAccessChain(node.expression, node.questionDotToken, argumentsExpression) :
ts.factory.createElementAccessExpression(node.expression, argumentsExpression));
@@ -151532,7 +154112,7 @@ var ts;
if (!ts.isFunctionDeclaration(fn) && !ts.isFunctionExpression(fn))
return undefined;
if (!ts.isSourceFile(ts.getThisContainer(fn, /*includeArrowFunctions*/ false))) { // 'this' is defined outside, convert to arrow function
- var fnKeyword = ts.Debug.checkDefined(ts.findChildOfKind(fn, 98 /* FunctionKeyword */, sourceFile));
+ var fnKeyword = ts.Debug.checkDefined(ts.findChildOfKind(fn, 98 /* SyntaxKind.FunctionKeyword */, sourceFile));
var name = fn.name;
var body = ts.Debug.checkDefined(fn.body); // Should be defined because the function contained a 'this' expression
if (ts.isFunctionExpression(fn)) {
@@ -151551,7 +154131,7 @@ var ts;
else {
// `function f() {}` => `const f = () => {}`
// `name` should be defined because we only do this in inner contexts, and name is only undefined for `export default function() {}`.
- changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* ConstKeyword */));
+ changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* SyntaxKind.ConstKeyword */));
changes.insertText(sourceFile, name.end, " = ");
changes.insertText(sourceFile, body.pos, " =>");
return [ts.Diagnostics.Convert_function_declaration_0_to_arrow_function, name.text];
@@ -151582,7 +154162,7 @@ var ts;
});
function getNamedTupleMember(sourceFile, pos) {
var token = ts.getTokenAtPosition(sourceFile, pos);
- return ts.findAncestor(token, function (t) { return t.kind === 196 /* NamedTupleMember */; });
+ return ts.findAncestor(token, function (t) { return t.kind === 197 /* SyntaxKind.NamedTupleMember */; });
}
function doChange(changes, sourceFile, namedTupleMember) {
if (!namedTupleMember) {
@@ -151591,16 +154171,16 @@ var ts;
var unwrappedType = namedTupleMember.type;
var sawOptional = false;
var sawRest = false;
- while (unwrappedType.kind === 184 /* OptionalType */ || unwrappedType.kind === 185 /* RestType */ || unwrappedType.kind === 190 /* ParenthesizedType */) {
- if (unwrappedType.kind === 184 /* OptionalType */) {
+ while (unwrappedType.kind === 185 /* SyntaxKind.OptionalType */ || unwrappedType.kind === 186 /* SyntaxKind.RestType */ || unwrappedType.kind === 191 /* SyntaxKind.ParenthesizedType */) {
+ if (unwrappedType.kind === 185 /* SyntaxKind.OptionalType */) {
sawOptional = true;
}
- else if (unwrappedType.kind === 185 /* RestType */) {
+ else if (unwrappedType.kind === 186 /* SyntaxKind.RestType */) {
sawRest = true;
}
unwrappedType = unwrappedType.type;
}
- var updated = ts.factory.updateNamedTupleMember(namedTupleMember, namedTupleMember.dotDotDotToken || (sawRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined), namedTupleMember.name, namedTupleMember.questionToken || (sawOptional ? ts.factory.createToken(57 /* QuestionToken */) : undefined), unwrappedType);
+ var updated = ts.factory.updateNamedTupleMember(namedTupleMember, namedTupleMember.dotDotDotToken || (sawRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined), namedTupleMember.name, namedTupleMember.questionToken || (sawOptional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined), unwrappedType);
if (updated === namedTupleMember) {
return;
}
@@ -151666,18 +154246,18 @@ var ts;
if (ts.isPropertyAccessExpression(parent) && parent.name === node) {
ts.Debug.assert(ts.isMemberName(node), "Expected an identifier for spelling (property access)");
var containingType = checker.getTypeAtLocation(parent.expression);
- if (parent.flags & 32 /* OptionalChain */) {
+ if (parent.flags & 32 /* NodeFlags.OptionalChain */) {
containingType = checker.getNonNullableType(containingType);
}
suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, containingType);
}
- else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 101 /* InKeyword */ && parent.left === node && ts.isPrivateIdentifier(node)) {
+ else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ && parent.left === node && ts.isPrivateIdentifier(node)) {
var receiverType = checker.getTypeAtLocation(parent.right);
suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, receiverType);
}
else if (ts.isQualifiedName(parent) && parent.right === node) {
var symbol = checker.getSymbolAtLocation(parent.left);
- if (symbol && symbol.flags & 1536 /* Module */) {
+ if (symbol && symbol.flags & 1536 /* SymbolFlags.Module */) {
suggestedSymbol = checker.getSuggestedSymbolForNonexistentModule(parent.right, symbol);
}
}
@@ -151695,7 +154275,7 @@ var ts;
var props = checker.getContextualTypeForArgumentAtIndex(tag, 0);
suggestedSymbol = checker.getSuggestedSymbolForNonexistentJSXAttribute(node, props);
}
- else if (ts.hasSyntacticModifier(parent, 16384 /* Override */) && ts.isClassElement(parent) && parent.name === node) {
+ else if (ts.hasSyntacticModifier(parent, 16384 /* ModifierFlags.Override */) && ts.isClassElement(parent) && parent.name === node) {
var baseDeclaration = ts.findAncestor(node, ts.isClassLike);
var baseTypeNode = baseDeclaration ? ts.getEffectiveBaseTypeNode(baseDeclaration) : undefined;
var baseType = baseTypeNode ? checker.getTypeAtLocation(baseTypeNode) : undefined;
@@ -151728,14 +154308,14 @@ var ts;
}
function convertSemanticMeaningToSymbolFlags(meaning) {
var flags = 0;
- if (meaning & 4 /* Namespace */) {
- flags |= 1920 /* Namespace */;
+ if (meaning & 4 /* SemanticMeaning.Namespace */) {
+ flags |= 1920 /* SymbolFlags.Namespace */;
}
- if (meaning & 2 /* Type */) {
- flags |= 788968 /* Type */;
+ if (meaning & 2 /* SemanticMeaning.Type */) {
+ flags |= 788968 /* SymbolFlags.Type */;
}
- if (meaning & 1 /* Value */) {
- flags |= 111551 /* Value */;
+ if (meaning & 1 /* SemanticMeaning.Value */) {
+ flags |= 111551 /* SymbolFlags.Value */;
}
return flags;
}
@@ -151807,7 +154387,7 @@ var ts;
}); },
});
function createObjectTypeFromLabeledExpression(checker, label, expression) {
- var member = checker.createSymbol(4 /* Property */, label.escapedText);
+ var member = checker.createSymbol(4 /* SymbolFlags.Property */, label.escapedText);
member.type = checker.getTypeAtLocation(expression);
var members = ts.createSymbolTable([member]);
return checker.createAnonymousType(/*symbol*/ undefined, members, [], [], []);
@@ -151866,7 +154446,7 @@ var ts;
if (isFunctionType) {
var sig = checker.getSignatureFromDeclaration(declaration);
if (sig) {
- if (ts.hasSyntacticModifier(declaration, 256 /* Async */)) {
+ if (ts.hasSyntacticModifier(declaration, 256 /* ModifierFlags.Async */)) {
exprType = checker.createPromiseType(exprType);
}
var newSig = checker.createSignature(declaration, sig.typeParameters, sig.thisParameter, sig.parameters, exprType,
@@ -151910,19 +154490,19 @@ var ts;
}
function getVariableLikeInitializer(declaration) {
switch (declaration.kind) {
- case 253 /* VariableDeclaration */:
- case 163 /* Parameter */:
- case 202 /* BindingElement */:
- case 166 /* PropertyDeclaration */:
- case 294 /* PropertyAssignment */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
+ case 164 /* SyntaxKind.Parameter */:
+ case 203 /* SyntaxKind.BindingElement */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
return declaration.initializer;
- case 284 /* JsxAttribute */:
+ case 285 /* SyntaxKind.JsxAttribute */:
return declaration.initializer && (ts.isJsxExpression(declaration.initializer) ? declaration.initializer.expression : undefined);
- case 295 /* ShorthandPropertyAssignment */:
- case 165 /* PropertySignature */:
- case 297 /* EnumMember */:
- case 345 /* JSDocPropertyTag */:
- case 338 /* JSDocParameterTag */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 299 /* SyntaxKind.EnumMember */:
+ case 347 /* SyntaxKind.JSDocPropertyTag */:
+ case 340 /* SyntaxKind.JSDocParameterTag */:
return undefined;
}
}
@@ -151984,19 +154564,19 @@ var ts;
if (!info) {
return undefined;
}
- if (info.kind === 3 /* ObjectLiteral */) {
+ if (info.kind === 3 /* InfoKind.ObjectLiteral */) {
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addObjectLiteralProperties(t, context, info); });
return [codefix.createCodeFixAction(fixMissingProperties, changes, ts.Diagnostics.Add_missing_properties, fixMissingProperties, ts.Diagnostics.Add_all_missing_properties)];
}
- if (info.kind === 4 /* JsxAttributes */) {
+ if (info.kind === 4 /* InfoKind.JsxAttributes */) {
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addJsxAttributes(t, context, info); });
return [codefix.createCodeFixAction(fixMissingAttributes, changes, ts.Diagnostics.Add_missing_attributes, fixMissingAttributes, ts.Diagnostics.Add_all_missing_attributes)];
}
- if (info.kind === 2 /* Function */) {
+ if (info.kind === 2 /* InfoKind.Function */) {
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addFunctionDeclaration(t, context, info); });
return [codefix.createCodeFixAction(fixMissingFunctionDeclaration, changes, [ts.Diagnostics.Add_missing_function_declaration_0, info.token.text], fixMissingFunctionDeclaration, ts.Diagnostics.Add_all_missing_function_declarations)];
}
- if (info.kind === 0 /* Enum */) {
+ if (info.kind === 1 /* InfoKind.Enum */) {
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), info); });
return [codefix.createCodeFixAction(fixMissingMember, changes, [ts.Diagnostics.Add_missing_enum_member_0, info.token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members)];
}
@@ -152014,20 +154594,20 @@ var ts;
if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) {
return;
}
- if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* Function */) {
+ if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* InfoKind.Function */) {
addFunctionDeclaration(changes, context, info);
}
- else if (fixId === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) {
+ else if (fixId === fixMissingProperties && info.kind === 3 /* InfoKind.ObjectLiteral */) {
addObjectLiteralProperties(changes, context, info);
}
- else if (fixId === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) {
+ else if (fixId === fixMissingAttributes && info.kind === 4 /* InfoKind.JsxAttributes */) {
addJsxAttributes(changes, context, info);
}
else {
- if (info.kind === 0 /* Enum */) {
+ if (info.kind === 1 /* InfoKind.Enum */) {
addEnumMemberDeclaration(changes, checker, info);
}
- if (info.kind === 1 /* ClassOrInterface */) {
+ if (info.kind === 0 /* InfoKind.TypeLikeDeclaration */) {
var parentDeclaration = info.parentDeclaration, token_1 = info.token;
var infos = ts.getOrUpdate(typeDeclToMembers, parentDeclaration, function () { return []; });
if (!infos.some(function (i) { return i.token.text === token_1.text; })) {
@@ -152036,11 +154616,11 @@ var ts;
}
}
});
- typeDeclToMembers.forEach(function (infos, classDeclaration) {
- var supers = codefix.getAllSupers(classDeclaration, checker);
+ typeDeclToMembers.forEach(function (infos, declaration) {
+ var supers = ts.isTypeLiteralNode(declaration) ? undefined : codefix.getAllSupers(declaration, checker);
var _loop_15 = function (info) {
// If some superclass added this property, don't add it again.
- if (supers.some(function (superClassOrInterface) {
+ if (supers === null || supers === void 0 ? void 0 : supers.some(function (superClassOrInterface) {
var superInfos = typeDeclToMembers.get(superClassOrInterface);
return !!superInfos && superInfos.some(function (_a) {
var token = _a.token;
@@ -152051,15 +154631,15 @@ var ts;
var parentDeclaration = info.parentDeclaration, declSourceFile = info.declSourceFile, modifierFlags = info.modifierFlags, token = info.token, call = info.call, isJSFile = info.isJSFile;
// Always prefer to add a method declaration if possible.
if (call && !ts.isPrivateIdentifier(token)) {
- addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* Static */, parentDeclaration, declSourceFile);
+ addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* ModifierFlags.Static */, parentDeclaration, declSourceFile);
}
else {
- if (isJSFile && !ts.isInterfaceDeclaration(parentDeclaration)) {
- addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */));
+ if (isJSFile && !ts.isInterfaceDeclaration(parentDeclaration) && !ts.isTypeLiteralNode(parentDeclaration)) {
+ addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* ModifierFlags.Static */));
}
else {
- var typeNode = getTypeNode(program.getTypeChecker(), parentDeclaration, token);
- addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* Static */);
+ var typeNode = getTypeNode(checker, parentDeclaration, token);
+ addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* ModifierFlags.Static */);
}
}
};
@@ -152073,8 +154653,8 @@ var ts;
});
var InfoKind;
(function (InfoKind) {
- InfoKind[InfoKind["Enum"] = 0] = "Enum";
- InfoKind[InfoKind["ClassOrInterface"] = 1] = "ClassOrInterface";
+ InfoKind[InfoKind["TypeLikeDeclaration"] = 0] = "TypeLikeDeclaration";
+ InfoKind[InfoKind["Enum"] = 1] = "Enum";
InfoKind[InfoKind["Function"] = 2] = "Function";
InfoKind[InfoKind["ObjectLiteral"] = 3] = "ObjectLiteral";
InfoKind[InfoKind["JsxAttributes"] = 4] = "JsxAttributes";
@@ -152086,21 +154666,21 @@ var ts;
var token = ts.getTokenAtPosition(sourceFile, tokenPos);
var parent = token.parent;
if (errorCode === ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code) {
- if (!(token.kind === 18 /* OpenBraceToken */ && ts.isObjectLiteralExpression(parent) && ts.isCallExpression(parent.parent)))
+ if (!(token.kind === 18 /* SyntaxKind.OpenBraceToken */ && ts.isObjectLiteralExpression(parent) && ts.isCallExpression(parent.parent)))
return undefined;
var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; });
if (argIndex < 0)
return undefined;
- var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* Call */));
+ var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* SignatureKind.Call */));
if (!(signature && signature.declaration && signature.parameters[argIndex]))
return undefined;
var param = signature.parameters[argIndex].valueDeclaration;
if (!(param && ts.isParameter(param) && ts.isIdentifier(param.name)))
return undefined;
- var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getTypeAtLocation(param), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
+ var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getParameterType(signature, argIndex), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
if (!ts.length(properties))
return undefined;
- return { kind: 3 /* ObjectLiteral */, token: param.name, properties: properties, indentation: 0, parentDeclaration: parent };
+ return { kind: 3 /* InfoKind.ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent };
}
if (!ts.isMemberName(token))
return undefined;
@@ -152108,17 +154688,17 @@ var ts;
var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent.initializer), checker.getTypeAtLocation(token), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
if (!ts.length(properties))
return undefined;
- return { kind: 3 /* ObjectLiteral */, token: token, properties: properties, indentation: undefined, parentDeclaration: parent.initializer };
+ return { kind: 3 /* InfoKind.ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer };
}
if (ts.isIdentifier(token) && ts.isJsxOpeningLikeElement(token.parent)) {
var target = ts.getEmitScriptTarget(program.getCompilerOptions());
var attributes = getUnmatchedAttributes(checker, target, token.parent);
if (!ts.length(attributes))
return undefined;
- return { kind: 4 /* JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent };
+ return { kind: 4 /* InfoKind.JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent };
}
if (ts.isIdentifier(token) && ts.isCallExpression(parent)) {
- return { kind: 2 /* Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: sourceFile };
+ return { kind: 2 /* InfoKind.Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* ModifierFlags.None */, parentDeclaration: sourceFile };
}
if (!ts.isPropertyAccessExpression(parent))
return undefined;
@@ -152130,13 +154710,13 @@ var ts;
var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration);
var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile();
if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
- return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration };
+ return { kind: 2 /* InfoKind.Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration };
}
var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile);
if (sourceFile.commonJsModuleIndicator)
return undefined;
if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) {
- return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile };
+ return { kind: 2 /* InfoKind.Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile };
}
}
var classDeclaration = ts.find(symbol.declarations, ts.isClassLike);
@@ -152144,20 +154724,21 @@ var ts;
if (!classDeclaration && ts.isPrivateIdentifier(token))
return undefined;
// Prefer to change the class instead of the interface if they are merged
- var classOrInterface = classDeclaration || ts.find(symbol.declarations, ts.isInterfaceDeclaration);
- if (classOrInterface && !isSourceFileFromLibrary(program, classOrInterface.getSourceFile())) {
- var makeStatic = (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol);
- if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(classOrInterface)))
+ var declaration = classDeclaration || ts.find(symbol.declarations, function (d) { return ts.isInterfaceDeclaration(d) || ts.isTypeLiteralNode(d); });
+ if (declaration && !isSourceFileFromLibrary(program, declaration.getSourceFile())) {
+ var makeStatic = !ts.isTypeLiteralNode(declaration) && (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol);
+ if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration)))
return undefined;
- var declSourceFile = classOrInterface.getSourceFile();
- var modifierFlags = (makeStatic ? 32 /* Static */ : 0) | (ts.startsWithUnderscore(token.text) ? 8 /* Private */ : 0);
+ var declSourceFile = declaration.getSourceFile();
+ var modifierFlags = ts.isTypeLiteralNode(declaration) ? 0 /* ModifierFlags.None */ :
+ (makeStatic ? 32 /* ModifierFlags.Static */ : 0 /* ModifierFlags.None */) | (ts.startsWithUnderscore(token.text) ? 8 /* ModifierFlags.Private */ : 0 /* ModifierFlags.None */);
var isJSFile = ts.isSourceFileJS(declSourceFile);
var call = ts.tryCast(parent.parent, ts.isCallExpression);
- return { kind: 1 /* ClassOrInterface */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: classOrInterface, declSourceFile: declSourceFile, isJSFile: isJSFile };
+ return { kind: 0 /* InfoKind.TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
}
var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
- return { kind: 0 /* Enum */, token: token, parentDeclaration: enumDeclaration };
+ return { kind: 1 /* InfoKind.Enum */, token: token, parentDeclaration: enumDeclaration };
}
return undefined;
}
@@ -152170,26 +154751,26 @@ var ts;
}
function createActionForAddMissingMemberInJavascriptFile(context, _a) {
var parentDeclaration = _a.parentDeclaration, declSourceFile = _a.declSourceFile, modifierFlags = _a.modifierFlags, token = _a.token;
- if (ts.isInterfaceDeclaration(parentDeclaration)) {
+ if (ts.isInterfaceDeclaration(parentDeclaration) || ts.isTypeLiteralNode(parentDeclaration)) {
return undefined;
}
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */)); });
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* ModifierFlags.Static */)); });
if (changes.length === 0) {
return undefined;
}
- var diagnostic = modifierFlags & 32 /* Static */ ? ts.Diagnostics.Initialize_static_property_0 :
+ var diagnostic = modifierFlags & 32 /* ModifierFlags.Static */ ? ts.Diagnostics.Initialize_static_property_0 :
ts.isPrivateIdentifier(token) ? ts.Diagnostics.Declare_a_private_field_named_0 : ts.Diagnostics.Initialize_property_0_in_the_constructor;
return codefix.createCodeFixAction(fixMissingMember, changes, [diagnostic, token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members);
}
- function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, token, makeStatic) {
+ function addMissingMemberInJs(changeTracker, sourceFile, classDeclaration, token, makeStatic) {
var tokenName = token.text;
if (makeStatic) {
- if (classDeclaration.kind === 225 /* ClassExpression */) {
+ if (classDeclaration.kind === 226 /* SyntaxKind.ClassExpression */) {
return;
}
var className = classDeclaration.name.getText();
var staticInitialization = initializePropertyToUndefined(ts.factory.createIdentifier(className), tokenName);
- changeTracker.insertNodeAfter(declSourceFile, classDeclaration, staticInitialization);
+ changeTracker.insertNodeAfter(sourceFile, classDeclaration, staticInitialization);
}
else if (ts.isPrivateIdentifier(token)) {
var property = ts.factory.createPropertyDeclaration(
@@ -152200,10 +154781,10 @@ var ts;
/*initializer*/ undefined);
var lastProp = getNodeToInsertPropertyAfter(classDeclaration);
if (lastProp) {
- changeTracker.insertNodeAfter(declSourceFile, lastProp, property);
+ changeTracker.insertNodeAfter(sourceFile, lastProp, property);
}
else {
- changeTracker.insertNodeAtClassStart(declSourceFile, classDeclaration, property);
+ changeTracker.insertMemberAtStart(sourceFile, classDeclaration, property);
}
}
else {
@@ -152212,7 +154793,7 @@ var ts;
return;
}
var propertyInitialization = initializePropertyToUndefined(ts.factory.createThis(), tokenName);
- changeTracker.insertNodeAtConstructorEnd(declSourceFile, classConstructor, propertyInitialization);
+ changeTracker.insertNodeAtConstructorEnd(sourceFile, classConstructor, propertyInitialization);
}
}
function initializePropertyToUndefined(obj, propertyName) {
@@ -152221,51 +154802,50 @@ var ts;
function createActionsForAddMissingMemberInTypeScriptFile(context, _a) {
var parentDeclaration = _a.parentDeclaration, declSourceFile = _a.declSourceFile, modifierFlags = _a.modifierFlags, token = _a.token;
var memberName = token.text;
- var isStatic = modifierFlags & 32 /* Static */;
+ var isStatic = modifierFlags & 32 /* ModifierFlags.Static */;
var typeNode = getTypeNode(context.program.getTypeChecker(), parentDeclaration, token);
var addPropertyDeclarationChanges = function (modifierFlags) { return ts.textChanges.ChangeTracker.with(context, function (t) { return addPropertyDeclaration(t, declSourceFile, parentDeclaration, memberName, typeNode, modifierFlags); }); };
- var actions = [codefix.createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 32 /* Static */), [isStatic ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, memberName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)];
+ var actions = [codefix.createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 32 /* ModifierFlags.Static */), [isStatic ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, memberName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)];
if (isStatic || ts.isPrivateIdentifier(token)) {
return actions;
}
- if (modifierFlags & 8 /* Private */) {
- actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(8 /* Private */), [ts.Diagnostics.Declare_private_property_0, memberName]));
+ if (modifierFlags & 8 /* ModifierFlags.Private */) {
+ actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(8 /* ModifierFlags.Private */), [ts.Diagnostics.Declare_private_property_0, memberName]));
}
actions.push(createAddIndexSignatureAction(context, declSourceFile, parentDeclaration, token.text, typeNode));
return actions;
}
- function getTypeNode(checker, classDeclaration, token) {
+ function getTypeNode(checker, node, token) {
var typeNode;
- if (token.parent.parent.kind === 220 /* BinaryExpression */) {
+ if (token.parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */) {
var binaryExpression = token.parent.parent;
var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left;
var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression)));
- typeNode = checker.typeToTypeNode(widenedType, classDeclaration, 1 /* NoTruncation */);
+ typeNode = checker.typeToTypeNode(widenedType, node, 1 /* NodeBuilderFlags.NoTruncation */);
}
else {
var contextualType = checker.getContextualType(token.parent);
- typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NoTruncation */) : undefined;
+ typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NodeBuilderFlags.NoTruncation */) : undefined;
}
- return typeNode || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */);
+ return typeNode || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */);
}
- function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, modifierFlags) {
- var property = ts.factory.createPropertyDeclaration(
- /*decorators*/ undefined,
- /*modifiers*/ modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined, tokenName,
- /*questionToken*/ undefined, typeNode,
- /*initializer*/ undefined);
- var lastProp = getNodeToInsertPropertyAfter(classDeclaration);
+ function addPropertyDeclaration(changeTracker, sourceFile, node, tokenName, typeNode, modifierFlags) {
+ var modifiers = modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined;
+ var property = ts.isClassLike(node)
+ ? ts.factory.createPropertyDeclaration(/*decorators*/ undefined, modifiers, tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined)
+ : ts.factory.createPropertySignature(/*modifiers*/ undefined, tokenName, /*questionToken*/ undefined, typeNode);
+ var lastProp = getNodeToInsertPropertyAfter(node);
if (lastProp) {
- changeTracker.insertNodeAfter(declSourceFile, lastProp, property);
+ changeTracker.insertNodeAfter(sourceFile, lastProp, property);
}
else {
- changeTracker.insertNodeAtClassStart(declSourceFile, classDeclaration, property);
+ changeTracker.insertMemberAtStart(sourceFile, node, property);
}
}
// Gets the last of the first run of PropertyDeclarations, or undefined if the class does not start with a PropertyDeclaration.
- function getNodeToInsertPropertyAfter(cls) {
+ function getNodeToInsertPropertyAfter(node) {
var res;
- for (var _i = 0, _a = cls.members; _i < _a.length; _i++) {
+ for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
var member = _a[_i];
if (!ts.isPropertyDeclaration(member))
break;
@@ -152273,9 +154853,9 @@ var ts;
}
return res;
}
- function createAddIndexSignatureAction(context, declSourceFile, classDeclaration, tokenName, typeNode) {
+ function createAddIndexSignatureAction(context, sourceFile, node, tokenName, typeNode) {
// Index signatures cannot have the static modifier.
- var stringTypeNode = ts.factory.createKeywordTypeNode(149 /* StringKeyword */);
+ var stringTypeNode = ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */);
var indexingParameter = ts.factory.createParameterDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined,
@@ -152285,7 +154865,7 @@ var ts;
var indexSignature = ts.factory.createIndexSignature(
/*decorators*/ undefined,
/*modifiers*/ undefined, [indexingParameter], typeNode);
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.insertNodeAtClassStart(declSourceFile, classDeclaration, indexSignature); });
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.insertMemberAtStart(sourceFile, node, indexSignature); });
// No fixId here because code-fix-all currently only works on adding individual named properties.
return codefix.createCodeFixActionWithoutFixAll(fixMissingMember, changes, [ts.Diagnostics.Add_index_signature_for_property_0, tokenName]);
}
@@ -152300,21 +154880,22 @@ var ts;
}
var methodName = token.text;
var addMethodDeclarationChanges = function (modifierFlags) { return ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(context, t, call, token, modifierFlags, parentDeclaration, declSourceFile); }); };
- var actions = [codefix.createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* Static */), [modifierFlags & 32 /* Static */ ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, methodName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)];
- if (modifierFlags & 8 /* Private */) {
- actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(8 /* Private */), [ts.Diagnostics.Declare_private_method_0, methodName]));
+ var actions = [codefix.createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* ModifierFlags.Static */), [modifierFlags & 32 /* ModifierFlags.Static */ ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, methodName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)];
+ if (modifierFlags & 8 /* ModifierFlags.Private */) {
+ actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(8 /* ModifierFlags.Private */), [ts.Diagnostics.Declare_private_method_0, methodName]));
}
return actions;
}
function addMethodDeclaration(context, changes, callExpression, name, modifierFlags, parentDeclaration, sourceFile) {
var importAdder = codefix.createImportAdder(sourceFile, context.program, context.preferences, context.host);
- var methodDeclaration = codefix.createSignatureDeclarationFromCallExpression(168 /* MethodDeclaration */, context, importAdder, callExpression, name, modifierFlags, parentDeclaration);
- var containingMethodDeclaration = ts.findAncestor(callExpression, function (n) { return ts.isMethodDeclaration(n) || ts.isConstructorDeclaration(n); });
- if (containingMethodDeclaration && containingMethodDeclaration.parent === parentDeclaration) {
- changes.insertNodeAfter(sourceFile, containingMethodDeclaration, methodDeclaration);
+ var kind = ts.isClassLike(parentDeclaration) ? 169 /* SyntaxKind.MethodDeclaration */ : 168 /* SyntaxKind.MethodSignature */;
+ var signatureDeclaration = codefix.createSignatureDeclarationFromCallExpression(kind, context, importAdder, callExpression, name, modifierFlags, parentDeclaration);
+ var containingMethodDeclaration = tryGetContainingMethodDeclaration(parentDeclaration, callExpression);
+ if (containingMethodDeclaration) {
+ changes.insertNodeAfter(sourceFile, containingMethodDeclaration, signatureDeclaration);
}
else {
- changes.insertNodeAtClassStart(sourceFile, parentDeclaration, methodDeclaration);
+ changes.insertMemberAtStart(sourceFile, parentDeclaration, signatureDeclaration);
}
importAdder.writeFixes(changes);
}
@@ -152327,7 +154908,7 @@ var ts;
*/
var hasStringInitializer = ts.some(parentDeclaration.members, function (member) {
var type = checker.getTypeAtLocation(member);
- return !!(type && type.flags & 402653316 /* StringLike */);
+ return !!(type && type.flags & 402653316 /* TypeFlags.StringLike */);
});
var enumMember = ts.factory.createEnumMember(token, hasStringInitializer ? ts.factory.createStringLiteral(token.text) : undefined);
changes.replaceNode(parentDeclaration.getSourceFile(), parentDeclaration, ts.factory.updateEnumDeclaration(parentDeclaration, parentDeclaration.decorators, parentDeclaration.modifiers, parentDeclaration.name, ts.concatenate(parentDeclaration.members, ts.singleElementArray(enumMember))), {
@@ -152337,7 +154918,7 @@ var ts;
}
function addFunctionDeclaration(changes, context, info) {
var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
- var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(255 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration);
+ var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* SyntaxKind.FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration);
changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration);
}
function addJsxAttributes(changes, context, info) {
@@ -152365,7 +154946,7 @@ var ts;
var checker = context.program.getTypeChecker();
var props = ts.map(info.properties, function (prop) {
var initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop));
- return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* Single */), initializer);
+ return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* QuotePreference.Single */), initializer);
});
var options = {
leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude,
@@ -152375,42 +154956,42 @@ var ts;
changes.replaceNode(context.sourceFile, info.parentDeclaration, ts.factory.createObjectLiteralExpression(__spreadArray(__spreadArray([], info.parentDeclaration.properties, true), props, true), /*multiLine*/ true), options);
}
function tryGetValueFromType(context, checker, importAdder, quotePreference, type) {
- if (type.flags & 3 /* AnyOrUnknown */) {
+ if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) {
return createUndefined();
}
- if (type.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) {
- return ts.factory.createStringLiteral("", /* isSingleQuote */ quotePreference === 0 /* Single */);
+ if (type.flags & (4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */)) {
+ return ts.factory.createStringLiteral("", /* isSingleQuote */ quotePreference === 0 /* QuotePreference.Single */);
}
- if (type.flags & 8 /* Number */) {
+ if (type.flags & 8 /* TypeFlags.Number */) {
return ts.factory.createNumericLiteral(0);
}
- if (type.flags & 64 /* BigInt */) {
+ if (type.flags & 64 /* TypeFlags.BigInt */) {
return ts.factory.createBigIntLiteral("0n");
}
- if (type.flags & 16 /* Boolean */) {
+ if (type.flags & 16 /* TypeFlags.Boolean */) {
return ts.factory.createFalse();
}
- if (type.flags & 1056 /* EnumLike */) {
+ if (type.flags & 1056 /* TypeFlags.EnumLike */) {
var enumMember = type.symbol.exports ? ts.firstOrUndefined(ts.arrayFrom(type.symbol.exports.values())) : type.symbol;
- var name = checker.symbolToExpression(type.symbol.parent ? type.symbol.parent : type.symbol, 111551 /* Value */, /*enclosingDeclaration*/ undefined, /*flags*/ undefined);
+ var name = checker.symbolToExpression(type.symbol.parent ? type.symbol.parent : type.symbol, 111551 /* SymbolFlags.Value */, /*enclosingDeclaration*/ undefined, /*flags*/ undefined);
return enumMember === undefined || name === undefined ? ts.factory.createNumericLiteral(0) : ts.factory.createPropertyAccessExpression(name, checker.symbolToString(enumMember));
}
- if (type.flags & 256 /* NumberLiteral */) {
+ if (type.flags & 256 /* TypeFlags.NumberLiteral */) {
return ts.factory.createNumericLiteral(type.value);
}
- if (type.flags & 2048 /* BigIntLiteral */) {
+ if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) {
return ts.factory.createBigIntLiteral(type.value);
}
- if (type.flags & 128 /* StringLiteral */) {
- return ts.factory.createStringLiteral(type.value, /* isSingleQuote */ quotePreference === 0 /* Single */);
+ if (type.flags & 128 /* TypeFlags.StringLiteral */) {
+ return ts.factory.createStringLiteral(type.value, /* isSingleQuote */ quotePreference === 0 /* QuotePreference.Single */);
}
- if (type.flags & 512 /* BooleanLiteral */) {
+ if (type.flags & 512 /* TypeFlags.BooleanLiteral */) {
return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.factory.createFalse() : ts.factory.createTrue();
}
- if (type.flags & 65536 /* Null */) {
+ if (type.flags & 65536 /* TypeFlags.Null */) {
return ts.factory.createNull();
}
- if (type.flags & 1048576 /* Union */) {
+ if (type.flags & 1048576 /* TypeFlags.Union */) {
var expression = ts.firstDefined(type.types, function (t) { return tryGetValueFromType(context, checker, importAdder, quotePreference, t); });
return expression !== null && expression !== void 0 ? expression : createUndefined();
}
@@ -152424,17 +155005,17 @@ var ts;
});
return ts.factory.createObjectLiteralExpression(props, /*multiLine*/ true);
}
- if (ts.getObjectFlags(type) & 16 /* Anonymous */) {
+ if (ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) {
var decl = ts.find(type.symbol.declarations || ts.emptyArray, ts.or(ts.isFunctionTypeNode, ts.isMethodSignature, ts.isMethodDeclaration));
if (decl === undefined)
return createUndefined();
- var signature = checker.getSignaturesOfType(type, 0 /* Call */);
+ var signature = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */);
if (signature === undefined)
return createUndefined();
- var func = codefix.createSignatureDeclarationFromSignature(212 /* FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ undefined, importAdder);
+ var func = codefix.createSignatureDeclarationFromSignature(213 /* SyntaxKind.FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ undefined, importAdder);
return func !== null && func !== void 0 ? func : createUndefined();
}
- if (ts.getObjectFlags(type) & 1 /* Class */) {
+ if (ts.getObjectFlags(type) & 1 /* ObjectFlags.Class */) {
var classDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol);
if (classDeclaration === undefined || ts.hasAbstractModifier(classDeclaration))
return createUndefined();
@@ -152449,8 +155030,8 @@ var ts;
return ts.factory.createIdentifier("undefined");
}
function isObjectLiteralType(type) {
- return (type.flags & 524288 /* Object */) &&
- ((ts.getObjectFlags(type) & 128 /* ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode)));
+ return (type.flags & 524288 /* TypeFlags.Object */) &&
+ ((ts.getObjectFlags(type) & 128 /* ObjectFlags.ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode)));
}
function getUnmatchedAttributes(checker, target, source) {
var attrsType = checker.getContextualType(source.attributes);
@@ -152474,9 +155055,16 @@ var ts;
}
}
return ts.filter(targetProps, function (targetProp) {
- return ts.isIdentifierText(targetProp.name, target, 1 /* JSX */) && !((targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */) || seenNames.has(targetProp.escapedName));
+ return ts.isIdentifierText(targetProp.name, target, 1 /* LanguageVariant.JSX */) && !((targetProp.flags & 16777216 /* SymbolFlags.Optional */ || ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */) || seenNames.has(targetProp.escapedName));
});
}
+ function tryGetContainingMethodDeclaration(node, callExpression) {
+ if (ts.isTypeLiteralNode(node)) {
+ return undefined;
+ }
+ var declaration = ts.findAncestor(callExpression, function (n) { return ts.isMethodDeclaration(n) || ts.isConstructorDeclaration(n); });
+ return declaration && declaration.parent === node ? declaration : undefined;
+ }
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
/* @internal */
@@ -152620,14 +155208,14 @@ var ts;
// so duplicates cannot occur.
var abstractAndNonPrivateExtendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType).filter(symbolPointsToNonPrivateAndAbstractMember);
var importAdder = codefix.createImportAdder(sourceFile, context.program, preferences, context.host);
- codefix.createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, sourceFile, context, preferences, importAdder, function (member) { return changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, member); });
+ codefix.createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, sourceFile, context, preferences, importAdder, function (member) { return changeTracker.insertMemberAtStart(sourceFile, classDeclaration, member); });
importAdder.writeFixes(changeTracker);
}
function symbolPointsToNonPrivateAndAbstractMember(symbol) {
// See `codeFixClassExtendAbstractProtectedProperty.ts` in https://github.com/Microsoft/TypeScript/pull/11547/files
// (now named `codeFixClassExtendAbstractPrivateProperty.ts`)
var flags = ts.getSyntacticModifierFlags(ts.first(symbol.getDeclarations()));
- return !(flags & 8 /* Private */) && !!(flags & 128 /* Abstract */);
+ return !(flags & 8 /* ModifierFlags.Private */) && !!(flags & 128 /* ModifierFlags.Abstract */);
}
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
@@ -152670,7 +155258,7 @@ var ts;
}
function getNodes(sourceFile, pos) {
var token = ts.getTokenAtPosition(sourceFile, pos);
- if (token.kind !== 108 /* ThisKeyword */)
+ if (token.kind !== 108 /* SyntaxKind.ThisKeyword */)
return undefined;
var constructor = ts.getContainingFunction(token);
var superCall = findSuperCall(constructor.body);
@@ -152795,8 +155383,8 @@ var ts;
(function (codefix) {
codefix.registerCodeFix({
errorCodes: [
- ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code,
- ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code,
+ ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code,
+ ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code,
],
getCodeActions: function getCodeActionsToFixModuleAndTarget(context) {
var compilerOptions = context.program.getCompilerOptions();
@@ -152814,7 +155402,7 @@ var ts;
codeFixes.push(codefix.createCodeFixActionWithoutFixAll("fixModuleOption", changes, [ts.Diagnostics.Set_the_module_option_in_your_configuration_file_to_0, "esnext"]));
}
var target = ts.getEmitScriptTarget(compilerOptions);
- var targetOutOfRange = target < 4 /* ES2017 */ || target > 99 /* ESNext */;
+ var targetOutOfRange = target < 4 /* ScriptTarget.ES2017 */ || target > 99 /* ScriptTarget.ESNext */;
if (targetOutOfRange) {
var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) {
var configObject = ts.getTsConfigObjectLiteralExpression(configFile);
@@ -152893,17 +155481,17 @@ var ts;
var token = ts.getTokenAtPosition(sourceFile, pos);
var heritageClauses = ts.getContainingClass(token).heritageClauses;
var extendsToken = heritageClauses[0].getFirstToken();
- return extendsToken.kind === 94 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined;
+ return extendsToken.kind === 94 /* SyntaxKind.ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined;
}
function doChanges(changes, sourceFile, extendsToken, heritageClauses) {
- changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* ImplementsKeyword */));
+ changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* SyntaxKind.ImplementsKeyword */));
// If there is already an implements clause, replace the implements keyword with a comma.
if (heritageClauses.length === 2 &&
- heritageClauses[0].token === 94 /* ExtendsKeyword */ &&
- heritageClauses[1].token === 117 /* ImplementsKeyword */) {
+ heritageClauses[0].token === 94 /* SyntaxKind.ExtendsKeyword */ &&
+ heritageClauses[1].token === 117 /* SyntaxKind.ImplementsKeyword */) {
var implementsToken = heritageClauses[1].getFirstToken();
var implementsFullStart = implementsToken.getFullStart();
- changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* CommaToken */));
+ changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* SyntaxKind.CommaToken */));
// Rough heuristic: delete trailing whitespace after keyword so that it's not excessive.
// (Trailing because leading might be indentation, which is more sensitive.)
var text = sourceFile.text;
@@ -153099,6 +155687,74 @@ var ts;
(function (ts) {
var codefix;
(function (codefix) {
+ var fixId = "fixUnreferenceableDecoratorMetadata";
+ var errorCodes = [ts.Diagnostics.A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled.code];
+ codefix.registerCodeFix({
+ errorCodes: errorCodes,
+ getCodeActions: function (context) {
+ var importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start);
+ if (!importDeclaration)
+ return;
+ var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); });
+ var typeOnlyChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return doTypeOnlyImportChange(t, context.sourceFile, importDeclaration, context.program); });
+ var actions;
+ if (namespaceChanges.length) {
+ actions = ts.append(actions, codefix.createCodeFixActionWithoutFixAll(fixId, namespaceChanges, ts.Diagnostics.Convert_named_imports_to_namespace_import));
+ }
+ if (typeOnlyChanges.length) {
+ actions = ts.append(actions, codefix.createCodeFixActionWithoutFixAll(fixId, typeOnlyChanges, ts.Diagnostics.Convert_to_type_only_import));
+ }
+ return actions;
+ },
+ fixIds: [fixId],
+ });
+ function getImportDeclaration(sourceFile, program, start) {
+ var identifier = ts.tryCast(ts.getTokenAtPosition(sourceFile, start), ts.isIdentifier);
+ if (!identifier || identifier.parent.kind !== 178 /* SyntaxKind.TypeReference */)
+ return;
+ var checker = program.getTypeChecker();
+ var symbol = checker.getSymbolAtLocation(identifier);
+ return ts.find((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray, ts.or(ts.isImportClause, ts.isImportSpecifier, ts.isImportEqualsDeclaration));
+ }
+ // Converts the import declaration of the offending import to a type-only import,
+ // only if it can be done without affecting other imported names. If the conversion
+ // cannot be done cleanly, we could offer to *extract* the offending import to a
+ // new type-only import declaration, but honestly I doubt anyone will ever use this
+ // codefix at all, so it's probably not worth the lines of code.
+ function doTypeOnlyImportChange(changes, sourceFile, importDeclaration, program) {
+ if (importDeclaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) {
+ changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, importDeclaration.name);
+ return;
+ }
+ var importClause = importDeclaration.kind === 267 /* SyntaxKind.ImportClause */ ? importDeclaration : importDeclaration.parent.parent;
+ if (importClause.name && importClause.namedBindings) {
+ // Cannot convert an import with a default import and named bindings to type-only
+ // (it's a grammar error).
+ return;
+ }
+ var checker = program.getTypeChecker();
+ var importsValue = !!ts.forEachImportClauseDeclaration(importClause, function (decl) {
+ if (ts.skipAlias(decl.symbol, checker).flags & 111551 /* SymbolFlags.Value */)
+ return true;
+ });
+ if (importsValue) {
+ // Assume that if someone wrote a non-type-only import that includes some values,
+ // they intend to use those values in value positions, even if they haven't yet.
+ // Don't convert it to type-only.
+ return;
+ }
+ changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, importClause);
+ }
+ function doNamespaceImportChange(changes, sourceFile, importDeclaration, program) {
+ ts.refactor.doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, importDeclaration.parent);
+ }
+ })(codefix = ts.codefix || (ts.codefix = {}));
+})(ts || (ts = {}));
+/* @internal */
+var ts;
+(function (ts) {
+ var codefix;
+ (function (codefix) {
var fixName = "unusedIdentifier";
var fixIdPrefix = "unusedIdentifier_prefix";
var fixIdDelete = "unusedIdentifier_delete";
@@ -153123,7 +155779,7 @@ var ts;
if (ts.isJSDocTemplateTag(token)) {
return [createDeleteFix(ts.textChanges.ChangeTracker.with(context, function (t) { return t.delete(sourceFile, token); }), ts.Diagnostics.Remove_template_tag)];
}
- if (token.kind === 29 /* LessThanToken */) {
+ if (token.kind === 29 /* SyntaxKind.LessThanToken */) {
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return deleteTypeParameters(t, sourceFile, token); });
return [createDeleteFix(changes, ts.Diagnostics.Remove_type_parameters)];
}
@@ -153165,7 +155821,7 @@ var ts;
];
}
var result = [];
- if (token.kind === 137 /* InferKeyword */) {
+ if (token.kind === 137 /* SyntaxKind.InferKeyword */) {
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return changeInferToUnknown(t, sourceFile, token); });
var name = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name.text;
result.push(codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Replace_infer_0_with_unknown, name], fixIdInfer, ts.Diagnostics.Replace_all_unused_infer_with_unknown));
@@ -153207,13 +155863,13 @@ var ts;
break;
}
case fixIdDelete: {
- if (token.kind === 137 /* InferKeyword */ || isImport(token)) {
+ if (token.kind === 137 /* SyntaxKind.InferKeyword */ || isImport(token)) {
break; // Can't delete
}
else if (ts.isJSDocTemplateTag(token)) {
changes.delete(sourceFile, token);
}
- else if (token.kind === 29 /* LessThanToken */) {
+ else if (token.kind === 29 /* SyntaxKind.LessThanToken */) {
deleteTypeParameters(changes, sourceFile, token);
}
else if (ts.isObjectBindingPattern(token.parent)) {
@@ -153236,7 +155892,7 @@ var ts;
break;
}
case fixIdInfer:
- if (token.kind === 137 /* InferKeyword */) {
+ if (token.kind === 137 /* SyntaxKind.InferKeyword */) {
changeInferToUnknown(changes, sourceFile, token);
}
break;
@@ -153247,7 +155903,7 @@ var ts;
},
});
function changeInferToUnknown(changes, sourceFile, token) {
- changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */));
+ changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */));
}
function createDeleteFix(changes, diag) {
return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations);
@@ -153256,18 +155912,18 @@ var ts;
changes.delete(sourceFile, ts.Debug.checkDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist"));
}
function isImport(token) {
- return token.kind === 100 /* ImportKeyword */
- || token.kind === 79 /* Identifier */ && (token.parent.kind === 269 /* ImportSpecifier */ || token.parent.kind === 266 /* ImportClause */);
+ return token.kind === 100 /* SyntaxKind.ImportKeyword */
+ || token.kind === 79 /* SyntaxKind.Identifier */ && (token.parent.kind === 270 /* SyntaxKind.ImportSpecifier */ || token.parent.kind === 267 /* SyntaxKind.ImportClause */);
}
/** Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. */
function tryGetFullImport(token) {
- return token.kind === 100 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined;
+ return token.kind === 100 /* SyntaxKind.ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined;
}
function canDeleteEntireVariableStatement(sourceFile, token) {
return ts.isVariableDeclarationList(token.parent) && ts.first(token.parent.getChildren(sourceFile)) === token;
}
function deleteEntireVariableStatement(changes, sourceFile, node) {
- changes.delete(sourceFile, node.parent.kind === 236 /* VariableStatement */ ? node.parent : node);
+ changes.delete(sourceFile, node.parent.kind === 237 /* SyntaxKind.VariableStatement */ ? node.parent : node);
}
function deleteDestructuringElements(changes, sourceFile, node) {
ts.forEach(node.elements, function (n) { return changes.delete(sourceFile, n); });
@@ -153276,7 +155932,7 @@ var ts;
// Don't offer to prefix a property.
if (errorCode === ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code)
return;
- if (token.kind === 137 /* InferKeyword */) {
+ if (token.kind === 137 /* SyntaxKind.InferKeyword */) {
token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name;
}
if (ts.isIdentifier(token) && canPrefix(token)) {
@@ -153292,14 +155948,14 @@ var ts;
}
function canPrefix(token) {
switch (token.parent.kind) {
- case 163 /* Parameter */:
- case 162 /* TypeParameter */:
+ case 164 /* SyntaxKind.Parameter */:
+ case 163 /* SyntaxKind.TypeParameter */:
return true;
- case 253 /* VariableDeclaration */: {
+ case 254 /* SyntaxKind.VariableDeclaration */: {
var varDecl = token.parent;
switch (varDecl.parent.parent.kind) {
- case 243 /* ForOfStatement */:
- case 242 /* ForInStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
return true;
}
}
@@ -153349,8 +156005,8 @@ var ts;
function mayDeleteParameter(checker, sourceFile, parameter, sourceFiles, program, cancellationToken, isFixAll) {
var parent = parameter.parent;
switch (parent.kind) {
- case 168 /* MethodDeclaration */:
- case 170 /* Constructor */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 171 /* SyntaxKind.Constructor */:
var index = parent.parameters.indexOf(parameter);
var referent = ts.isMethodDeclaration(parent) ? parent.name : parent;
var entries = ts.FindAllReferences.Core.getReferencedSymbolsForNode(parent.pos, referent, program, sourceFiles, cancellationToken);
@@ -153359,7 +156015,7 @@ var ts;
var entry = entries_2[_i];
for (var _a = 0, _b = entry.references; _a < _b.length; _a++) {
var reference = _b[_a];
- if (reference.kind === 1 /* Node */) {
+ if (reference.kind === 1 /* FindAllReferences.EntryKind.Node */) {
// argument in super(...)
var isSuperCall_1 = ts.isSuperKeyword(reference.node)
&& ts.isCallExpression(reference.node.parent)
@@ -153380,20 +156036,20 @@ var ts;
}
}
return true;
- case 255 /* FunctionDeclaration */: {
+ case 256 /* SyntaxKind.FunctionDeclaration */: {
if (parent.name && isCallbackLike(checker, sourceFile, parent.name)) {
return isLastParameter(parent, parameter, isFixAll);
}
return true;
}
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
// Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused.
return isLastParameter(parent, parameter, isFixAll);
- case 172 /* SetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
// Setter must have a parameter
return false;
- case 171 /* GetAccessor */:
+ case 172 /* SyntaxKind.GetAccessor */:
// Getter cannot have parameters
return true;
default:
@@ -153454,7 +156110,7 @@ var ts;
var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent;
if (!ts.isBlock(statement.parent) || statement === ts.first(statement.parent.statements)) {
switch (container.kind) {
- case 238 /* IfStatement */:
+ case 239 /* SyntaxKind.IfStatement */:
if (container.elseStatement) {
if (ts.isBlock(statement.parent)) {
break;
@@ -153465,8 +156121,8 @@ var ts;
return;
}
// falls through
- case 240 /* WhileStatement */:
- case 241 /* ForStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
changes.delete(sourceFile, container);
return;
}
@@ -153515,7 +156171,7 @@ var ts;
var statementPos = labeledStatement.statement.getStart(sourceFile);
// If label is on a separate line, just delete the rest of that line, but not the indentation of the labeled statement.
var end = ts.positionsAreOnSameLine(pos, statementPos, sourceFile) ? statementPos
- : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true);
+ : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* SyntaxKind.ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true);
changes.deleteRange(sourceFile, { pos: pos, end: end });
}
})(codefix = ts.codefix || (ts.codefix = {}));
@@ -153539,10 +156195,10 @@ var ts;
var typeNode = info.typeNode, type = info.type;
var original = typeNode.getText(sourceFile);
var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)];
- if (typeNode.kind === 312 /* JSDocNullableType */) {
+ if (typeNode.kind === 314 /* SyntaxKind.JSDocNullableType */) {
// for nullable types, suggest the flow-compatible `T | null | undefined`
// in addition to the jsdoc/closure-compatible `T | null`
- actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types));
+ actions.push(fix(checker.getNullableType(type, 32768 /* TypeFlags.Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types));
}
return actions;
function fix(type, fixId, fixAllDescription) {
@@ -153559,7 +156215,7 @@ var ts;
if (!info)
return;
var typeNode = info.typeNode, type = info.type;
- var fixedType = typeNode.kind === 312 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type;
+ var fixedType = typeNode.kind === 314 /* SyntaxKind.JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* TypeFlags.Undefined */) : type;
doChange(changes, sourceFile, typeNode, fixedType, checker);
});
}
@@ -153576,22 +156232,22 @@ var ts;
// NOTE: Some locations are not handled yet:
// MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments
switch (node.kind) {
- case 228 /* AsExpression */:
- case 173 /* CallSignature */:
- case 174 /* ConstructSignature */:
- case 255 /* FunctionDeclaration */:
- case 171 /* GetAccessor */:
- case 175 /* IndexSignature */:
- case 194 /* MappedType */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 163 /* Parameter */:
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
- case 172 /* SetAccessor */:
- case 258 /* TypeAliasDeclaration */:
- case 210 /* TypeAssertionExpression */:
- case 253 /* VariableDeclaration */:
+ case 229 /* SyntaxKind.AsExpression */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 176 /* SyntaxKind.IndexSignature */:
+ case 195 /* SyntaxKind.MappedType */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 164 /* SyntaxKind.Parameter */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 211 /* SyntaxKind.TypeAssertionExpression */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return true;
default:
return false;
@@ -153694,15 +156350,15 @@ var ts;
}
var insertBefore;
switch (containingFunction.kind) {
- case 168 /* MethodDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
insertBefore = containingFunction.name;
break;
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- insertBefore = ts.findChildOfKind(containingFunction, 98 /* FunctionKeyword */, sourceFile);
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ insertBefore = ts.findChildOfKind(containingFunction, 98 /* SyntaxKind.FunctionKeyword */, sourceFile);
break;
- case 213 /* ArrowFunction */:
- var kind = containingFunction.typeParameters ? 29 /* LessThanToken */ : 20 /* OpenParenToken */;
+ case 214 /* SyntaxKind.ArrowFunction */:
+ var kind = containingFunction.typeParameters ? 29 /* SyntaxKind.LessThanToken */ : 20 /* SyntaxKind.OpenParenToken */;
insertBefore = ts.findChildOfKind(containingFunction, kind, sourceFile) || ts.first(containingFunction.parameters);
break;
default:
@@ -153717,11 +156373,11 @@ var ts;
var insertBefore = _a.insertBefore, returnType = _a.returnType;
if (returnType) {
var entityName = ts.getEntityNameFromTypeNode(returnType);
- if (!entityName || entityName.kind !== 79 /* Identifier */ || entityName.text !== "Promise") {
+ if (!entityName || entityName.kind !== 79 /* SyntaxKind.Identifier */ || entityName.text !== "Promise") {
changes.replaceNode(sourceFile, returnType, ts.factory.createTypeReferenceNode("Promise", ts.factory.createNodeArray([returnType])));
}
}
- changes.insertModifierBefore(sourceFile, 131 /* AsyncKeyword */, insertBefore);
+ changes.insertModifierBefore(sourceFile, 131 /* SyntaxKind.AsyncKeyword */, insertBefore);
}
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
@@ -153883,7 +156539,7 @@ var ts;
return errorCode;
}
function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) {
- if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 108 /* ThisKeyword */) {
+ if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* SyntaxKind.Identifier */ && token.kind !== 25 /* SyntaxKind.DotDotDotToken */ && token.kind !== 108 /* SyntaxKind.ThisKeyword */) {
return undefined;
}
var parent = token.parent;
@@ -153984,9 +156640,9 @@ var ts;
annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host);
}
else {
- var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile);
+ var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* SyntaxKind.OpenParenToken */, sourceFile);
if (needParens)
- changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.factory.createToken(20 /* OpenParenToken */));
+ changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */));
for (var _i = 0, parameterInferences_1 = parameterInferences; _i < parameterInferences_1.length; _i++) {
var _a = parameterInferences_1[_i], declaration = _a.declaration, type = _a.type;
if (declaration && !declaration.type && !declaration.initializer) {
@@ -153994,7 +156650,7 @@ var ts;
}
}
if (needParens)
- changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.factory.createToken(21 /* CloseParenToken */));
+ changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */));
}
}
function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) {
@@ -154037,7 +156693,7 @@ var ts;
function annotate(changes, importAdder, sourceFile, declaration, type, program, host) {
var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host);
if (typeNode) {
- if (ts.isInJSFile(sourceFile) && declaration.kind !== 165 /* PropertySignature */) {
+ if (ts.isInJSFile(sourceFile) && declaration.kind !== 166 /* SyntaxKind.PropertySignature */) {
var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration;
if (!parent) {
return;
@@ -154073,7 +156729,7 @@ var ts;
var typeNode = inference.type && ts.getTypeNodeIfAccessible(inference.type, param, program, host);
if (typeNode) {
var name = ts.factory.cloneNode(param.name);
- ts.setEmitFlags(name, 1536 /* NoComments */ | 2048 /* NoNestedComments */);
+ ts.setEmitFlags(name, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */);
return { name: ts.factory.cloneNode(param.name), param: param, isOptional: !!inference.isOptional, typeNode: typeNode };
}
});
@@ -154081,9 +156737,9 @@ var ts;
return;
}
if (ts.isArrowFunction(signature) || ts.isFunctionExpression(signature)) {
- var needParens = ts.isArrowFunction(signature) && !ts.findChildOfKind(signature, 20 /* OpenParenToken */, sourceFile);
+ var needParens = ts.isArrowFunction(signature) && !ts.findChildOfKind(signature, 20 /* SyntaxKind.OpenParenToken */, sourceFile);
if (needParens) {
- changes.insertNodeBefore(sourceFile, ts.first(signature.parameters), ts.factory.createToken(20 /* OpenParenToken */));
+ changes.insertNodeBefore(sourceFile, ts.first(signature.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */));
}
ts.forEach(inferences, function (_a) {
var typeNode = _a.typeNode, param = _a.param;
@@ -154092,7 +156748,7 @@ var ts;
changes.insertNodeAt(sourceFile, param.getStart(sourceFile), jsDoc, { suffix: " " });
});
if (needParens) {
- changes.insertNodeAfter(sourceFile, ts.last(signature.parameters), ts.factory.createToken(21 /* CloseParenToken */));
+ changes.insertNodeAfter(sourceFile, ts.last(signature.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */));
}
}
else {
@@ -154106,7 +156762,7 @@ var ts;
function getReferences(token, program, cancellationToken) {
// Position shouldn't matter since token is not a SourceFile.
return ts.mapDefined(ts.FindAllReferences.getReferenceEntriesForNode(-1, token, program, program.getSourceFiles(), cancellationToken), function (entry) {
- return entry.kind !== 0 /* Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined;
+ return entry.kind !== 0 /* FindAllReferences.EntryKind.Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined;
});
}
function inferTypeForVariableFromUsage(token, program, cancellationToken) {
@@ -154124,19 +156780,19 @@ var ts;
function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) {
var searchToken;
switch (containingFunction.kind) {
- case 170 /* Constructor */:
- searchToken = ts.findChildOfKind(containingFunction, 134 /* ConstructorKeyword */, sourceFile);
+ case 171 /* SyntaxKind.Constructor */:
+ searchToken = ts.findChildOfKind(containingFunction, 134 /* SyntaxKind.ConstructorKeyword */, sourceFile);
break;
- case 213 /* ArrowFunction */:
- case 212 /* FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 213 /* SyntaxKind.FunctionExpression */:
var parent = containingFunction.parent;
searchToken = (ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) && ts.isIdentifier(parent.name) ?
parent.name :
containingFunction.name;
break;
- case 255 /* FunctionDeclaration */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
searchToken = containingFunction.name;
break;
}
@@ -154278,24 +156934,24 @@ var ts;
node = node.parent;
}
switch (node.parent.kind) {
- case 237 /* ExpressionStatement */:
+ case 238 /* SyntaxKind.ExpressionStatement */:
inferTypeFromExpressionStatement(node, usage);
break;
- case 219 /* PostfixUnaryExpression */:
+ case 220 /* SyntaxKind.PostfixUnaryExpression */:
usage.isNumber = true;
break;
- case 218 /* PrefixUnaryExpression */:
+ case 219 /* SyntaxKind.PrefixUnaryExpression */:
inferTypeFromPrefixUnaryExpression(node.parent, usage);
break;
- case 220 /* BinaryExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
inferTypeFromBinaryExpression(node, node.parent, usage);
break;
- case 288 /* CaseClause */:
- case 289 /* DefaultClause */:
+ case 289 /* SyntaxKind.CaseClause */:
+ case 290 /* SyntaxKind.DefaultClause */:
inferTypeFromSwitchStatementLabel(node.parent, usage);
break;
- case 207 /* CallExpression */:
- case 208 /* NewExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
if (node.parent.expression === node) {
inferTypeFromCallExpression(node.parent, usage);
}
@@ -154303,20 +156959,20 @@ var ts;
inferTypeFromContextualType(node, usage);
}
break;
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
inferTypeFromPropertyAccessExpression(node.parent, usage);
break;
- case 206 /* ElementAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
inferTypeFromPropertyElementExpression(node.parent, node, usage);
break;
- case 294 /* PropertyAssignment */:
- case 295 /* ShorthandPropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
+ case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
inferTypeFromPropertyAssignment(node.parent, usage);
break;
- case 166 /* PropertyDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
inferTypeFromPropertyDeclaration(node.parent, usage);
break;
- case 253 /* VariableDeclaration */: {
+ case 254 /* SyntaxKind.VariableDeclaration */: {
var _a = node.parent, name = _a.name, initializer = _a.initializer;
if (node === name) {
if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error.
@@ -154340,13 +156996,13 @@ var ts;
}
function inferTypeFromPrefixUnaryExpression(node, usage) {
switch (node.operator) {
- case 45 /* PlusPlusToken */:
- case 46 /* MinusMinusToken */:
- case 40 /* MinusToken */:
- case 54 /* TildeToken */:
+ case 45 /* SyntaxKind.PlusPlusToken */:
+ case 46 /* SyntaxKind.MinusMinusToken */:
+ case 40 /* SyntaxKind.MinusToken */:
+ case 54 /* SyntaxKind.TildeToken */:
usage.isNumber = true;
break;
- case 39 /* PlusToken */:
+ case 39 /* SyntaxKind.PlusToken */:
usage.isNumberOrString = true;
break;
// case SyntaxKind.ExclamationToken:
@@ -154356,65 +157012,65 @@ var ts;
function inferTypeFromBinaryExpression(node, parent, usage) {
switch (parent.operatorToken.kind) {
// ExponentiationOperator
- case 42 /* AsteriskAsteriskToken */:
+ case 42 /* SyntaxKind.AsteriskAsteriskToken */:
// MultiplicativeOperator
// falls through
- case 41 /* AsteriskToken */:
- case 43 /* SlashToken */:
- case 44 /* PercentToken */:
+ case 41 /* SyntaxKind.AsteriskToken */:
+ case 43 /* SyntaxKind.SlashToken */:
+ case 44 /* SyntaxKind.PercentToken */:
// ShiftOperator
// falls through
- case 47 /* LessThanLessThanToken */:
- case 48 /* GreaterThanGreaterThanToken */:
- case 49 /* GreaterThanGreaterThanGreaterThanToken */:
+ case 47 /* SyntaxKind.LessThanLessThanToken */:
+ case 48 /* SyntaxKind.GreaterThanGreaterThanToken */:
+ case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */:
// BitwiseOperator
// falls through
- case 50 /* AmpersandToken */:
- case 51 /* BarToken */:
- case 52 /* CaretToken */:
+ case 50 /* SyntaxKind.AmpersandToken */:
+ case 51 /* SyntaxKind.BarToken */:
+ case 52 /* SyntaxKind.CaretToken */:
// CompoundAssignmentOperator
// falls through
- case 65 /* MinusEqualsToken */:
- case 67 /* AsteriskAsteriskEqualsToken */:
- case 66 /* AsteriskEqualsToken */:
- case 68 /* SlashEqualsToken */:
- case 69 /* PercentEqualsToken */:
- case 73 /* AmpersandEqualsToken */:
- case 74 /* BarEqualsToken */:
- case 78 /* CaretEqualsToken */:
- case 70 /* LessThanLessThanEqualsToken */:
- case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
- case 71 /* GreaterThanGreaterThanEqualsToken */:
+ case 65 /* SyntaxKind.MinusEqualsToken */:
+ case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */:
+ case 66 /* SyntaxKind.AsteriskEqualsToken */:
+ case 68 /* SyntaxKind.SlashEqualsToken */:
+ case 69 /* SyntaxKind.PercentEqualsToken */:
+ case 73 /* SyntaxKind.AmpersandEqualsToken */:
+ case 74 /* SyntaxKind.BarEqualsToken */:
+ case 78 /* SyntaxKind.CaretEqualsToken */:
+ case 70 /* SyntaxKind.LessThanLessThanEqualsToken */:
+ case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */:
+ case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */:
// AdditiveOperator
// falls through
- case 40 /* MinusToken */:
+ case 40 /* SyntaxKind.MinusToken */:
// RelationalOperator
// falls through
- case 29 /* LessThanToken */:
- case 32 /* LessThanEqualsToken */:
- case 31 /* GreaterThanToken */:
- case 33 /* GreaterThanEqualsToken */:
+ case 29 /* SyntaxKind.LessThanToken */:
+ case 32 /* SyntaxKind.LessThanEqualsToken */:
+ case 31 /* SyntaxKind.GreaterThanToken */:
+ case 33 /* SyntaxKind.GreaterThanEqualsToken */:
var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left);
- if (operandType.flags & 1056 /* EnumLike */) {
+ if (operandType.flags & 1056 /* TypeFlags.EnumLike */) {
addCandidateType(usage, operandType);
}
else {
usage.isNumber = true;
}
break;
- case 64 /* PlusEqualsToken */:
- case 39 /* PlusToken */:
+ case 64 /* SyntaxKind.PlusEqualsToken */:
+ case 39 /* SyntaxKind.PlusToken */:
var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left);
- if (otherOperandType.flags & 1056 /* EnumLike */) {
+ if (otherOperandType.flags & 1056 /* TypeFlags.EnumLike */) {
addCandidateType(usage, otherOperandType);
}
- else if (otherOperandType.flags & 296 /* NumberLike */) {
+ else if (otherOperandType.flags & 296 /* TypeFlags.NumberLike */) {
usage.isNumber = true;
}
- else if (otherOperandType.flags & 402653316 /* StringLike */) {
+ else if (otherOperandType.flags & 402653316 /* TypeFlags.StringLike */) {
usage.isString = true;
}
- else if (otherOperandType.flags & 1 /* Any */) {
+ else if (otherOperandType.flags & 1 /* TypeFlags.Any */) {
// do nothing, maybe we'll learn something elsewhere
}
else {
@@ -154422,31 +157078,31 @@ var ts;
}
break;
// AssignmentOperators
- case 63 /* EqualsToken */:
- case 34 /* EqualsEqualsToken */:
- case 36 /* EqualsEqualsEqualsToken */:
- case 37 /* ExclamationEqualsEqualsToken */:
- case 35 /* ExclamationEqualsToken */:
+ case 63 /* SyntaxKind.EqualsToken */:
+ case 34 /* SyntaxKind.EqualsEqualsToken */:
+ case 36 /* SyntaxKind.EqualsEqualsEqualsToken */:
+ case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */:
+ case 35 /* SyntaxKind.ExclamationEqualsToken */:
addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left));
break;
- case 101 /* InKeyword */:
+ case 101 /* SyntaxKind.InKeyword */:
if (node === parent.left) {
usage.isString = true;
}
break;
// LogicalOperator Or NullishCoalescing
- case 56 /* BarBarToken */:
- case 60 /* QuestionQuestionToken */:
+ case 56 /* SyntaxKind.BarBarToken */:
+ case 60 /* SyntaxKind.QuestionQuestionToken */:
if (node === parent.left &&
- (node.parent.parent.kind === 253 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) {
+ (node.parent.parent.kind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) {
// var x = x || {};
// TODO: use getFalsyflagsOfType
addCandidateType(usage, checker.getTypeAtLocation(parent.right));
}
break;
- case 55 /* AmpersandAmpersandToken */:
- case 27 /* CommaToken */:
- case 102 /* InstanceOfKeyword */:
+ case 55 /* SyntaxKind.AmpersandAmpersandToken */:
+ case 27 /* SyntaxKind.CommaToken */:
+ case 102 /* SyntaxKind.InstanceOfKeyword */:
// nothing to infer here
break;
}
@@ -154466,7 +157122,7 @@ var ts;
}
}
calculateUsageOfNode(parent, call.return_);
- if (parent.kind === 207 /* CallExpression */) {
+ if (parent.kind === 208 /* SyntaxKind.CallExpression */) {
(usage.calls || (usage.calls = [])).push(call);
}
else {
@@ -154491,7 +157147,7 @@ var ts;
var indexType = checker.getTypeAtLocation(parent.argumentExpression);
var indexUsage = createEmptyUsage();
calculateUsageOfNode(parent, indexUsage);
- if (indexType.flags & 296 /* NumberLike */) {
+ if (indexType.flags & 296 /* TypeFlags.NumberLike */) {
usage.numberIndex = indexUsage;
}
else {
@@ -154538,21 +157194,21 @@ var ts;
low: function (t) { return t === stringNumber; }
},
{
- high: function (t) { return !(t.flags & (1 /* Any */ | 16384 /* Void */)); },
- low: function (t) { return !!(t.flags & (1 /* Any */ | 16384 /* Void */)); }
+ high: function (t) { return !(t.flags & (1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)); },
+ low: function (t) { return !!(t.flags & (1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)); }
},
{
- high: function (t) { return !(t.flags & (98304 /* Nullable */ | 1 /* Any */ | 16384 /* Void */)) && !(ts.getObjectFlags(t) & 16 /* Anonymous */); },
- low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* Anonymous */); }
+ high: function (t) { return !(t.flags & (98304 /* TypeFlags.Nullable */ | 1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)) && !(ts.getObjectFlags(t) & 16 /* ObjectFlags.Anonymous */); },
+ low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* ObjectFlags.Anonymous */); }
}
];
var good = removeLowPriorityInferences(inferences, priorities);
- var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* Anonymous */; });
+ var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* ObjectFlags.Anonymous */; });
if (anons.length) {
- good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* Anonymous */); });
+ good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* ObjectFlags.Anonymous */); });
good.push(combineAnonymousTypes(anons));
}
- return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* Subtype */));
+ return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* UnionReduction.Subtype */));
}
function combineAnonymousTypes(anons) {
if (anons.length === 1) {
@@ -154571,22 +157227,22 @@ var ts;
var p = _b[_a];
props.add(p.name, p.valueDeclaration ? checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration) : checker.getAnyType());
}
- calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* Call */));
- constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* Construct */));
- var stringIndexInfo = checker.getIndexInfoOfType(anon, 0 /* String */);
+ calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* SignatureKind.Call */));
+ constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* SignatureKind.Construct */));
+ var stringIndexInfo = checker.getIndexInfoOfType(anon, 0 /* IndexKind.String */);
if (stringIndexInfo) {
stringIndices.push(stringIndexInfo.type);
stringIndexReadonly = stringIndexReadonly || stringIndexInfo.isReadonly;
}
- var numberIndexInfo = checker.getIndexInfoOfType(anon, 1 /* Number */);
+ var numberIndexInfo = checker.getIndexInfoOfType(anon, 1 /* IndexKind.Number */);
if (numberIndexInfo) {
numberIndices.push(numberIndexInfo.type);
numberIndexReadonly = numberIndexReadonly || numberIndexInfo.isReadonly;
}
}
var members = ts.mapEntries(props, function (name, types) {
- var isOptional = types.length < anons.length ? 16777216 /* Optional */ : 0;
- var s = checker.createSymbol(4 /* Property */ | isOptional, name);
+ var isOptional = types.length < anons.length ? 16777216 /* SymbolFlags.Optional */ : 0;
+ var s = checker.createSymbol(4 /* SymbolFlags.Property */ | isOptional, name);
s.type = checker.getUnionType(types);
return [name, s];
});
@@ -154618,7 +157274,7 @@ var ts;
var candidateTypes = (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); });
var callsType = ((_c = usage.calls) === null || _c === void 0 ? void 0 : _c.length) ? inferStructuralType(usage) : undefined;
if (callsType && candidateTypes) {
- types.push(checker.getUnionType(__spreadArray([callsType], candidateTypes, true), 2 /* Subtype */));
+ types.push(checker.getUnionType(__spreadArray([callsType], candidateTypes, true), 2 /* UnionReduction.Subtype */));
}
else {
if (callsType) {
@@ -154635,7 +157291,7 @@ var ts;
var members = new ts.Map();
if (usage.properties) {
usage.properties.forEach(function (u, name) {
- var symbol = checker.createSymbol(4 /* Property */, name);
+ var symbol = checker.createSymbol(4 /* SymbolFlags.Property */, name);
symbol.type = combineFromUsage(u);
members.set(name, symbol);
});
@@ -154663,7 +157319,7 @@ var ts;
return true;
}
if (propUsage.calls) {
- var sigs = checker.getSignaturesOfType(source, 0 /* Call */);
+ var sigs = checker.getSignaturesOfType(source, 0 /* SignatureKind.Call */);
return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls));
}
else {
@@ -154677,7 +157333,7 @@ var ts;
* 2. inference to/from calls with a single signature
*/
function inferInstantiationFromUsage(type, usage) {
- if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !usage.properties) {
+ if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !usage.properties) {
return type;
}
var generic = type.target;
@@ -154696,10 +157352,10 @@ var ts;
if (genericType === typeParameter) {
return [usageType];
}
- else if (genericType.flags & 3145728 /* UnionOrIntersection */) {
+ else if (genericType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) {
return ts.flatMap(genericType.types, function (t) { return inferTypeParameters(t, usageType, typeParameter); });
}
- else if (ts.getObjectFlags(genericType) & 4 /* Reference */ && ts.getObjectFlags(usageType) & 4 /* Reference */) {
+ else if (ts.getObjectFlags(genericType) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(usageType) & 4 /* ObjectFlags.Reference */) {
// this is wrong because we need a reference to the targetType to, so we can check that it's also a reference
var genericArgs = checker.getTypeArguments(genericType);
var usageArgs = checker.getTypeArguments(usageType);
@@ -154713,8 +157369,8 @@ var ts;
}
return types;
}
- var genericSigs = checker.getSignaturesOfType(genericType, 0 /* Call */);
- var usageSigs = checker.getSignaturesOfType(usageType, 0 /* Call */);
+ var genericSigs = checker.getSignaturesOfType(genericType, 0 /* SignatureKind.Call */);
+ var usageSigs = checker.getSignaturesOfType(usageType, 0 /* SignatureKind.Call */);
if (genericSigs.length === 1 && usageSigs.length === 1) {
return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter);
}
@@ -154750,10 +157406,10 @@ var ts;
var parameters = [];
var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; }));
var _loop_16 = function (i) {
- var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg".concat(i)));
+ var symbol = checker.createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg".concat(i)));
symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); }));
if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) {
- symbol.flags |= 16777216 /* Optional */;
+ symbol.flags |= 16777216 /* SymbolFlags.Optional */;
}
parameters.push(symbol);
};
@@ -154761,15 +157417,15 @@ var ts;
_loop_16(i);
}
var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; })));
- return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */);
+ return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* SignatureFlags.None */);
}
function addCandidateType(usage, type) {
- if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) {
+ if (type && !(type.flags & 1 /* TypeFlags.Any */) && !(type.flags & 131072 /* TypeFlags.Never */)) {
(usage.candidateTypes || (usage.candidateTypes = [])).push(type);
}
}
function addCandidateThisType(usage, type) {
- if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) {
+ if (type && !(type.flags & 1 /* TypeFlags.Any */) && !(type.flags & 131072 /* TypeFlags.Never */)) {
(usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type);
}
}
@@ -154920,7 +157576,7 @@ var ts;
* @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub.
*/
function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional, isAmbient) {
- if (preserveOptional === void 0) { preserveOptional = 3 /* All */; }
+ if (preserveOptional === void 0) { preserveOptional = 3 /* PreserveOptionalFlags.All */; }
if (isAmbient === void 0) { isAmbient = false; }
var declarations = symbol.getDeclarations();
if (!(declarations && declarations.length)) {
@@ -154933,13 +157589,13 @@ var ts;
var visibilityModifier = createVisibilityModifier(ts.getEffectiveModifierFlags(declaration));
var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined;
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
- var optional = !!(symbol.flags & 16777216 /* Optional */);
- var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */) || isAmbient;
+ var optional = !!(symbol.flags & 16777216 /* SymbolFlags.Optional */);
+ var ambient = !!(enclosingDeclaration.flags & 16777216 /* NodeFlags.Ambient */) || isAmbient;
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
switch (declaration.kind) {
- case 165 /* PropertySignature */:
- case 166 /* PropertyDeclaration */:
- var flags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined;
+ case 166 /* SyntaxKind.PropertySignature */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ var flags = quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : undefined;
var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context));
if (importAdder) {
var importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
@@ -154949,11 +157605,11 @@ var ts;
}
}
addClassElement(ts.factory.createPropertyDeclaration(
- /*decorators*/ undefined, modifiers, name, optional && (preserveOptional & 2 /* Property */) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode,
+ /*decorators*/ undefined, modifiers, name, optional && (preserveOptional & 2 /* PreserveOptionalFlags.Property */) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, typeNode,
/*initializer*/ undefined));
break;
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */: {
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */: {
var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context));
var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration);
var orderedAccessors = allAccessors.secondAccessor
@@ -154982,8 +157638,8 @@ var ts;
}
break;
}
- case 167 /* MethodSignature */:
- case 168 /* MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
// The signature for the implementation appears as an entry in `signatures` iff
// there is only one signature.
// If there are overloads and an implementation signature, it appears as an
@@ -154991,7 +157647,7 @@ var ts;
// If there is more than one overload but no implementation signature
// (eg: an abstract method or interface declaration), there is a 1-1
// correspondence of declarations and signatures.
- var signatures = checker.getSignaturesOfType(type, 0 /* Call */);
+ var signatures = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */);
if (!ts.some(signatures)) {
break;
}
@@ -155013,13 +157669,13 @@ var ts;
}
else {
ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count");
- addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* Method */), modifiers, quotePreference, body));
+ addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), modifiers, quotePreference, body));
}
}
break;
}
function outputMethod(quotePreference, signature, modifiers, name, body) {
- var method = createSignatureDeclarationFromSignature(168 /* MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* Method */), enclosingDeclaration, importAdder);
+ var method = createSignatureDeclarationFromSignature(169 /* SyntaxKind.MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), enclosingDeclaration, importAdder);
if (method)
addClassElement(method);
}
@@ -155029,7 +157685,10 @@ var ts;
var program = context.program;
var checker = program.getTypeChecker();
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
- var flags = 1 /* NoTruncation */ | 1073741824 /* NoUndefinedOptionalParameterType */ | 256 /* SuppressAnyReturnType */ | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0);
+ var flags = 1 /* NodeBuilderFlags.NoTruncation */
+ | 256 /* NodeBuilderFlags.SuppressAnyReturnType */
+ | 524288 /* NodeBuilderFlags.AllowEmptyTuple */
+ | (quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : 0 /* NodeBuilderFlags.None */);
var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, kind, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context));
if (!signatureDeclaration) {
return undefined;
@@ -155056,7 +157715,7 @@ var ts;
importSymbols(importAdder, importableReference.symbols);
}
}
- return ts.factory.updateTypeParameterDeclaration(typeParameterDecl, typeParameterDecl.name, constraint, defaultType);
+ return ts.factory.updateTypeParameterDeclaration(typeParameterDecl, typeParameterDecl.modifiers, typeParameterDecl.name, constraint, defaultType);
});
if (typeParameters !== newTypeParameters) {
typeParameters = ts.setTextRange(ts.factory.createNodeArray(newTypeParameters, typeParameters.hasTrailingComma), typeParameters);
@@ -155082,7 +157741,7 @@ var ts;
}
}
}
- var questionToken = optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined;
+ var questionToken = optional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined;
var asteriskToken = signatureDeclaration.asteriskToken;
if (ts.isFunctionExpression(signatureDeclaration)) {
return ts.factory.updateFunctionExpression(signatureDeclaration, modifiers, signatureDeclaration.asteriskToken, ts.tryCast(name, ts.isIdentifier), typeParameters, parameters, type, body !== null && body !== void 0 ? body : signatureDeclaration.body);
@@ -155114,24 +157773,31 @@ var ts;
? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags))
: undefined;
var asteriskToken = ts.isYieldExpression(parent)
- ? ts.factory.createToken(41 /* AsteriskToken */)
+ ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */)
: undefined;
var typeParameters = isJs || typeArguments === undefined
? undefined
: ts.map(typeArguments, function (_, i) {
- return ts.factory.createTypeParameterDeclaration(84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T".concat(i));
+ return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, 84 /* CharacterCodes.T */ + typeArguments.length - 1 <= 90 /* CharacterCodes.Z */ ? String.fromCharCode(84 /* CharacterCodes.T */ + i) : "T".concat(i));
});
var parameters = createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, isJs);
var type = isJs || contextualType === undefined
? undefined
: checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker);
- if (kind === 168 /* MethodDeclaration */) {
- return ts.factory.createMethodDeclaration(
- /*decorators*/ undefined, modifiers, asteriskToken, name,
- /*questionToken*/ undefined, typeParameters, parameters, type, ts.isInterfaceDeclaration(contextNode) ? undefined : createStubbedMethodBody(quotePreference));
+ switch (kind) {
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ return ts.factory.createMethodDeclaration(
+ /*decorators*/ undefined, modifiers, asteriskToken, name,
+ /*questionToken*/ undefined, typeParameters, parameters, type, createStubbedMethodBody(quotePreference));
+ case 168 /* SyntaxKind.MethodSignature */:
+ return ts.factory.createMethodSignature(modifiers, name,
+ /*questionToken*/ undefined, typeParameters, parameters, type);
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ return ts.factory.createFunctionDeclaration(
+ /*decorators*/ undefined, modifiers, asteriskToken, name, typeParameters, parameters, type, createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference));
+ default:
+ ts.Debug.fail("Unexpected kind");
}
- return ts.factory.createFunctionDeclaration(
- /*decorators*/ undefined, modifiers, asteriskToken, name, typeParameters, parameters, type, createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference));
}
codefix.createSignatureDeclarationFromCallExpression = createSignatureDeclarationFromCallExpression;
function typeToAutoImportableTypeNode(checker, importAdder, type, contextNode, scriptTarget, flags, tracker) {
@@ -155155,8 +157821,8 @@ var ts;
/*modifiers*/ undefined,
/*dotDotDotToken*/ undefined,
/*name*/ names && names[i] || "arg".concat(i),
- /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined,
- /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */),
+ /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined,
+ /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */),
/*initializer*/ undefined);
parameters.push(newParameter);
}
@@ -155184,11 +157850,10 @@ var ts;
var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; });
var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false);
if (someSigHasRestParameter) {
- var anyArrayType = ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */));
var restParameter = ts.factory.createParameterDeclaration(
/*decorators*/ undefined,
- /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest",
- /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, anyArrayType,
+ /*modifiers*/ undefined, ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest",
+ /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)),
/*initializer*/ undefined);
parameters.push(restParameter);
}
@@ -155204,7 +157869,7 @@ var ts;
function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference, body) {
return ts.factory.createMethodDeclaration(
/*decorators*/ undefined, modifiers,
- /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference));
+ /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference));
}
function createStubbedMethodBody(quotePreference) {
return createStubbedBody(ts.Diagnostics.Method_not_implemented.message, quotePreference);
@@ -155213,16 +157878,16 @@ var ts;
return ts.factory.createBlock([ts.factory.createThrowStatement(ts.factory.createNewExpression(ts.factory.createIdentifier("Error"),
/*typeArguments*/ undefined,
// TODO Handle auto quote preference.
- [ts.factory.createStringLiteral(text, /*isSingleQuote*/ quotePreference === 0 /* Single */)]))],
+ [ts.factory.createStringLiteral(text, /*isSingleQuote*/ quotePreference === 0 /* QuotePreference.Single */)]))],
/*multiline*/ true);
}
codefix.createStubbedBody = createStubbedBody;
function createVisibilityModifier(flags) {
- if (flags & 4 /* Public */) {
- return ts.factory.createToken(123 /* PublicKeyword */);
+ if (flags & 4 /* ModifierFlags.Public */) {
+ return ts.factory.createToken(123 /* SyntaxKind.PublicKeyword */);
}
- else if (flags & 16 /* Protected */) {
- return ts.factory.createToken(122 /* ProtectedKeyword */);
+ else if (flags & 16 /* ModifierFlags.Protected */) {
+ return ts.factory.createToken(122 /* SyntaxKind.ProtectedKeyword */);
}
return undefined;
}
@@ -155295,7 +157960,7 @@ var ts;
}
codefix.tryGetAutoImportableReferenceFromTypeNode = tryGetAutoImportableReferenceFromTypeNode;
function replaceFirstIdentifierOfEntityName(name, newIdentifier) {
- if (name.kind === 79 /* Identifier */) {
+ if (name.kind === 79 /* SyntaxKind.Identifier */) {
return newIdentifier;
}
return ts.factory.createQualifiedName(replaceFirstIdentifierOfEntityName(name.left, newIdentifier), name.right);
@@ -155368,17 +158033,17 @@ var ts;
return ts.isIdentifier(fieldName) ? ts.factory.createPropertyAccessExpression(leftHead, fieldName) : ts.factory.createElementAccessExpression(leftHead, ts.factory.createStringLiteralFromNode(fieldName));
}
function prepareModifierFlagsForAccessor(modifierFlags) {
- modifierFlags &= ~64 /* Readonly */; // avoid Readonly modifier because it will convert to get accessor
- modifierFlags &= ~8 /* Private */;
- if (!(modifierFlags & 16 /* Protected */)) {
- modifierFlags |= 4 /* Public */;
+ modifierFlags &= ~64 /* ModifierFlags.Readonly */; // avoid Readonly modifier because it will convert to get accessor
+ modifierFlags &= ~8 /* ModifierFlags.Private */;
+ if (!(modifierFlags & 16 /* ModifierFlags.Protected */)) {
+ modifierFlags |= 4 /* ModifierFlags.Public */;
}
return modifierFlags;
}
function prepareModifierFlagsForField(modifierFlags) {
- modifierFlags &= ~4 /* Public */;
- modifierFlags &= ~16 /* Protected */;
- modifierFlags |= 8 /* Private */;
+ modifierFlags &= ~4 /* ModifierFlags.Public */;
+ modifierFlags &= ~16 /* ModifierFlags.Protected */;
+ modifierFlags |= 8 /* ModifierFlags.Private */;
return modifierFlags;
}
function getAccessorConvertiblePropertyAtPosition(file, program, start, end, considerEmptySpans) {
@@ -155387,7 +158052,7 @@ var ts;
var cursorRequest = start === end && considerEmptySpans;
var declaration = ts.findAncestor(node.parent, isAcceptedDeclaration);
// make sure declaration have AccessibilityModifier or Static Modifier or Readonly Modifier
- var meaning = 28 /* AccessibilityModifier */ | 32 /* Static */ | 64 /* Readonly */;
+ var meaning = 28 /* ModifierFlags.AccessibilityModifier */ | 32 /* ModifierFlags.Static */ | 64 /* ModifierFlags.Readonly */;
if (!declaration || (!(ts.nodeOverlapsWithStartEnd(declaration.name, file, start, end) || cursorRequest))) {
return {
error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_property_for_which_to_generate_accessor)
@@ -155411,7 +158076,7 @@ var ts;
isStatic: ts.hasStaticModifier(declaration),
isReadonly: ts.hasEffectiveReadonlyModifier(declaration),
type: getDeclarationType(declaration, program),
- container: declaration.kind === 163 /* Parameter */ ? declaration.parent.parent : declaration.parent,
+ container: declaration.kind === 164 /* SyntaxKind.Parameter */ ? declaration.parent.parent : declaration.parent,
originalName: declaration.name.text,
declaration: declaration,
fieldName: fieldName,
@@ -155458,7 +158123,7 @@ var ts;
}
}
function insertAccessor(changeTracker, file, accessor, declaration, container) {
- ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.insertNodeAtClassStart(file, container, accessor) :
+ ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.insertMemberAtStart(file, container, accessor) :
ts.isPropertyAssignment(declaration) ? changeTracker.insertNodeAfterComma(file, declaration, accessor) :
changeTracker.insertNodeAfter(file, declaration, accessor);
}
@@ -155467,13 +158132,13 @@ var ts;
return;
constructor.body.forEachChild(function recur(node) {
if (ts.isElementAccessExpression(node) &&
- node.expression.kind === 108 /* ThisKeyword */ &&
+ node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ &&
ts.isStringLiteral(node.argumentExpression) &&
node.argumentExpression.text === originalName &&
ts.isWriteAccess(node)) {
changeTracker.replaceNode(file, node.argumentExpression, ts.factory.createStringLiteral(fieldName));
}
- if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) {
+ if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) {
changeTracker.replaceNode(file, node.name, ts.factory.createIdentifier(fieldName));
}
if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) {
@@ -155488,7 +158153,7 @@ var ts;
var type = typeChecker.getTypeFromTypeNode(typeNode);
if (!typeChecker.isTypeAssignableTo(typeChecker.getUndefinedType(), type)) {
var types = ts.isUnionTypeNode(typeNode) ? typeNode.types : [typeNode];
- return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(152 /* UndefinedKeyword */)], false));
+ return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)], false));
}
}
return typeNode;
@@ -155500,7 +158165,7 @@ var ts;
var superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression);
if (!superSymbol)
break;
- var symbol = superSymbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol;
+ var symbol = superSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol;
var superDecl = symbol.declarations && ts.find(symbol.declarations, ts.isClassLike);
if (!superDecl)
break;
@@ -155547,7 +158212,7 @@ var ts;
});
function getActionsForUsageOfInvalidImport(context) {
var sourceFile = context.sourceFile;
- var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 207 /* CallExpression */ : 208 /* NewExpression */;
+ var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 208 /* SyntaxKind.CallExpression */ : 209 /* SyntaxKind.NewExpression */;
var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; });
if (!node) {
return [];
@@ -155664,7 +158329,8 @@ var ts;
return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, info.prop.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties);
}
function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
- var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer);
+ ts.suppressLeadingAndTrailingTrivia(propertyDeclaration);
+ var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* SyntaxKind.ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer);
changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
}
function getActionForAddMissingUndefinedType(context, info) {
@@ -155672,7 +158338,7 @@ var ts;
return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, info.prop.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties);
}
function addUndefinedType(changeTracker, sourceFile, info) {
- var undefinedTypeNode = ts.factory.createKeywordTypeNode(152 /* UndefinedKeyword */);
+ var undefinedTypeNode = ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */);
var types = ts.isUnionTypeNode(info.type) ? info.type.types.concat(undefinedTypeNode) : [info.type, undefinedTypeNode];
var unionTypeNode = ts.factory.createUnionTypeNode(types);
if (info.isJs) {
@@ -155693,6 +158359,7 @@ var ts;
return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_initializer_to_property_0, info.prop.name.getText()], fixIdAddInitializer, ts.Diagnostics.Add_initializers_to_all_uninitialized_properties);
}
function addInitializer(changeTracker, propertyDeclarationSourceFile, propertyDeclaration, initializer) {
+ ts.suppressLeadingAndTrailingTrivia(propertyDeclaration);
var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, propertyDeclaration.questionToken, propertyDeclaration.type, initializer);
changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
}
@@ -155700,7 +158367,7 @@ var ts;
return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type)); // TODO: GH#18217
}
function getDefaultValueFromType(checker, type) {
- if (type.flags & 512 /* BooleanLiteral */) {
+ if (type.flags & 512 /* TypeFlags.BooleanLiteral */) {
return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.factory.createFalse() : ts.factory.createTrue();
}
else if (type.isStringLiteral()) {
@@ -155709,7 +158376,7 @@ var ts;
else if (type.isNumberLiteral()) {
return ts.factory.createNumericLiteral(type.value);
}
- else if (type.flags & 2048 /* BigIntLiteral */) {
+ else if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) {
return ts.factory.createBigIntLiteral(type.value);
}
else if (type.isUnion()) {
@@ -155717,7 +158384,7 @@ var ts;
}
else if (type.isClass()) {
var classDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol);
- if (!classDeclaration || ts.hasSyntacticModifier(classDeclaration, 128 /* Abstract */))
+ if (!classDeclaration || ts.hasSyntacticModifier(classDeclaration, 128 /* ModifierFlags.Abstract */))
return undefined;
var constructorDeclaration = ts.getFirstConstructorWithBody(classDeclaration);
if (constructorDeclaration && constructorDeclaration.parameters.length)
@@ -155893,8 +158560,8 @@ var ts;
});
function getImportTypeNode(sourceFile, pos) {
var token = ts.getTokenAtPosition(sourceFile, pos);
- ts.Debug.assert(token.kind === 100 /* ImportKeyword */, "This token should be an ImportKeyword");
- ts.Debug.assert(token.parent.kind === 199 /* ImportType */, "Token parent should be an ImportType");
+ ts.Debug.assert(token.kind === 100 /* SyntaxKind.ImportKeyword */, "This token should be an ImportKeyword");
+ ts.Debug.assert(token.parent.kind === 200 /* SyntaxKind.ImportType */, "Token parent should be an ImportType");
return token.parent;
}
function doChange(changes, sourceFile, importType) {
@@ -155957,7 +158624,7 @@ var ts;
var children = [];
var current = node;
while (true) {
- if (ts.isBinaryExpression(current) && ts.nodeIsMissing(current.operatorToken) && current.operatorToken.kind === 27 /* CommaToken */) {
+ if (ts.isBinaryExpression(current) && ts.nodeIsMissing(current.operatorToken) && current.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) {
children.push(current.left);
if (ts.isJsxChild(current.right)) {
children.push(current.right);
@@ -156022,8 +158689,8 @@ var ts;
var members = ts.isInterfaceDeclaration(container) ? container.members : container.type.members;
var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); });
var parameter = ts.first(indexSignature.parameters);
- var mappedTypeParameter = ts.factory.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type);
- var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(144 /* ReadonlyKeyword */) : undefined, mappedTypeParameter,
+ var mappedTypeParameter = ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.cast(parameter.name, ts.isIdentifier), parameter.type);
+ var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(145 /* SyntaxKind.ReadonlyKeyword */) : undefined, mappedTypeParameter,
/*nameType*/ undefined, indexSignature.questionToken, indexSignature.type,
/*members*/ undefined);
var intersectionType = ts.factory.createIntersectionTypeNode(__spreadArray(__spreadArray(__spreadArray([], ts.getAllSuperTypeNodes(container), true), [
@@ -156081,7 +158748,7 @@ var ts;
},
});
function makeChange(changeTracker, sourceFile, span) {
- var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 132 /* AwaitKeyword */; });
+ var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 132 /* SyntaxKind.AwaitKeyword */; });
var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression);
if (!awaitExpression) {
return;
@@ -156092,7 +158759,7 @@ var ts;
var leftMostExpression = ts.getLeftmostExpression(awaitExpression.expression, /*stopAtCallExpressions*/ false);
if (ts.isIdentifier(leftMostExpression)) {
var precedingToken = ts.findPrecedingToken(awaitExpression.parent.pos, sourceFile);
- if (precedingToken && precedingToken.kind !== 103 /* NewKeyword */) {
+ if (precedingToken && precedingToken.kind !== 103 /* SyntaxKind.NewKeyword */) {
expressionToReplace = awaitExpression.parent;
}
}
@@ -156164,7 +158831,7 @@ var ts;
var declaration = ts.tryCast((_a = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.parent, ts.isVariableDeclarationList);
if (declaration === undefined)
return;
- var constToken = ts.findChildOfKind(declaration, 85 /* ConstKeyword */, sourceFile);
+ var constToken = ts.findChildOfKind(declaration, 85 /* SyntaxKind.ConstKeyword */, sourceFile);
if (constToken === undefined)
return;
return ts.createRange(constToken.pos, constToken.end);
@@ -156201,14 +158868,14 @@ var ts;
});
function getInfo(sourceFile, pos, _) {
var node = ts.getTokenAtPosition(sourceFile, pos);
- return (node.kind === 26 /* SemicolonToken */ &&
+ return (node.kind === 26 /* SyntaxKind.SemicolonToken */ &&
node.parent &&
(ts.isObjectLiteralExpression(node.parent) ||
ts.isArrayLiteralExpression(node.parent))) ? { node: node } : undefined;
}
function doChange(changes, sourceFile, _a) {
var node = _a.node;
- var newNode = ts.factory.createToken(27 /* CommaToken */);
+ var newNode = ts.factory.createToken(27 /* SyntaxKind.CommaToken */);
changes.replaceNode(sourceFile, node, newNode);
}
})(codefix = ts.codefix || (ts.codefix = {}));
@@ -156221,6 +158888,7 @@ var ts;
var fixName = "addVoidToPromise";
var fixId = "addVoidToPromise";
var errorCodes = [
+ ts.Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments.code,
ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code
];
codefix.registerCodeFix({
@@ -156255,7 +158923,7 @@ var ts;
// append ` | void` to type argument
var typeArgument = typeArguments[0];
var needsParens = !ts.isUnionTypeNode(typeArgument) && !ts.isParenthesizedTypeNode(typeArgument) &&
- ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* VoidKeyword */)]).types[0]);
+ ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* SyntaxKind.VoidKeyword */)]).types[0]);
if (needsParens) {
changes.insertText(sourceFile, typeArgument.pos, "(");
}
@@ -156267,14 +158935,14 @@ var ts;
var parameter = signature === null || signature === void 0 ? void 0 : signature.parameters[0];
var parameterType = parameter && checker.getTypeOfSymbolAtLocation(parameter, decl.parent.parent);
if (ts.isInJSFile(decl)) {
- if (!parameterType || parameterType.flags & 3 /* AnyOrUnknown */) {
+ if (!parameterType || parameterType.flags & 3 /* TypeFlags.AnyOrUnknown */) {
// give the expression a type
changes.insertText(sourceFile, decl.parent.parent.end, ")");
changes.insertText(sourceFile, ts.skipTrivia(sourceFile.text, decl.parent.parent.pos), "/** @type {Promise<void>} */(");
}
}
else {
- if (!parameterType || parameterType.flags & 2 /* Unknown */) {
+ if (!parameterType || parameterType.flags & 2 /* TypeFlags.Unknown */) {
// add `void` type argument
changes.insertText(sourceFile, decl.parent.parent.expression.end, "<void>");
}
@@ -156350,15 +159018,15 @@ var ts;
var file = context.file, program = context.program;
var span = ts.getRefactorContextSpan(context);
var token = ts.getTokenAtPosition(file, span.start);
- var exportNode = !!(token.parent && ts.getSyntacticModifierFlags(token.parent) & 1 /* Export */) && considerPartialSpans ? token.parent : ts.getParentNodeInSpan(token, file, span);
+ var exportNode = !!(token.parent && ts.getSyntacticModifierFlags(token.parent) & 1 /* ModifierFlags.Export */) && considerPartialSpans ? token.parent : ts.getParentNodeInSpan(token, file, span);
if (!exportNode || (!ts.isSourceFile(exportNode.parent) && !(ts.isModuleBlock(exportNode.parent) && ts.isAmbientModule(exportNode.parent.parent)))) {
return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_export_statement) };
}
var exportingModuleSymbol = ts.isSourceFile(exportNode.parent) ? exportNode.parent.symbol : exportNode.parent.parent.symbol;
- var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ExportDefault */ : 0 /* None */);
- var wasDefault = !!(flags & 512 /* Default */);
+ var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ModifierFlags.ExportDefault */ : 0 /* ModifierFlags.None */);
+ var wasDefault = !!(flags & 512 /* ModifierFlags.Default */);
// If source file already has a default export, don't offer refactor.
- if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) {
+ if (!(flags & 1 /* ModifierFlags.Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* InternalSymbolName.Default */)) {
return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.This_file_already_has_a_default_export) };
}
var checker = program.getTypeChecker();
@@ -156367,22 +159035,22 @@ var ts;
: { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_named_export) };
};
switch (exportNode.kind) {
- case 255 /* FunctionDeclaration */:
- case 256 /* ClassDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 259 /* EnumDeclaration */:
- case 258 /* TypeAliasDeclaration */:
- case 260 /* ModuleDeclaration */: {
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */: {
var node = exportNode;
if (!node.name)
return undefined;
return noSymbolError(node.name)
|| { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol };
}
- case 236 /* VariableStatement */: {
+ case 237 /* SyntaxKind.VariableStatement */: {
var vs = exportNode;
// Must be `export const x = something;`.
- if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) {
+ if (!(vs.declarationList.flags & 2 /* NodeFlags.Const */) || vs.declarationList.declarations.length !== 1) {
return undefined;
}
var decl = ts.first(vs.declarationList.declarations);
@@ -156392,7 +159060,7 @@ var ts;
return noSymbolError(decl.name)
|| { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol };
}
- case 270 /* ExportAssignment */: {
+ case 271 /* SyntaxKind.ExportAssignment */: {
var node = exportNode;
if (node.isExportEquals)
return undefined;
@@ -156416,18 +159084,18 @@ var ts;
changes.replaceNode(exportingSourceFile, exportNode, ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports([spec])));
}
else {
- changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 88 /* DefaultKeyword */), "Should find a default keyword in modifier list"));
+ changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 88 /* SyntaxKind.DefaultKeyword */), "Should find a default keyword in modifier list"));
}
}
else {
- var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* ExportKeyword */), "Should find an export keyword in modifier list");
+ var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* SyntaxKind.ExportKeyword */), "Should find an export keyword in modifier list");
switch (exportNode.kind) {
- case 255 /* FunctionDeclaration */:
- case 256 /* ClassDeclaration */:
- case 257 /* InterfaceDeclaration */:
- changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* DefaultKeyword */));
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* SyntaxKind.DefaultKeyword */));
break;
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
// If 'x' isn't used in this file and doesn't have type definition, `export const x = 0;` --> `export default 0;`
var decl = ts.first(exportNode.declarationList.declarations);
if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile) && !decl.type) {
@@ -156436,9 +159104,9 @@ var ts;
break;
}
// falls through
- case 259 /* EnumDeclaration */:
- case 258 /* TypeAliasDeclaration */:
- case 260 /* ModuleDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
// `export type T = number;` -> `type T = number; export default T;`
changes.deleteModifier(exportingSourceFile, exportKeyword);
changes.insertNodeAfter(exportingSourceFile, exportNode, ts.factory.createExportDefault(ts.factory.createIdentifier(exportName.text)));
@@ -156465,18 +159133,18 @@ var ts;
function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) {
var parent = ref.parent;
switch (parent.kind) {
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
// `a.default` --> `a.foo`
changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier(exportName));
break;
- case 269 /* ImportSpecifier */:
- case 274 /* ExportSpecifier */: {
+ case 270 /* SyntaxKind.ImportSpecifier */:
+ case 275 /* SyntaxKind.ExportSpecifier */: {
var spec = parent;
// `default as foo` --> `foo`, `default as bar` --> `foo as bar`
changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text));
break;
}
- case 266 /* ImportClause */: {
+ case 267 /* SyntaxKind.ImportClause */: {
var clause = parent;
ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref");
var spec = makeImportSpecifier(exportName, ref.text);
@@ -156485,10 +159153,10 @@ var ts;
// `import foo from "./a";` --> `import { foo } from "./a";`
changes.replaceNode(importingSourceFile, ref, ts.factory.createNamedImports([spec]));
}
- else if (namedBindings.kind === 267 /* NamespaceImport */) {
+ else if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) {
// `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";`
changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) });
- var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* Double */;
+ var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* QuotePreference.Double */;
var newImport = ts.makeImport(/*default*/ undefined, [makeImportSpecifier(exportName, ref.text)], clause.parent.moduleSpecifier, quotePreference);
changes.insertNodeAfter(importingSourceFile, clause.parent, newImport);
}
@@ -156499,6 +159167,10 @@ var ts;
}
break;
}
+ case 200 /* SyntaxKind.ImportType */:
+ var importTypeNode = parent;
+ changes.replaceNode(importingSourceFile, parent, ts.factory.createImportTypeNode(importTypeNode.argument, ts.factory.createIdentifier(exportName), importTypeNode.typeArguments, importTypeNode.isTypeOf));
+ break;
default:
ts.Debug.failBadSyntaxKind(parent);
}
@@ -156506,11 +159178,11 @@ var ts;
function changeNamedToDefaultImport(importingSourceFile, ref, changes) {
var parent = ref.parent;
switch (parent.kind) {
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
// `a.foo` --> `a.default`
changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier("default"));
break;
- case 269 /* ImportSpecifier */: {
+ case 270 /* SyntaxKind.ImportSpecifier */: {
// `import { foo } from "./a";` --> `import foo from "./a";`
// `import { foo as bar } from "./a";` --> `import bar from "./a";`
var defaultImport = ts.factory.createIdentifier(parent.name.text);
@@ -156523,7 +159195,7 @@ var ts;
}
break;
}
- case 274 /* ExportSpecifier */: {
+ case 275 /* SyntaxKind.ExportSpecifier */: {
// `export { foo } from "./a";` --> `export { default as foo } from "./a";`
// `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";`
// `export { foo as default } from "./a";` --> `export { default } from "./a";`
@@ -156551,17 +159223,17 @@ var ts;
var _a;
var refactorName = "Convert import";
var actions = (_a = {},
- _a[0 /* Named */] = {
+ _a[0 /* ImportKind.Named */] = {
name: "Convert namespace import to named imports",
description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message,
kind: "refactor.rewrite.import.named",
},
- _a[2 /* Namespace */] = {
+ _a[2 /* ImportKind.Namespace */] = {
name: "Convert named imports to namespace import",
description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message,
kind: "refactor.rewrite.import.namespace",
},
- _a[1 /* Default */] = {
+ _a[1 /* ImportKind.Default */] = {
name: "Convert named imports to default import",
description: ts.Diagnostics.Convert_named_imports_to_default_import.message,
kind: "refactor.rewrite.import.default",
@@ -156613,23 +159285,25 @@ var ts;
if (!importClause.namedBindings) {
return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_namespace_import_or_named_imports) };
}
- if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
- return { convertTo: 0 /* Named */, import: importClause.namedBindings };
+ if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) {
+ return { convertTo: 0 /* ImportKind.Named */, import: importClause.namedBindings };
}
- var compilerOptions = context.program.getCompilerOptions();
- var shouldUseDefault = ts.getAllowSyntheticDefaultImports(compilerOptions)
- && isExportEqualsModule(importClause.parent.moduleSpecifier, context.program.getTypeChecker());
+ var shouldUseDefault = getShouldUseDefault(context.program, importClause);
return shouldUseDefault
- ? { convertTo: 1 /* Default */, import: importClause.namedBindings }
- : { convertTo: 2 /* Namespace */, import: importClause.namedBindings };
+ ? { convertTo: 1 /* ImportKind.Default */, import: importClause.namedBindings }
+ : { convertTo: 2 /* ImportKind.Namespace */, import: importClause.namedBindings };
+ }
+ function getShouldUseDefault(program, importClause) {
+ return ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())
+ && isExportEqualsModule(importClause.parent.moduleSpecifier, program.getTypeChecker());
}
function doChange(sourceFile, program, changes, info) {
var checker = program.getTypeChecker();
- if (info.convertTo === 0 /* Named */) {
+ if (info.convertTo === 0 /* ImportKind.Named */) {
doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
}
else {
- doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, info.import, info.convertTo === 1 /* Default */);
+ doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* ImportKind.Default */);
}
}
function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) {
@@ -156642,7 +159316,7 @@ var ts;
}
else {
var exportName = getRightOfPropertyAccessOrQualifiedName(id.parent).text;
- if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) {
+ if (checker.resolveName(exportName, id, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true)) {
conflictingNames.set(exportName, true);
}
ts.Debug.assert(getLeftOfPropertyAccessOrQualifiedName(id.parent) === id, "Parent expression should match id");
@@ -156679,7 +159353,9 @@ var ts;
function getLeftOfPropertyAccessOrQualifiedName(propertyAccessOrQualifiedName) {
return ts.isPropertyAccessExpression(propertyAccessOrQualifiedName) ? propertyAccessOrQualifiedName.expression : propertyAccessOrQualifiedName.left;
}
- function doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, toConvert, shouldUseDefault) {
+ function doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, toConvert, shouldUseDefault) {
+ if (shouldUseDefault === void 0) { shouldUseDefault = getShouldUseDefault(program, toConvert.parent); }
+ var checker = program.getTypeChecker();
var importDecl = toConvert.parent.parent;
var moduleSpecifier = importDecl.moduleSpecifier;
var toConvertSymbols = new ts.Set();
@@ -156689,14 +159365,14 @@ var ts;
toConvertSymbols.add(symbol);
}
});
- var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 99 /* ESNext */) : "module";
+ var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 99 /* ScriptTarget.ESNext */) : "module";
function hasNamespaceNameConflict(namedImport) {
// We need to check if the preferred namespace name (`preferredName`) we'd like to use in the refactored code will present a name conflict.
// A name conflict means that, in a scope where we would like to use the preferred namespace name, there already exists a symbol with that name in that scope.
// We are going to use the namespace name in the scopes the named imports being refactored are referenced,
// so we look for conflicts by looking at every reference to those named imports.
return !!ts.FindAllReferences.Core.eachSymbolReferenceInFile(namedImport.name, checker, sourceFile, function (id) {
- var symbol = checker.resolveName(preferredName, id, 67108863 /* All */, /*excludeGlobals*/ true);
+ var symbol = checker.resolveName(preferredName, id, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true);
if (symbol) { // There already is a symbol with the same name as the preferred namespace name.
if (toConvertSymbols.has(symbol)) { // `preferredName` resolves to a symbol for one of the named import references we are going to transform into namespace import references...
return ts.isExportSpecifier(id.parent); // ...but if this reference is an export specifier, it will not be transformed, so it is a conflict; otherwise, it will be renamed and is not a conflict.
@@ -156740,6 +159416,7 @@ var ts;
changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, newNamedImports));
}
}
+ refactor.doChangeNamedToNamespaceOrDefault = doChangeNamedToNamespaceOrDefault;
function isExportEqualsModule(moduleSpecifier, checker) {
var externalModule = checker.resolveExternalModuleName(moduleSpecifier);
if (!externalModule)
@@ -156844,7 +159521,7 @@ var ts;
}
}
function getBinaryInfo(expression) {
- if (expression.operatorToken.kind !== 55 /* AmpersandAmpersandToken */) {
+ if (expression.operatorToken.kind !== 55 /* SyntaxKind.AmpersandAmpersandToken */) {
return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_logical_AND_access_chains) };
}
;
@@ -156860,7 +159537,7 @@ var ts;
*/
function getOccurrencesInExpression(matchTo, expression) {
var occurrences = [];
- while (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 55 /* AmpersandAmpersandToken */) {
+ while (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) {
var match = getMatchingStart(ts.skipParentheses(matchTo), ts.skipParentheses(expression.right));
if (!match) {
break;
@@ -156986,17 +159663,17 @@ var ts;
occurrences.pop();
if (ts.isCallExpression(toConvert)) {
return isOccurrence ?
- ts.factory.createCallChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.typeArguments, toConvert.arguments) :
+ ts.factory.createCallChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.typeArguments, toConvert.arguments) :
ts.factory.createCallChain(chain, toConvert.questionDotToken, toConvert.typeArguments, toConvert.arguments);
}
else if (ts.isPropertyAccessExpression(toConvert)) {
return isOccurrence ?
- ts.factory.createPropertyAccessChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.name) :
+ ts.factory.createPropertyAccessChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.name) :
ts.factory.createPropertyAccessChain(chain, toConvert.questionDotToken, toConvert.name);
}
else if (ts.isElementAccessExpression(toConvert)) {
return isOccurrence ?
- ts.factory.createElementAccessChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.argumentExpression) :
+ ts.factory.createElementAccessChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.argumentExpression) :
ts.factory.createElementAccessChain(chain, toConvert.questionDotToken, toConvert.argumentExpression);
}
}
@@ -157011,7 +159688,7 @@ var ts;
changes.replaceNodeRange(sourceFile, firstOccurrence, finalExpression, convertedChain);
}
else if (ts.isConditionalExpression(expression)) {
- changes.replaceNode(sourceFile, expression, ts.factory.createBinaryExpression(convertedChain, ts.factory.createToken(60 /* QuestionQuestionToken */), expression.whenFalse));
+ changes.replaceNode(sourceFile, expression, ts.factory.createBinaryExpression(convertedChain, ts.factory.createToken(60 /* SyntaxKind.QuestionQuestionToken */), expression.whenFalse));
}
}
}
@@ -157057,27 +159734,27 @@ var ts;
var lastDeclaration = signatureDecls[signatureDecls.length - 1];
var updated = lastDeclaration;
switch (lastDeclaration.kind) {
- case 167 /* MethodSignature */: {
+ case 168 /* SyntaxKind.MethodSignature */: {
updated = ts.factory.updateMethodSignature(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type);
break;
}
- case 168 /* MethodDeclaration */: {
+ case 169 /* SyntaxKind.MethodDeclaration */: {
updated = ts.factory.updateMethodDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body);
break;
}
- case 173 /* CallSignature */: {
+ case 174 /* SyntaxKind.CallSignature */: {
updated = ts.factory.updateCallSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type);
break;
}
- case 170 /* Constructor */: {
+ case 171 /* SyntaxKind.Constructor */: {
updated = ts.factory.updateConstructorDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.body);
break;
}
- case 174 /* ConstructSignature */: {
+ case 175 /* SyntaxKind.ConstructSignature */: {
updated = ts.factory.updateConstructSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type);
break;
}
- case 255 /* FunctionDeclaration */: {
+ case 256 /* SyntaxKind.FunctionDeclaration */: {
updated = ts.factory.updateFunctionDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body);
break;
}
@@ -157099,24 +159776,24 @@ var ts;
return ts.factory.createNodeArray([
ts.factory.createParameterDeclaration(
/*decorators*/ undefined,
- /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), "args",
+ /*modifiers*/ undefined, ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */), "args",
/*questionToken*/ undefined, ts.factory.createUnionTypeNode(ts.map(signatureDeclarations, convertSignatureParametersToTuple)))
]);
}
function convertSignatureParametersToTuple(decl) {
var members = ts.map(decl.parameters, convertParameterToNamedTupleMember);
- return ts.setEmitFlags(ts.factory.createTupleTypeNode(members), ts.some(members, function (m) { return !!ts.length(ts.getSyntheticLeadingComments(m)); }) ? 0 /* None */ : 1 /* SingleLine */);
+ return ts.setEmitFlags(ts.factory.createTupleTypeNode(members), ts.some(members, function (m) { return !!ts.length(ts.getSyntheticLeadingComments(m)); }) ? 0 /* EmitFlags.None */ : 1 /* EmitFlags.SingleLine */);
}
function convertParameterToNamedTupleMember(p) {
ts.Debug.assert(ts.isIdentifier(p.name)); // This is checked during refactoring applicability checking
- var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)), p);
+ var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)), p);
var parameterDocComment = p.symbol && p.symbol.getDocumentationComment(checker);
if (parameterDocComment) {
var newComment = ts.displayPartsToString(parameterDocComment);
if (newComment.length) {
ts.setSyntheticLeadingComments(result, [{
text: "*\n".concat(newComment.split("\n").map(function (c) { return " * ".concat(c); }).join("\n"), "\n "),
- kind: 3 /* MultiLineCommentTrivia */,
+ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */,
pos: -1,
end: -1,
hasTrailingNewLine: true,
@@ -157129,12 +159806,12 @@ var ts;
}
function isConvertableSignatureDeclaration(d) {
switch (d.kind) {
- case 167 /* MethodSignature */:
- case 168 /* MethodDeclaration */:
- case 173 /* CallSignature */:
- case 170 /* Constructor */:
- case 174 /* ConstructSignature */:
- case 255 /* FunctionDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 174 /* SyntaxKind.CallSignature */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 175 /* SyntaxKind.ConstructSignature */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
return true;
}
return false;
@@ -157388,6 +160065,7 @@ var ts;
Messages.cannotAccessVariablesFromNestedScopes = createMessage("Cannot access variables from nested scopes");
Messages.cannotExtractToJSClass = createMessage("Cannot extract constant to a class scope in JS");
Messages.cannotExtractToExpressionArrowFunction = createMessage("Cannot extract constant to an arrow function without a block");
+ Messages.cannotExtractFunctionsContainingThisToMethod = createMessage("Cannot extract functions containing this to method");
})(Messages = extractSymbol.Messages || (extractSymbol.Messages = {}));
var RangeFacts;
(function (RangeFacts) {
@@ -157396,10 +160074,11 @@ var ts;
RangeFacts[RangeFacts["IsGenerator"] = 2] = "IsGenerator";
RangeFacts[RangeFacts["IsAsyncFunction"] = 4] = "IsAsyncFunction";
RangeFacts[RangeFacts["UsesThis"] = 8] = "UsesThis";
+ RangeFacts[RangeFacts["UsesThisInFunction"] = 16] = "UsesThisInFunction";
/**
* The range is in a function which needs the 'static' modifier in a class
*/
- RangeFacts[RangeFacts["InStaticRegion"] = 16] = "InStaticRegion";
+ RangeFacts[RangeFacts["InStaticRegion"] = 32] = "InStaticRegion";
})(RangeFacts || (RangeFacts = {}));
/**
* getRangeToExtract takes a span inside a text file and returns either an expression or an array
@@ -157430,11 +160109,12 @@ var ts;
// We'll modify these flags as we walk the tree to collect data
// about what things need to be done as part of the extraction.
var rangeFacts = RangeFacts.None;
+ var thisNode;
if (!start || !end) {
// cannot find either start or end node
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
}
- if (start.flags & 4194304 /* JSDoc */) {
+ if (start.flags & 8388608 /* NodeFlags.JSDoc */) {
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] };
}
if (start.parent !== end.parent) {
@@ -157468,7 +160148,7 @@ var ts;
// the expression.
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
}
- return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } };
+ return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations, thisNode: thisNode } };
}
if (ts.isReturnStatement(start) && !start.expression) {
// Makes no sense to extract an expression-less return statement.
@@ -157480,7 +160160,7 @@ var ts;
if (errors) {
return { errors: errors };
}
- return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations } }; // TODO: GH#18217
+ return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; // TODO: GH#18217
/**
* Attempt to refine the extraction node (generally, by shrinking it) to produce better results.
* @param node The unrefined extraction node.
@@ -157523,20 +160203,20 @@ var ts;
function checkForStaticContext(nodeToCheck, containingClass) {
var current = nodeToCheck;
while (current !== containingClass) {
- if (current.kind === 166 /* PropertyDeclaration */) {
+ if (current.kind === 167 /* SyntaxKind.PropertyDeclaration */) {
if (ts.isStatic(current)) {
rangeFacts |= RangeFacts.InStaticRegion;
}
break;
}
- else if (current.kind === 163 /* Parameter */) {
+ else if (current.kind === 164 /* SyntaxKind.Parameter */) {
var ctorOrMethod = ts.getContainingFunction(current);
- if (ctorOrMethod.kind === 170 /* Constructor */) {
+ if (ctorOrMethod.kind === 171 /* SyntaxKind.Constructor */) {
rangeFacts |= RangeFacts.InStaticRegion;
}
break;
}
- else if (current.kind === 168 /* MethodDeclaration */) {
+ else if (current.kind === 169 /* SyntaxKind.MethodDeclaration */) {
if (ts.isStatic(current)) {
rangeFacts |= RangeFacts.InStaticRegion;
}
@@ -157557,10 +160237,10 @@ var ts;
ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (1)");
// For understanding how skipTrivia functioned:
ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (2)");
- if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck))) {
+ if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) {
return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)];
}
- if (nodeToCheck.flags & 8388608 /* Ambient */) {
+ if (nodeToCheck.flags & 16777216 /* NodeFlags.Ambient */) {
return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)];
}
// If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default)
@@ -157569,9 +160249,17 @@ var ts;
checkForStaticContext(nodeToCheck, containingClass);
}
var errors;
- var permittedJumps = 4 /* Return */;
+ var permittedJumps = 4 /* PermittedJumps.Return */;
var seenLabels;
visit(nodeToCheck);
+ if (rangeFacts & RangeFacts.UsesThis) {
+ var container = ts.getThisContainer(nodeToCheck, /** includeArrowFunctions */ false);
+ if (container.kind === 256 /* SyntaxKind.FunctionDeclaration */ ||
+ (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) ||
+ container.kind === 213 /* SyntaxKind.FunctionExpression */) {
+ rangeFacts |= RangeFacts.UsesThisInFunction;
+ }
+ }
return errors;
function visit(node) {
if (errors) {
@@ -157579,8 +160267,8 @@ var ts;
return true;
}
if (ts.isDeclaration(node)) {
- var declaringNode = (node.kind === 253 /* VariableDeclaration */) ? node.parent.parent : node;
- if (ts.hasSyntacticModifier(declaringNode, 1 /* Export */)) {
+ var declaringNode = (node.kind === 254 /* SyntaxKind.VariableDeclaration */) ? node.parent.parent : node;
+ if (ts.hasSyntacticModifier(declaringNode, 1 /* ModifierFlags.Export */)) {
// TODO: GH#18217 Silly to use `errors ||` since it's definitely not defined (see top of `visit`)
// Also, if we're only pushing one error, just use `let error: Diagnostic | undefined`!
// Also TODO: GH#19956
@@ -157591,16 +160279,16 @@ var ts;
}
// Some things can't be extracted in certain situations
switch (node.kind) {
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
(errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport));
return true;
- case 270 /* ExportAssignment */:
+ case 271 /* SyntaxKind.ExportAssignment */:
(errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity));
return true;
- case 106 /* SuperKeyword */:
+ case 106 /* SyntaxKind.SuperKeyword */:
// For a super *constructor call*, we have to be extracting the entire class,
// but a super *method call* simply implies a 'this' reference
- if (node.parent.kind === 207 /* CallExpression */) {
+ if (node.parent.kind === 208 /* SyntaxKind.CallExpression */) {
// Super constructor call
var containingClass_1 = ts.getContainingClass(node);
if (containingClass_1 === undefined || containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) {
@@ -157610,13 +160298,15 @@ var ts;
}
else {
rangeFacts |= RangeFacts.UsesThis;
+ thisNode = node;
}
break;
- case 213 /* ArrowFunction */:
+ case 214 /* SyntaxKind.ArrowFunction */:
// check if arrow function uses this
ts.forEachChild(node, function check(n) {
if (ts.isThis(n)) {
rangeFacts |= RangeFacts.UsesThis;
+ thisNode = node;
}
else if (ts.isClassLike(n) || (ts.isFunctionLike(n) && !ts.isArrowFunction(n))) {
return false;
@@ -157626,63 +160316,64 @@ var ts;
}
});
// falls through
- case 256 /* ClassDeclaration */:
- case 255 /* FunctionDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) {
// You cannot extract global declarations
(errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope));
}
// falls through
- case 225 /* ClassExpression */:
- case 212 /* FunctionExpression */:
- case 168 /* MethodDeclaration */:
- case 170 /* Constructor */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
// do not dive into functions or classes
return false;
}
var savedPermittedJumps = permittedJumps;
switch (node.kind) {
- case 238 /* IfStatement */:
- permittedJumps = 0 /* None */;
+ case 239 /* SyntaxKind.IfStatement */:
+ permittedJumps = 0 /* PermittedJumps.None */;
break;
- case 251 /* TryStatement */:
+ case 252 /* SyntaxKind.TryStatement */:
// forbid all jumps inside try blocks
- permittedJumps = 0 /* None */;
+ permittedJumps = 0 /* PermittedJumps.None */;
break;
- case 234 /* Block */:
- if (node.parent && node.parent.kind === 251 /* TryStatement */ && node.parent.finallyBlock === node) {
+ case 235 /* SyntaxKind.Block */:
+ if (node.parent && node.parent.kind === 252 /* SyntaxKind.TryStatement */ && node.parent.finallyBlock === node) {
// allow unconditional returns from finally blocks
- permittedJumps = 4 /* Return */;
+ permittedJumps = 4 /* PermittedJumps.Return */;
}
break;
- case 289 /* DefaultClause */:
- case 288 /* CaseClause */:
+ case 290 /* SyntaxKind.DefaultClause */:
+ case 289 /* SyntaxKind.CaseClause */:
// allow unlabeled break inside case clauses
- permittedJumps |= 1 /* Break */;
+ permittedJumps |= 1 /* PermittedJumps.Break */;
break;
default:
if (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false)) {
// allow unlabeled break/continue inside loops
- permittedJumps |= 1 /* Break */ | 2 /* Continue */;
+ permittedJumps |= 1 /* PermittedJumps.Break */ | 2 /* PermittedJumps.Continue */;
}
break;
}
switch (node.kind) {
- case 191 /* ThisType */:
- case 108 /* ThisKeyword */:
+ case 192 /* SyntaxKind.ThisType */:
+ case 108 /* SyntaxKind.ThisKeyword */:
rangeFacts |= RangeFacts.UsesThis;
+ thisNode = node;
break;
- case 249 /* LabeledStatement */: {
+ case 250 /* SyntaxKind.LabeledStatement */: {
var label = node.label;
(seenLabels || (seenLabels = [])).push(label.escapedText);
ts.forEachChild(node, visit);
seenLabels.pop();
break;
}
- case 245 /* BreakStatement */:
- case 244 /* ContinueStatement */: {
+ case 246 /* SyntaxKind.BreakStatement */:
+ case 245 /* SyntaxKind.ContinueStatement */: {
var label = node.label;
if (label) {
if (!ts.contains(seenLabels, label.escapedText)) {
@@ -157691,21 +160382,21 @@ var ts;
}
}
else {
- if (!(permittedJumps & (node.kind === 245 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) {
+ if (!(permittedJumps & (node.kind === 246 /* SyntaxKind.BreakStatement */ ? 1 /* PermittedJumps.Break */ : 2 /* PermittedJumps.Continue */))) {
// attempt to break or continue in a forbidden context
(errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements));
}
}
break;
}
- case 217 /* AwaitExpression */:
+ case 218 /* SyntaxKind.AwaitExpression */:
rangeFacts |= RangeFacts.IsAsyncFunction;
break;
- case 223 /* YieldExpression */:
+ case 224 /* SyntaxKind.YieldExpression */:
rangeFacts |= RangeFacts.IsGenerator;
break;
- case 246 /* ReturnStatement */:
- if (permittedJumps & 4 /* Return */) {
+ case 247 /* SyntaxKind.ReturnStatement */:
+ if (permittedJumps & 4 /* PermittedJumps.Return */) {
rangeFacts |= RangeFacts.HasReturn;
}
else {
@@ -157728,7 +160419,7 @@ var ts;
function getAdjustedSpanFromNodes(startNode, endNode, sourceFile) {
var start = startNode.getStart(sourceFile);
var end = endNode.getEnd();
- if (sourceFile.text.charCodeAt(end) === 59 /* semicolon */) {
+ if (sourceFile.text.charCodeAt(end) === 59 /* CharacterCodes.semicolon */) {
end++;
}
return { start: start, length: end - start };
@@ -157737,17 +160428,21 @@ var ts;
if (ts.isStatement(node)) {
return [node];
}
- else if (ts.isExpressionNode(node)) {
+ if (ts.isExpressionNode(node)) {
// If our selection is the expression in an ExpressionStatement, expand
// the selection to include the enclosing Statement (this stops us
// from trying to care about the return value of the extracted function
// and eliminates double semicolon insertion in certain scenarios)
return ts.isExpressionStatement(node.parent) ? [node.parent] : node;
}
+ if (isStringLiteralJsxAttribute(node)) {
+ return node;
+ }
return undefined;
}
function isScope(node) {
- return ts.isFunctionLikeDeclaration(node) || ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isClassLike(node);
+ return ts.isArrowFunction(node) ? ts.isFunctionBody(node.body) :
+ ts.isFunctionLikeDeclaration(node) || ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isClassLike(node);
}
/**
* Computes possible places we could extract the function into. For example,
@@ -157756,7 +160451,7 @@ var ts;
*/
function collectEnclosingScopes(range) {
var current = isReadonlyArray(range.range) ? ts.first(range.range) : range.range;
- if (range.facts & RangeFacts.UsesThis) {
+ if (range.facts & RangeFacts.UsesThis && !(range.facts & RangeFacts.UsesThisInFunction)) {
// if range uses this as keyword or as type inside the class then it can only be extracted to a method of the containing class
var containingClass = ts.getContainingClass(current);
if (containingClass) {
@@ -157770,7 +160465,7 @@ var ts;
while (true) {
current = current.parent;
// A function parameter's initializer is actually in the outer scope, not the function declaration
- if (current.kind === 163 /* Parameter */) {
+ if (current.kind === 164 /* SyntaxKind.Parameter */) {
// Skip all the way to the outer scope of the function that declared this parameter
current = ts.findAncestor(current, function (parent) { return ts.isFunctionLikeDeclaration(parent); }).parent;
}
@@ -157781,7 +160476,7 @@ var ts;
// * Module/namespace or source file
if (isScope(current)) {
scopes.push(current);
- if (current.kind === 303 /* SourceFile */) {
+ if (current.kind === 305 /* SyntaxKind.SourceFile */) {
return scopes;
}
}
@@ -157821,11 +160516,11 @@ var ts;
: getDescriptionForModuleLikeDeclaration(scope);
var functionDescription;
var constantDescription;
- if (scopeDescription === 1 /* Global */) {
+ if (scopeDescription === 1 /* SpecialScope.Global */) {
functionDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [functionDescriptionPart, "global"]);
constantDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [constantDescriptionPart, "global"]);
}
- else if (scopeDescription === 0 /* Module */) {
+ else if (scopeDescription === 0 /* SpecialScope.Module */) {
functionDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [functionDescriptionPart, "module"]);
constantDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [constantDescriptionPart, "module"]);
}
@@ -157871,34 +160566,34 @@ var ts;
}
function getDescriptionForFunctionLikeDeclaration(scope) {
switch (scope.kind) {
- case 170 /* Constructor */:
+ case 171 /* SyntaxKind.Constructor */:
return "constructor";
- case 212 /* FunctionExpression */:
- case 255 /* FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
return scope.name
? "function '".concat(scope.name.text, "'")
: ts.ANONYMOUS;
- case 213 /* ArrowFunction */:
+ case 214 /* SyntaxKind.ArrowFunction */:
return "arrow function";
- case 168 /* MethodDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
return "method '".concat(scope.name.getText(), "'");
- case 171 /* GetAccessor */:
+ case 172 /* SyntaxKind.GetAccessor */:
return "'get ".concat(scope.name.getText(), "'");
- case 172 /* SetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
return "'set ".concat(scope.name.getText(), "'");
default:
throw ts.Debug.assertNever(scope, "Unexpected scope kind ".concat(scope.kind));
}
}
function getDescriptionForClassLikeDeclaration(scope) {
- return scope.kind === 256 /* ClassDeclaration */
+ return scope.kind === 257 /* SyntaxKind.ClassDeclaration */
? scope.name ? "class '".concat(scope.name.text, "'") : "anonymous class declaration"
: scope.name ? "class expression '".concat(scope.name.text, "'") : "anonymous class expression";
}
function getDescriptionForModuleLikeDeclaration(scope) {
- return scope.kind === 261 /* ModuleBlock */
+ return scope.kind === 262 /* SyntaxKind.ModuleBlock */
? "namespace '".concat(scope.parent.name.getText(), "'")
- : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */;
+ : scope.externalModuleIndicator ? 0 /* SpecialScope.Module */ : 1 /* SpecialScope.Global */;
}
var SpecialScope;
(function (SpecialScope) {
@@ -157929,7 +160624,7 @@ var ts;
var type = checker.getTypeOfSymbolAtLocation(usage.symbol, usage.node);
// Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {"
type = checker.getBaseTypeOfLiteralType(type);
- typeNode = ts.codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, scriptTarget, 1 /* NoTruncation */);
+ typeNode = ts.codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, scriptTarget, 1 /* NodeBuilderFlags.NoTruncation */);
}
var paramDecl = ts.factory.createParameterDeclaration(
/*decorators*/ undefined,
@@ -157938,7 +160633,7 @@ var ts;
/*name*/ name,
/*questionToken*/ undefined, typeNode);
parameters.push(paramDecl);
- if (usage.usage === 2 /* Write */) {
+ if (usage.usage === 2 /* Usage.Write */) {
(writes || (writes = [])).push(usage);
}
callArguments.push(ts.factory.createIdentifier(name));
@@ -157957,27 +160652,37 @@ var ts;
// to avoid problems when there are literal types present
if (ts.isExpression(node) && !isJS) {
var contextualType = checker.getContextualType(node);
- returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NoTruncation */); // TODO: GH#18217
+ returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NodeBuilderFlags.NoTruncation */); // TODO: GH#18217
}
var _b = transformFunctionBody(node, exposedVariableDeclarations, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty;
ts.suppressLeadingAndTrailingTrivia(body);
var newFunction;
+ var callThis = !!(range.facts & RangeFacts.UsesThisInFunction);
if (ts.isClassLike(scope)) {
// always create private method in TypeScript files
- var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* PrivateKeyword */)];
+ var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* SyntaxKind.PrivateKeyword */)];
if (range.facts & RangeFacts.InStaticRegion) {
- modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */));
+ modifiers.push(ts.factory.createModifier(124 /* SyntaxKind.StaticKeyword */));
}
if (range.facts & RangeFacts.IsAsyncFunction) {
- modifiers.push(ts.factory.createModifier(131 /* AsyncKeyword */));
+ modifiers.push(ts.factory.createModifier(131 /* SyntaxKind.AsyncKeyword */));
}
newFunction = ts.factory.createMethodDeclaration(
- /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName,
+ /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, functionName,
/*questionToken*/ undefined, typeParameters, parameters, returnType, body);
}
else {
+ if (callThis) {
+ parameters.unshift(ts.factory.createParameterDeclaration(
+ /*decorators*/ undefined,
+ /*modifiers*/ undefined,
+ /*dotDotDotToken*/ undefined,
+ /*name*/ "this",
+ /*questionToken*/ undefined, checker.typeToTypeNode(checker.getTypeAtLocation(range.thisNode), scope, 1 /* NodeBuilderFlags.NoTruncation */),
+ /*initializer*/ undefined));
+ }
newFunction = ts.factory.createFunctionDeclaration(
- /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body);
+ /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* SyntaxKind.AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body);
}
var changeTracker = ts.textChanges.ChangeTracker.fromContext(context);
var minInsertionPos = (isReadonlyArray(range.range) ? ts.last(range.range) : range.range).end;
@@ -157992,10 +160697,13 @@ var ts;
var newNodes = [];
// replace range with function call
var called = getCalledExpression(scope, range, functionNameText);
- var call = ts.factory.createCallExpression(called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference
+ if (callThis) {
+ callArguments.unshift(ts.factory.createIdentifier("this"));
+ }
+ var call = ts.factory.createCallExpression(callThis ? ts.factory.createPropertyAccessExpression(called, "call") : called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference
callArguments);
if (range.facts & RangeFacts.IsGenerator) {
- call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* AsteriskToken */), call);
+ call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */), call);
}
if (range.facts & RangeFacts.IsAsyncFunction) {
call = ts.factory.createAwaitExpression(call);
@@ -158029,7 +160737,7 @@ var ts;
/*propertyName*/ undefined,
/*name*/ ts.getSynthesizedDeepClone(variableDeclaration.name)));
// Being returned through an object literal will have widened the type.
- var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, 1 /* NoTruncation */);
+ var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, 1 /* NodeBuilderFlags.NoTruncation */);
typeElements.push(ts.factory.createPropertySignature(
/*modifiers*/ undefined,
/*name*/ variableDeclaration.symbol.name,
@@ -158040,7 +160748,7 @@ var ts;
}
var typeLiteral = sawExplicitType ? ts.factory.createTypeLiteralNode(typeElements) : undefined;
if (typeLiteral) {
- ts.setEmitFlags(typeLiteral, 1 /* SingleLine */);
+ ts.setEmitFlags(typeLiteral, 1 /* EmitFlags.SingleLine */);
}
newNodes.push(ts.factory.createVariableStatement(
/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(ts.factory.createObjectBindingPattern(bindingElements),
@@ -158055,8 +160763,8 @@ var ts;
for (var _c = 0, exposedVariableDeclarations_2 = exposedVariableDeclarations; _c < exposedVariableDeclarations_2.length; _c++) {
var variableDeclaration = exposedVariableDeclarations_2[_c];
var flags = variableDeclaration.parent.flags;
- if (flags & 2 /* Const */) {
- flags = (flags & ~2 /* Const */) | 1 /* Let */;
+ if (flags & 2 /* NodeFlags.Const */) {
+ flags = (flags & ~2 /* NodeFlags.Const */) | 1 /* NodeFlags.Let */;
}
newNodes.push(ts.factory.createVariableStatement(
/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(variableDeclaration.symbol.name, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(variableDeclaration.type))], flags)));
@@ -158065,7 +160773,7 @@ var ts;
if (returnValueProperty) {
// has both writes and return, need to create variable declaration to hold return value;
newNodes.push(ts.factory.createVariableStatement(
- /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(returnValueProperty, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(returnType))], 1 /* Let */)));
+ /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(returnValueProperty, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(returnType))], 1 /* NodeFlags.Let */)));
}
var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes);
if (returnValueProperty) {
@@ -158122,9 +160830,9 @@ var ts;
while (ts.isParenthesizedTypeNode(withoutParens)) {
withoutParens = withoutParens.type;
}
- return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 152 /* UndefinedKeyword */; })
+ return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 153 /* SyntaxKind.UndefinedKeyword */; })
? clone
- : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(152 /* UndefinedKeyword */)]);
+ : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)]);
}
}
/**
@@ -158137,11 +160845,13 @@ var ts;
var checker = context.program.getTypeChecker();
// Make a unique name for the extracted variable
var file = scope.getSourceFile();
- var localNameText = ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file);
+ var localNameText = ts.isPropertyAccessExpression(node) && !ts.isClassLike(scope) && !checker.resolveName(node.name.text, node, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false) && !ts.isPrivateIdentifier(node.name) && !ts.isKeyword(node.name.originalKeywordKind)
+ ? node.name.text
+ : ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file);
var isJS = ts.isInJSFile(scope);
var variableType = isJS || !checker.isContextSensitive(node)
? undefined
- : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217
+ : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NodeBuilderFlags.NoTruncation */); // TODO: GH#18217
var initializer = transformConstantInitializer(ts.skipParentheses(node), substitutions);
(_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer);
ts.suppressLeadingAndTrailingTrivia(initializer);
@@ -158149,11 +160859,11 @@ var ts;
if (ts.isClassLike(scope)) {
ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass
var modifiers = [];
- modifiers.push(ts.factory.createModifier(121 /* PrivateKeyword */));
+ modifiers.push(ts.factory.createModifier(121 /* SyntaxKind.PrivateKeyword */));
if (rangeFacts & RangeFacts.InStaticRegion) {
- modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */));
+ modifiers.push(ts.factory.createModifier(124 /* SyntaxKind.StaticKeyword */));
}
- modifiers.push(ts.factory.createModifier(144 /* ReadonlyKeyword */));
+ modifiers.push(ts.factory.createModifier(145 /* SyntaxKind.ReadonlyKeyword */));
var newVariable = ts.factory.createPropertyDeclaration(
/*decorators*/ undefined, modifiers, localNameText,
/*questionToken*/ undefined, variableType, initializer);
@@ -158185,16 +160895,16 @@ var ts;
var localReference = ts.factory.createIdentifier(localNameText);
changeTracker.replaceNode(context.file, node, localReference);
}
- else if (node.parent.kind === 237 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) {
+ else if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) {
// If the parent is an expression statement and the target scope is the immediately enclosing one,
// replace the statement with the declaration.
var newVariableStatement = ts.factory.createVariableStatement(
- /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* Const */));
+ /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* NodeFlags.Const */));
changeTracker.replaceNode(context.file, node.parent, newVariableStatement);
}
else {
var newVariableStatement = ts.factory.createVariableStatement(
- /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* Const */));
+ /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* NodeFlags.Const */));
// Declare
var nodeToInsertBefore = getNodeToInsertConstantBefore(node, scope);
if (nodeToInsertBefore.pos === 0) {
@@ -158204,7 +160914,7 @@ var ts;
changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false);
}
// Consume
- if (node.parent.kind === 237 /* ExpressionStatement */) {
+ if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */) {
// If the parent is an expression statement, delete it.
changeTracker.delete(context.file, node.parent);
}
@@ -158231,7 +160941,7 @@ var ts;
if (!ts.isFunctionExpression(initializer) && !ts.isArrowFunction(initializer) || !!initializer.typeParameters)
return { variableType: variableType, initializer: initializer };
var functionType = checker.getTypeAtLocation(node);
- var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* Call */));
+ var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* SignatureKind.Call */));
// If no function signature, maybe there was an error, do nothing
if (!functionSignature)
return { variableType: variableType, initializer: initializer };
@@ -158250,7 +160960,7 @@ var ts;
var paramType = checker.getTypeAtLocation(p);
if (paramType === checker.getAnyType())
hasAny = true;
- parameters.push(ts.factory.updateParameterDeclaration(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NoTruncation */), p.initializer));
+ parameters.push(ts.factory.updateParameterDeclaration(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NodeBuilderFlags.NoTruncation */), p.initializer));
}
}
// If a parameter was inferred as any we skip adding function parameters at all.
@@ -158260,7 +160970,7 @@ var ts;
return { variableType: variableType, initializer: initializer };
variableType = undefined;
if (ts.isArrowFunction(initializer)) {
- initializer = ts.factory.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.equalsGreaterThanToken, initializer.body);
+ initializer = ts.factory.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NodeBuilderFlags.NoTruncation */), initializer.equalsGreaterThanToken, initializer.body);
}
else {
if (functionSignature && !!functionSignature.thisParameter) {
@@ -158273,10 +160983,10 @@ var ts;
/* decorators */ undefined,
/* modifiers */ undefined,
/* dotDotDotToken */ undefined, "this",
- /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NoTruncation */)));
+ /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NodeBuilderFlags.NoTruncation */)));
}
}
- initializer = ts.factory.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.body);
+ initializer = ts.factory.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NodeBuilderFlags.NoTruncation */), initializer.body);
}
return { variableType: variableType, initializer: initializer };
}
@@ -158523,7 +161233,7 @@ var ts;
var end = ts.last(statements).end;
expressionDiagnostic = ts.createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected);
}
- else if (checker.getTypeAtLocation(expression).flags & (16384 /* Void */ | 131072 /* Never */)) {
+ else if (checker.getTypeAtLocation(expression).flags & (16384 /* TypeFlags.Void */ | 131072 /* TypeFlags.Never */)) {
expressionDiagnostic = ts.createDiagnosticForNode(expression, Messages.uselessConstantType);
}
// initialize results
@@ -158553,7 +161263,7 @@ var ts;
// Unfortunately, this code takes advantage of the knowledge that the generated method
// will use the contextual type of an expression as the return type of the extracted
// method (and will therefore "use" all the types involved).
- if (inGenericContext && !isReadonlyArray(targetRange.range)) {
+ if (inGenericContext && !isReadonlyArray(targetRange.range) && !ts.isJsxAttribute(targetRange.range)) {
var contextualType = checker.getContextualType(targetRange.range); // TODO: GH#18217
recordTypeParameterUsages(contextualType);
}
@@ -158601,14 +161311,17 @@ var ts;
var errorNode = isReadonlyArray(targetRange.range) ? targetRange.range[0] : targetRange.range;
constantErrorsPerScope[i].push(ts.createDiagnosticForNode(errorNode, Messages.cannotAccessVariablesFromNestedScopes));
}
+ if (targetRange.facts & RangeFacts.UsesThisInFunction && ts.isClassLike(scopes[i])) {
+ functionErrorsPerScope[i].push(ts.createDiagnosticForNode(targetRange.thisNode, Messages.cannotExtractFunctionsContainingThisToMethod));
+ }
var hasWrite = false;
var readonlyClassPropertyWrite;
usagesPerScope[i].usages.forEach(function (value) {
- if (value.usage === 2 /* Write */) {
+ if (value.usage === 2 /* Usage.Write */) {
hasWrite = true;
- if (value.symbol.flags & 106500 /* ClassMember */ &&
+ if (value.symbol.flags & 106500 /* SymbolFlags.ClassMember */ &&
value.symbol.valueDeclaration &&
- ts.hasEffectiveModifier(value.symbol.valueDeclaration, 64 /* Readonly */)) {
+ ts.hasEffectiveModifier(value.symbol.valueDeclaration, 64 /* ModifierFlags.Readonly */)) {
readonlyClassPropertyWrite = value.symbol.valueDeclaration;
}
}
@@ -158652,7 +161365,7 @@ var ts;
}
}
function collectUsages(node, valueUsage) {
- if (valueUsage === void 0) { valueUsage = 1 /* Read */; }
+ if (valueUsage === void 0) { valueUsage = 1 /* Usage.Read */; }
if (inGenericContext) {
var type = checker.getTypeAtLocation(node);
recordTypeParameterUsages(type);
@@ -158662,11 +161375,11 @@ var ts;
}
if (ts.isAssignmentExpression(node)) {
// use 'write' as default usage for values
- collectUsages(node.left, 2 /* Write */);
+ collectUsages(node.left, 2 /* Usage.Write */);
collectUsages(node.right);
}
else if (ts.isUnaryExpressionWithWrite(node)) {
- collectUsages(node.operand, 2 /* Write */);
+ collectUsages(node.operand, 2 /* Usage.Write */);
}
else if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) {
// use 'write' as default usage for values
@@ -158740,7 +161453,7 @@ var ts;
// declaration is located in range to be extracted - do nothing
return undefined;
}
- if (targetRange.facts & RangeFacts.IsGenerator && usage === 2 /* Write */) {
+ if (targetRange.facts & RangeFacts.IsGenerator && usage === 2 /* Usage.Write */) {
// this is write to a reference located outside of the target scope and range is extracted into generator
// currently this is unsupported scenario
var diag = ts.createDiagnosticForNode(identifier, Messages.cannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators);
@@ -158767,7 +161480,7 @@ var ts;
else if (isTypeName) {
// If the symbol is a type parameter that won't be in scope, we'll pass it as a type argument
// so there's no problem.
- if (!(symbol.flags & 262144 /* TypeParameter */)) {
+ if (!(symbol.flags & 262144 /* SymbolFlags.TypeParameter */)) {
var diag = ts.createDiagnosticForNode(identifier, Messages.typeWillNotBeVisibleInTheNewScope);
functionErrorsPerScope[i].push(diag);
constantErrorsPerScope[i].push(diag);
@@ -158848,37 +161561,41 @@ var ts;
function isExtractableExpression(node) {
var parent = node.parent;
switch (parent.kind) {
- case 297 /* EnumMember */:
+ case 299 /* SyntaxKind.EnumMember */:
return false;
}
switch (node.kind) {
- case 10 /* StringLiteral */:
- return parent.kind !== 265 /* ImportDeclaration */ &&
- parent.kind !== 269 /* ImportSpecifier */;
- case 224 /* SpreadElement */:
- case 200 /* ObjectBindingPattern */:
- case 202 /* BindingElement */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ return parent.kind !== 266 /* SyntaxKind.ImportDeclaration */ &&
+ parent.kind !== 270 /* SyntaxKind.ImportSpecifier */;
+ case 225 /* SyntaxKind.SpreadElement */:
+ case 201 /* SyntaxKind.ObjectBindingPattern */:
+ case 203 /* SyntaxKind.BindingElement */:
return false;
- case 79 /* Identifier */:
- return parent.kind !== 202 /* BindingElement */ &&
- parent.kind !== 269 /* ImportSpecifier */ &&
- parent.kind !== 274 /* ExportSpecifier */;
+ case 79 /* SyntaxKind.Identifier */:
+ return parent.kind !== 203 /* SyntaxKind.BindingElement */ &&
+ parent.kind !== 270 /* SyntaxKind.ImportSpecifier */ &&
+ parent.kind !== 275 /* SyntaxKind.ExportSpecifier */;
}
return true;
}
function isBlockLike(node) {
switch (node.kind) {
- case 234 /* Block */:
- case 303 /* SourceFile */:
- case 261 /* ModuleBlock */:
- case 288 /* CaseClause */:
+ case 235 /* SyntaxKind.Block */:
+ case 305 /* SyntaxKind.SourceFile */:
+ case 262 /* SyntaxKind.ModuleBlock */:
+ case 289 /* SyntaxKind.CaseClause */:
return true;
default:
return false;
}
}
function isInJSXContent(node) {
- return (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && (ts.isJsxElement(node.parent) || ts.isJsxFragment(node.parent));
+ return isStringLiteralJsxAttribute(node) ||
+ (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && (ts.isJsxElement(node.parent) || ts.isJsxFragment(node.parent));
+ }
+ function isStringLiteralJsxAttribute(node) {
+ return ts.isStringLiteral(node) && node.parent && ts.isJsxAttribute(node.parent);
}
})(extractSymbol = refactor.extractSymbol || (refactor.extractSymbol = {}));
})(refactor = ts.refactor || (ts.refactor = {}));
@@ -159013,7 +161730,7 @@ var ts;
if (ts.isTypeReferenceNode(node)) {
if (ts.isIdentifier(node.typeName)) {
var typeName = node.typeName;
- var symbol = checker.resolveName(typeName.text, typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true);
+ var symbol = checker.resolveName(typeName.text, typeName, 262144 /* SymbolFlags.TypeParameter */, /* excludeGlobals */ true);
for (var _i = 0, _a = (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray; _i < _a.length; _i++) {
var decl = _a[_i];
if (ts.isTypeParameterDeclaration(decl) && decl.getSourceFile() === file) {
@@ -159044,7 +161761,7 @@ var ts;
}
else if (ts.isTypeQueryNode(node)) {
if (ts.isIdentifier(node.exprName)) {
- var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* Value */, /* excludeGlobals */ false);
+ var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* SymbolFlags.Value */, /* excludeGlobals */ false);
if ((symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) {
return true;
}
@@ -159056,7 +161773,7 @@ var ts;
}
}
if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) {
- ts.setEmitFlags(node, 1 /* SingleLine */);
+ ts.setEmitFlags(node, 1 /* EmitFlags.SingleLine */);
}
return ts.forEachChild(node, visitor);
}
@@ -159065,7 +161782,7 @@ var ts;
var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters;
var newTypeNode = ts.factory.createTypeAliasDeclaration(
/* decorators */ undefined,
- /* modifiers */ undefined, name, typeParameters.map(function (id) { return ts.factory.updateTypeParameterDeclaration(id, id.name, id.constraint, /* defaultType */ undefined); }), selection);
+ /* modifiers */ undefined, name, typeParameters.map(function (id) { return ts.factory.updateTypeParameterDeclaration(id, id.modifiers, id.name, id.constraint, /* defaultType */ undefined); }), selection);
changes.insertNodeBefore(file, firstStatement, ts.ignoreSourceNewlines(newTypeNode), /* blankLineBetween */ true);
changes.replaceNode(file, selection, ts.factory.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.factory.createTypeReferenceNode(id.name, /* typeArguments */ undefined); })), { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude, trailingTriviaOption: ts.textChanges.TrailingTriviaOption.ExcludeWhitespace });
}
@@ -159082,11 +161799,12 @@ var ts;
}
function doTypedefChange(changes, file, name, info) {
var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters;
+ ts.setEmitFlags(selection, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */);
var node = ts.factory.createJSDocTypedefTag(ts.factory.createIdentifier("typedef"), ts.factory.createJSDocTypeExpression(selection), ts.factory.createIdentifier(name));
var templates = [];
ts.forEach(typeParameters, function (typeParameter) {
var constraint = ts.getEffectiveConstraintOfTypeParameter(typeParameter);
- var parameter = ts.factory.createTypeParameterDeclaration(typeParameter.name);
+ var parameter = ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, typeParameter.name);
var template = ts.factory.createJSDocTemplateTag(ts.factory.createIdentifier("template"), constraint && ts.cast(constraint, ts.isJSDocTypeExpression), [parameter]);
templates.push(template);
});
@@ -159265,11 +161983,11 @@ var ts;
}
function isPureImport(node) {
switch (node.kind) {
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
return true;
- case 264 /* ImportEqualsDeclaration */:
- return !ts.hasSyntacticModifier(node, 1 /* Export */);
- case 236 /* VariableStatement */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ return !ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */);
+ case 237 /* SyntaxKind.VariableStatement */:
return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); });
default:
return false;
@@ -159309,7 +162027,7 @@ var ts;
var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEsModuleSyntax);
if (imports.length && body.length) {
return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), [
- 4 /* NewLineTrivia */
+ 4 /* SyntaxKind.NewLineTrivia */
], false), body, true);
}
return __spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), body, true);
@@ -159365,25 +162083,25 @@ var ts;
}
function getNamespaceLikeImport(node) {
switch (node.kind) {
- case 265 /* ImportDeclaration */:
- return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 267 /* NamespaceImport */ ?
+ case 266 /* SyntaxKind.ImportDeclaration */:
+ return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ?
node.importClause.namedBindings.name : undefined;
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return node.name;
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return ts.tryCast(node.name, ts.isIdentifier);
default:
return ts.Debug.assertNever(node, "Unexpected node kind ".concat(node.kind));
}
}
function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) {
- var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 99 /* ESNext */);
+ var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 99 /* ScriptTarget.ESNext */);
var needUniqueName = false;
var toChange = [];
ts.FindAllReferences.Core.eachSymbolReferenceInFile(oldImportId, checker, sourceFile, function (ref) {
if (!ts.isPropertyAccessExpression(ref.parent))
return;
- needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863 /* All */, /*excludeGlobals*/ true);
+ needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true);
if (movedSymbols.has(checker.getSymbolAtLocation(ref.parent.name))) {
toChange.push(ref);
}
@@ -159401,21 +162119,21 @@ var ts;
var newNamespaceId = ts.factory.createIdentifier(newNamespaceName);
var newModuleString = ts.factory.createStringLiteral(newModuleSpecifier);
switch (node.kind) {
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
return ts.factory.createImportDeclaration(
/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamespaceImport(newNamespaceId)), newModuleString,
/*assertClause*/ undefined);
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return ts.factory.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, newNamespaceId, ts.factory.createExternalModuleReference(newModuleString));
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return ts.factory.createVariableDeclaration(newNamespaceId, /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(newModuleString));
default:
return ts.Debug.assertNever(node, "Unexpected node kind ".concat(node.kind));
}
}
function moduleSpecifierFromImport(i) {
- return (i.kind === 265 /* ImportDeclaration */ ? i.moduleSpecifier
- : i.kind === 264 /* ImportEqualsDeclaration */ ? i.moduleReference.expression
+ return (i.kind === 266 /* SyntaxKind.ImportDeclaration */ ? i.moduleSpecifier
+ : i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? i.moduleReference.expression
: i.initializer.arguments[0]);
}
function forEachImportInStatement(statement, cb) {
@@ -159441,7 +162159,7 @@ var ts;
var defaultImport;
var imports = [];
newFileNeedExport.forEach(function (symbol) {
- if (symbol.escapedName === "default" /* Default */) {
+ if (symbol.escapedName === "default" /* InternalSymbolName.Default */) {
defaultImport = ts.factory.createIdentifier(ts.symbolNameNoDefault(symbol)); // TODO: GH#18217
}
else {
@@ -159465,7 +162183,7 @@ var ts;
}
}
function makeVariableStatement(name, type, initializer, flags) {
- if (flags === void 0) { flags = 2 /* Const */; }
+ if (flags === void 0) { flags = 2 /* NodeFlags.Const */; }
return ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, initializer)], flags));
}
function createRequireCall(moduleSpecifier) {
@@ -159485,15 +162203,15 @@ var ts;
}
function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) {
switch (importDecl.kind) {
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused);
break;
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
if (isUnused(importDecl.name)) {
changes.delete(sourceFile, importDecl);
}
break;
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused);
break;
default:
@@ -159506,7 +162224,7 @@ var ts;
var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings;
var defaultUnused = !name || isUnused(name);
var namedBindingsUnused = !namedBindings ||
- (namedBindings.kind === 267 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); }));
+ (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); }));
if (defaultUnused && namedBindingsUnused) {
changes.delete(sourceFile, importDecl);
}
@@ -159518,7 +162236,7 @@ var ts;
if (namedBindingsUnused) {
changes.replaceNode(sourceFile, importDecl.importClause, ts.factory.updateImportClause(importDecl.importClause, importDecl.importClause.isTypeOnly, name, /*namedBindings*/ undefined));
}
- else if (namedBindings.kind === 268 /* NamedImports */) {
+ else if (namedBindings.kind === 269 /* SyntaxKind.NamedImports */) {
for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) {
var element = _b[_i];
if (isUnused(element.name))
@@ -159531,14 +162249,14 @@ var ts;
function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) {
var name = varDecl.name;
switch (name.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
if (isUnused(name)) {
changes.delete(sourceFile, name);
}
break;
- case 201 /* ArrayBindingPattern */:
+ case 202 /* SyntaxKind.ArrayBindingPattern */:
break;
- case 200 /* ObjectBindingPattern */:
+ case 201 /* SyntaxKind.ObjectBindingPattern */:
if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) {
changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl);
}
@@ -159580,7 +162298,7 @@ var ts;
if (markSeenTop(top)) {
addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax);
}
- if (ts.hasSyntacticModifier(decl, 512 /* Default */)) {
+ if (ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */)) {
oldFileDefault = name;
}
else {
@@ -159596,7 +162314,7 @@ var ts;
for (var i = 1;; i++) {
var name = ts.combinePaths(inDirectory, newModuleName + extension);
if (!host.fileExists(name))
- return newModuleName; // TODO: GH#18217
+ return newModuleName;
newModuleName = "".concat(moduleName, ".").concat(i);
}
}
@@ -159607,7 +162325,7 @@ var ts;
var movedSymbols = new SymbolSet();
var oldImportsNeededByNewFile = new SymbolSet();
var newFileImportsFromOldFile = new SymbolSet();
- var containsJsx = ts.find(toMove, function (statement) { return !!(statement.transformFlags & 2 /* ContainsJsx */); });
+ var containsJsx = ts.find(toMove, function (statement) { return !!(statement.transformFlags & 2 /* TransformFlags.ContainsJsx */); });
var jsxNamespaceSymbol = getJsxNamespaceSymbol(containsJsx);
if (jsxNamespaceSymbol) { // Might not exist (e.g. in non-compiling code)
oldImportsNeededByNewFile.add(jsxNamespaceSymbol);
@@ -159641,7 +162359,7 @@ var ts;
if (ts.contains(toMove, statement))
continue;
// jsxNamespaceSymbol will only be set iff it is in oldImportsNeededByNewFile.
- if (jsxNamespaceSymbol && !!(statement.transformFlags & 2 /* ContainsJsx */)) {
+ if (jsxNamespaceSymbol && !!(statement.transformFlags & 2 /* TransformFlags.ContainsJsx */)) {
unusedImportsFromOldFile.delete(jsxNamespaceSymbol);
}
forEachReference(statement, checker, function (symbol) {
@@ -159659,7 +162377,7 @@ var ts;
// Strictly speaking, this could resolve to a symbol other than the JSX namespace.
// This will produce erroneous output (probably, an incorrectly copied import) but
// is expected to be very rare and easily reversible.
- var jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, 1920 /* Namespace */, /*excludeGlobals*/ true);
+ var jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, 1920 /* SymbolFlags.Namespace */, /*excludeGlobals*/ true);
return !!jsxNamespaceSymbol && ts.some(jsxNamespaceSymbol.declarations, isInImport)
? jsxNamespaceSymbol
: undefined;
@@ -159668,14 +162386,14 @@ var ts;
// Below should all be utilities
function isInImport(decl) {
switch (decl.kind) {
- case 264 /* ImportEqualsDeclaration */:
- case 269 /* ImportSpecifier */:
- case 266 /* ImportClause */:
- case 267 /* NamespaceImport */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
+ case 267 /* SyntaxKind.ImportClause */:
+ case 268 /* SyntaxKind.NamespaceImport */:
return true;
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return isVariableDeclarationInImport(decl);
- case 202 /* BindingElement */:
+ case 203 /* SyntaxKind.BindingElement */:
return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent);
default:
return false;
@@ -159687,7 +162405,7 @@ var ts;
}
function filterImport(i, moduleSpecifier, keep) {
switch (i.kind) {
- case 265 /* ImportDeclaration */: {
+ case 266 /* SyntaxKind.ImportDeclaration */: {
var clause = i.importClause;
if (!clause)
return undefined;
@@ -159697,9 +162415,9 @@ var ts;
? ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImport, namedBindings), moduleSpecifier, /*assertClause*/ undefined)
: undefined;
}
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return keep(i.name) ? i : undefined;
- case 253 /* VariableDeclaration */: {
+ case 254 /* SyntaxKind.VariableDeclaration */: {
var name = filterBindingName(i.name, keep);
return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined;
}
@@ -159708,7 +162426,7 @@ var ts;
}
}
function filterNamedBindings(namedBindings, keep) {
- if (namedBindings.kind === 267 /* NamespaceImport */) {
+ if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) {
return keep(namedBindings.name) ? namedBindings : undefined;
}
else {
@@ -159718,11 +162436,11 @@ var ts;
}
function filterBindingName(name, keep) {
switch (name.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return keep(name) ? name : undefined;
- case 201 /* ArrayBindingPattern */:
+ case 202 /* SyntaxKind.ArrayBindingPattern */:
return name;
- case 200 /* ObjectBindingPattern */: {
+ case 201 /* SyntaxKind.ObjectBindingPattern */: {
// We can't handle nested destructurings or property names well here, so just copy them all.
var newElements = name.elements.filter(function (prop) { return prop.propertyName || !ts.isIdentifier(prop.name) || keep(prop.name); });
return newElements.length ? ts.factory.createObjectBindingPattern(newElements) : undefined;
@@ -159779,13 +162497,13 @@ var ts;
}
function isNonVariableTopLevelDeclaration(node) {
switch (node.kind) {
- case 255 /* FunctionDeclaration */:
- case 256 /* ClassDeclaration */:
- case 260 /* ModuleDeclaration */:
- case 259 /* EnumDeclaration */:
- case 258 /* TypeAliasDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 264 /* ImportEqualsDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return true;
default:
return false;
@@ -159793,19 +162511,19 @@ var ts;
}
function forEachTopLevelDeclaration(statement, cb) {
switch (statement.kind) {
- case 255 /* FunctionDeclaration */:
- case 256 /* ClassDeclaration */:
- case 260 /* ModuleDeclaration */:
- case 259 /* EnumDeclaration */:
- case 258 /* TypeAliasDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 264 /* ImportEqualsDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return cb(statement);
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); });
- case 237 /* ExpressionStatement */: {
+ case 238 /* SyntaxKind.ExpressionStatement */: {
var expression = statement.expression;
- return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */
+ return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* AssignmentDeclarationKind.ExportsProperty */
? cb(statement)
: undefined;
}
@@ -159813,10 +162531,10 @@ var ts;
}
function forEachTopLevelDeclarationInBindingName(name, cb) {
switch (name.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); }));
- case 201 /* ArrayBindingPattern */:
- case 200 /* ObjectBindingPattern */:
+ case 202 /* SyntaxKind.ArrayBindingPattern */:
+ case 201 /* SyntaxKind.ObjectBindingPattern */:
return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); });
default:
return ts.Debug.assertNever(name, "Unexpected name kind ".concat(name.kind));
@@ -159827,9 +162545,9 @@ var ts;
}
function getTopLevelDeclarationStatement(d) {
switch (d.kind) {
- case 253 /* VariableDeclaration */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
return d.parent.parent;
- case 202 /* BindingElement */:
+ case 203 /* SyntaxKind.BindingElement */:
return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); }));
default:
return d;
@@ -159851,7 +162569,7 @@ var ts;
function isExported(sourceFile, decl, useEs6Exports, name) {
var _a;
if (useEs6Exports) {
- return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText)));
+ return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText)));
}
return getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); });
}
@@ -159859,25 +162577,25 @@ var ts;
return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl);
}
function addEs6Export(d) {
- var modifiers = ts.concatenate([ts.factory.createModifier(93 /* ExportKeyword */)], d.modifiers);
+ var modifiers = ts.concatenate([ts.factory.createModifier(93 /* SyntaxKind.ExportKeyword */)], d.modifiers);
switch (d.kind) {
- case 255 /* FunctionDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
return ts.factory.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body);
- case 256 /* ClassDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
return ts.factory.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members);
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
return ts.factory.updateVariableStatement(d, modifiers, d.declarationList);
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
return ts.factory.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body);
- case 259 /* EnumDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
return ts.factory.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members);
- case 258 /* TypeAliasDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
return ts.factory.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type);
- case 257 /* InterfaceDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
return ts.factory.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members);
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return ts.factory.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.isTypeOnly, d.name, d.moduleReference);
- case 237 /* ExpressionStatement */:
+ case 238 /* SyntaxKind.ExpressionStatement */:
return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...`
default:
return ts.Debug.assertNever(d, "Unexpected declaration kind ".concat(d.kind));
@@ -159888,18 +162606,18 @@ var ts;
}
function getNamesToExportInCommonJS(decl) {
switch (decl.kind) {
- case 255 /* FunctionDeclaration */:
- case 256 /* ClassDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
return [decl.name.text]; // TODO: GH#18217
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; });
- case 260 /* ModuleDeclaration */:
- case 259 /* EnumDeclaration */:
- case 258 /* TypeAliasDeclaration */:
- case 257 /* InterfaceDeclaration */:
- case 264 /* ImportEqualsDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
return ts.emptyArray;
- case 237 /* ExpressionStatement */:
+ case 238 /* SyntaxKind.ExpressionStatement */:
return ts.Debug.fail("Can't export an ExpressionStatement"); // Shouldn't try to add 'export' keyword to `exports.x = ...`
default:
return ts.Debug.assertNever(decl, "Unexpected decl kind ".concat(decl.kind));
@@ -159907,7 +162625,7 @@ var ts;
}
/** Creates `exports.x = x;` */
function createExportAssignment(name) {
- return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), ts.factory.createIdentifier(name)), 63 /* EqualsToken */, ts.factory.createIdentifier(name)));
+ return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), ts.factory.createIdentifier(name)), 63 /* SyntaxKind.EqualsToken */, ts.factory.createIdentifier(name)));
}
})(refactor = ts.refactor || (ts.refactor = {}));
})(ts || (ts = {}));
@@ -159970,14 +162688,14 @@ var ts;
if (actionName === addBracesAction.name) {
var returnStatement_1 = ts.factory.createReturnStatement(expression);
body = ts.factory.createBlock([returnStatement_1], /* multiLine */ true);
- ts.copyLeadingComments(expression, returnStatement_1, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ true);
+ ts.copyLeadingComments(expression, returnStatement_1, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ true);
}
else if (actionName === removeBracesAction.name && returnStatement) {
var actualExpression = expression || ts.factory.createVoidZero();
body = ts.needsParentheses(actualExpression) ? ts.factory.createParenthesizedExpression(actualExpression) : actualExpression;
- ts.copyTrailingAsLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false);
- ts.copyLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false);
- ts.copyTrailingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false);
+ ts.copyTrailingAsLeadingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false);
+ ts.copyLeadingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false);
+ ts.copyTrailingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false);
}
else {
ts.Debug.fail("invalid action");
@@ -160111,7 +162829,7 @@ var ts;
var contextualSymbols = ts.map(functionNames, function (name) { return getSymbolForContextualType(name, checker); });
for (var _i = 0, referenceEntries_1 = referenceEntries; _i < referenceEntries_1.length; _i++) {
var entry = referenceEntries_1[_i];
- if (entry.kind === 0 /* Span */) {
+ if (entry.kind === 0 /* FindAllReferences.EntryKind.Span */) {
groupedReferences.valid = false;
continue;
}
@@ -160210,7 +162928,7 @@ var ts;
if (element) {
var contextualType = checker.getContextualTypeForObjectLiteralElement(element);
var symbol = contextualType === null || contextualType === void 0 ? void 0 : contextualType.getSymbol();
- if (symbol && !(ts.getCheckFlags(symbol) & 6 /* Synthetic */)) {
+ if (symbol && !(ts.getCheckFlags(symbol) & 6 /* CheckFlags.Synthetic */)) {
return symbol;
}
}
@@ -160240,15 +162958,15 @@ var ts;
var parent = functionReference.parent;
switch (parent.kind) {
// foo(...) or super(...) or new Foo(...)
- case 207 /* CallExpression */:
- case 208 /* NewExpression */:
+ case 208 /* SyntaxKind.CallExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression);
if (callOrNewExpression && callOrNewExpression.expression === functionReference) {
return callOrNewExpression;
}
break;
// x.foo(...)
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression);
if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) {
var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression);
@@ -160258,7 +162976,7 @@ var ts;
}
break;
// x["foo"](...)
- case 206 /* ElementAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression);
if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) {
var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression);
@@ -160277,14 +162995,14 @@ var ts;
var parent = reference.parent;
switch (parent.kind) {
// `C.foo`
- case 205 /* PropertyAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression);
if (propertyAccessExpression && propertyAccessExpression.expression === reference) {
return propertyAccessExpression;
}
break;
// `C["foo"]`
- case 206 /* ElementAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression);
if (elementAccessExpression && elementAccessExpression.expression === reference) {
return elementAccessExpression;
@@ -160296,7 +163014,7 @@ var ts;
}
function entryToType(entry) {
var reference = entry.node;
- if (ts.getMeaningFromLocation(reference) === 2 /* Type */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(reference.parent)) {
+ if (ts.getMeaningFromLocation(reference) === 2 /* SemanticMeaning.Type */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(reference.parent)) {
return reference;
}
return undefined;
@@ -160330,16 +163048,16 @@ var ts;
if (!isValidParameterNodeArray(functionDeclaration.parameters, checker))
return false;
switch (functionDeclaration.kind) {
- case 255 /* FunctionDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker);
- case 168 /* MethodDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
if (ts.isObjectLiteralExpression(functionDeclaration.parent)) {
var contextualSymbol = getSymbolForContextualType(functionDeclaration.name, checker);
// don't offer the refactor when there are multiple signatures since we won't know which ones the user wants to change
return ((_a = contextualSymbol === null || contextualSymbol === void 0 ? void 0 : contextualSymbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 && isSingleImplementation(functionDeclaration, checker);
}
return isSingleImplementation(functionDeclaration, checker);
- case 170 /* Constructor */:
+ case 171 /* SyntaxKind.Constructor */:
if (ts.isClassDeclaration(functionDeclaration.parent)) {
return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker);
}
@@ -160347,8 +163065,8 @@ var ts;
return isValidVariableDeclaration(functionDeclaration.parent.parent)
&& isSingleImplementation(functionDeclaration, checker);
}
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
return isValidVariableDeclaration(functionDeclaration.parent);
}
return false;
@@ -160358,7 +163076,7 @@ var ts;
}
function hasNameOrDefault(functionOrClassDeclaration) {
if (!functionOrClassDeclaration.name) {
- var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* DefaultKeyword */);
+ var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* SyntaxKind.DefaultKeyword */);
return !!defaultKeyword;
}
return true;
@@ -160464,7 +163182,7 @@ var ts;
}
function createParameterTypeNode(parameters) {
var members = ts.map(parameters, createPropertySignatureFromParameterDeclaration);
- var typeNode = ts.addEmitFlags(ts.factory.createTypeLiteralNode(members), 1 /* SingleLine */);
+ var typeNode = ts.addEmitFlags(ts.factory.createTypeLiteralNode(members), 1 /* EmitFlags.SingleLine */);
return typeNode;
}
function createPropertySignatureFromParameterDeclaration(parameterDeclaration) {
@@ -160473,7 +163191,7 @@ var ts;
parameterType = getTypeNode(parameterDeclaration);
}
var propertySignature = ts.factory.createPropertySignature(
- /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.factory.createToken(57 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType);
+ /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : parameterDeclaration.questionToken, parameterType);
ts.suppressLeadingAndTrailingTrivia(propertySignature);
ts.copyComments(parameterDeclaration.name, propertySignature.name);
if (parameterDeclaration.type && propertySignature.type) {
@@ -160498,15 +163216,15 @@ var ts;
}
function getClassNames(constructorDeclaration) {
switch (constructorDeclaration.parent.kind) {
- case 256 /* ClassDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
var classDeclaration = constructorDeclaration.parent;
if (classDeclaration.name)
return [classDeclaration.name];
// If the class declaration doesn't have a name, it should have a default modifier.
// We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault`
- var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* DefaultKeyword */), "Nameless class declaration should be a default export");
+ var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* SyntaxKind.DefaultKeyword */), "Nameless class declaration should be a default export");
return [defaultModifier];
- case 225 /* ClassExpression */:
+ case 226 /* SyntaxKind.ClassExpression */:
var classExpression = constructorDeclaration.parent;
var variableDeclaration = constructorDeclaration.parent.parent;
var className = classExpression.name;
@@ -160517,25 +163235,25 @@ var ts;
}
function getFunctionNames(functionDeclaration) {
switch (functionDeclaration.kind) {
- case 255 /* FunctionDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
if (functionDeclaration.name)
return [functionDeclaration.name];
// If the function declaration doesn't have a name, it should have a default modifier.
// We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault`
- var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* DefaultKeyword */), "Nameless function declaration should be a default export");
+ var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* SyntaxKind.DefaultKeyword */), "Nameless function declaration should be a default export");
return [defaultModifier];
- case 168 /* MethodDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
return [functionDeclaration.name];
- case 170 /* Constructor */:
- var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 134 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword");
- if (functionDeclaration.parent.kind === 225 /* ClassExpression */) {
+ case 171 /* SyntaxKind.Constructor */:
+ var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 134 /* SyntaxKind.ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword");
+ if (functionDeclaration.parent.kind === 226 /* SyntaxKind.ClassExpression */) {
var variableDeclaration = functionDeclaration.parent.parent;
return [variableDeclaration.name, ctrKeyword];
}
return [ctrKeyword];
- case 213 /* ArrowFunction */:
+ case 214 /* SyntaxKind.ArrowFunction */:
return [functionDeclaration.parent.name];
- case 212 /* FunctionExpression */:
+ case 213 /* SyntaxKind.FunctionExpression */:
if (functionDeclaration.name)
return [functionDeclaration.name, functionDeclaration.parent.name];
return [functionDeclaration.parent.name];
@@ -160621,16 +163339,16 @@ var ts;
}
}
function isNotEqualsOperator(node) {
- return node.operatorToken.kind !== 63 /* EqualsToken */;
+ return node.operatorToken.kind !== 63 /* SyntaxKind.EqualsToken */;
}
function getParentBinaryExpression(expr) {
var container = ts.findAncestor(expr.parent, function (n) {
switch (n.kind) {
- case 205 /* PropertyAccessExpression */:
- case 206 /* ElementAccessExpression */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 207 /* SyntaxKind.ElementAccessExpression */:
return false;
- case 222 /* TemplateExpression */:
- case 220 /* BinaryExpression */:
+ case 223 /* SyntaxKind.TemplateExpression */:
+ case 221 /* SyntaxKind.BinaryExpression */:
return !(ts.isBinaryExpression(n.parent) && isNotEqualsOperator(n.parent));
default:
return "quit";
@@ -160648,7 +163366,7 @@ var ts;
if (!(leftHasString || ts.isStringLiteral(current.right) || ts.isTemplateExpression(current.right))) {
return { nodes: [current], operators: [], hasString: false, validOperators: true };
}
- var currentOperatorValid = current.operatorToken.kind === 39 /* PlusToken */;
+ var currentOperatorValid = current.operatorToken.kind === 39 /* SyntaxKind.PlusToken */;
var validOperators = leftOperatorValid && currentOperatorValid;
nodes.push(current.right);
operators.push(current.operatorToken);
@@ -160661,7 +163379,7 @@ var ts;
// "foo" + /* comment */ "bar"
var copyTrailingOperatorComments = function (operators, file) { return function (index, targetNode) {
if (index < operators.length) {
- ts.copyTrailingComments(operators[index], targetNode, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false);
+ ts.copyTrailingComments(operators[index], targetNode, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false);
}
}; };
// to copy comments following the string
@@ -160670,7 +163388,7 @@ var ts;
return function (indexes, targetNode) {
while (indexes.length > 0) {
var index = indexes.shift();
- ts.copyTrailingComments(nodes[index], targetNode, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false);
+ ts.copyTrailingComments(nodes[index], targetNode, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false);
copyOperatorComments(index, targetNode);
}
};
@@ -160736,7 +163454,7 @@ var ts;
var isLastSpan = index === currentNode.templateSpans.length - 1;
var text = span.literal.text + (isLastSpan ? subsequentText : "");
var rawText = getRawTextOfTemplate(span.literal) + (isLastSpan ? rawSubsequentText : "");
- return ts.factory.createTemplateSpan(span.expression, isLast
+ return ts.factory.createTemplateSpan(span.expression, isLast && isLastSpan
? ts.factory.createTemplateTail(text, rawText)
: ts.factory.createTemplateMiddle(text, rawText));
});
@@ -160762,8 +163480,8 @@ var ts;
// "foo" + ( /* comment */ 5 + 5 ) /* comment */ + "bar"
function copyExpressionComments(node) {
var file = node.getSourceFile();
- ts.copyTrailingComments(node, node.expression, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false);
- ts.copyTrailingAsLeadingComments(node.expression, node.expression, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false);
+ ts.copyTrailingComments(node, node.expression, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false);
+ ts.copyTrailingAsLeadingComments(node.expression, node.expression, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false);
}
function getExpressionFromParenthesesOrExpression(node) {
if (ts.isParenthesizedExpression(node)) {
@@ -160958,7 +163676,7 @@ var ts;
var body = convertToBlock(func.body);
var variableDeclaration = variableInfo.variableDeclaration, variableDeclarationList = variableInfo.variableDeclarationList, statement = variableInfo.statement, name = variableInfo.name;
ts.suppressLeadingTrivia(statement);
- var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* Export */) | ts.getEffectiveModifierFlags(func);
+ var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* ModifierFlags.Export */) | ts.getEffectiveModifierFlags(func);
var modifiers = ts.factory.createModifiersFromModifierFlags(modifiersFlags);
var newNode = ts.factory.createFunctionDeclaration(func.decorators, ts.length(modifiers) ? modifiers : undefined, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body);
if (variableDeclarationList.declarations.length === 1) {
@@ -160984,7 +163702,7 @@ var ts;
else {
body = func.body;
}
- var newNode = ts.factory.createArrowFunction(func.modifiers, func.typeParameters, func.parameters, func.type, ts.factory.createToken(38 /* EqualsGreaterThanToken */), body);
+ var newNode = ts.factory.createArrowFunction(func.modifiers, func.typeParameters, func.parameters, func.type, ts.factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), body);
return ts.textChanges.ChangeTracker.with(context, function (t) { return t.replaceNode(file, func, newNode); });
}
function canBeConvertedToExpression(body, head) {
@@ -161044,13 +163762,13 @@ var ts;
return ts.emptyArray;
}
function doChange(sourceFile, changes, declaration, typeNode) {
- var closeParen = ts.findChildOfKind(declaration, 21 /* CloseParenToken */, sourceFile);
+ var closeParen = ts.findChildOfKind(declaration, 21 /* SyntaxKind.CloseParenToken */, sourceFile);
var needParens = ts.isArrowFunction(declaration) && closeParen === undefined;
var endNode = needParens ? ts.first(declaration.parameters) : closeParen;
if (endNode) {
if (needParens) {
- changes.insertNodeBefore(sourceFile, endNode, ts.factory.createToken(20 /* OpenParenToken */));
- changes.insertNodeAfter(sourceFile, endNode, ts.factory.createToken(21 /* CloseParenToken */));
+ changes.insertNodeBefore(sourceFile, endNode, ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */));
+ changes.insertNodeAfter(sourceFile, endNode, ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */));
}
changes.insertNodeAt(sourceFile, endNode.end, typeNode, { prefix: ": " });
}
@@ -161060,7 +163778,7 @@ var ts;
return;
var token = ts.getTokenAtPosition(context.file, context.startPosition);
var declaration = ts.findAncestor(token, function (n) {
- return ts.isBlock(n) || n.parent && ts.isArrowFunction(n.parent) && (n.kind === 38 /* EqualsGreaterThanToken */ || n.parent.body === n) ? "quit" :
+ return ts.isBlock(n) || n.parent && ts.isArrowFunction(n.parent) && (n.kind === 38 /* SyntaxKind.EqualsGreaterThanToken */ || n.parent.body === n) ? "quit" :
isConvertibleDeclaration(n);
});
if (!declaration || !declaration.body || declaration.type) {
@@ -161071,17 +163789,17 @@ var ts;
if (!returnType) {
return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_determine_function_return_type) };
}
- var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NoTruncation */);
+ var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NodeBuilderFlags.NoTruncation */);
if (returnTypeNode) {
return { declaration: declaration, returnTypeNode: returnTypeNode };
}
}
function isConvertibleDeclaration(node) {
switch (node.kind) {
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
- case 168 /* MethodDeclaration */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
return true;
default:
return false;
@@ -161108,20 +163826,20 @@ var ts;
ts.servicesVersion = "0.8";
function createNode(kind, pos, end, parent) {
var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) :
- kind === 79 /* Identifier */ ? new IdentifierObject(79 /* Identifier */, pos, end) :
- kind === 80 /* PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* PrivateIdentifier */, pos, end) :
+ kind === 79 /* SyntaxKind.Identifier */ ? new IdentifierObject(79 /* SyntaxKind.Identifier */, pos, end) :
+ kind === 80 /* SyntaxKind.PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* SyntaxKind.PrivateIdentifier */, pos, end) :
new TokenObject(kind, pos, end);
node.parent = parent;
- node.flags = parent.flags & 25358336 /* ContextFlags */;
+ node.flags = parent.flags & 50720768 /* NodeFlags.ContextFlags */;
return node;
}
var NodeObject = /** @class */ (function () {
function NodeObject(kind, pos, end) {
this.pos = pos;
this.end = end;
- this.flags = 0 /* None */;
- this.modifierFlagsCache = 0 /* None */;
- this.transformFlags = 0 /* None */;
+ this.flags = 0 /* NodeFlags.None */;
+ this.modifierFlagsCache = 0 /* ModifierFlags.None */;
+ this.transformFlags = 0 /* TransformFlags.None */;
this.parent = undefined;
this.kind = kind;
}
@@ -161183,8 +163901,8 @@ var ts;
if (!children.length) {
return undefined;
}
- var child = ts.find(children, function (kid) { return kid.kind < 307 /* FirstJSDocNode */ || kid.kind > 345 /* LastJSDocNode */; });
- return child.kind < 160 /* FirstNode */ ?
+ var child = ts.find(children, function (kid) { return kid.kind < 309 /* SyntaxKind.FirstJSDocNode */ || kid.kind > 347 /* SyntaxKind.LastJSDocNode */; });
+ return child.kind < 161 /* SyntaxKind.FirstNode */ ?
child :
child.getFirstToken(sourceFile);
};
@@ -161195,7 +163913,7 @@ var ts;
if (!child) {
return undefined;
}
- return child.kind < 160 /* FirstNode */ ? child : child.getLastToken(sourceFile);
+ return child.kind < 161 /* SyntaxKind.FirstNode */ ? child : child.getLastToken(sourceFile);
};
NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) {
return ts.forEachChild(this, cbNode, cbNodeArray);
@@ -161243,19 +163961,19 @@ var ts;
var token = ts.scanner.scan();
var textPos = ts.scanner.getTextPos();
if (textPos <= end) {
- if (token === 79 /* Identifier */) {
+ if (token === 79 /* SyntaxKind.Identifier */) {
ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia"));
}
nodes.push(createNode(token, pos, textPos, parent));
}
pos = textPos;
- if (token === 1 /* EndOfFileToken */) {
+ if (token === 1 /* SyntaxKind.EndOfFileToken */) {
break;
}
}
}
function createSyntaxList(nodes, parent) {
- var list = createNode(346 /* SyntaxList */, nodes.pos, nodes.end, parent);
+ var list = createNode(348 /* SyntaxKind.SyntaxList */, nodes.pos, nodes.end, parent);
list._children = [];
var pos = nodes.pos;
for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
@@ -161272,9 +163990,9 @@ var ts;
// Set properties in same order as NodeObject
this.pos = pos;
this.end = end;
- this.flags = 0 /* None */;
- this.modifierFlagsCache = 0 /* None */;
- this.transformFlags = 0 /* None */;
+ this.flags = 0 /* NodeFlags.None */;
+ this.modifierFlagsCache = 0 /* ModifierFlags.None */;
+ this.transformFlags = 0 /* TransformFlags.None */;
this.parent = undefined;
}
TokenOrIdentifierObject.prototype.getSourceFile = function () {
@@ -161314,7 +164032,7 @@ var ts;
return this.getChildren()[index];
};
TokenOrIdentifierObject.prototype.getChildren = function () {
- return this.kind === 1 /* EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray;
+ return this.kind === 1 /* SyntaxKind.EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray;
};
TokenOrIdentifierObject.prototype.getFirstToken = function () {
return undefined;
@@ -161366,12 +164084,12 @@ var ts;
};
SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) {
switch (context === null || context === void 0 ? void 0 : context.kind) {
- case 171 /* GetAccessor */:
+ case 172 /* SyntaxKind.GetAccessor */:
if (!this.contextualGetAccessorDocumentationComment) {
this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker);
}
return this.contextualGetAccessorDocumentationComment;
- case 172 /* SetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
if (!this.contextualSetAccessorDocumentationComment) {
this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker);
}
@@ -161388,12 +164106,12 @@ var ts;
};
SymbolObject.prototype.getContextualJsDocTags = function (context, checker) {
switch (context === null || context === void 0 ? void 0 : context.kind) {
- case 171 /* GetAccessor */:
+ case 172 /* SyntaxKind.GetAccessor */:
if (!this.contextualGetAccessorTags) {
this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isGetAccessor), checker);
}
return this.contextualGetAccessorTags;
- case 172 /* SetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
if (!this.contextualSetAccessorTags) {
this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isSetAccessor), checker);
}
@@ -161417,7 +164135,7 @@ var ts;
__extends(IdentifierObject, _super);
function IdentifierObject(_kind, pos, end) {
var _this = _super.call(this, pos, end) || this;
- _this.kind = 79 /* Identifier */;
+ _this.kind = 79 /* SyntaxKind.Identifier */;
return _this;
}
Object.defineProperty(IdentifierObject.prototype, "text", {
@@ -161429,7 +164147,7 @@ var ts;
});
return IdentifierObject;
}(TokenOrIdentifierObject));
- IdentifierObject.prototype.kind = 79 /* Identifier */;
+ IdentifierObject.prototype.kind = 79 /* SyntaxKind.Identifier */;
var PrivateIdentifierObject = /** @class */ (function (_super) {
__extends(PrivateIdentifierObject, _super);
function PrivateIdentifierObject(_kind, pos, end) {
@@ -161444,7 +164162,7 @@ var ts;
});
return PrivateIdentifierObject;
}(TokenOrIdentifierObject));
- PrivateIdentifierObject.prototype.kind = 80 /* PrivateIdentifier */;
+ PrivateIdentifierObject.prototype.kind = 80 /* SyntaxKind.PrivateIdentifier */;
var TypeObject = /** @class */ (function () {
function TypeObject(checker, flags) {
this.checker = checker;
@@ -161466,16 +164184,16 @@ var ts;
return this.checker.getAugmentedPropertiesOfType(this);
};
TypeObject.prototype.getCallSignatures = function () {
- return this.checker.getSignaturesOfType(this, 0 /* Call */);
+ return this.checker.getSignaturesOfType(this, 0 /* SignatureKind.Call */);
};
TypeObject.prototype.getConstructSignatures = function () {
- return this.checker.getSignaturesOfType(this, 1 /* Construct */);
+ return this.checker.getSignaturesOfType(this, 1 /* SignatureKind.Construct */);
};
TypeObject.prototype.getStringIndexType = function () {
- return this.checker.getIndexTypeOfType(this, 0 /* String */);
+ return this.checker.getIndexTypeOfType(this, 0 /* IndexKind.String */);
};
TypeObject.prototype.getNumberIndexType = function () {
- return this.checker.getIndexTypeOfType(this, 1 /* Number */);
+ return this.checker.getIndexTypeOfType(this, 1 /* IndexKind.Number */);
};
TypeObject.prototype.getBaseTypes = function () {
return this.isClassOrInterface() ? this.checker.getBaseTypes(this) : undefined;
@@ -161496,41 +164214,41 @@ var ts;
return this.checker.getDefaultFromTypeParameter(this);
};
TypeObject.prototype.isUnion = function () {
- return !!(this.flags & 1048576 /* Union */);
+ return !!(this.flags & 1048576 /* TypeFlags.Union */);
};
TypeObject.prototype.isIntersection = function () {
- return !!(this.flags & 2097152 /* Intersection */);
+ return !!(this.flags & 2097152 /* TypeFlags.Intersection */);
};
TypeObject.prototype.isUnionOrIntersection = function () {
- return !!(this.flags & 3145728 /* UnionOrIntersection */);
+ return !!(this.flags & 3145728 /* TypeFlags.UnionOrIntersection */);
};
TypeObject.prototype.isLiteral = function () {
- return !!(this.flags & 384 /* StringOrNumberLiteral */);
+ return !!(this.flags & 384 /* TypeFlags.StringOrNumberLiteral */);
};
TypeObject.prototype.isStringLiteral = function () {
- return !!(this.flags & 128 /* StringLiteral */);
+ return !!(this.flags & 128 /* TypeFlags.StringLiteral */);
};
TypeObject.prototype.isNumberLiteral = function () {
- return !!(this.flags & 256 /* NumberLiteral */);
+ return !!(this.flags & 256 /* TypeFlags.NumberLiteral */);
};
TypeObject.prototype.isTypeParameter = function () {
- return !!(this.flags & 262144 /* TypeParameter */);
+ return !!(this.flags & 262144 /* TypeFlags.TypeParameter */);
};
TypeObject.prototype.isClassOrInterface = function () {
- return !!(ts.getObjectFlags(this) & 3 /* ClassOrInterface */);
+ return !!(ts.getObjectFlags(this) & 3 /* ObjectFlags.ClassOrInterface */);
};
TypeObject.prototype.isClass = function () {
- return !!(ts.getObjectFlags(this) & 1 /* Class */);
+ return !!(ts.getObjectFlags(this) & 1 /* ObjectFlags.Class */);
};
TypeObject.prototype.isIndexType = function () {
- return !!(this.flags & 4194304 /* Index */);
+ return !!(this.flags & 4194304 /* TypeFlags.Index */);
};
Object.defineProperty(TypeObject.prototype, "typeArguments", {
/**
* This polyfills `referenceType.typeArguments` for API consumers
*/
get: function () {
- if (ts.getObjectFlags(this) & 4 /* Reference */) {
+ if (ts.getObjectFlags(this) & 4 /* ObjectFlags.Reference */) {
return this.checker.getTypeArguments(this);
}
return undefined;
@@ -161594,7 +164312,7 @@ var ts;
var _a;
if (!seenSymbols_1.has(symbol)) {
seenSymbols_1.add(symbol);
- if (declaration.kind === 171 /* GetAccessor */ || declaration.kind === 172 /* SetAccessor */) {
+ if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) {
return symbol.getContextualJsDocTags(declaration, checker);
}
return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined;
@@ -161621,7 +164339,7 @@ var ts;
var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) {
if (!seenSymbols_2.has(symbol)) {
seenSymbols_2.add(symbol);
- if (declaration.kind === 171 /* GetAccessor */ || declaration.kind === 172 /* SetAccessor */) {
+ if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) {
return symbol.getContextualDocumentationComment(declaration, checker);
}
return symbol.getDocumentationComment(checker);
@@ -161642,7 +164360,7 @@ var ts;
var _a;
if (ts.hasStaticModifier(declaration))
return;
- var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 170 /* Constructor */ ? declaration.parent.parent : declaration.parent;
+ var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* SyntaxKind.Constructor */ ? declaration.parent.parent : declaration.parent;
if (!classOrInterfaceDeclaration)
return;
return ts.firstDefined(ts.getAllSuperTypeNodes(classOrInterfaceDeclaration), function (superTypeNode) {
@@ -161654,7 +164372,7 @@ var ts;
__extends(SourceFileObject, _super);
function SourceFileObject(kind, pos, end) {
var _this = _super.call(this, kind, pos, end) || this;
- _this.kind = 303 /* SourceFile */;
+ _this.kind = 305 /* SyntaxKind.SourceFile */;
return _this;
}
SourceFileObject.prototype.update = function (newText, textChangeRange) {
@@ -161713,10 +164431,10 @@ var ts;
}
function visit(node) {
switch (node.kind) {
- case 255 /* FunctionDeclaration */:
- case 212 /* FunctionExpression */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
var functionDeclaration = node;
var declarationName = getDeclarationName(functionDeclaration);
if (declarationName) {
@@ -161736,31 +164454,31 @@ var ts;
}
ts.forEachChild(node, visit);
break;
- case 256 /* ClassDeclaration */:
- case 225 /* ClassExpression */:
- case 257 /* InterfaceDeclaration */:
- case 258 /* TypeAliasDeclaration */:
- case 259 /* EnumDeclaration */:
- case 260 /* ModuleDeclaration */:
- case 264 /* ImportEqualsDeclaration */:
- case 274 /* ExportSpecifier */:
- case 269 /* ImportSpecifier */:
- case 266 /* ImportClause */:
- case 267 /* NamespaceImport */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 181 /* TypeLiteral */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 226 /* SyntaxKind.ClassExpression */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
+ case 275 /* SyntaxKind.ExportSpecifier */:
+ case 270 /* SyntaxKind.ImportSpecifier */:
+ case 267 /* SyntaxKind.ImportClause */:
+ case 268 /* SyntaxKind.NamespaceImport */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 182 /* SyntaxKind.TypeLiteral */:
addDeclaration(node);
ts.forEachChild(node, visit);
break;
- case 163 /* Parameter */:
+ case 164 /* SyntaxKind.Parameter */:
// Only consider parameter properties
- if (!ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) {
+ if (!ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */)) {
break;
}
// falls through
- case 253 /* VariableDeclaration */:
- case 202 /* BindingElement */: {
+ case 254 /* SyntaxKind.VariableDeclaration */:
+ case 203 /* SyntaxKind.BindingElement */: {
var decl = node;
if (ts.isBindingPattern(decl.name)) {
ts.forEachChild(decl.name, visit);
@@ -161771,12 +164489,12 @@ var ts;
}
}
// falls through
- case 297 /* EnumMember */:
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
+ case 299 /* SyntaxKind.EnumMember */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
addDeclaration(node);
break;
- case 271 /* ExportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
// Handle named exports case e.g.:
// export {a, b as B} from "mod";
var exportDeclaration = node;
@@ -161789,7 +164507,7 @@ var ts;
}
}
break;
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
var importClause = node.importClause;
if (importClause) {
// Handle default import case e.g.:
@@ -161801,7 +164519,7 @@ var ts;
// import * as NS from "mod";
// import {a, b as B} from "mod";
if (importClause.namedBindings) {
- if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
+ if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) {
addDeclaration(importClause.namedBindings);
}
else {
@@ -161810,8 +164528,8 @@ var ts;
}
}
break;
- case 220 /* BinaryExpression */:
- if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) {
+ case 221 /* SyntaxKind.BinaryExpression */:
+ if (ts.getAssignmentDeclarationKind(node) !== 0 /* AssignmentDeclarationKind.None */) {
addDeclaration(node);
}
// falls through
@@ -161880,8 +164598,8 @@ var ts;
function getDefaultCompilerOptions() {
// Always default to "ScriptTarget.ES5" for the language service
return {
- target: 1 /* ES5 */,
- jsx: 1 /* Preserve */
+ target: 1 /* ScriptTarget.ES5 */,
+ jsx: 1 /* JsxEmit.Preserve */
};
}
ts.getDefaultCompilerOptions = getDefaultCompilerOptions;
@@ -161900,10 +164618,12 @@ var ts;
this.fileNameToEntry = new ts.Map();
// Initialize the list with the root file names
var rootFileNames = host.getScriptFileNames();
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "initializeHostCache", { count: rootFileNames.length });
for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) {
var fileName = rootFileNames_1[_i];
this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName));
}
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
}
HostCache.prototype.createEntry = function (fileName, path) {
var entry;
@@ -161956,6 +164676,7 @@ var ts;
this.host = host;
}
SyntaxTreeCache.prototype.getCurrentSourceFile = function (fileName) {
+ var _a, _b, _c, _d, _e, _f, _g, _h;
var scriptSnapshot = this.host.getScriptSnapshot(fileName);
if (!scriptSnapshot) {
// The host does not know about this file.
@@ -161966,7 +164687,12 @@ var ts;
var sourceFile;
if (this.currentFileName !== fileName) {
// This is a new file, just parse it
- sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 99 /* Latest */, version, /*setNodeParents*/ true, scriptKind);
+ var options = {
+ languageVersion: 99 /* ScriptTarget.Latest */,
+ impliedNodeFormat: ts.getImpliedNodeFormatForFile(ts.toPath(fileName, this.host.getCurrentDirectory(), ((_c = (_b = (_a = this.host).getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(_a)) === null || _c === void 0 ? void 0 : _c.getCanonicalFileName) || ts.hostGetCanonicalFileName(this.host)), (_h = (_g = (_f = (_e = (_d = this.host).getCompilerHost) === null || _e === void 0 ? void 0 : _e.call(_d)) === null || _f === void 0 ? void 0 : _f.getModuleResolutionCache) === null || _g === void 0 ? void 0 : _g.call(_f)) === null || _h === void 0 ? void 0 : _h.getPackageJsonInfoCache(), this.host, this.host.getCompilationSettings()),
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(this.host.getCompilationSettings())
+ };
+ sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, options, version, /*setNodeParents*/ true, scriptKind);
}
else if (this.currentFileVersion !== version) {
// This is the same file, just a newer version. Incrementally parse the file.
@@ -161988,8 +164714,8 @@ var ts;
sourceFile.version = version;
sourceFile.scriptSnapshot = scriptSnapshot;
}
- function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents, scriptKind) {
- var sourceFile = ts.createSourceFile(fileName, ts.getSnapshotText(scriptSnapshot), scriptTarget, setNodeParents, scriptKind);
+ function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTargetOrOptions, version, setNodeParents, scriptKind) {
+ var sourceFile = ts.createSourceFile(fileName, ts.getSnapshotText(scriptSnapshot), scriptTargetOrOptions, setNodeParents, scriptKind);
setSourceFileFields(sourceFile, scriptSnapshot, version);
return sourceFile;
}
@@ -162037,8 +164763,13 @@ var ts;
return newSourceFile;
}
}
+ var options = {
+ languageVersion: sourceFile.languageVersion,
+ impliedNodeFormat: sourceFile.impliedNodeFormat,
+ setExternalModuleIndicator: sourceFile.setExternalModuleIndicator,
+ };
// Otherwise, just create a new source file.
- return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents*/ true, sourceFile.scriptKind);
+ return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, options, version, /*setNodeParents*/ true, sourceFile.scriptKind);
}
ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile;
var NoopCancellationToken = {
@@ -162054,7 +164785,7 @@ var ts;
};
CancellationTokenObject.prototype.throwIfCancellationRequested = function () {
if (this.isCancellationRequested()) {
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "CancellationTokenObject" });
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "cancellationThrown", { kind: "CancellationTokenObject" });
throw new ts.OperationCanceledException();
}
};
@@ -162084,7 +164815,7 @@ var ts;
};
ThrottledCancellationToken.prototype.throwIfCancellationRequested = function () {
if (this.isCancellationRequested()) {
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" });
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" });
throw new ts.OperationCanceledException();
}
};
@@ -162294,7 +165025,7 @@ var ts;
return result;
}
function getParsedCommandLineOfConfigFileUsingSourceFile(configFileName) {
- var result = getOrCreateSourceFile(configFileName, 100 /* JSON */);
+ var result = getOrCreateSourceFile(configFileName, 100 /* ScriptTarget.JSON */);
if (!result)
return undefined;
result.path = ts.toPath(configFileName, currentDirectory, getCanonicalFileName);
@@ -162382,7 +165113,7 @@ var ts;
// file's script kind, i.e. in one project some file is treated as ".ts"
// and in another as ".js"
if (hostFileInformation.scriptKind === oldSourceFile.scriptKind) {
- return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
+ return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
}
else {
// Release old source file and fall through to aquire new file with new script kind
@@ -162392,7 +165123,7 @@ var ts;
// We didn't already have the file. Fall through and acquire it from the registry.
}
// Could not find this file in the old program, create a new SourceFile for it.
- return documentRegistry.acquireDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
+ return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
}
}
// TODO: GH#18217 frequently asserted as defined
@@ -162484,8 +165215,8 @@ var ts;
if (!symbol || typeChecker.isUnknownSymbol(symbol)) {
var type_2 = shouldGetType(sourceFile, nodeForQuickInfo, position) ? typeChecker.getTypeAtLocation(nodeForQuickInfo) : undefined;
return type_2 && {
- kind: "" /* unknown */,
- kindModifiers: "" /* none */,
+ kind: "" /* ScriptElementKind.unknown */,
+ kindModifiers: "" /* ScriptElementKindModifier.none */,
textSpan: ts.createTextSpanFromNode(nodeForQuickInfo, sourceFile),
displayParts: typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return ts.typeToDisplayParts(typeChecker, type_2, ts.getContainerNode(nodeForQuickInfo)); }),
documentation: type_2.symbol ? type_2.symbol.getDocumentationComment(typeChecker) : undefined,
@@ -162511,29 +165242,34 @@ var ts;
if (ts.isNamedTupleMember(node.parent) && node.pos === node.parent.pos) {
return node.parent;
}
+ if (ts.isImportMeta(node.parent) && node.parent.name === node) {
+ return node.parent;
+ }
return node;
}
function shouldGetType(sourceFile, node, position) {
switch (node.kind) {
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return !ts.isLabelName(node) && !ts.isTagName(node) && !ts.isConstTypeReference(node.parent);
- case 205 /* PropertyAccessExpression */:
- case 160 /* QualifiedName */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 161 /* SyntaxKind.QualifiedName */:
// Don't return quickInfo if inside the comment in `a/**/.b`
return !ts.isInComment(sourceFile, position);
- case 108 /* ThisKeyword */:
- case 191 /* ThisType */:
- case 106 /* SuperKeyword */:
- case 196 /* NamedTupleMember */:
+ case 108 /* SyntaxKind.ThisKeyword */:
+ case 192 /* SyntaxKind.ThisType */:
+ case 106 /* SyntaxKind.SuperKeyword */:
+ case 197 /* SyntaxKind.NamedTupleMember */:
return true;
+ case 231 /* SyntaxKind.MetaProperty */:
+ return ts.isImportMeta(node);
default:
return false;
}
}
/// Goto definition
- function getDefinitionAtPosition(fileName, position) {
+ function getDefinitionAtPosition(fileName, position, searchOtherFilesOnly, stopAtAlias) {
synchronizeHostData();
- return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position);
+ return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position, searchOtherFilesOnly, stopAtAlias);
}
function getDefinitionAndBoundSpan(fileName, position) {
synchronizeHostData();
@@ -162550,7 +165286,7 @@ var ts;
}
/// References and Occurrences
function getOccurrencesAtPosition(fileName, position) {
- return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */, isDefinition: false }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); });
+ return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* HighlightSpanKind.writtenReference */ }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); });
}
function getDocumentHighlights(fileName, position, filesToSearch) {
var normalizedFileName = ts.normalizePath(fileName);
@@ -162574,17 +165310,17 @@ var ts;
});
}
else {
- return getReferencesWorker(node, position, { findInStrings: findInStrings, findInComments: findInComments, providePrefixAndSuffixTextForRename: providePrefixAndSuffixTextForRename, use: 2 /* Rename */ }, function (entry, originalNode, checker) { return ts.FindAllReferences.toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixTextForRename || false); });
+ return getReferencesWorker(node, position, { findInStrings: findInStrings, findInComments: findInComments, providePrefixAndSuffixTextForRename: providePrefixAndSuffixTextForRename, use: 2 /* FindAllReferences.FindReferencesUse.Rename */ }, function (entry, originalNode, checker) { return ts.FindAllReferences.toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixTextForRename || false); });
}
}
function getReferencesAtPosition(fileName, position) {
synchronizeHostData();
- return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ }, function (entry, node, checker) { return ts.FindAllReferences.toReferenceEntry(entry, checker.getSymbolAtLocation(node)); });
+ return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }, ts.FindAllReferences.toReferenceEntry);
}
function getReferencesWorker(node, position, options, cb) {
synchronizeHostData();
// Exclude default library when renaming as commonly user don't want to change that file.
- var sourceFiles = options && options.use === 2 /* Rename */
+ var sourceFiles = options && options.use === 2 /* FindAllReferences.FindReferencesUse.Rename */
? program.getSourceFiles().filter(function (sourceFile) { return !program.isSourceFileDefaultLibrary(sourceFile); })
: program.getSourceFiles();
return ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, sourceFiles, node, position, options, cb);
@@ -162594,10 +165330,8 @@ var ts;
return ts.FindAllReferences.findReferencedSymbols(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position);
}
function getFileReferences(fileName) {
- var _a;
synchronizeHostData();
- var moduleSymbol = (_a = program.getSourceFile(fileName)) === null || _a === void 0 ? void 0 : _a.symbol;
- return ts.FindAllReferences.Core.getReferencesForFileName(fileName, program, program.getSourceFiles()).map(function (r) { return ts.FindAllReferences.toReferenceEntry(r, moduleSymbol); });
+ return ts.FindAllReferences.Core.getReferencesForFileName(fileName, program, program.getSourceFiles()).map(ts.FindAllReferences.toReferenceEntry);
}
function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) {
if (excludeDtsFiles === void 0) { excludeDtsFiles = false; }
@@ -162633,16 +165367,16 @@ var ts;
return undefined;
}
switch (node.kind) {
- case 205 /* PropertyAccessExpression */:
- case 160 /* QualifiedName */:
- case 10 /* StringLiteral */:
- case 95 /* FalseKeyword */:
- case 110 /* TrueKeyword */:
- case 104 /* NullKeyword */:
- case 106 /* SuperKeyword */:
- case 108 /* ThisKeyword */:
- case 191 /* ThisType */:
- case 79 /* Identifier */:
+ case 206 /* SyntaxKind.PropertyAccessExpression */:
+ case 161 /* SyntaxKind.QualifiedName */:
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 95 /* SyntaxKind.FalseKeyword */:
+ case 110 /* SyntaxKind.TrueKeyword */:
+ case 104 /* SyntaxKind.NullKeyword */:
+ case 106 /* SyntaxKind.SuperKeyword */:
+ case 108 /* SyntaxKind.ThisKeyword */:
+ case 192 /* SyntaxKind.ThisType */:
+ case 79 /* SyntaxKind.Identifier */:
break;
// Cant create the text span
default:
@@ -162658,7 +165392,7 @@ var ts;
// If this is name of a module declarations, check if this is right side of dotted module name
// If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of
// Then this name is name from dotted module
- if (nodeForStartPos.parent.parent.kind === 260 /* ModuleDeclaration */ &&
+ if (nodeForStartPos.parent.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */ &&
nodeForStartPos.parent.parent.body === nodeForStartPos.parent) {
// Use parent module declarations name for start pos
nodeForStartPos = nodeForStartPos.parent.parent.name;
@@ -162688,8 +165422,8 @@ var ts;
}
function getSemanticClassifications(fileName, span, format) {
synchronizeHostData();
- var responseFormat = format || "original" /* Original */;
- if (responseFormat === "2020" /* TwentyTwenty */) {
+ var responseFormat = format || "original" /* SemanticClassificationFormat.Original */;
+ if (responseFormat === "2020" /* SemanticClassificationFormat.TwentyTwenty */) {
return ts.classifier.v2020.getSemanticClassifications(program, cancellationToken, getValidSourceFile(fileName), span);
}
else {
@@ -162698,8 +165432,8 @@ var ts;
}
function getEncodedSemanticClassifications(fileName, span, format) {
synchronizeHostData();
- var responseFormat = format || "original" /* Original */;
- if (responseFormat === "original" /* Original */) {
+ var responseFormat = format || "original" /* SemanticClassificationFormat.Original */;
+ if (responseFormat === "original" /* SemanticClassificationFormat.Original */) {
return ts.getEncodedSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span);
}
else {
@@ -162720,10 +165454,10 @@ var ts;
return ts.OutliningElementsCollector.collectElements(sourceFile, cancellationToken);
}
var braceMatching = new ts.Map(ts.getEntries((_a = {},
- _a[18 /* OpenBraceToken */] = 19 /* CloseBraceToken */,
- _a[20 /* OpenParenToken */] = 21 /* CloseParenToken */,
- _a[22 /* OpenBracketToken */] = 23 /* CloseBracketToken */,
- _a[31 /* GreaterThanToken */] = 29 /* LessThanToken */,
+ _a[18 /* SyntaxKind.OpenBraceToken */] = 19 /* SyntaxKind.CloseBraceToken */,
+ _a[20 /* SyntaxKind.OpenParenToken */] = 21 /* SyntaxKind.CloseParenToken */,
+ _a[22 /* SyntaxKind.OpenBracketToken */] = 23 /* SyntaxKind.CloseBracketToken */,
+ _a[31 /* SyntaxKind.GreaterThanToken */] = 29 /* SyntaxKind.LessThanToken */,
_a)));
braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); });
function getBraceMatchingAtPosition(fileName, position) {
@@ -162820,7 +165554,7 @@ var ts;
// var x = new foo<| ( with class foo<T>{} )
// or
// var y = 3 <|
- if (openingBrace === 60 /* lessThan */) {
+ if (openingBrace === 60 /* CharacterCodes.lessThan */) {
return false;
}
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
@@ -162829,15 +165563,15 @@ var ts;
return false;
}
if (ts.isInsideJsxElementOrAttribute(sourceFile, position)) {
- return openingBrace === 123 /* openBrace */;
+ return openingBrace === 123 /* CharacterCodes.openBrace */;
}
if (ts.isInTemplateString(sourceFile, position)) {
return false;
}
switch (openingBrace) {
- case 39 /* singleQuote */:
- case 34 /* doubleQuote */:
- case 96 /* backtick */:
+ case 39 /* CharacterCodes.singleQuote */:
+ case 34 /* CharacterCodes.doubleQuote */:
+ case 96 /* CharacterCodes.backtick */:
return !ts.isInComment(sourceFile, position);
}
return true;
@@ -162847,12 +165581,12 @@ var ts;
var token = ts.findPrecedingToken(position, sourceFile);
if (!token)
return undefined;
- var element = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent
+ var element = token.kind === 31 /* SyntaxKind.GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent
: ts.isJsxText(token) && ts.isJsxElement(token.parent) ? token.parent : undefined;
if (element && isUnclosedTag(element)) {
return { newText: "</".concat(element.openingElement.tagName.getText(sourceFile), ">") };
}
- var fragment = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningFragment(token.parent) ? token.parent.parent
+ var fragment = token.kind === 31 /* SyntaxKind.GreaterThanToken */ && ts.isJsxOpeningFragment(token.parent) ? token.parent.parent
: ts.isJsxText(token) && ts.isJsxFragment(token.parent) ? token.parent : undefined;
if (fragment && isUnclosedFragment(fragment)) {
return { newText: "</>" };
@@ -162949,7 +165683,7 @@ var ts;
commentRange.end++;
}
positions.push(commentRange.pos);
- if (commentRange.kind === 3 /* MultiLineCommentTrivia */) {
+ if (commentRange.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) {
positions.push(commentRange.end);
}
hasComment = true;
@@ -162966,7 +165700,7 @@ var ts;
// If it didn't found a comment and isCommenting is false means is only empty space.
// We want to insert comment in this scenario.
if (isCommenting || !hasComment) {
- if (((_a = ts.isInComment(sourceFile, textRange.pos)) === null || _a === void 0 ? void 0 : _a.kind) !== 2 /* SingleLineCommentTrivia */) {
+ if (((_a = ts.isInComment(sourceFile, textRange.pos)) === null || _a === void 0 ? void 0 : _a.kind) !== 2 /* SyntaxKind.SingleLineCommentTrivia */) {
ts.insertSorted(positions, textRange.pos, ts.compareValues);
}
ts.insertSorted(positions, textRange.end, ts.compareValues);
@@ -163052,10 +165786,10 @@ var ts;
var commentRange = ts.isInComment(sourceFile, i);
if (commentRange) {
switch (commentRange.kind) {
- case 2 /* SingleLineCommentTrivia */:
+ case 2 /* SyntaxKind.SingleLineCommentTrivia */:
textChanges.push.apply(textChanges, toggleLineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, /*insertComment*/ false));
break;
- case 3 /* MultiLineCommentTrivia */:
+ case 3 /* SyntaxKind.MultiLineCommentTrivia */:
textChanges.push.apply(textChanges, toggleMultilineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, /*insertComment*/ false));
}
i = commentRange.end + 1;
@@ -163070,12 +165804,12 @@ var ts;
}
function isUnclosedFragment(_a) {
var closingFragment = _a.closingFragment, parent = _a.parent;
- return !!(closingFragment.flags & 65536 /* ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent));
+ return !!(closingFragment.flags & 131072 /* NodeFlags.ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent));
}
function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) {
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position);
- return range && (!onlyMultiLine || range.kind === 3 /* MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined;
+ return range && (!onlyMultiLine || range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined;
}
function getTodoComments(fileName, descriptors) {
// Note: while getting todo comments seems like a syntactic operation, we actually
@@ -163193,9 +165927,9 @@ var ts;
return new RegExp(regExpString, "gim");
}
function isLetterOrDigit(char) {
- return (char >= 97 /* a */ && char <= 122 /* z */) ||
- (char >= 65 /* A */ && char <= 90 /* Z */) ||
- (char >= 48 /* _0 */ && char <= 57 /* _9 */);
+ return (char >= 97 /* CharacterCodes.a */ && char <= 122 /* CharacterCodes.z */) ||
+ (char >= 65 /* CharacterCodes.A */ && char <= 90 /* CharacterCodes.Z */) ||
+ (char >= 48 /* CharacterCodes._0 */ && char <= 57 /* CharacterCodes._9 */);
}
function isNodeModulesFile(path) {
return ts.stringContains(path, "/node_modules/");
@@ -163405,7 +166139,7 @@ var ts;
*/
function literalIsName(node) {
return ts.isDeclarationName(node) ||
- node.parent.kind === 276 /* ExternalModuleReference */ ||
+ node.parent.kind === 277 /* SyntaxKind.ExternalModuleReference */ ||
isArgumentOfElementAccessExpression(node) ||
ts.isLiteralComputedPropertyDeclarationName(node);
}
@@ -163420,16 +166154,16 @@ var ts;
ts.getContainingObjectLiteralElement = getContainingObjectLiteralElement;
function getContainingObjectLiteralElementWorker(node) {
switch (node.kind) {
- case 10 /* StringLiteral */:
- case 14 /* NoSubstitutionTemplateLiteral */:
- case 8 /* NumericLiteral */:
- if (node.parent.kind === 161 /* ComputedPropertyName */) {
+ case 10 /* SyntaxKind.StringLiteral */:
+ case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
+ case 8 /* SyntaxKind.NumericLiteral */:
+ if (node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) {
return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined;
}
// falls through
- case 79 /* Identifier */:
+ case 79 /* SyntaxKind.Identifier */:
return ts.isObjectLiteralElement(node.parent) &&
- (node.parent.parent.kind === 204 /* ObjectLiteralExpression */ || node.parent.parent.kind === 285 /* JsxAttributes */) &&
+ (node.parent.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || node.parent.parent.kind === 286 /* SyntaxKind.JsxAttributes */) &&
node.parent.name === node ? node.parent : undefined;
}
return undefined;
@@ -163471,7 +166205,7 @@ var ts;
function isArgumentOfElementAccessExpression(node) {
return node &&
node.parent &&
- node.parent.kind === 206 /* ElementAccessExpression */ &&
+ node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ &&
node.parent.argumentExpression === node;
}
/**
@@ -163518,7 +166252,7 @@ var ts;
tokenAtLocation = preceding;
}
// Cannot set breakpoint in ambient declarations
- if (tokenAtLocation.flags & 8388608 /* Ambient */) {
+ if (tokenAtLocation.flags & 16777216 /* NodeFlags.Ambient */) {
return undefined;
}
// Get the span in the node based on its syntax
@@ -163551,144 +166285,144 @@ var ts;
if (node) {
var parent = node.parent;
switch (node.kind) {
- case 236 /* VariableStatement */:
+ case 237 /* SyntaxKind.VariableStatement */:
// Span on first variable declaration
return spanInVariableDeclaration(node.declarationList.declarations[0]);
- case 253 /* VariableDeclaration */:
- case 166 /* PropertyDeclaration */:
- case 165 /* PropertySignature */:
+ case 254 /* SyntaxKind.VariableDeclaration */:
+ case 167 /* SyntaxKind.PropertyDeclaration */:
+ case 166 /* SyntaxKind.PropertySignature */:
return spanInVariableDeclaration(node);
- case 163 /* Parameter */:
+ case 164 /* SyntaxKind.Parameter */:
return spanInParameterDeclaration(node);
- case 255 /* FunctionDeclaration */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 170 /* Constructor */:
- case 212 /* FunctionExpression */:
- case 213 /* ArrowFunction */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 214 /* SyntaxKind.ArrowFunction */:
return spanInFunctionDeclaration(node);
- case 234 /* Block */:
+ case 235 /* SyntaxKind.Block */:
if (ts.isFunctionBlock(node)) {
return spanInFunctionBlock(node);
}
// falls through
- case 261 /* ModuleBlock */:
+ case 262 /* SyntaxKind.ModuleBlock */:
return spanInBlock(node);
- case 291 /* CatchClause */:
+ case 292 /* SyntaxKind.CatchClause */:
return spanInBlock(node.block);
- case 237 /* ExpressionStatement */:
+ case 238 /* SyntaxKind.ExpressionStatement */:
// span on the expression
return textSpan(node.expression);
- case 246 /* ReturnStatement */:
+ case 247 /* SyntaxKind.ReturnStatement */:
// span on return keyword and expression if present
return textSpan(node.getChildAt(0), node.expression);
- case 240 /* WhileStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
// Span on while(...)
return textSpanEndingAtNextToken(node, node.expression);
- case 239 /* DoStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
// span in statement of the do statement
return spanInNode(node.statement);
- case 252 /* DebuggerStatement */:
+ case 253 /* SyntaxKind.DebuggerStatement */:
// span on debugger keyword
return textSpan(node.getChildAt(0));
- case 238 /* IfStatement */:
+ case 239 /* SyntaxKind.IfStatement */:
// set on if(..) span
return textSpanEndingAtNextToken(node, node.expression);
- case 249 /* LabeledStatement */:
+ case 250 /* SyntaxKind.LabeledStatement */:
// span in statement
return spanInNode(node.statement);
- case 245 /* BreakStatement */:
- case 244 /* ContinueStatement */:
+ case 246 /* SyntaxKind.BreakStatement */:
+ case 245 /* SyntaxKind.ContinueStatement */:
// On break or continue keyword and label if present
return textSpan(node.getChildAt(0), node.label);
- case 241 /* ForStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
return spanInForStatement(node);
- case 242 /* ForInStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
// span of for (a in ...)
return textSpanEndingAtNextToken(node, node.expression);
- case 243 /* ForOfStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
// span in initializer
return spanInInitializerOfForLike(node);
- case 248 /* SwitchStatement */:
+ case 249 /* SyntaxKind.SwitchStatement */:
// span on switch(...)
return textSpanEndingAtNextToken(node, node.expression);
- case 288 /* CaseClause */:
- case 289 /* DefaultClause */:
+ case 289 /* SyntaxKind.CaseClause */:
+ case 290 /* SyntaxKind.DefaultClause */:
// span in first statement of the clause
return spanInNode(node.statements[0]);
- case 251 /* TryStatement */:
+ case 252 /* SyntaxKind.TryStatement */:
// span in try block
return spanInBlock(node.tryBlock);
- case 250 /* ThrowStatement */:
+ case 251 /* SyntaxKind.ThrowStatement */:
// span in throw ...
return textSpan(node, node.expression);
- case 270 /* ExportAssignment */:
+ case 271 /* SyntaxKind.ExportAssignment */:
// span on export = id
return textSpan(node, node.expression);
- case 264 /* ImportEqualsDeclaration */:
+ case 265 /* SyntaxKind.ImportEqualsDeclaration */:
// import statement without including semicolon
return textSpan(node, node.moduleReference);
- case 265 /* ImportDeclaration */:
+ case 266 /* SyntaxKind.ImportDeclaration */:
// import statement without including semicolon
return textSpan(node, node.moduleSpecifier);
- case 271 /* ExportDeclaration */:
+ case 272 /* SyntaxKind.ExportDeclaration */:
// import statement without including semicolon
return textSpan(node, node.moduleSpecifier);
- case 260 /* ModuleDeclaration */:
+ case 261 /* SyntaxKind.ModuleDeclaration */:
// span on complete module if it is instantiated
- if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) {
+ if (ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) {
return undefined;
}
// falls through
- case 256 /* ClassDeclaration */:
- case 259 /* EnumDeclaration */:
- case 297 /* EnumMember */:
- case 202 /* BindingElement */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 299 /* SyntaxKind.EnumMember */:
+ case 203 /* SyntaxKind.BindingElement */:
// span on complete node
return textSpan(node);
- case 247 /* WithStatement */:
+ case 248 /* SyntaxKind.WithStatement */:
// span in statement
return spanInNode(node.statement);
- case 164 /* Decorator */:
+ case 165 /* SyntaxKind.Decorator */:
return spanInNodeArray(parent.decorators);
- case 200 /* ObjectBindingPattern */:
- case 201 /* ArrayBindingPattern */:
+ case 201 /* SyntaxKind.ObjectBindingPattern */:
+ case 202 /* SyntaxKind.ArrayBindingPattern */:
return spanInBindingPattern(node);
// No breakpoint in interface, type alias
- case 257 /* InterfaceDeclaration */:
- case 258 /* TypeAliasDeclaration */:
+ case 258 /* SyntaxKind.InterfaceDeclaration */:
+ case 259 /* SyntaxKind.TypeAliasDeclaration */:
return undefined;
// Tokens:
- case 26 /* SemicolonToken */:
- case 1 /* EndOfFileToken */:
+ case 26 /* SyntaxKind.SemicolonToken */:
+ case 1 /* SyntaxKind.EndOfFileToken */:
return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile));
- case 27 /* CommaToken */:
+ case 27 /* SyntaxKind.CommaToken */:
return spanInPreviousNode(node);
- case 18 /* OpenBraceToken */:
+ case 18 /* SyntaxKind.OpenBraceToken */:
return spanInOpenBraceToken(node);
- case 19 /* CloseBraceToken */:
+ case 19 /* SyntaxKind.CloseBraceToken */:
return spanInCloseBraceToken(node);
- case 23 /* CloseBracketToken */:
+ case 23 /* SyntaxKind.CloseBracketToken */:
return spanInCloseBracketToken(node);
- case 20 /* OpenParenToken */:
+ case 20 /* SyntaxKind.OpenParenToken */:
return spanInOpenParenToken(node);
- case 21 /* CloseParenToken */:
+ case 21 /* SyntaxKind.CloseParenToken */:
return spanInCloseParenToken(node);
- case 58 /* ColonToken */:
+ case 58 /* SyntaxKind.ColonToken */:
return spanInColonToken(node);
- case 31 /* GreaterThanToken */:
- case 29 /* LessThanToken */:
+ case 31 /* SyntaxKind.GreaterThanToken */:
+ case 29 /* SyntaxKind.LessThanToken */:
return spanInGreaterThanOrLessThanToken(node);
// Keywords:
- case 115 /* WhileKeyword */:
+ case 115 /* SyntaxKind.WhileKeyword */:
return spanInWhileKeyword(node);
- case 91 /* ElseKeyword */:
- case 83 /* CatchKeyword */:
- case 96 /* FinallyKeyword */:
+ case 91 /* SyntaxKind.ElseKeyword */:
+ case 83 /* SyntaxKind.CatchKeyword */:
+ case 96 /* SyntaxKind.FinallyKeyword */:
return spanInNextNode(node);
- case 159 /* OfKeyword */:
+ case 160 /* SyntaxKind.OfKeyword */:
return spanInOfKeyword(node);
default:
// Destructuring pattern in destructuring assignment
@@ -163700,14 +166434,14 @@ var ts;
// Set breakpoint on identifier element of destructuring pattern
// `a` or `...c` or `d: x` from
// `[a, b, ...c]` or `{ a, b }` or `{ d: x }` from destructuring pattern
- if ((node.kind === 79 /* Identifier */ ||
- node.kind === 224 /* SpreadElement */ ||
- node.kind === 294 /* PropertyAssignment */ ||
- node.kind === 295 /* ShorthandPropertyAssignment */) &&
+ if ((node.kind === 79 /* SyntaxKind.Identifier */ ||
+ node.kind === 225 /* SyntaxKind.SpreadElement */ ||
+ node.kind === 296 /* SyntaxKind.PropertyAssignment */ ||
+ node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) &&
ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) {
return textSpan(node);
}
- if (node.kind === 220 /* BinaryExpression */) {
+ if (node.kind === 221 /* SyntaxKind.BinaryExpression */) {
var _a = node, left = _a.left, operatorToken = _a.operatorToken;
// Set breakpoint in destructuring pattern if its destructuring assignment
// [a, b, c] or {a, b, c} of
@@ -163716,35 +166450,35 @@ var ts;
if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) {
return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left);
}
- if (operatorToken.kind === 63 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) {
+ if (operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) {
// Set breakpoint on assignment expression element of destructuring pattern
// a = expression of
// [a = expression, b, c] = someExpression or
// { a = expression, b, c } = someExpression
return textSpan(node);
}
- if (operatorToken.kind === 27 /* CommaToken */) {
+ if (operatorToken.kind === 27 /* SyntaxKind.CommaToken */) {
return spanInNode(left);
}
}
if (ts.isExpressionNode(node)) {
switch (parent.kind) {
- case 239 /* DoStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
// Set span as if on while keyword
return spanInPreviousNode(node);
- case 164 /* Decorator */:
+ case 165 /* SyntaxKind.Decorator */:
// Set breakpoint on the decorator emit
return spanInNode(node.parent);
- case 241 /* ForStatement */:
- case 243 /* ForOfStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
return textSpan(node);
- case 220 /* BinaryExpression */:
- if (node.parent.operatorToken.kind === 27 /* CommaToken */) {
+ case 221 /* SyntaxKind.BinaryExpression */:
+ if (node.parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) {
// If this is a comma expression, the breakpoint is possible in this expression
return textSpan(node);
}
break;
- case 213 /* ArrowFunction */:
+ case 214 /* SyntaxKind.ArrowFunction */:
if (node.parent.body === node) {
// If this is body of arrow function, it is allowed to have the breakpoint
return textSpan(node);
@@ -163753,21 +166487,21 @@ var ts;
}
}
switch (node.parent.kind) {
- case 294 /* PropertyAssignment */:
+ case 296 /* SyntaxKind.PropertyAssignment */:
// If this is name of property assignment, set breakpoint in the initializer
if (node.parent.name === node &&
!ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) {
return spanInNode(node.parent.initializer);
}
break;
- case 210 /* TypeAssertionExpression */:
+ case 211 /* SyntaxKind.TypeAssertionExpression */:
// Breakpoint in type assertion goes to its operand
if (node.parent.type === node) {
return spanInNextNode(node.parent.type);
}
break;
- case 253 /* VariableDeclaration */:
- case 163 /* Parameter */: {
+ case 254 /* SyntaxKind.VariableDeclaration */:
+ case 164 /* SyntaxKind.Parameter */: {
// initializer of variable/parameter declaration go to previous node
var _b = node.parent, initializer = _b.initializer, type = _b.type;
if (initializer === node || type === node || ts.isAssignmentOperator(node.kind)) {
@@ -163775,7 +166509,7 @@ var ts;
}
break;
}
- case 220 /* BinaryExpression */: {
+ case 221 /* SyntaxKind.BinaryExpression */: {
var left = node.parent.left;
if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) {
// If initializer of destructuring assignment move to previous token
@@ -163805,7 +166539,7 @@ var ts;
}
function spanInVariableDeclaration(variableDeclaration) {
// If declaration of for in statement, just set the span in parent
- if (variableDeclaration.parent.parent.kind === 242 /* ForInStatement */) {
+ if (variableDeclaration.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) {
return spanInNode(variableDeclaration.parent.parent);
}
var parent = variableDeclaration.parent;
@@ -163816,8 +166550,8 @@ var ts;
// Breakpoint is possible in variableDeclaration only if there is initialization
// or its declaration from 'for of'
if (variableDeclaration.initializer ||
- ts.hasSyntacticModifier(variableDeclaration, 1 /* Export */) ||
- parent.parent.kind === 243 /* ForOfStatement */) {
+ ts.hasSyntacticModifier(variableDeclaration, 1 /* ModifierFlags.Export */) ||
+ parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) {
return textSpanFromVariableDeclaration(variableDeclaration);
}
if (ts.isVariableDeclarationList(variableDeclaration.parent) &&
@@ -163832,7 +166566,7 @@ var ts;
function canHaveSpanInParameterDeclaration(parameter) {
// Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier
return !!parameter.initializer || parameter.dotDotDotToken !== undefined ||
- ts.hasSyntacticModifier(parameter, 4 /* Public */ | 8 /* Private */);
+ ts.hasSyntacticModifier(parameter, 4 /* ModifierFlags.Public */ | 8 /* ModifierFlags.Private */);
}
function spanInParameterDeclaration(parameter) {
if (ts.isBindingPattern(parameter.name)) {
@@ -163857,8 +166591,8 @@ var ts;
}
}
function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) {
- return ts.hasSyntacticModifier(functionDeclaration, 1 /* Export */) ||
- (functionDeclaration.parent.kind === 256 /* ClassDeclaration */ && functionDeclaration.kind !== 170 /* Constructor */);
+ return ts.hasSyntacticModifier(functionDeclaration, 1 /* ModifierFlags.Export */) ||
+ (functionDeclaration.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ && functionDeclaration.kind !== 171 /* SyntaxKind.Constructor */);
}
function spanInFunctionDeclaration(functionDeclaration) {
// No breakpoints in the function signature
@@ -163881,26 +166615,26 @@ var ts;
}
function spanInBlock(block) {
switch (block.parent.kind) {
- case 260 /* ModuleDeclaration */:
- if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) {
+ case 261 /* SyntaxKind.ModuleDeclaration */:
+ if (ts.getModuleInstanceState(block.parent) !== 1 /* ModuleInstanceState.Instantiated */) {
return undefined;
}
// Set on parent if on same line otherwise on first statement
// falls through
- case 240 /* WhileStatement */:
- case 238 /* IfStatement */:
- case 242 /* ForInStatement */:
+ case 241 /* SyntaxKind.WhileStatement */:
+ case 239 /* SyntaxKind.IfStatement */:
+ case 243 /* SyntaxKind.ForInStatement */:
return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]);
// Set span on previous token if it starts on same line otherwise on the first statement of the block
- case 241 /* ForStatement */:
- case 243 /* ForOfStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]);
}
// Default action is to set on first statement
return spanInNode(block.statements[0]);
}
function spanInInitializerOfForLike(forLikeStatement) {
- if (forLikeStatement.initializer.kind === 254 /* VariableDeclarationList */) {
+ if (forLikeStatement.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) {
// Declaration list - set breakpoint in first declaration
var variableDeclarationList = forLikeStatement.initializer;
if (variableDeclarationList.declarations.length > 0) {
@@ -163925,21 +166659,21 @@ var ts;
}
function spanInBindingPattern(bindingPattern) {
// Set breakpoint in first binding element
- var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 226 /* OmittedExpression */ ? element : undefined; });
+ var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 227 /* SyntaxKind.OmittedExpression */ ? element : undefined; });
if (firstBindingElement) {
return spanInNode(firstBindingElement);
}
// Empty binding pattern of binding element, set breakpoint on binding element
- if (bindingPattern.parent.kind === 202 /* BindingElement */) {
+ if (bindingPattern.parent.kind === 203 /* SyntaxKind.BindingElement */) {
return textSpan(bindingPattern.parent);
}
// Variable declaration is used as the span
return textSpanFromVariableDeclaration(bindingPattern.parent);
}
function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) {
- ts.Debug.assert(node.kind !== 201 /* ArrayBindingPattern */ && node.kind !== 200 /* ObjectBindingPattern */);
- var elements = node.kind === 203 /* ArrayLiteralExpression */ ? node.elements : node.properties;
- var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 226 /* OmittedExpression */ ? element : undefined; });
+ ts.Debug.assert(node.kind !== 202 /* SyntaxKind.ArrayBindingPattern */ && node.kind !== 201 /* SyntaxKind.ObjectBindingPattern */);
+ var elements = node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ ? node.elements : node.properties;
+ var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 227 /* SyntaxKind.OmittedExpression */ ? element : undefined; });
if (firstBindingElement) {
return spanInNode(firstBindingElement);
}
@@ -163947,18 +166681,18 @@ var ts;
// just nested element in another destructuring assignment
// set breakpoint on assignment when parent is destructuring assignment
// Otherwise set breakpoint for this element
- return textSpan(node.parent.kind === 220 /* BinaryExpression */ ? node.parent : node);
+ return textSpan(node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ ? node.parent : node);
}
// Tokens:
function spanInOpenBraceToken(node) {
switch (node.parent.kind) {
- case 259 /* EnumDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
var enumDeclaration = node.parent;
return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile));
- case 256 /* ClassDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
var classDeclaration = node.parent;
return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile));
- case 262 /* CaseBlock */:
+ case 263 /* SyntaxKind.CaseBlock */:
return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]);
}
// Default to parent node
@@ -163966,25 +166700,25 @@ var ts;
}
function spanInCloseBraceToken(node) {
switch (node.parent.kind) {
- case 261 /* ModuleBlock */:
+ case 262 /* SyntaxKind.ModuleBlock */:
// If this is not an instantiated module block, no bp span
- if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) {
+ if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* ModuleInstanceState.Instantiated */) {
return undefined;
}
// falls through
- case 259 /* EnumDeclaration */:
- case 256 /* ClassDeclaration */:
+ case 260 /* SyntaxKind.EnumDeclaration */:
+ case 257 /* SyntaxKind.ClassDeclaration */:
// Span on close brace token
return textSpan(node);
- case 234 /* Block */:
+ case 235 /* SyntaxKind.Block */:
if (ts.isFunctionBlock(node.parent)) {
// Span on close brace token
return textSpan(node);
}
// falls through
- case 291 /* CatchClause */:
+ case 292 /* SyntaxKind.CatchClause */:
return spanInNode(ts.lastOrUndefined(node.parent.statements));
- case 262 /* CaseBlock */:
+ case 263 /* SyntaxKind.CaseBlock */:
// breakpoint in last statement of the last clause
var caseBlock = node.parent;
var lastClause = ts.lastOrUndefined(caseBlock.clauses);
@@ -163992,7 +166726,7 @@ var ts;
return spanInNode(ts.lastOrUndefined(lastClause.statements));
}
return undefined;
- case 200 /* ObjectBindingPattern */:
+ case 201 /* SyntaxKind.ObjectBindingPattern */:
// Breakpoint in last binding element or binding pattern if it contains no elements
var bindingPattern = node.parent;
return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern);
@@ -164008,7 +166742,7 @@ var ts;
}
function spanInCloseBracketToken(node) {
switch (node.parent.kind) {
- case 201 /* ArrayBindingPattern */:
+ case 202 /* SyntaxKind.ArrayBindingPattern */:
// Breakpoint in last binding element or binding pattern if it contains no elements
var bindingPattern = node.parent;
return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern);
@@ -164023,12 +166757,12 @@ var ts;
}
}
function spanInOpenParenToken(node) {
- if (node.parent.kind === 239 /* DoStatement */ || // Go to while keyword and do action instead
- node.parent.kind === 207 /* CallExpression */ ||
- node.parent.kind === 208 /* NewExpression */) {
+ if (node.parent.kind === 240 /* SyntaxKind.DoStatement */ || // Go to while keyword and do action instead
+ node.parent.kind === 208 /* SyntaxKind.CallExpression */ ||
+ node.parent.kind === 209 /* SyntaxKind.NewExpression */) {
return spanInPreviousNode(node);
}
- if (node.parent.kind === 211 /* ParenthesizedExpression */) {
+ if (node.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) {
return spanInNextNode(node);
}
// Default to parent node
@@ -164037,21 +166771,21 @@ var ts;
function spanInCloseParenToken(node) {
// Is this close paren token of parameter list, set span in previous token
switch (node.parent.kind) {
- case 212 /* FunctionExpression */:
- case 255 /* FunctionDeclaration */:
- case 213 /* ArrowFunction */:
- case 168 /* MethodDeclaration */:
- case 167 /* MethodSignature */:
- case 171 /* GetAccessor */:
- case 172 /* SetAccessor */:
- case 170 /* Constructor */:
- case 240 /* WhileStatement */:
- case 239 /* DoStatement */:
- case 241 /* ForStatement */:
- case 243 /* ForOfStatement */:
- case 207 /* CallExpression */:
- case 208 /* NewExpression */:
- case 211 /* ParenthesizedExpression */:
+ case 213 /* SyntaxKind.FunctionExpression */:
+ case 256 /* SyntaxKind.FunctionDeclaration */:
+ case 214 /* SyntaxKind.ArrowFunction */:
+ case 169 /* SyntaxKind.MethodDeclaration */:
+ case 168 /* SyntaxKind.MethodSignature */:
+ case 172 /* SyntaxKind.GetAccessor */:
+ case 173 /* SyntaxKind.SetAccessor */:
+ case 171 /* SyntaxKind.Constructor */:
+ case 241 /* SyntaxKind.WhileStatement */:
+ case 240 /* SyntaxKind.DoStatement */:
+ case 242 /* SyntaxKind.ForStatement */:
+ case 244 /* SyntaxKind.ForOfStatement */:
+ case 208 /* SyntaxKind.CallExpression */:
+ case 209 /* SyntaxKind.NewExpression */:
+ case 212 /* SyntaxKind.ParenthesizedExpression */:
return spanInPreviousNode(node);
// Default to parent node
default:
@@ -164061,20 +166795,20 @@ var ts;
function spanInColonToken(node) {
// Is this : specifying return annotation of the function declaration
if (ts.isFunctionLike(node.parent) ||
- node.parent.kind === 294 /* PropertyAssignment */ ||
- node.parent.kind === 163 /* Parameter */) {
+ node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ||
+ node.parent.kind === 164 /* SyntaxKind.Parameter */) {
return spanInPreviousNode(node);
}
return spanInNode(node.parent);
}
function spanInGreaterThanOrLessThanToken(node) {
- if (node.parent.kind === 210 /* TypeAssertionExpression */) {
+ if (node.parent.kind === 211 /* SyntaxKind.TypeAssertionExpression */) {
return spanInNextNode(node);
}
return spanInNode(node.parent);
}
function spanInWhileKeyword(node) {
- if (node.parent.kind === 239 /* DoStatement */) {
+ if (node.parent.kind === 240 /* SyntaxKind.DoStatement */) {
// Set span on while expression
return textSpanEndingAtNextToken(node, node.parent.expression);
}
@@ -164082,7 +166816,7 @@ var ts;
return spanInNode(node.parent);
}
function spanInOfKeyword(node) {
- if (node.parent.kind === 243 /* ForOfStatement */) {
+ if (node.parent.kind === 244 /* SyntaxKind.ForOfStatement */) {
// Set using next token
return spanInNextNode(node);
}
@@ -164193,7 +166927,7 @@ var ts;
if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) {
this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) {
var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); // TODO: GH#18217
- return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); });
+ return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, ts.isString(name) ? name : name.fileName.toLowerCase()); });
};
}
}
@@ -164250,7 +166984,7 @@ var ts;
return this.shimHost.getScriptKind(fileName); // TODO: GH#18217
}
else {
- return 0 /* Unknown */;
+ return 0 /* ScriptKind.Unknown */;
}
};
LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) {
@@ -164777,7 +167511,7 @@ var ts;
var compilerOptions = JSON.parse(compilerOptionsJson);
var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host);
var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined;
- if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Ts */ && result.resolvedModule.extension !== ".tsx" /* Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Dts */) {
+ if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Extension.Ts */ && result.resolvedModule.extension !== ".tsx" /* Extension.Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Extension.Dts */) {
resolvedFileName = undefined;
}
return {
@@ -165620,11 +168354,11 @@ var ts;
}, factoryDeprecation);
/** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic)` or the factory supplied by your transformation context instead. */
ts.createOptimisticUniqueName = ts.Debug.deprecate(function createOptimisticUniqueName(text) {
- return ts.factory.createUniqueName(text, 16 /* Optimistic */);
+ return ts.factory.createUniqueName(text, 16 /* GeneratedIdentifierFlags.Optimistic */);
}, factoryDeprecation);
/** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel)` or the factory supplied by your transformation context instead. */
ts.createFileLevelUniqueName = ts.Debug.deprecate(function createFileLevelUniqueName(text) {
- return ts.factory.createUniqueName(text, 16 /* Optimistic */ | 32 /* FileLevel */);
+ return ts.factory.createUniqueName(text, 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */);
}, factoryDeprecation);
/** @deprecated Use `factory.createIndexSignature` or the factory supplied by your transformation context instead. */
ts.createIndexSignature = ts.Debug.deprecate(function createIndexSignature(decorators, modifiers, parameters, type) {
@@ -165671,7 +168405,7 @@ var ts;
}
else {
type = operatorOrType;
- operator = 140 /* KeyOfKeyword */;
+ operator = 140 /* SyntaxKind.KeyOfKeyword */;
}
return ts.factory.createTypeOperatorNode(operator, type);
}, factoryDeprecation);
@@ -165708,7 +168442,7 @@ var ts;
/** @deprecated Use `factory.createConditional` or the factory supplied by your transformation context instead. */
ts.createConditional = ts.Debug.deprecate(function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) {
return arguments.length === 5 ? ts.factory.createConditionalExpression(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) :
- arguments.length === 3 ? ts.factory.createConditionalExpression(condition, ts.factory.createToken(57 /* QuestionToken */), questionTokenOrWhenTrue, ts.factory.createToken(58 /* ColonToken */), whenTrueOrWhenFalse) :
+ arguments.length === 3 ? ts.factory.createConditionalExpression(condition, ts.factory.createToken(57 /* SyntaxKind.QuestionToken */), questionTokenOrWhenTrue, ts.factory.createToken(58 /* SyntaxKind.ColonToken */), whenTrueOrWhenFalse) :
ts.Debug.fail("Argument count mismatch");
}, factoryDeprecation);
/** @deprecated Use `factory.createYield` or the factory supplied by your transformation context instead. */
@@ -165849,9 +168583,9 @@ var ts;
ts.createNode = ts.Debug.deprecate(function createNode(kind, pos, end) {
if (pos === void 0) { pos = 0; }
if (end === void 0) { end = 0; }
- return ts.setTextRangePosEnd(kind === 303 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) :
- kind === 79 /* Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) :
- kind === 80 /* PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) :
+ return ts.setTextRangePosEnd(kind === 305 /* SyntaxKind.SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) :
+ kind === 79 /* SyntaxKind.Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) :
+ kind === 80 /* SyntaxKind.PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) :
!ts.isNodeKind(kind) ? ts.parseBaseNodeFactory.createBaseTokenNode(kind) :
ts.parseBaseNodeFactory.createBaseNode(kind), pos, end);
}, { since: "4.0", warnAfter: "4.1", message: "Use an appropriate `factory` method instead." });
@@ -165878,7 +168612,7 @@ var ts;
// #region Renamed node Tests
/** @deprecated Use `isTypeAssertionExpression` instead. */
ts.isTypeAssertion = ts.Debug.deprecate(function isTypeAssertion(node) {
- return node.kind === 210 /* TypeAssertionExpression */;
+ return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */;
}, {
since: "4.0",
warnAfter: "4.1",
diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js
index 362fdd762..ac036f082 100644
--- a/cli/tsc/99_main_compiler.js
+++ b/cli/tsc/99_main_compiler.js
@@ -30,6 +30,15 @@ delete Object.prototype.__proto__;
// See: https://github.com/denoland/deno/issues/9277#issuecomment-769653834
const normalizedToOriginalMap = new Map();
+ /**
+ * @param {unknown} value
+ * @returns {value is ts.CreateSourceFileOptions}
+ */
+ function isCreateSourceFileOptions(value) {
+ return value != null && typeof value === "object" &&
+ "languageVersion" in value;
+ }
+
function setLogDebug(debug, source) {
logDebug = debug;
if (source) {
@@ -290,7 +299,11 @@ delete Object.prototype.__proto__;
) {
debug(
`host.getSourceFile("${specifier}", ${
- ts.ScriptTarget[languageVersion]
+ ts.ScriptTarget[
+ isCreateSourceFileOptions(languageVersion)
+ ? languageVersion.languageVersion
+ : languageVersion
+ ]
})`,
);
@@ -302,7 +315,7 @@ delete Object.prototype.__proto__;
return sourceFile;
}
- /** @type {{ data: string; scriptKind: ts.ScriptKind }} */
+ /** @type {{ data: string; scriptKind: ts.ScriptKind; version: string; }} */
const { data, scriptKind, version } = core.opSync(
"op_load",
{ specifier },
diff --git a/cli/tsc/compiler.d.ts b/cli/tsc/compiler.d.ts
index 7d935434b..2ea7eb298 100644
--- a/cli/tsc/compiler.d.ts
+++ b/cli/tsc/compiler.d.ts
@@ -9,10 +9,15 @@ declare global {
var libs: string[];
var libMap: Map<string, string>;
var base64encode: (host: ts.CompilerHost, input: string) => string;
+ var normalizePath: (path: string) => string;
interface SourceFile {
version?: string;
}
+ interface CompilerHost {
+ base64encode?: (data: any) => string;
+ }
+
interface Performance {
enable(): void;
getDuration(value: string): number;
@@ -31,6 +36,7 @@ declare global {
}
interface DenoCore {
+ encode(value: string): Uint8Array;
// deno-lint-ignore no-explicit-any
opSync<T>(name: string, params: T): any;
ops(): void;
diff --git a/ext/web/lib.deno_web.d.ts b/ext/web/lib.deno_web.d.ts
index 13ad113fe..220a3cc60 100644
--- a/ext/web/lib.deno_web.d.ts
+++ b/ext/web/lib.deno_web.d.ts
@@ -275,7 +275,7 @@ interface AbortSignal extends EventTarget {
/** Returns true if this AbortSignal's AbortController has signaled to abort,
* and false otherwise. */
readonly aborted: boolean;
- readonly reason?: unknown;
+ readonly reason: any;
onabort: ((this: AbortSignal, ev: Event) => any) | null;
addEventListener<K extends keyof AbortSignalEventMap>(
type: K,
diff --git a/test_util/std b/test_util/std
-Subproject 852968f631b09f6df4a3b0ac6169ba3436d75fc
+Subproject 3e884daf3ae04712e7edd16333fd4fbb0f05b03